示例#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')