2018-08-14 10:20:46 -05:00
|
|
|
import os
|
2020-05-27 06:59:11 +01:00
|
|
|
import pprint
|
2018-08-14 10:20:46 -05:00
|
|
|
import pytest
|
|
|
|
import testinfra
|
2020-05-27 06:59:11 +01:00
|
|
|
import logging
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
2018-08-14 10:20:46 -05:00
|
|
|
|
|
|
|
|
2020-12-08 22:22:46 +00:00
|
|
|
@pytest.fixture(scope="session")
|
2018-08-14 10:20:46 -05:00
|
|
|
def host():
|
2022-08-11 16:26:40 +01:00
|
|
|
if (
|
|
|
|
os.environ.get("RUNNER_OS", "") == "macOS"
|
|
|
|
and os.environ.get("KITCHEN_LOCAL_YAML", "") == "kitchen.macos.yml"
|
|
|
|
):
|
2022-04-25 21:56:09 +01:00
|
|
|
# Adjust the `PATH` so that the `salt-call` executable can be found
|
|
|
|
os.environ["PATH"] = "/opt/salt/bin{}{}".format(os.pathsep, os.environ["PATH"])
|
|
|
|
return testinfra.get_host("local://", sudo=True)
|
|
|
|
|
2021-03-28 10:36:27 +01:00
|
|
|
if os.environ.get("KITCHEN_USERNAME") == "vagrant" or "windows" in os.environ.get(
|
|
|
|
"KITCHEN_INSTANCE"
|
|
|
|
):
|
2020-12-08 22:22:46 +00:00
|
|
|
if "windows" in os.environ.get("KITCHEN_INSTANCE"):
|
2019-05-15 16:10:06 +01:00
|
|
|
return testinfra.get_host(
|
2020-12-08 22:22:46 +00:00
|
|
|
"winrm://{KITCHEN_USERNAME}:{KITCHEN_PASSWORD}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}".format(
|
|
|
|
**os.environ
|
|
|
|
),
|
|
|
|
no_ssl=True,
|
|
|
|
)
|
2019-05-15 16:10:06 +01:00
|
|
|
return testinfra.get_host(
|
2020-12-08 22:22:46 +00:00
|
|
|
"paramiko://{KITCHEN_USERNAME}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}".format(
|
|
|
|
**os.environ
|
|
|
|
),
|
|
|
|
ssh_identity_file=os.environ.get("KITCHEN_SSH_KEY"),
|
|
|
|
)
|
|
|
|
return testinfra.get_host(
|
|
|
|
"docker://{KITCHEN_USERNAME}@{KITCHEN_CONTAINER_ID}".format(**os.environ)
|
|
|
|
)
|
2020-05-27 06:59:11 +01:00
|
|
|
|
|
|
|
|
2020-12-08 22:22:46 +00:00
|
|
|
@pytest.fixture(scope="session")
|
2020-05-27 06:59:11 +01:00
|
|
|
def target_python_version():
|
2022-08-11 16:26:40 +01:00
|
|
|
return 3
|
2020-05-27 06:59:11 +01:00
|
|
|
|
|
|
|
|
2020-12-08 22:22:46 +00:00
|
|
|
@pytest.fixture(scope="session")
|
2020-05-27 06:59:11 +01:00
|
|
|
def target_salt_version():
|
|
|
|
target_salt = os.environ["KITCHEN_SUITE"].split("-", 2)[-1].replace("-", ".")
|
|
|
|
if target_salt in ("latest", "master"):
|
|
|
|
pytest.skip("Don't have a specific salt version to test against")
|
|
|
|
return target_salt
|