Skip to content

Commit

Permalink
DAOS-16825 test: Support register cleanup for all Test classes
Browse files Browse the repository at this point in the history
Support calling register cleanup methods for tests based upon the Test
and TestWithoutServers classes. Also remove stopping agents as part of
calling TestWithServers.stop_servers() since DAOS-6873 is no longer an
issue.

Skip-unit-tests: true
Skip-fault-injection-test: true
Test-tag: pr daily_regression full_regression

Required-githooks: true

Signed-off-by: Phil Henderson <[email protected]>
  • Loading branch information
phender committed Nov 22, 2024
1 parent f198b57 commit 1307c2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
16 changes: 6 additions & 10 deletions src/tests/ftest/control/config_generate_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def test_config_generate_run(self):
control_metadata = os.path.join(self.test_env.log_dir, 'control_metadata')

# Call dmg config generate. AP is always the first server host.
self.log_step("Generating server configuration")
server_host = self.hostlist_servers[0]
result = self.get_dmg_command().config_generate(
access_points=server_host, num_engines=num_engines, scm_only=scm_only,
Expand All @@ -66,25 +67,20 @@ def test_config_generate_run(self):
# Stop and restart daos_server. self.start_server_managers() has the
# server start-up check built into it, so if there's something wrong,
# it'll throw an error.
self.log.info("Stopping servers")
self.log_step("Stopping servers")
self.stop_servers()

# Create a new server config from generated_yaml and update SCM-related
# data in engine_params so that the cleanup before the server start
# works.
self.log.info("Copy config to %s and update engine_params", self.test_env.server_config)
self.log_step(f"Copy config to {self.test_env.server_config} and update engine_params")
self.server_managers[0].update_config_file_from_file(generated_yaml)

# Start server with the generated config.
self.log.info("Restarting server with the generated config")
self.log_step("Restarting server with the generated config")
try:
agent_force = self.start_server_managers(force=True)
self.start_server_managers(force=True)
except ServerFailed as error:
self.fail(f"Restarting server failed! {error}")

# We don't need agent for this test. However, when we stop the server,
# agent is also stopped. Then the harness checks that the agent is
# running during the teardown. If agent isn't running at that point, it
# would cause an error, so start it here.
self.log.info("Restarting agents")
self.start_agent_managers(force=agent_force)
self.log.info("Test passed")
22 changes: 6 additions & 16 deletions src/tests/ftest/util/apricot/apricot/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ def tearDown(self):
self.report_timeout()
super().tearDown()

# Execute any tear down steps in the reverse order of which they were registered.
self._teardown_errors.extend(self._cleanup())

# Clean up any temporary files
self._teardown_errors.extend(self.remove_temp_test_dir())

Expand Down Expand Up @@ -894,6 +897,7 @@ def start_agents(self, agent_groups=None, force=False):
self.setup_agents(agent_groups)
if self.agent_managers:
self.start_agent_managers(force)
self.register_cleanup(self.stop_agents)

def start_servers(self, server_groups=None, force=False):
"""Start the daos_server processes.
Expand All @@ -917,6 +921,7 @@ def start_servers(self, server_groups=None, force=False):
self.setup_servers(server_groups)
if self.server_managers:
force_agent_start = self.start_server_managers(force)
self.register_cleanup(self.stop_servers)
return force_agent_start

def restart_servers(self):
Expand Down Expand Up @@ -1396,24 +1401,14 @@ def tearDown(self):
# class (see DAOS-1452/DAOS-9941 and Avocado issue #5217 with
# associated PR-5224)
if self.status is not None and self.status != 'PASS' and self.status != 'SKIP':
self.__dump_engines_stacks("Test status is {}".format(self.status))
self.__dump_engines_stacks(f"Test status is {self.status}")

# Report whether or not the timeout has expired
self.report_timeout()

# Tear down any test-specific items
self._teardown_errors = self.pre_tear_down()

# Destroy any job managers, containers, pools, and dfuse instances next
# Eventually this call will encompass all teardown steps
self._teardown_errors.extend(self._cleanup())

# Stop the agents
self._teardown_errors.extend(self.stop_agents())

# Stop the servers
self._teardown_errors.extend(self.stop_servers())

super().tearDown()

def pre_tear_down(self):
Expand Down Expand Up @@ -1613,11 +1608,6 @@ def stop_servers(self):
"Stopping %s group(s) of servers", len(self.server_managers))
errors.extend(self._stop_managers(self.server_managers, "servers"))

# Stopping agents whenever servers are stopped for DAOS-6873
self.log.info(
"Workaround for DAOS-6873: Stopping %s group(s) of agents",
len(self.agent_managers))
errors.extend(self._stop_managers(self.agent_managers, "agents"))
return errors

def _stop_managers(self, managers, name):
Expand Down

0 comments on commit 1307c2e

Please sign in to comment.