当前位置: 首页>>代码示例>>Python>>正文


Python Bootstrap.start_test方法代码示例

本文整理汇总了Python中client_test_lib.Bootstrap.start_test方法的典型用法代码示例。如果您正苦于以下问题:Python Bootstrap.start_test方法的具体用法?Python Bootstrap.start_test怎么用?Python Bootstrap.start_test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在client_test_lib.Bootstrap的用法示例。


在下文中一共展示了Bootstrap.start_test方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bootstrap

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
 def bootstrap(cls, xmpp):
     bootstrap = Bootstrap()
     bootstrap.ztps.set_config_response(xmpp=xmpp)
     bootstrap.ztps.set_node_check_response()
     bootstrap.ztps.set_definition_response()
     bootstrap.start_test()
     return bootstrap
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:9,代码来源:test_xmpp_bootstrap.py

示例2: test_success

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_success(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        config = random_string()
        url = config
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'test_action',
                      'attributes': {'url' : url}}])

        bootstrap.ztps.set_action_response(
            'startup_config_action', startup_config_action())
        bootstrap.ztps.set_action_response('test_action',
                                           get_action('run_bash_script'))

        print_string = random_string()
        contents = '''#!/usr/bin/env python
print "%s"''' % print_string
        bootstrap.ztps.set_file_response(config, contents)
        bootstrap.start_test()

        try:
            self.failUnless(os.path.isfile(bootstrap.startup_config))
            self.failUnless(print_string in bootstrap.output)
            self.failUnless(bootstrap.success())
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:32,代码来源:test_run_bash_script.py

示例3: test

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test(self):
        open(RC_EOS, 'w').write(random_string())
        open(BOOT_EXTENSIONS, 'w').write(random_string())
        os.makedirs(BOOT_EXTENSIONS_FOLDER)
        open('%s/%s' % (BOOT_EXTENSIONS_FOLDER, random_string()),
             'w').write(random_string())

        bootstrap = Bootstrap()
        bootstrap.ztps.set_config_response()
        bootstrap.ztps.set_node_check_response()
        bootstrap.ztps.set_definition_response()
        bootstrap.start_test()

        try:
            self.failUnless(bootstrap.eapi_node_information_collected())
            self.failUnless(bootstrap.missing_startup_config_failure())
            self.failIf(os.path.exists(RC_EOS))
            self.failIf(os.path.exists(BOOT_EXTENSIONS))
            self.failIf(os.path.exists(BOOT_EXTENSIONS_FOLDER))
            self.failIf(bootstrap.error)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise assertion
        finally:
            bootstrap.end_test()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:28,代码来源:test_bootstrap.py

示例4: test_success

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_success(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        version = random_string()
        image = random_string()
        url = 'http://%s/%s' % (bootstrap.server, image)
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'test_action',
                      'attributes' : {
                        'url' : url,
                        'version' : version}},
                     {'action' :'startup_config_action'}])

        action = get_action('install_image')
        bootstrap.ztps.set_action_response('test_action',
                                           action)
        bootstrap.ztps.set_action_response('startup_config_action',
                                           startup_config_action())
        bootstrap.ztps.set_file_response(image, print_action())
        bootstrap.start_test()

        image_file = '%s/EOS-%s.swi' % (FLASH, version)
        try:
            self.failUnless(os.path.isfile(image_file))
            self.failUnless(bootstrap.success())
            self.failUnless(eapi_log()[-1] == 
                            'install source flash:EOS-%s.swi' % version)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            remove_file(image_file)
            bootstrap.end_test()
开发者ID:einstone,项目名称:ztpserver,代码行数:35,代码来源:test_install_image.py

示例5: test_multi_lines

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_multi_lines(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        config = random_string()
        url = 'http://%s/%s' % (bootstrap.server, config)
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'test_action',
                      'attributes': {'url' : url}}])
        bootstrap.ztps.set_action_response('test_action',
                                           get_action('add_config'))

        startup_config_lines = [random_string(), random_string(),
                                random_string(), random_string()]
        bootstrap.ztps.set_action_response(
            'startup_config_action',
            startup_config_action(lines=startup_config_lines))
        contents = '\n'.join([random_string(), random_string(),
                              random_string(), random_string(),
                              random_string(), random_string()])
        bootstrap.ztps.set_file_response(config, contents)
        bootstrap.start_test()

        try:
            self.failUnless(os.path.isfile(bootstrap.startup_config))
            log = file_log(bootstrap.startup_config)
            all_lines = startup_config_lines + contents.split()
            for line in all_lines:
                self.failUnless(line in log)
            self.failUnless(bootstrap.success())
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:37,代码来源:test_add_config.py

示例6: test_no_downgrade

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_no_downgrade(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        version1 = '4.18.1F'
        version2 = '4.17.2F'
        bootstrap.eapi.version = version1
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'test_action',
                      'attributes': {
                        'downgrade' : False,
                        'url' : random_string(),
                        'version' : version2}},
                     {'action' :'startup_config_action'}])
        bootstrap.ztps.set_action_response('test_action',
                                           get_action('install_image'))
        bootstrap.ztps.set_action_response('startup_config_action',
                                           startup_config_action())
        bootstrap.start_test()

        image_file = '%s/EOS-%s.swi' % (bootstrap.flash, version2)
        try:
            self.failUnless(bootstrap.success())
            self.failUnless('install_image: nothing to do: downgrade disabled'
                            in bootstrap.output)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            remove_file(image_file)
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:32,代码来源:test_install_image.py

示例7: test

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test(self):
        bootstrap = Bootstrap()

        open(bootstrap.rc_eos, 'w').write(random_string())
        open(bootstrap.boot_extensions, 'w').write(random_string())
        os.makedirs(bootstrap.boot_extensions_folder)
        open('%s/%s' % (bootstrap.boot_extensions_folder, 
                        random_string()),
             'w').write(random_string())

        bootstrap.ztps.set_config_response()
        bootstrap.ztps.set_node_check_response()
        bootstrap.ztps.set_definition_response()
        bootstrap.start_test()

        try:
            self.failUnless(bootstrap.eapi_node_information_collected())
            self.failUnless(bootstrap.missing_startup_config_failure())
            self.failIf(os.path.exists(bootstrap.rc_eos))
            self.failIf(os.path.exists(bootstrap.boot_extensions))
            self.failIf(os.path.exists(bootstrap.boot_extensions_folder))

            self.failIf(bootstrap.error)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:31,代码来源:test_bootstrap.py

示例8: test_success

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_success(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        config = random_string()
        url = config
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'test_action',
                      'attributes': {'url' : url}}])

        bootstrap.ztps.set_action_response(
            'startup_config_action', startup_config_action())
        bootstrap.ztps.set_action_response('test_action',
                                           get_action('run_cli_commands'))

        contents = random_string()
        bootstrap.ztps.set_file_response(config, contents)
        bootstrap.start_test()

        try:
            self.failUnless(os.path.isfile(bootstrap.startup_config))
            self.failUnless(eapi_log()[-1] == contents)
            self.failUnless(bootstrap.success())
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:30,代码来源:test_run_cli_commands.py

示例9: test_failure

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_failure(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        config = random_string()
        url = config
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'test_action',
                      'attributes': {'url' : url}}])

        bootstrap.ztps.set_action_response('test_action',
                                           get_action('run_cli_commands'))

        contents = random_string()
        bootstrap.ztps.set_file_response(config, contents)
        bootstrap.eapi.add_failing_command(contents)
        bootstrap.start_test()

        try:
            self.failUnless(eapi_log()[-1] == contents)
            self.failUnless(bootstrap.action_failure())
            self.failUnless('Running CLI commands [\'%s\'] failed' % 
                            contents in bootstrap.output)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:29,代码来源:test_run_cli_commands.py

示例10: test_append

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_append(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        config = random_string()
        url = 'http://%s/%s' % (bootstrap.server, config)
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'test_action',
                      'attributes': {'url' : url}}])
        bootstrap.ztps.set_action_response('test_action',
                                           get_action('add_config'))

        startup_config_text = random_string()
        bootstrap.ztps.set_action_response(
            'startup_config_action',
            startup_config_action(lines=[startup_config_text]))
        contents = random_string()
        bootstrap.ztps.set_file_response(config, contents)
        bootstrap.start_test()

        try:
            self.failUnless(os.path.isfile(STARTUP_CONFIG))
            log = file_log(STARTUP_CONFIG)
            self.failUnless(contents in log)
            self.failUnless(startup_config_text in log)
            self.failUnless(bootstrap.success())
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise assertion
        finally:
            bootstrap.end_test()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:33,代码来源:test_add_config.py

示例11: test_multiple_actions

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_multiple_actions(self):
        bootstrap = Bootstrap()
        bootstrap.ztps.set_config_response()
        bootstrap.ztps.set_node_check_response()
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'print_action_1'},
                     {'action' : 'print_action_2'}])
        bootstrap.ztps.set_action_response('startup_config_action',
                                           startup_config_action())

        text_1 = random_string()
        bootstrap.ztps.set_action_response('print_action_1',
                                           print_action(text_1))
        text_2 = random_string()
        bootstrap.ztps.set_action_response('print_action_2',
                                           print_action(text_2))
        bootstrap.start_test()

        try:
            self.failUnless(bootstrap.eapi_node_information_collected())
            self.failUnless(bootstrap.success())
            self.failUnless(text_1 in bootstrap.output)
            self.failUnless(text_2 in bootstrap.output)
            self.failIf(bootstrap.error)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise assertion
        finally:
            bootstrap.end_test()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:33,代码来源:test_bootstrap.py

示例12: test_variables_loose

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_variables_loose(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        config = random_string()
        url = config
        var_dict = { 'a' : 'A',
                     'b' : 'A',
                     'xxx' : '999',
                     'dummy': 'DUMMY'}
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'test_action',
                      'attributes': {'url' : url,
                                     'substitution_mode': 'loose',
                                     'variables': var_dict}}])
        bootstrap.ztps.set_action_response('test_action',
                                           get_action('add_config'))
        contents = '$a 1234 $b 4  321 $xxx$a'
        expected_contents = Template(contents).safe_substitute(var_dict)
        bootstrap.ztps.set_file_response(config, contents)
        bootstrap.start_test()

        try:
            self.failUnless(os.path.isfile(bootstrap.startup_config))
            self.failUnless([expected_contents] ==
                            file_log(bootstrap.startup_config))
            self.failUnless(bootstrap.success())
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(assertion)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:33,代码来源:test_add_config.py

示例13: test_success

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_success(self):
        bootstrap = Bootstrap(ztps_default_config=True)

        smarthost = "%s:2525" % str(bootstrap.server).split(':')[0]

        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'test_action',
                      'attributes' : {
                        'smarthost': smarthost,
                        'sender': '[email protected]',
                        'receivers': ['[email protected]']}}])


        bootstrap.ztps.set_action_response('startup_config_action',
                                           startup_config_action())

        action = get_action('send_email')
        bootstrap.ztps.set_action_response('test_action',
                                           action)

        bootstrap.start_test()
        try:
            self.failUnless(bootstrap.success())
        except Exception as exception: #pylint: disable=W0703
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise_exception(exception)
        finally:
            bootstrap.end_test()
开发者ID:arista-eosplus,项目名称:ztpserver,代码行数:32,代码来源:test_send_email.py

示例14: test_success

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_success(self):
        bootstrap = Bootstrap(ztps_default_config=True)
        version = random_string()
        image = random_string()
        url = 'http://%s/%s' % (bootstrap.server, image)
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'test_action',
                      'attributes' : {
                        'url' : url,
                        'version' : version}}])

        boot_file = '/tmp/boot-config'
        action = get_action('install_image')
        action = action.replace('/mnt/flash/boot-config',
                                boot_file)
        bootstrap.ztps.set_action_response('test_action',
                                           action)
        bootstrap.ztps.set_file_response(image, print_action())
        bootstrap.start_test()

        image_file = '%s/%s.swi' % (FLASH, version)
        try:
            self.failUnless('! boot system flash:/%s.swi' % version
                            in file_log(STARTUP_CONFIG))
            self.failUnless(os.path.isfile(image_file))
            self.failUnless(['SWI=flash:/%s.swi' % version] ==
                            file_log(boot_file))
            self.failUnless(bootstrap.success())
        except AssertionError:
            raise
        finally:
            remove_file(image_file)
            remove_file(boot_file)
            bootstrap.end_test()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:36,代码来源:test_install_image.py

示例15: test_attribute

# 需要导入模块: from client_test_lib import Bootstrap [as 别名]
# 或者: from client_test_lib.Bootstrap import start_test [as 别名]
    def test_attribute(self):
        bootstrap = Bootstrap()
        bootstrap.ztps.set_config_response()
        bootstrap.ztps.set_node_check_response()
        text = random_string()
        bootstrap.ztps.set_definition_response(
            actions=[{'action' : 'startup_config_action'},
                     {'action' : 'print_action',
                      'attributes' : {'print_action-attr':text}}])
        bootstrap.ztps.set_action_response('startup_config_action',
                                           startup_config_action())
        bootstrap.ztps.set_action_response('print_action',
                                           print_action(use_attribute=True))
        bootstrap.start_test()

        try:
            self.failUnless(bootstrap.eapi_node_information_collected())
            self.failUnless(bootstrap.success())
            self.failUnless(text in bootstrap.output)
            self.failIf(bootstrap.error)
        except AssertionError as assertion:
            print 'Output: %s' % bootstrap.output
            print 'Error: %s' % bootstrap.error
            raise assertion
        finally:
            bootstrap.end_test()
开发者ID:IntelligentVisibility,项目名称:ztpserver,代码行数:28,代码来源:test_bootstrap.py


注:本文中的client_test_lib.Bootstrap.start_test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。