From 4d983d2fea7605859609f00220a6cf1d3ffc3950 Mon Sep 17 00:00:00 2001 From: elajkat Date: Wed, 18 Jan 2023 14:30:44 +0100 Subject: [PATCH] Fullstack: Wait placement process fixtrue to really stop It seems that in test test_configurations_are_synced_towards_placement when the fake placement process is stopped it can take longer and the test restarts the agent before it is really dead. In this case neutron-server can report the status and the agent's 'resources_synced' field is True when the tests checks it. A simple workaround for this can be to check if the AsyncProcess class' _is_running property is False. Closes-Bug: #1856319 Change-Id: Ia4c25110ee5a7b7539407d3531f559555fec50cc (cherry picked from commit 0ae432e71712be671ec93dded3245513b6810cd0) --- neutron/agent/common/async_process.py | 4 ++++ neutron/tests/fullstack/resources/process.py | 6 ++++++ neutron/tests/fullstack/test_agent_bandwidth_report.py | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/neutron/agent/common/async_process.py b/neutron/agent/common/async_process.py index 41578418b71..7e27da68b1d 100644 --- a/neutron/agent/common/async_process.py +++ b/neutron/agent/common/async_process.py @@ -95,6 +95,10 @@ class AsyncProcess(object): def cmd(self): return ' '.join(self._cmd) + @property + def is_running(self): + return self._is_running + def _reset_queues(self): self._stdout_lines = eventlet.queue.LightQueue() self._stderr_lines = eventlet.queue.LightQueue() diff --git a/neutron/tests/fullstack/resources/process.py b/neutron/tests/fullstack/resources/process.py index a062bc5671d..3664a58343c 100644 --- a/neutron/tests/fullstack/resources/process.py +++ b/neutron/tests/fullstack/resources/process.py @@ -98,6 +98,12 @@ class ProcessFixture(fixtures.Fixture): else: return executor.submit(_restart) + def process_is_running(self): + return self.process.is_running + + def process_is_not_running(self): + return not self.process_is_running() + class RabbitmqEnvironmentFixture(fixtures.Fixture): diff --git a/neutron/tests/fullstack/test_agent_bandwidth_report.py b/neutron/tests/fullstack/test_agent_bandwidth_report.py index 0b6d9bc4751..6e9839f1576 100644 --- a/neutron/tests/fullstack/test_agent_bandwidth_report.py +++ b/neutron/tests/fullstack/test_agent_bandwidth_report.py @@ -237,6 +237,14 @@ class TestPlacementBandwidthReport(base.BaseFullStackTestCase): sleep=1) self.environment.placement.process_fixture.stop() + + placement_fixture = self.environment.placement.process_fixture + utils.wait_until_true( + predicate=functools.partial( + placement_fixture.process_is_not_running), + timeout=report_interval, sleep=1 + ) + _add_new_bridge_and_restart_agent(self.environment.hosts[0]) check_agent_not_synced = functools.partial(