Пример #1
0
def test_custom_ansible_cfg(scenario_setup):
    sh.molecule('create')
    assert os.path.exists('.molecule/ansible.cfg')

    sh.molecule('destroy')
    assert os.path.exists('.molecule/ansible.cfg')
    assert os.path.exists('ansible.cfg')
Пример #2
0
def test_command_init_verifier_serverspec(temp_dir):
    d = os.path.join(temp_dir, 'command-test-serverspec')
    sh.molecule('init', '--role', 'command-test-serverspec', '--driver',
                'docker', '--verifier', 'serverspec')
    os.chdir(d)
    sh.bundle('install')
    sh.molecule('test')
Пример #3
0
def test_command_verify_trailing_whitespace(scenario_setup):
    try:
        sh.molecule('verify')
    except sh.ErrorReturnCode_1 as e:
        message = ansi_escape(e.message)

        assert re.search('\[ANSIBLE0002\] Trailing whitespace', message)
        assert re.search('playbook.yml:5', message)
Пример #4
0
def test_command_init_role_goss(temp_dir):
    role_directory = os.path.join(temp_dir.strpath, 'test-init')
    cmd = sh.molecule.bake('init', 'role', '--role-name', 'test-init',
                           '--verifier-name', 'goss')
    pytest.helpers.run_command(cmd)

    os.chdir(role_directory)

    sh.molecule('test')
Пример #5
0
def test_command_init_role_inspec(temp_dir):
    role_directory = os.path.join(temp_dir.strpath, 'test-init')
    options = {
        'role_name': 'test-init',
        'verifier_name': 'inspec',
    }
    cmd = sh.molecule.bake('init', 'role', **options)
    pytest.helpers.run_command(cmd)

    with change_dir_to(role_directory):
        sh.molecule('test')
Пример #6
0
def test_command_init_role_goss(temp_dir):
    role_directory = os.path.join(temp_dir.strpath, 'test-init')
    options = {
        'role_name': 'test-init',
        'verifier_name': 'goss',
    }
    cmd = sh.molecule.bake('init', 'role', **options)
    pytest.helpers.run_command(cmd)

    os.chdir(role_directory)

    sh.molecule('test')
Пример #7
0
def scenario_setup(request):
    scenario = request.param
    d = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                     os.path.pardir, 'scenarios', scenario)

    os.chdir(d)
    sh.molecule('destroy')

    def cleanup():
        sh.molecule('destroy')

    request.addfinalizer(cleanup)
Пример #8
0
def test_command_init_role_goss(temp_dir):
    role_directory = os.path.join(temp_dir.strpath, 'test-init')
    options = {
        'role_name': 'test-init',
        'verifier_name': 'goss',
    }
    cmd = sh.molecule.bake('init', 'role', **options)
    pytest.helpers.run_command(cmd)

    os.chdir(role_directory)

    sh.molecule('test')
Пример #9
0
def scenario_setup(request):
    scenario = request.param
    d = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), '..', 'scenarios',
        scenario)

    os.chdir(d)
    sh.molecule('destroy')

    def cleanup():
        sh.molecule('destroy')

    request.addfinalizer(cleanup)
Пример #10
0
def test_command_init_role_with_template(temp_dir):
    role_name = 'test-init'
    role_directory = os.path.join(temp_dir.strpath, role_name)

    options = {
        'url': 'https://github.com/retr0h/cookiecutter-molecule.git',
        'no_input': True,
        'role_name': role_name,
    }
    cmd = sh.molecule.bake('init', 'template', **options)
    pytest.helpers.run_command(cmd)

    with change_dir_to(role_directory):
        sh.molecule('test')
Пример #11
0
def test_command_init_role_with_template(temp_dir):
    role_name = 'test-init'
    role_directory = os.path.join(temp_dir.strpath, role_name)

    options = {
        'url': 'https://github.com/retr0h/cookiecutter-molecule.git',
        'no_input': True,
        'role_name': role_name,
    }
    cmd = sh.molecule.bake('init', 'template', **options)
    pytest.helpers.run_command(cmd)

    os.chdir(role_directory)

    sh.molecule('test')
Пример #12
0
def test_command_status(scenario_setup):
    out = sh.molecule('status', '--driver', 'vagrant', '--porcelain')

    assert re.search('status-scenario-01 .*not_created .*virtualbox',
                     out.stdout)
    assert re.search('status-scenario-02 .*not_created .*virtualbox',
                     out.stdout)
def test_command_status(scenario_setup):
    out = sh.molecule('status', '--driver', 'vagrant', '--porcelain')

    assert re.search('status-scenario-01 .*not_created .*virtualbox',
                     out.stdout)
    assert re.search('status-scenario-02 .*not_created .*virtualbox',
                     out.stdout)
def test_command_status(scenario_setup):
    out = sh.molecule('status', '--driver', 'openstack', '--porcelain')

    assert re.search('status-scenario-01 .*not_created .*openstack',
                     out.stdout)
    assert re.search('status-scenario-02 .*not_created .*openstack',
                     out.stdout)
Пример #15
0
def test_command_status(scenario_setup):
    out = sh.molecule('status', '--driver', 'openstack', '--porcelain')

    assert re.search('status-scenario-01 .*not_created .*openstack',
                     out.stdout)
    assert re.search('status-scenario-02 .*not_created .*openstack',
                     out.stdout)
Пример #16
0
def test_command_converge_with_debug(scenario_setup):
    sh.molecule('--debug', 'converge')
Пример #17
0
def test_command_converge(scenario_setup):
    sh.molecule('converge')
Пример #18
0
def test_command_check(scenario_setup):
    sh.molecule('create')
    out = sh.molecule('check')
    sh.molecule('verify')

    assert re.search('changed=1', ansi_escape(out.stdout))
Пример #19
0
def test_requirements_file(scenario_setup):
    sh.molecule('test')
Пример #20
0
def test_command_test_platform_centos(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant', '--platform', 'centos7')
Пример #21
0
def test_command_init_verifier_goss(temp_dir):
    d = os.path.join(temp_dir, 'command-test-goss')
    sh.molecule('init', '--role', 'command-test-goss', '--driver', 'docker',
                '--verifier', 'goss')
    os.chdir(d)
    sh.molecule('test')
Пример #22
0
 def cleanup():
     sh.molecule('destroy')
Пример #23
0
 def cleanup():
     try:
         sh.molecule('destroy')
     except:
         pass
Пример #24
0
def test_command_verify(scenario_setup):
    sh.molecule('verify')
Пример #25
0
def test_command_test(scenario_setup):
    sh.molecule('test')
Пример #26
0
def test_group_host_vars(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant')
Пример #27
0
def test_command_test_platform_all(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant', '--platform', 'all')
Пример #28
0
def test_command_idempotence(scenario_setup):
    try:
        sh.molecule('test')
    except sh.ErrorReturnCode_1 as e:
        assert re.search('Idempotence test failed.', e.stdout)
Пример #29
0
def test_command_init(temp_dir):
    d = os.path.join(temp_dir, 'command-test')
    sh.molecule('init', '--role', 'command-test', '--driver', 'docker')
    os.chdir(d)
    sh.molecule('test')
def test_command_test(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant')
def test_group_host_vars(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant')
def test_command_test_platform_all(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant', '--platform', 'all')
Пример #33
0
def test_group_host_vars(scenario_setup):
    sh.molecule('test')
Пример #34
0
def test_command_test(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant')
Пример #35
0
def test_docker_cluster(scenario_setup):
    sh.molecule('test')
def test_command_test_platform_centos(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant', '--platform', 'centos7')
Пример #37
0
def test_command_verify_trailing_newline(scenario_setup):
    try:
        sh.molecule('verify')
    except sh.ErrorReturnCode_1 as e:
        assert re.search('Trailing newline found at the end of ./playbook.yml',
                         e.message)
Пример #38
0
def test_dockerfile(scenario_setup):
    sh.molecule('test')