Skip to content

Commit

Permalink
Fix CI with newest molecule
Browse files Browse the repository at this point in the history
Get rid of the use of  molecule ephemeral_directory() as it's gone.
The most affected test was the vagrant one, as it's checking the
generated Vagrantfile. Set the environment variable for the
ephemeral directory in this case, so that we know for sure
the path of the ephemeral directory.

Signed-off-by: Arnaud Patard <[email protected]>
  • Loading branch information
apatard committed Feb 21, 2025
1 parent 980db38 commit e4b1469
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
11 changes: 0 additions & 11 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from molecule import config, logger
from molecule.app import get_app
from molecule.scenario import ephemeral_directory

LOG = logger.get_logger(__name__)

Expand Down Expand Up @@ -79,16 +78,6 @@ def get_molecule_file(path):
return config.molecule_file(path)


@pytest.helpers.register
def molecule_ephemeral_directory(_fixture_uuid):
project_directory = f"test-project-{_fixture_uuid}"
scenario_name = "test-instance"

return ephemeral_directory(
os.path.join("molecule_test", project_directory, scenario_name),
)


def metadata_lint_update(role_directory: str) -> None:
# By default, ansible-lint will fail on newly-created roles because the
# fields in this file have not been changed from their defaults. This is
Expand Down
10 changes: 5 additions & 5 deletions test/vagrant-plugin/functional/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from conftest import change_dir_to
from molecule import logger, util
from molecule.app import get_app
from molecule.scenario import ephemeral_directory

LOG = logger.get_logger(__name__)

Expand Down Expand Up @@ -141,16 +140,17 @@ def test_multi_node(temp_dir):
"scenarios",
)

molecule_eph_directory = os.path.join(temp_dir, "ephemeral")
env = os.environ
env["MOLECULE_EPHEMERAL_DIRECTORY"] = molecule_eph_directory

with change_dir_to(scenario_directory):
cmd = ["molecule", "test", "--scenario-name", "multi-node"]
result = get_app(Path()).run_command(cmd)
result = get_app(Path()).run_command(cmd, env=env)
assert result.returncode == 0

molecule_eph_directory = ephemeral_directory()
vagrantfile = os.path.join(
molecule_eph_directory,
"scenarios",
"multi-node",
"Vagrantfile",
)
with open(vagrantfile) as f:
Expand Down

0 comments on commit e4b1469

Please sign in to comment.