Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 16
0
def test_command_converge_with_debug(scenario_setup):
    sh.molecule('--debug', 'converge')
Ejemplo n.º 17
0
def test_command_converge(scenario_setup):
    sh.molecule('converge')
Ejemplo n.º 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))
Ejemplo n.º 19
0
def test_requirements_file(scenario_setup):
    sh.molecule('test')
Ejemplo n.º 20
0
def test_command_test_platform_centos(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant', '--platform', 'centos7')
Ejemplo n.º 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')
Ejemplo n.º 22
0
 def cleanup():
     sh.molecule('destroy')
Ejemplo n.º 23
0
 def cleanup():
     try:
         sh.molecule('destroy')
     except:
         pass
Ejemplo n.º 24
0
def test_command_verify(scenario_setup):
    sh.molecule('verify')
Ejemplo n.º 25
0
def test_command_test(scenario_setup):
    sh.molecule('test')
Ejemplo n.º 26
0
def test_group_host_vars(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant')
Ejemplo n.º 27
0
def test_command_test_platform_all(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant', '--platform', 'all')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 33
0
def test_group_host_vars(scenario_setup):
    sh.molecule('test')
Ejemplo n.º 34
0
def test_command_test(scenario_setup):
    sh.molecule('test', '--driver', 'vagrant')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 38
0
def test_dockerfile(scenario_setup):
    sh.molecule('test')