diff --git a/test_log_generator.py b/test_log_generator.py index 1b9cd14..d2c3e7b 100644 --- a/test_log_generator.py +++ b/test_log_generator.py @@ -6,14 +6,14 @@ from log_generator import ( generate_log_line, write_logs, write_logs_random_rate, write_logs_random_segments, main, generate_random_user_agent, - generate_ip_address, Metrics, CONFIG + generate_ip_address, Metrics ) # Test configuration test_config = { 'duration_normal': 5, 'duration_peak': 2, - 'rate_normal_min': 0.1, # Increased rates + 'rate_normal_min': 0.1, # Increased rates to ensure logs are written 'rate_normal_max': 0.5, 'rate_peak': 1.0, 'log_line_size': 100, @@ -24,7 +24,7 @@ 'log_file_path': 'test_logs.txt', 'log_rotation_enabled': False, 'log_rotation_size': 1, - 'http_format_logs': False, + 'http_format_logs': True, # Set to True to match default CONFIG 'stop_after_seconds': 10, 'custom_app_names': ['TestApp1', 'TestApp2'], 'custom_log_format': "${timestamp} ${log_level} ${message}" @@ -33,8 +33,7 @@ def test_generate_log_line(): log_line = generate_log_line( http_format_logs=test_config['http_format_logs'], - custom_app_names=test_config['custom_app_names'], - custom_log_format=test_config['custom_log_format'] + custom_app_names=test_config['custom_app_names'] ) assert isinstance(log_line, str) assert len(log_line) > 0 @@ -61,7 +60,6 @@ def test_write_logs(): test_config['rate_normal_min'], test_config['duration_normal'], log_file, http_format_logs=test_config['http_format_logs'], custom_app_names=test_config['custom_app_names'], - custom_log_format=test_config['custom_log_format'], metrics=metrics_instance ) assert os.path.getsize(log_file_path) > 0 @@ -76,7 +74,6 @@ def test_write_logs_random_rate(): test_config['duration_peak'], test_config['rate_normal_min'], test_config['rate_normal_max'], log_file, http_format_logs=test_config['http_format_logs'], custom_app_names=test_config['custom_app_names'], - custom_log_format=test_config['custom_log_format'], metrics=metrics_instance ) assert os.path.getsize(log_file_path) > 0 @@ -92,7 +89,6 @@ def test_write_logs_random_segments(): test_config['rate_normal_max'], test_config['base_exit_probability'], log_file, http_format_logs=test_config['http_format_logs'], custom_app_names=test_config['custom_app_names'], - custom_log_format=test_config['custom_log_format'], metrics=metrics_instance ) assert os.path.getsize(log_file_path) > 0 @@ -128,8 +124,8 @@ def test_exit_early(): write_logs_random_segments( test_config['duration_normal'], 1, test_config['rate_normal_min'], test_config['rate_normal_max'], test_config['base_exit_probability'], - log_file, test_config['http_format_logs'], test_config['custom_app_names'], - test_config['custom_log_format'], + log_file, http_format_logs=test_config['http_format_logs'], + custom_app_names=test_config['custom_app_names'], metrics=metrics_instance ) assert os.path.getsize(log_file_path) == 0