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')
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')
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)
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')
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')
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')
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)
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)
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')
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')
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)
def test_command_converge_with_debug(scenario_setup): sh.molecule('--debug', 'converge')
def test_command_converge(scenario_setup): sh.molecule('converge')
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))
def test_requirements_file(scenario_setup): sh.molecule('test')
def test_command_test_platform_centos(scenario_setup): sh.molecule('test', '--driver', 'vagrant', '--platform', 'centos7')
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')
def cleanup(): sh.molecule('destroy')
def cleanup(): try: sh.molecule('destroy') except: pass
def test_command_verify(scenario_setup): sh.molecule('verify')
def test_command_test(scenario_setup): sh.molecule('test')
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')
def test_command_idempotence(scenario_setup): try: sh.molecule('test') except sh.ErrorReturnCode_1 as e: assert re.search('Idempotence test failed.', e.stdout)
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')
def test_docker_cluster(scenario_setup): sh.molecule('test')
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)
def test_dockerfile(scenario_setup): sh.molecule('test')