def teardown(self, test_name, run, env_cfg, extra_vars): """Does clean-up steps after a test.""" playbook = self.abspath(env_cfg["teardown_playbook"]) inventory = self.get_inventory_path(test_name) try: ansible_manager.run_playbook(playbook, inventory, extra_vars=extra_vars) except ansible_manager.AnsiblePlaybookError as exc: exc_info = traceback.format_exc() teamcity_messages.report_test("test_" + test_name + "_teardown", failed=True, message=exc.message, details=exc_info) raise TestError("Teardown for test {} raised exception: {}".format(test_name, exc_info))
def setup(self, test_name, env_cfg, run, extra_vars): playbook = self.abspath(env_cfg["setup_playbook"]) inventory = self.get_inventory_path(test_name) try: # Do prerequisite steps for a test ansible_manager.run_playbook(playbook, inventory, extra_vars=extra_vars) except ansible_manager.AnsiblePlaybookError as exc: exc_info = traceback.format_exc() teamcity_messages.report_test("test_" + test_name + "_setup", failed=True, message=exc.message, details=exc_info) raise TestError("Setup for test {} raised exception: {}".format(test_name, exc_info)) # Check if it's a pytest test if run["type"] == "pytest": self.generate_pytest_cfg(run["addopts"])