diff --git a/.gitignore b/.gitignore index 53434a58..6072fd94 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,6 @@ MANIFEST # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest -*.spec # Installer logs pip-log.txt @@ -127,7 +126,6 @@ dmypy.json # Pyre type checker .pyre/ -src/molecule_plugins/_version.py # Ignore generated files test/roles @@ -138,3 +136,5 @@ patches *.patch *.orig *.rej + +.pybuild/ diff --git a/conftest.py b/conftest.py index c9b4a4f2..aba16d0c 100644 --- a/conftest.py +++ b/conftest.py @@ -8,6 +8,7 @@ from molecule import config, logger, util from molecule.scenario import ephemeral_directory +from molecule.app import App LOG = logger.get_logger(__name__) @@ -18,7 +19,7 @@ def run_command(cmd, env=os.environ, log=True): if log: cmd = _rebake_command(cmd, env) cmd = cmd.bake(_truncate_exc=False) - return util.run_command(cmd, env=env) + return app.run_command(cmd, env=env) def _rebake_command(cmd, env, out=LOG.info, err=LOG.error): diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 00000000..4a569ac5 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,6 @@ +*.substvars +*debhelper* +.debhelper +files +python3-molecule-plugins +tmp diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..d46298d1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +python-molecule-plugins (100:23.6.0-1) UNRELEASED; urgency=medium + + * https://github.com/ansible-community/molecule-plugins/releases/tag/v23.6.0 + + -- Wong Hoi Sing Edison Fri, 20 Dec 2024 12:45:26 +0800 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..90866e54 --- /dev/null +++ b/debian/control @@ -0,0 +1,41 @@ +Source: python-molecule-plugins +Section: python +Priority: optional +Standards-Version: 4.5.0 +Maintainer: Wong Hoi Sing Edison +Homepage: https://github.com/ansible-community/molecule-plugins/tags +Vcs-Browser: https://github.com/alvistack/ansible-community-molecule-plugins +Vcs-Git: https://github.com/alvistack/ansible-community-molecule-plugins.git +Build-Depends: + debhelper, + debhelper-compat (= 10), + dh-python, + fdupes, + python3-dev, + python3-setuptools, + +Package: python3-molecule-plugins +Architecture: all +Description: Molecule Plugins + Molecule Plugins. +Depends: + ${misc:Depends}, + ${shlibs:Depends}, + ${python3:Depends}, + python3, + python3-docker (>= 4.3.1), + python3-jinja2 (>= 2.11.3), + python3-molecule (>= 6.0.0~alpha1), + python3-openstacksdk (>= 1.1.0), + python3-requests, + python3-selinux, + python3-vagrant (>= 1.0.0), + python3-yaml (>= 5.1), +Conflicts: + python3-molecule-docker, + python3-molecule-podman, + python3-molecule-vagrant, +Replaces: + python3-molecule-docker, + python3-molecule-podman, + python3-molecule-vagrant, diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..b3b6b931 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,21 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: debian/* +Copyright: 2025 Wong Hoi Sing Edison +License: Apache-2.0 + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + The complete text of the Apache version 2.0 license + can be found in "/usr/share/common-licenses/Apache-2.0". diff --git a/debian/python3-molecule-plugins.install b/debian/python3-molecule-plugins.install new file mode 100644 index 00000000..e3da3e75 --- /dev/null +++ b/debian/python3-molecule-plugins.install @@ -0,0 +1 @@ +usr/lib/python*/*-packages/* diff --git a/debian/python3-molecule-plugins.lintian-overrides b/debian/python3-molecule-plugins.lintian-overrides new file mode 100644 index 00000000..35a863a2 --- /dev/null +++ b/debian/python3-molecule-plugins.lintian-overrides @@ -0,0 +1,4 @@ +python3-molecule-plugins: copyright-without-copyright-notice +python3-molecule-plugins: initial-upload-closes-no-bugs +python3-molecule-plugins: no-manual-page +python3-molecule-plugins: zero-byte-file-in-doc-directory diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..fcaa45ef --- /dev/null +++ b/debian/rules @@ -0,0 +1,15 @@ +#!/usr/bin/make -f + +SHELL := /bin/bash + +override_dh_auto_install: + dh_auto_install --destdir=debian/tmp + find debian/tmp/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \; + fdupes -qnrps debian/tmp/usr/lib/python*/*-packages + +override_dh_auto_test: + +override_dh_auto_clean: + +%: + dh $@ --buildsystem=pybuild --with python3 diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 00000000..699b4c4d --- /dev/null +++ b/debian/source/lintian-overrides @@ -0,0 +1,5 @@ +python-molecule-plugins source: file-without-copyright-information +python-molecule-plugins source: no-debian-changes +python-molecule-plugins source: source-contains-prebuilt-windows-binary +python-molecule-plugins source: source-is-missing +python-molecule-plugins source: source-package-encodes-python-version diff --git a/pyproject.toml b/pyproject.toml index 18d1c2df..5d0c0ce5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] requires = [ "setuptools >= 64.0.0", # required by pyproject+setuptools_scm integration - "setuptools_scm[toml] >= 7.0.5", # required for "no-local-version" scheme ] build-backend = "setuptools.build_meta" @@ -9,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] # https://peps.python.org/pep-0621/#readme requires-python = ">=3.9" -dynamic = ["version"] +version = "23.6.0" name = "molecule-plugins" description = "Molecule Plugins" readme = "README.md" @@ -139,7 +138,3 @@ gce = "molecule_plugins.gce.driver:GCE" podman = "molecule_plugins.podman.driver:Podman" vagrant = "molecule_plugins.vagrant.driver:Vagrant" openstack = "molecule_plugins.openstack.driver:Openstack" - -[tool.setuptools_scm] -local_scheme = "no-local-version" -write_to = "src/molecule_plugins/_version.py" diff --git a/python-molecule-plugins.spec b/python-molecule-plugins.spec new file mode 100644 index 00000000..945ff970 --- /dev/null +++ b/python-molecule-plugins.spec @@ -0,0 +1,141 @@ +# Copyright 2025 Wong Hoi Sing Edison +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +%global debug_package %{nil} + +%global source_date_epoch_from_changelog 0 + +Name: python-molecule-plugins +Epoch: 100 +Version: 23.6.0 +Release: 1%{?dist} +BuildArch: noarch +Summary: Molecule Plugins +License: BSD-3-Clause +URL: https://github.com/ansible-community/molecule-plugins/tags +Source0: %{name}_%{version}.orig.tar.gz +BuildRequires: fdupes +BuildRequires: python-rpm-macros +BuildRequires: python3-devel +BuildRequires: python3-setuptools + +%description +Molecule Plugins. + +%prep +%autosetup -T -c -n %{name}_%{version}-%{release} +tar -zx -f %{S:0} --strip-components=1 -C . + +%build +%py3_build + +%install +%py3_install +find %{buildroot}%{python3_sitelib} -type f -name '*.pyc' -exec rm -rf {} \; +fdupes -qnrps %{buildroot}%{python3_sitelib} + +%check + +%if 0%{?suse_version} > 1500 +%package -n python%{python3_version_nodots}-molecule-plugins +Summary: Molecule Plugins +Requires: python3 +Requires: python3-docker >= 4.3.1 +Requires: python3-Jinja2 >= 2.11.3 +Requires: python3-molecule >= 6.0.0-alpha1 +Requires: python3-openstacksdk >= 1.1.0 +Requires: python3-PyYAML >= 5.1 +Requires: python3-requests +Requires: python3-selinux +Requires: python3-vagrant >= 1.0.0 +Provides: python3-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python3dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Conflicts: python3-molecule-docker +Conflicts: python3-molecule-podman +Conflicts: python3-molecule-vagrant + +%description -n python%{python3_version_nodots}-molecule-plugins +Molecule Plugins. + +%files -n python%{python3_version_nodots}-molecule-plugins +%license LICENSE +%{python3_sitelib}/* +%endif + +%if 0%{?sle_version} > 150000 +%package -n python3-molecule-plugins +Summary: Molecule Plugins +Requires: python3 +Requires: python3-docker >= 4.3.1 +Requires: python3-Jinja2 >= 2.11.3 +Requires: python3-molecule >= 6.0.0-alpha1 +Requires: python3-openstacksdk >= 1.1.0 +Requires: python3-PyYAML >= 5.1 +Requires: python3-requests +Requires: python3-selinux +Requires: python3-vagrant >= 1.0.0 +Provides: python3-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python3dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Conflicts: python3-molecule-docker +Conflicts: python3-molecule-podman +Conflicts: python3-molecule-vagrant + +%description -n python3-molecule-plugins +Molecule Plugins. + +%files -n python3-molecule-plugins +%license LICENSE +%{python3_sitelib}/* +%endif + +%if !(0%{?suse_version} > 1500) && !(0%{?sle_version} > 150000) +%package -n python3-molecule-plugins +Summary: Molecule Plugins +Requires: python3 +Requires: python3-docker >= 4.3.1 +Requires: python3-jinja2 >= 2.11.3 +Requires: python3-libselinux +Requires: python3-molecule >= 6.0.0-alpha1 +Requires: python3-openstacksdk >= 1.1.0 +Requires: python3-pyyaml >= 5.1 +Requires: python3-requests +Requires: python3-selinux +Requires: python3-vagrant >= 1.0.0 +Provides: python3-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python3dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-molecule-plugins = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(molecule-plugins) = %{epoch}:%{version}-%{release} +Conflicts: python3-molecule-docker +Conflicts: python3-molecule-podman +Conflicts: python3-molecule-vagrant + +%description -n python3-molecule-plugins +Molecule Plugins. + +%files -n python3-molecule-plugins +%license LICENSE +%{python3_sitelib}/* +%endif + +%changelog diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..8bfd5a12 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,4 @@ +[egg_info] +tag_build = +tag_date = 0 + diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..8bf1ba93 --- /dev/null +++ b/setup.py @@ -0,0 +1,2 @@ +from setuptools import setup +setup() diff --git a/src/molecule_plugins/_version.py b/src/molecule_plugins/_version.py new file mode 100644 index 00000000..654e2623 --- /dev/null +++ b/src/molecule_plugins/_version.py @@ -0,0 +1,4 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '23.6.0' +__version_tuple__ = version_tuple = (23, 6, 0) diff --git a/src/molecule_plugins/podman/driver.py b/src/molecule_plugins/podman/driver.py index 5f7621c6..3e84ed7d 100644 --- a/src/molecule_plugins/podman/driver.py +++ b/src/molecule_plugins/podman/driver.py @@ -30,7 +30,8 @@ from molecule import logger, util from molecule.api import Driver, MoleculeRuntimeWarning from molecule.constants import RC_SETUP_ERROR -from molecule.util import run_command, sysexit_with_message +from molecule.util import sysexit_with_message +from molecule.app import App log = logger.get_logger(__name__) @@ -246,4 +247,4 @@ def required_collections(self) -> dict[str, str]: def reset(self): # keep `--filter` in sync with playbooks/create.yml - run_command(["podman", "rm", "--force", "--filter=label=owner=molecule"]) + app.run_command(["podman", "rm", "--force", "--filter=label=owner=molecule"]) diff --git a/src/molecule_plugins/podman/playbooks/create.yml b/src/molecule_plugins/podman/playbooks/create.yml index 57eab266..89e131d5 100644 --- a/src/molecule_plugins/podman/playbooks/create.yml +++ b/src/molecule_plugins/podman/playbooks/create.yml @@ -8,6 +8,24 @@ vars: podman_exec: "{{ lookup('env','MOLECULE_PODMAN_EXECUTABLE')|default('podman',true) }}" tasks: + - name: Get passwd entries for USER env + ansible.builtin.getent: + database: passwd + key: "{{ lookup('env', 'USER') }}" + + - name: Get shell async_dir + ansible.builtin.set_fact: + _shell_async_dir: >- + {{ lookup('ansible.builtin.config', 'async_dir', plugin_type='shell', plugin_name='sh') + | regex_replace('^~', ansible_facts.getent_passwd[lookup('env', 'USER')][4]) }} + + - name: Set async_dir for HOME env + ansible.builtin.set_fact: + ansible_async_dir: >- + {{ _shell_async_dir + | regex_replace('^' + ansible_facts.getent_passwd[lookup('env', 'USER')][4], lookup('env', 'HOME')) }} + when: lookup('env', 'HOME') != ansible_facts.getent_passwd[lookup('env', 'USER')][4] + - name: Log into a container registry containers.podman.podman_login: certdir: >- diff --git a/src/molecule_plugins/podman/playbooks/destroy.yml b/src/molecule_plugins/podman/playbooks/destroy.yml index 23823c2e..26199935 100644 --- a/src/molecule_plugins/podman/playbooks/destroy.yml +++ b/src/molecule_plugins/podman/playbooks/destroy.yml @@ -8,6 +8,24 @@ vars: podman_exec: "{{ lookup('env','MOLECULE_PODMAN_EXECUTABLE')|default('podman',true) }}" tasks: + - name: Get passwd entries for USER env + ansible.builtin.getent: + database: passwd + key: "{{ lookup('env', 'USER') }}" + + - name: Get shell async_dir + ansible.builtin.set_fact: + _shell_async_dir: >- + {{ lookup('ansible.builtin.config', 'async_dir', plugin_type='shell', plugin_name='sh') + | regex_replace('^~', ansible_facts.getent_passwd[lookup('env', 'USER')][4]) }} + + - name: Set async_dir for HOME env + ansible.builtin.set_fact: + ansible_async_dir: >- + {{ _shell_async_dir + | regex_replace('^' + ansible_facts.getent_passwd[lookup('env', 'USER')][4], lookup('env', 'HOME')) }} + when: lookup('env', 'HOME') != ansible_facts.getent_passwd[lookup('env', 'USER')][4] + - name: Destroy molecule instance(s) ansible.builtin.shell: "{{ podman_exec }} container exists {{ item.name }} && {{ podman_exec }} rm -f {{ item.name }} || true" register: server diff --git a/src/molecule_plugins/vagrant/modules/vagrant.py b/src/molecule_plugins/vagrant/modules/vagrant.py index 0900b174..9a97cf84 100755 --- a/src/molecule_plugins/vagrant/modules/vagrant.py +++ b/src/molecule_plugins/vagrant/modules/vagrant.py @@ -364,6 +364,7 @@ def merge_dicts(a: MutableMapping, b: MutableMapping) -> MutableMapping: class VagrantClient: def __init__(self, module) -> None: self._module = module + self.provider = self._module.params["provider_name"] self.provision = self._module.params["provision"] self.cachier = self._module.params["cachier"] @@ -451,9 +452,10 @@ def up(self): changed = False if self._running() != len(self.instances): changed = True + provider = self.provider provision = self.provision with contextlib.suppress(Exception): - self._vagrant.up(provision=provision) + self._vagrant.up(provider=provider, provision=provision) # NOTE(retr0h): Ansible wants only one module return `fail_json` # or `exit_json`. diff --git a/test/azure/functional/test_azure.py b/test/azure/functional/test_azure.py index ffe94689..43ce0e98 100644 --- a/test/azure/functional/test_azure.py +++ b/test/azure/functional/test_azure.py @@ -25,7 +25,7 @@ from conftest import change_dir_to from molecule import logger -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) @@ -33,7 +33,7 @@ def test_azure_command_init_scenario(temp_dir): role_directory = os.path.join(temp_dir.strpath, "test_init") cmd = ["ansible-galaxy", "role", "init", "test_init"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 with change_dir_to(role_directory): @@ -47,7 +47,7 @@ def test_azure_command_init_scenario(temp_dir): "-a", 'path=meta/main.yml line=" namespace: foo" insertafter=" author: your name"', ] - run_command(cmd_meta, check=True) + app.run_command(cmd_meta, check=True) # we need to inject namespace info into tests/test.yml cmd_tests = [ @@ -59,7 +59,7 @@ def test_azure_command_init_scenario(temp_dir): "-a", 'path=tests/test.yml line=" - foo.test_init" regex="^(.*) - test_init"', ] - run_command(cmd_tests, check=True) + app.run_command(cmd_tests, check=True) molecule_directory = pytest.helpers.molecule_directory() scenario_directory = os.path.join(molecule_directory, "test_scenario") @@ -71,7 +71,7 @@ def test_azure_command_init_scenario(temp_dir): "--driver-name", "azure", ] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 assert os.path.isdir(scenario_directory) @@ -82,5 +82,5 @@ def test_azure_command_init_scenario(temp_dir): # temporary trick to pass on CI/CD if "AZURE_SECRET" in os.environ: cmd = ["molecule", "test", "-s", "test-scenario"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 diff --git a/test/containers/functional/test_containers.py b/test/containers/functional/test_containers.py index 3b3ddea0..757b9b78 100644 --- a/test/containers/functional/test_containers.py +++ b/test/containers/functional/test_containers.py @@ -23,7 +23,7 @@ from conftest import change_dir_to, molecule_directory from molecule import logger -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) @@ -40,7 +40,7 @@ def test_containers_command_init_scenario(temp_dir): "--driver-name", "containers", ] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 assert os.path.isdir(scenario_directory) @@ -49,5 +49,5 @@ def test_containers_command_init_scenario(temp_dir): # is shorter but comprehensive enough to test the most important # functionality: destroy, dependency, create, prepare, converge cmd = ["molecule", "check", "-s", "default"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 diff --git a/test/docker/test_func.py b/test/docker/test_func.py index 481ebf6d..cbc7dc44 100644 --- a/test/docker/test_func.py +++ b/test/docker/test_func.py @@ -9,7 +9,7 @@ from conftest import change_dir_to from molecule import logger -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) @@ -40,21 +40,21 @@ def test_command_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) -> "--driver-name", DRIVER, ] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 assert scenario_directory.exists() # run molecule reset as this may clean some leftovers from other # test runs and also ensure that reset works. - result = run_command(["molecule", "reset"]) # default scenario + result = app.run_command(["molecule", "reset"]) # default scenario assert result.returncode == 0 - result = run_command(["molecule", "reset", "-s", scenario_name]) + result = app.run_command(["molecule", "reset", "-s", scenario_name]) assert result.returncode == 0 cmd = ["molecule", "--debug", "test", "-s", scenario_name] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 @@ -63,7 +63,7 @@ def test_command_static_scenario() -> None: """Validate that the scenario we included with code still works.""" cmd = ["molecule", "test"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 @@ -72,7 +72,7 @@ def test_dockerfile_with_context() -> None: """Verify that Dockerfile.j2 with context works.""" with change_dir_to("test/docker/scenarios/with-context"): cmd = ["molecule", "--debug", "test"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 @@ -82,5 +82,5 @@ def test_env_substitution() -> None: os.environ["MOLECULE_ROLE_IMAGE"] = "debian:bullseye" with change_dir_to("test/docker/scenarios/env-substitution"): cmd = ["molecule", "--debug", "test"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 diff --git a/test/ec2/functional/test_ec2.py b/test/ec2/functional/test_ec2.py index e546a442..3e089901 100644 --- a/test/ec2/functional/test_ec2.py +++ b/test/ec2/functional/test_ec2.py @@ -25,7 +25,7 @@ from conftest import change_dir_to, metadata_lint_update from molecule import logger -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) @@ -34,7 +34,7 @@ def test_ec2_command_init_scenario(temp_dir): role_directory = os.path.join(temp_dir.strpath, "test-init") cmd = ["molecule", "init", "role", "test-init"] - assert run_command(cmd).returncode == 0 + assert app.run_command(cmd).returncode == 0 metadata_lint_update(role_directory) with change_dir_to(role_directory): @@ -48,11 +48,11 @@ def test_ec2_command_init_scenario(temp_dir): "--role_name=test-init", "--driver-name=ec2", ] - assert run_command(cmd).returncode == 0 + assert app.run_command(cmd).returncode == 0 assert os.path.isdir(scenario_directory) os.unlink(os.path.join(scenario_directory, "create.yml")) os.unlink(os.path.join(scenario_directory, "destroy.yml")) cmd = ["molecule", "test", "-s", "test-scenario"] - assert run_command(cmd).returncode == 0 + assert app.run_command(cmd).returncode == 0 diff --git a/test/gce/functional/test_func.py b/test/gce/functional/test_func.py index 8fe05f15..bdb3ae32 100644 --- a/test/gce/functional/test_func.py +++ b/test/gce/functional/test_func.py @@ -25,7 +25,7 @@ from conftest import change_dir_to, metadata_lint_update from molecule import logger -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) driver_name = __name__.split(".")[0].split("_")[-1] @@ -36,7 +36,7 @@ def test_gce_command_init_scenario(temp_dir): """Test init scenario with driver.""" role_directory = os.path.join(temp_dir.strpath, "test-init") cmd = ["molecule", "init", "role", "test-init"] - assert run_command(cmd).returncode == 0 + assert app.run_command(cmd).returncode == 0 metadata_lint_update(role_directory) with change_dir_to(role_directory): @@ -52,11 +52,11 @@ def test_gce_command_init_scenario(temp_dir): "--driver-name", driver_name, ] - assert run_command(cmd).returncode == 0 + assert app.run_command(cmd).returncode == 0 assert os.path.isdir(scenario_directory) os.unlink(os.path.join(scenario_directory, "create.yml")) os.unlink(os.path.join(scenario_directory, "destroy.yml")) cmd = ["molecule", "test", "-s", "test-scenario"] - assert run_command(cmd).returncode == 0 + assert app.run_command(cmd).returncode == 0 diff --git a/test/openstack/test_func.py b/test/openstack/test_func.py index 44e57c5b..6a59d843 100644 --- a/test/openstack/test_func.py +++ b/test/openstack/test_func.py @@ -10,7 +10,7 @@ import openstack from conftest import change_dir_to from molecule import logger -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) @@ -53,7 +53,7 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) - "--driver-name", DRIVER, ] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 assert scenario_directory.exists() @@ -71,7 +71,7 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) - shutil.copyfile(testconf, confpath) cmd = ["molecule", "--debug", "test", "-s", scenario_name] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 @@ -86,5 +86,5 @@ def test_specific_scenarios(temp_dir, scenario) -> None: with change_dir_to(scenario_directory): cmd = ["molecule", "test", "--scenario-name", scenario] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 diff --git a/test/podman/test_func.py b/test/podman/test_func.py index f314a156..19d085bf 100644 --- a/test/podman/test_func.py +++ b/test/podman/test_func.py @@ -6,7 +6,7 @@ from conftest import change_dir_to from molecule import logger -from molecule.util import run_command +from molecule.app import App from molecule_plugins.podman import __file__ as module_file LOG = logger.get_logger(__name__) @@ -35,27 +35,27 @@ def test_podman_command_init_scenario(tmp_path: pathlib.Path): "--driver-name", "podman", ] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 assert scenario_directory.exists() # run molecule reset as this may clean some leftovers from other # test runs and also ensure that reset works. - result = run_command(["molecule", "reset"]) # default sceanario + result = app.run_command(["molecule", "reset"]) # default sceanario assert result.returncode == 0 - result = run_command(["molecule", "reset", "-s", scenario_name]) + result = app.run_command(["molecule", "reset", "-s", scenario_name]) assert result.returncode == 0 cmd = ["molecule", "--debug", "test", "-s", scenario_name] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 def test_sample() -> None: """Runs the sample scenario present at the repository root.""" - result = run_command(["molecule", "test", "-s", "test-podman"]) # default sceanario + result = app.run_command(["molecule", "test", "-s", "test-podman"]) # default sceanario assert result.returncode == 0 diff --git a/test/vagrant-plugin/functional/test_func.py b/test/vagrant-plugin/functional/test_func.py index 9fedef4e..e858e413 100644 --- a/test/vagrant-plugin/functional/test_func.py +++ b/test/vagrant-plugin/functional/test_func.py @@ -29,7 +29,7 @@ from conftest import change_dir_to from molecule import logger, util from molecule.scenario import ephemeral_directory -from molecule.util import run_command +from molecule.app import App LOG = logger.get_logger(__name__) @@ -59,7 +59,7 @@ def test_vagrant_command_init_scenario(temp_dir): "--driver-name", "vagrant", ] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 assert os.path.isdir(scenario_directory) @@ -77,7 +77,7 @@ def test_vagrant_command_init_scenario(temp_dir): conf["driver"]["provider"] = {"name": "libvirt"} util.write_file(confpath, util.safe_dump(conf)) cmd = ["molecule", "--debug", "test", "-s", "test-scenario"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 @@ -94,7 +94,7 @@ def test_invalid_settings(temp_dir): with change_dir_to(scenario_directory): cmd = ["molecule", "create", "--scenario-name", "invalid"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 2 assert "Failed to validate generated Vagrantfile" in result.stdout @@ -126,7 +126,7 @@ def test_vagrant_root(temp_dir, scenario): with change_dir_to(scenario_directory): cmd = ["molecule", "test", "--scenario-name", scenario] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 @@ -143,7 +143,7 @@ def test_multi_node(temp_dir): with change_dir_to(scenario_directory): cmd = ["molecule", "test", "--scenario-name", "multi-node"] - result = run_command(cmd) + result = app.run_command(cmd) assert result.returncode == 0 molecule_eph_directory = ephemeral_directory() diff --git a/tox.ini b/tox.ini index ee38120a..7e7d2223 100644 --- a/tox.ini +++ b/tox.ini @@ -59,6 +59,7 @@ passenv = SSL_CERT_FILE TOXENV TWINE_* + USER OS_* allowlist_externals = bash