def after_test(self, test, test_report): if not self._should_run_after_test_impl(): return # Change test_name and description to be more descriptive. description = "{0} after running '{1}'".format(self.description, test.short_name()) self.hook_test_case.test_name = test.short_name( ) + ":" + self.logger_name interface.CustomBehavior.start_dynamic_test(self.hook_test_case, test_report) try: self._after_test_impl(test, test_report, description) except pymongo.errors.OperationFailure as err: self.hook_test_case.logger.exception( "{0} failed".format(description)) self.hook_test_case.return_code = 1 test_report.addFailure(self.hook_test_case, sys.exc_info()) raise errors.StopExecution(err.args[0]) except self.hook_test_case.failureException as err: self.hook_test_case.logger.exception( "{0} failed".format(description)) test_report.addFailure(self.hook_test_case, sys.exc_info()) raise errors.StopExecution(err.args[0]) else: self.hook_test_case.return_code = 0 test_report.addSuccess(self.hook_test_case) finally: test_report.stopTest(self.hook_test_case)
def _run(self, test_report): self.hook_test_case = testcase.TestCase( self.logger, "Hook", "{}:{}".format(self._last_test_name, self.logger_name)) interface.CustomBehavior.start_dynamic_test(self.hook_test_case, test_report) try: self._kill_secondaries() self._check_secondaries_and_restart_fixture() # Validate all collections on all nodes after having the secondaries reconcile the end # of their oplogs. self._validate_collections(test_report) # Verify that the dbhashes match across all nodes after having the secondaries reconcile # the end of their oplogs. self._check_repl_dbhash(test_report) self._restart_and_clear_fixture() except Exception as err: self.hook_test_case.logger.exception( "Encountered an error running PeriodicKillSecondaries.") self.hook_test_case.return_code = 2 test_report.addFailure(self.hook_test_case, sys.exc_info()) raise errors.StopExecution(err.args[0]) else: self.hook_test_case.return_code = 0 test_report.addSuccess(self.hook_test_case) finally: test_report.stopTest(self.hook_test_case) # Set the hook back into a state where it will disable oplog application at the start # of the next test that runs. self._start_time = None
def _check_thread(self, test, test_report): if not self._stepdown_thread.is_alive(): msg = "The stepdown thread is not running." self.logger.error(msg) try: raise errors.StopExecution(msg) except errors.StopExecution: test_report.addError(test, sys.exc_info()) raise
def _run(self, test_report): test_name = "{}:{}".format(self._last_test_name, self.__class__.__name__) self.hook_test_case = self.make_dynamic_test(testcase.TestCase, "Hook", test_name) interface.CustomBehavior.start_dynamic_test(self.hook_test_case, test_report) try: self._kill_secondaries() self._check_secondaries_and_restart_fixture() # The CheckReplDBHash hook waits until all operations have replicated to and have been # applied on the secondaries, so we run the ValidateCollections hook after it to ensure # we're validating the entire contents of the collection. # # Verify that the dbhashes match across all nodes after having the secondaries reconcile # the end of their oplogs. self._check_repl_dbhash(test_report) # Validate all collections on all nodes after having the secondaries reconcile the end # of their oplogs. self._validate_collections(test_report) self._restart_and_clear_fixture() except Exception as err: self.hook_test_case.logger.exception( "Encountered an error running PeriodicKillSecondaries.") self.hook_test_case.return_code = 2 test_report.addFailure(self.hook_test_case, sys.exc_info()) raise errors.StopExecution(err.args[0]) else: self.hook_test_case.return_code = 0 test_report.addSuccess(self.hook_test_case) finally: test_report.stopTest(self.hook_test_case) # Set the hook back into a state where it will disable oplog application at the start # of the next test that runs. self._start_time = None
def _check_thread(self): if not self._stepdown_thread.is_alive(): msg = "The stepdown thread is not running." self.logger.error(msg) raise errors.StopExecution(msg)