Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log collector unit tests on 3.5 #3193

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def mock_cgroup(*args, **kwargs): # pylint: disable=W0613
agent = Agent(False, conf_file_path=os.path.join(data_dir, "test_waagent.conf"))
agent.collect_logs(is_full_mode=True)

mock_log_collector.assert_called_once()
self.assertEqual(1, mock_log_collector.call_count, "LogCollector should be called once")

finally:
CollectLogsHandler.disable_monitor_cgroups_check()
Expand Down Expand Up @@ -458,11 +458,11 @@ def raise_on_sys_exit(*args):

@patch("azurelinuxagent.agent.LogCollector")
@patch("azurelinuxagent.ga.collect_logs.LogCollectorMonitorHandler.get_max_recorded_metrics")
def test_collect_log_should_output_resource_usage_summary(self, mock_get_metrics_summary, mock_log_collector):
def test_collect_log_should_output_resource_usage_summary(self, mock_get_max_recorded_metrics, mock_log_collector):
try:
CollectLogsHandler.enable_monitor_cgroups_check()
mock_log_collector.return_value.collect_logs_and_get_archive.return_value = (Mock(), Mock()) # LogCollector.collect_logs_and_get_archive returns a tuple
mock_get_metrics_summary.return_value = "metric summary"
mock_get_max_recorded_metrics.return_value = {}

# Mock cgroup so process is in the log collector slice
def mock_cgroup(*args, **kwargs): # pylint: disable=W0613
Expand All @@ -484,8 +484,8 @@ def mock_cgroup(*args, **kwargs): # pylint: disable=W0613
agent = Agent(False, conf_file_path=os.path.join(data_dir, "test_waagent.conf"))
agent.collect_logs(is_full_mode=True)

mock_log_collector.assert_called_once()
mock_get_metrics_summary.assert_called_once()
self.assertEqual(1, mock_log_collector.call_count, "LogCollector should be called once")
self.assertEqual(1, mock_get_max_recorded_metrics.call_count, "get_max_recorded_metrics should be called once")

finally:
CollectLogsHandler.disable_monitor_cgroups_check()
Expand Down
Loading