def push_corosync_conf(lib_env, corosync_conf_facade, skip_offline_nodes=False): i, expected_call = call_queue.take(CALL_TYPE_PUSH_COROSYNC_CONF) if not isinstance(corosync_conf_facade, ConfigFacade): raise AssertionError( ("Trying to call env.push_corosync_conf (call no. {0}) with" " {1} instead of lib.corosync.config_facade.ConfigFacade" ).format(i, type(corosync_conf_facade))) to_push = corosync_conf_facade.config.export() if to_push != expected_call.corosync_conf_text: raise AssertionError( "Trying to call env.push_corosync_conf but the pushed " "corosync.conf is not as expected:\n{0}".format( prepare_diff(to_push, expected_call.corosync_conf_text)))
def cleanup(self, current_test): if self.__unpatch: self.__unpatch() if test_failed(current_test): # We have already got the message that main test failed. There is # a high probability that something remains in reports or in the # queue etc. But it is only consequence of the main test fail. And # we do not want to make the report confusing. return if not self.__reports_asserted: self.__assert_environment_created() if not self.__config.spy: self._env.report_processor.assert_reports( self.__extra_reports, hint="EnvAssistant.cleanup - is param" " 'expected_in_processor' in the method" " 'assert_raise_library_error' set correctly?") if not self.__config.spy: if self.__call_queue and self.__call_queue.remaining: raise AssertionError( "There are remaining expected calls: \n '{0}'".format( "'\n '".join([ repr(call) for call in self.__call_queue.remaining ]))) # If pushing corosync.conf has not been patched in the # LibraryEnvironment and the LibraryEnvironment was constructed # with a mocked corosync.conf, check if it was changed without the # change being specified in a test. # If no env.push_corosync_conf call has been specified, no mocking # occurs, any changes to corosync.conf are done just in memory and # nothing gets reported. So an explicit check is necessary. corosync_conf_orig = self.__original_mocked_corosync_conf # pylint: disable=protected-access corosync_conf_env = self._env._corosync_conf_data if (corosync_conf_orig and corosync_conf_orig != corosync_conf_env): raise AssertionError( ("An unexpected change to corosync.conf in " "LibraryEnvironment has been detected:\n{0}").format( prepare_diff(corosync_conf_orig, corosync_conf_env)))