Пример #1
0
def master_child_scenario(action_resource, host, execute_resource, report_resource,
                          scenario_resource, default_host_params, config):
    child_scenario = Scenario(config=Config(), parameters={'k': 'v'})
    host2 = Asset(
        name='host02',
        config=config,
        parameters=copy.deepcopy(default_host_params)
    )
    execute_res2 = Execute(name='execute02', config=config,
                           parameters=dict(description='description', hosts='host02', executor='runner'))
    child_scenario.add_assets(host2)
    child_scenario.add_executes(execute_res2)
    scenario_resource.add_child_scenario(child_scenario)
    scenario_resource.add_assets(host)
    scenario_resource.add_actions(action_resource)
    scenario_resource.add_executes(execute_resource)
    scenario_resource.add_reports(report_resource)
    return scenario_resource
Пример #2
0
 def test_create_execute_with_artifacts_as_str():
     params = dict(description='description',
                   hosts='host01, host02',
                   artifacts='test.log, console.log')
     execute = Execute(name='execute', parameters=params)
     assert isinstance(execute.artifacts, list)
Пример #3
0
 def test_create_execute_with_hosts_as_str():
     params = dict(description='description', hosts='host01, host02')
     execute = Execute(name='execute', parameters=params)
     assert isinstance(execute.hosts, list)
Пример #4
0
 def test_create_execute_without_hosts():
     params = dict(hosts=None, key='value', executor='runner')
     with pytest.raises(TefloExecuteError) as ex:
         Execute(name='execute', parameters=params)
     assert 'Unable to associate hosts to executor:execute. No hosts ' \
            'defined!' in ex.value.args
Пример #5
0
 def test_create_execute_with_invalid_executor():
     params = dict(hosts=['host01'], key='value', executor='abc')
     with pytest.raises(TefloExecuteError) as ex:
         Execute(name='execute', parameters=params)
     assert 'Executor: abc is not supported!' in ex.value.args
Пример #6
0
 def test_timeout_from_cfg(config, default_host_params):
     params = dict(hosts=['host01'], key='value')
     execute = Execute(name='action', parameters=params, config=config)
     assert execute._execute_timeout is 25
Пример #7
0
 def test_timeout_from_scenario(timeout_param_execute):
     execute = Execute(name='action', parameters=timeout_param_execute)
     assert execute._execute_timeout is 20
Пример #8
0
 def test_create_execute_without_name():
     with pytest.raises(TefloExecuteError) as ex:
         Execute()
     assert 'Unable to build execute object. Name field missing!' in \
         ex.value.args
Пример #9
0
 def test_create_execute_with_name():
     params = dict(hosts=['host01'], key='value')
     execute = Execute(name='execute', parameters=params)
     assert isinstance(execute, Execute)
Пример #10
0
def execute_resource(config):
    params = dict(description='description', hosts='host01', executor='runner')
    return Execute(name='execute', config=config, parameters=params)
Пример #11
0
def execute2(config):
    params = dict(description='description', hosts='group_test', executor='runner', labels='label3')
    return Execute(name='execute2', config=config, parameters=params)