def wait_for_idle(runner, timeout=None): """ Run waiting command. Raise LibraryError if command failed. runner is preconfigured object for running external programs string timeout is waiting timeout """ args = [__exec("crm_resource"), "--wait"] if timeout is not None: args.append("--timeout={0}".format(timeout)) stdout, stderr, retval = runner.run(args) if retval != 0: # Usefull info goes to stderr - not only error messages, a list of # pending actions in case of timeout goes there as well. # We use stdout just to be sure if that's get changed. if retval == __EXITCODE_WAIT_TIMEOUT: raise LibraryError( reports.wait_for_idle_timed_out( join_multilines([stderr, stdout]) ) ) raise LibraryError( reports.wait_for_idle_error( join_multilines([stderr, stdout]) ) )
def wait_for_idle(runner, timeout=None): """ Run waiting command. Raise LibraryError if command failed. runner is preconfigured object for running external programs string timeout is waiting timeout """ args = [__exec("crm_resource"), "--wait"] if timeout is not None: args.append("--timeout={0}".format(timeout)) stdout, stderr, retval = runner.run(args) if retval != 0: # Usefull info goes to stderr - not only error messages, a list of # pending actions in case of timeout goes there as well. # We use stdout just to be sure if that's get changed. if retval == __EXITCODE_WAIT_TIMEOUT: raise LibraryError( reports.wait_for_idle_timed_out( join_multilines([stderr, stdout]) ) ) else: raise LibraryError( reports.wait_for_idle_error( join_multilines([stderr, stdout]) ) )
def test_wait_fail(self): wait_error_message = dedent("""\ Pending actions: Action 12: {bundle_id}-node2-stop on node2 Error performing operation: Timer expired """.format(bundle_id=self.bundle_id)).strip() self.config.env.push_cib( resources=self.fixture_resources_bundle_simple, wait=TIMEOUT, exception=LibraryError( reports.wait_for_idle_timed_out(wait_error_message))) self.env_assist.assert_raise_library_error( lambda: self.run_bundle_cmd(wait=TIMEOUT), [fixture.report_wait_for_idle_timed_out(wait_error_message)], expected_in_processor=False)
def test_wait_fail(self): wait_error_message = dedent("""\ Pending actions: Action 12: B1-node2-stop on node2 Error performing operation: Timer expired """).strip() self.config.env.push_cib( resources=self.fixture_resources_bundle_simple, wait=TIMEOUT, exception=LibraryError( reports.wait_for_idle_timed_out(wait_error_message)), instead="env.push_cib") self.env_assist.assert_raise_library_error( lambda: simple_bundle_update(self.env_assist.get_env()), [fixture.report_wait_for_idle_timed_out(wait_error_message)], expected_in_processor=False)
def test_wait_fail(self): wait_error_message = dedent( """\ Pending actions: Action 12: {bundle_id}-node2-stop on node2 Error performing operation: Timer expired """ .format(bundle_id=self.bundle_id) ).strip() self.config.env.push_cib( resources=self.fixture_resources_bundle_simple, wait=TIMEOUT, exception=LibraryError( reports.wait_for_idle_timed_out(wait_error_message) ) ) self.env_assist.assert_raise_library_error( lambda: self.run_bundle_cmd(wait=TIMEOUT), [ fixture.report_wait_for_idle_timed_out(wait_error_message) ], expected_in_processor=False )