Exemplo n.º 1
0
    def test_action_failure_log(self):
        log = '/tmp/ztps-log-%s-debug' % os.getpid()

        bootstrap = Bootstrap()
        bootstrap.ztps.set_config_response(logging=[
            {
                'destination': 'file:%s' % log,
                'level': 'DEBUG'
            },
        ])
        bootstrap.ztps.set_node_check_response()

        text_onstart = random_string()
        text_onsuccess = random_string()
        text_onfailure = random_string()
        bootstrap.ztps.set_definition_response(actions=[
            {
                'action': 'test_action',
                'onstart': text_onstart,
                'onsuccess': text_onsuccess,
                'onfailure': text_onfailure
            },
        ])
        bootstrap.ztps.set_action_response('test_action', fail_action())
        bootstrap.start_test()

        try:
            self.failUnless(bootstrap.eapi_node_information_collected())
            self.failUnless(bootstrap.action_failure())
            self.failIf(bootstrap.error)
            log = ''.join(file_log(log))
            self.failUnless('test_action: %s' % text_onstart in log)
            self.failUnless('test_action: %s' % text_onsuccess not in log)
            self.failUnless('test_action: %s' % text_onfailure in log)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
    def test_action_failure_log(self):
        log = '/tmp/ztps-log-%s-debug' % os.getpid()

        bootstrap = Bootstrap()
        bootstrap.ztps.set_config_response(logging=[
                {'destination' : 'file:%s' % log,
                 'level' : 'DEBUG'},])
        bootstrap.ztps.set_node_check_response()

        text_onstart = random_string()
        text_onsuccess = random_string()
        text_onfailure = random_string()
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'test_action',
                      'onstart' : text_onstart,
                      'onsuccess' : text_onsuccess,
                      'onfailure' : text_onfailure},
                     ])
        bootstrap.ztps.set_action_response('test_action',
                                           fail_action())
        bootstrap.start_test()

        try:
            self.failUnless(bootstrap.eapi_node_information_collected())
            self.failUnless(bootstrap.action_failure())
            self.failIf(bootstrap.error)
            log = ''.join(file_log(log))
            self.failUnless('test_action:%s' % text_onstart in log)
            self.failUnless('test_action:%s' % text_onsuccess not in log)
            self.failUnless('test_action:%s' % text_onfailure in log)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise assertion
        finally:
            bootstrap.end_test()
 def test_return_code_action_failed(self):
     self.action_fail_test(fail_action())
Exemplo n.º 4
0
 def test_return_code_action_failed(self):
     self.action_fail_test(fail_action())