def test_molecule_drivers(): x = [ 'docker', 'ec2', 'lxc', 'lxd', 'openstack', 'static', 'vagrant', ] assert x == config.molecule_drivers()
def test_molecule_drivers(): x = [ 'delegated', 'docker', 'ec2', 'gce', 'lxc', 'lxd', 'openstack', 'vagrant', ] assert x == config.molecule_drivers()
def test_molecule_drivers(): x = [ 'azure', 'delegated', 'docker', 'ec2', 'gce', 'lxc', 'lxd', 'openstack', 'vagrant', ] assert x == config.molecule_drivers()
def test_molecule_drivers(): x = [ 'azure', 'delegated', 'digitalocean', 'docker', 'ec2', 'gce', 'hetznercloud', 'linode', 'lxc', 'lxd', 'openstack', 'podman', 'vagrant', ] assert x == config.molecule_drivers()
@click.group() def init(): """ Initialize a new role or scenario. """ @init.command() @click.option( '--dependency-name', type=click.Choice(['galaxy']), default='galaxy', help='Name of dependency to initialize. (galaxy)') @click.option( '--driver-name', type=click.Choice(config.molecule_drivers()), default='docker', help='Name of driver to initialize. (docker)') @click.option( '--lint-name', type=click.Choice(['yamllint']), default='yamllint', help='Name of lint to initialize. (yamllint)') @click.option( '--provisioner-name', type=click.Choice(['ansible']), default='ansible', help='Name of provisioner to initialize. (ansible)') @click.option('--role-name', required=True, help='Name of the role to create.') @click.option( '--verifier-name',
self._config.provisioner.create() self._config.state.change_state('created', True) @click.command() @click.pass_context @click.option( '--scenario-name', '-s', default='default', help='Name of the scenario to target. (default)') @click.option( '--driver-name', '-d', type=click.Choice(config.molecule_drivers()), help='Name of driver to use. (docker)') def create(ctx, scenario_name, driver_name): # pragma: no cover """ Start instances. """ args = ctx.obj.get('args') subcommand = base._get_subcommand(__name__) command_args = { 'subcommand': subcommand, 'driver_name': driver_name, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.print_matrix() for scenario in s: for term in scenario.sequence:
def pytest_configure(config): config.option.molecule = {} for driver in molecule_drivers(): config.addinivalue_line( "markers", "{0}: mark test to run only when {0} is available".format(driver)) config.option.molecule[driver] = {"available": True} # TODO(ssbarnea): extend molecule itself to allow it to report usable drivers if driver == "docker": try: import docker # validate docker connectivity # Default docker value is 60s but we want to fail faster # With parallel execution 5s proved to give errors. c = docker.from_env(timeout=10, version="auto") if not c.ping(): raise Exception("Failed to ping docker server.") except Exception as e: msg = "Molecule {} driver is not available due to: {}.".format( driver, e) if config.option.molecule_unavailable_driver: msg += " We will tag scenarios using it with '{}' marker.".format( config.option.molecule_unavailable_driver) logging.getLogger().warning(msg) config.option.molecule[driver]["available"] = False if driver == "delegated": # To protect ourselves from case where a molecule scenario using # `delegated` is accidentally altering the localhost on a developer # machine, we verify run delegated tests only when ansible `zuul` # or `use_for_testing` vars are defined. cmd = [ "ansible", "localhost", "-e", "ansible_connection=local" "-o", "-m", "shell", "-a", "exit {% if zuul is defined or use_for_testing is defined %}0{% else %}1{% endif %}", ] try: p = subprocess.Popen( cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, universal_newlines=True, ) p.wait() if p.returncode != 0: raise Exception("Error code %s returned by: %s" % (p.returncode, " ".join(cmd))) except Exception: msg = "Molecule {} driver was not enabled because missing zuul.build variable in current inventory.".format( driver) if config.option.molecule_unavailable_driver: msg += " We will tag scenarios using it with '{}' marker.".format( config.option.molecule_unavailable_driver) logging.getLogger().warning(msg) config.option.molecule[driver]["available"] = False config.addinivalue_line("markers", "molecule: mark used by all molecule scenarios") # validate selinux availability if sys.platform == "linux" and os.path.isfile("/etc/selinux/config"): try: import selinux # noqa except Exception: logging.error( "It appears that you are trying to use " "molecule with a Python interpreter that does not have the " "libselinux python bindings installed. These can only be " "installed using your distro package manager and are specific " "to each python version. Common package names: " "libselinux-python python2-libselinux python3-libselinux")