From c516daca85ec477758de5aafdf5dc00307a3ebd4 Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Thu, 3 Aug 2023 18:18:33 +0530 Subject: [PATCH] Revert "Update tests to use v6-alpha1 molecule version" (#178) Revert "Update tests to use v6-alpha1 molecule version (#177)" This reverts commit 83383587d7481f2ef36190500392eda4490d07fd. --- .ansible-lint-ignore | 15 --------------- pyproject.toml | 4 ++-- test/azure/functional/test_azure.py | 28 +++------------------------- test/ec2/functional/test_ec2.py | 2 +- test/gce/functional/test_func.py | 2 +- tools/generate-templates.sh | 11 +++-------- 6 files changed, 10 insertions(+), 52 deletions(-) diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore index 8773c24c..b1276b58 100644 --- a/.ansible-lint-ignore +++ b/.ansible-lint-ignore @@ -1,18 +1,3 @@ test/gce/scenarios/linux/molecule.yml yaml[line-length] test/gce/scenarios/windows/molecule.yml yaml[line-length] test/roles/ec2plugin/molecule/default/create.yml no-handler - -test/roles/vagrantplugin/molecule/default/destroy.yml yaml[octal-values] -test/roles/vagrantplugin/molecule/default/create.yml yaml[octal-values] -test/roles/podmanplugin/molecule/default/destroy.yml yaml[octal-values] -test/roles/podmanplugin/molecule/default/create.yml yaml[octal-values] -test/roles/gceplugin/molecule/default/destroy.yml yaml[octal-values] -test/roles/gceplugin/molecule/default/create.yml yaml[octal-values] -test/roles/ec2plugin/molecule/default/destroy.yml yaml[octal-values] -test/roles/ec2plugin/molecule/default/create.yml yaml[octal-values] -test/roles/dockerplugin/molecule/default/destroy.yml yaml[octal-values] -test/roles/dockerplugin/molecule/default/create.yml yaml[octal-values] -test/roles/containersplugin/molecule/default/destroy.yml yaml[octal-values] -test/roles/containersplugin/molecule/default/create.yml yaml[octal-values] -test/roles/azureplugin/molecule/default/create.yml yaml[octal-values] -test/roles/azureplugin/molecule/default/destroy.yml yaml[octal-values] diff --git a/pyproject.toml b/pyproject.toml index aede685a..24165ce5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ classifiers = [ keywords = ["ansible", "testing", "molecule", "plugin"] dependencies = [ # molecule plugins are not allowed to mention Ansible as a direct dependency - "molecule >= 6.0.0a1", + "molecule >= 5.0", ] [project.urls] @@ -51,7 +51,7 @@ changelog = "https://github.com/ansible-community/molecule-plugins/releases" [project.optional-dependencies] test = [ "pytest-helpers-namespace >= 2019.1.8", - "molecule[test] >= 6.0.0a1" + "molecule[test]" ] azure = [] docker = [ diff --git a/test/azure/functional/test_azure.py b/test/azure/functional/test_azure.py index 4ed26c3a..f9d7135c 100644 --- a/test/azure/functional/test_azure.py +++ b/test/azure/functional/test_azure.py @@ -32,35 +32,11 @@ def test_command_init_scenario(temp_dir): role_directory = os.path.join(temp_dir.strpath, "test_init") - cmd = ["ansible-galaxy", "role", "init", "test_init"] + cmd = ["molecule", "init", "role", "foo.test_init"] result = run_command(cmd) assert result.returncode == 0 with change_dir_to(role_directory): - # we need to inject namespace info into meta/main.yml - cmd_meta = [ - "ansible", - "localhost", - "-o", # one line output - "-m", - "lineinfile", - "-a", - 'path=meta/main.yml line=" namespace: foo" insertafter=" author: your name"', - ] - run_command(cmd_meta, check=True) - - # we need to inject namespace info into tests/test.yml - cmd_tests = [ - "ansible", - "localhost", - "-o", # one line output - "-m", - "lineinfile", - "-a", - 'path=tests/test.yml line=" - foo.test_init" regex="^(.*) - test_init"', - ] - run_command(cmd_tests, check=True) - molecule_directory = pytest.helpers.molecule_directory() scenario_directory = os.path.join(molecule_directory, "test_scenario") cmd = [ @@ -68,6 +44,8 @@ def test_command_init_scenario(temp_dir): "init", "scenario", "test_scenario", + "--role-name", + "test_init", "--driver-name", "azure", ] diff --git a/test/ec2/functional/test_ec2.py b/test/ec2/functional/test_ec2.py index bc6dbdd9..7374bc03 100644 --- a/test/ec2/functional/test_ec2.py +++ b/test/ec2/functional/test_ec2.py @@ -24,8 +24,8 @@ import pytest from molecule import logger -from molecule.test.b_functional.conftest import metadata_lint_update from molecule.test.conftest import change_dir_to +from molecule.test.functional.conftest import metadata_lint_update from molecule.util import run_command LOG = logger.get_logger(__name__) diff --git a/test/gce/functional/test_func.py b/test/gce/functional/test_func.py index 4d42c1a7..af210cd7 100644 --- a/test/gce/functional/test_func.py +++ b/test/gce/functional/test_func.py @@ -24,8 +24,8 @@ import pytest from molecule import logger -from molecule.test.b_functional.conftest import metadata_lint_update from molecule.test.conftest import change_dir_to +from molecule.test.functional.conftest import metadata_lint_update from molecule.util import run_command LOG = logger.get_logger(__name__) diff --git a/tools/generate-templates.sh b/tools/generate-templates.sh index 19fa1846..7a65c7fa 100644 --- a/tools/generate-templates.sh +++ b/tools/generate-templates.sh @@ -9,21 +9,16 @@ while IFS='' read -r line; do DRIVER_NAMES+=("$line"); done < <(python "tools/ex cd test/roles for DRIVER_NAME in "${DRIVER_NAMES[@]}"; do - ansible-galaxy role init "${DRIVER_NAME}"plugin - cd "${DRIVER_NAME}"plugin - ansible localhost -o -m lineinfile -a 'path=meta/main.yml line=" namespace: roles" insertafter=" author: your name"' - molecule init scenario --driver-name="${DRIVER_NAME}" + molecule init role roles."${DRIVER_NAME}"plugin --driver-name="${DRIVER_NAME}" sed \ -e 's!author:.*!author: molecule-plugins!g' \ - -e 's!namespace:.*!namespace: roles!g' \ -e 's!company:.*!company: ansible-community!g' \ -e 's!min_ansible_version:.*!min_ansible_version: "2.1"!g' \ -e 's!license:.*!license: MIT!g' \ - -i meta/main.yml + -i "${DRIVER_NAME}"plugin/meta/main.yml # Not sure if the issue is in molecule or ansible-lint or pre-commit ansible-lint hook # As a workaround, kill the offending files. - rm -rf tests - cd .. + rm -rf "${DRIVER_NAME}"plugin/tests done exit 0