Switch to using our onedir to run the package tests

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-03-08 15:23:57 +00:00 committed by Pedro Algarvio
parent fe440b5d49
commit f158710818
6 changed files with 71 additions and 9 deletions

View file

@ -114,6 +114,7 @@ jobs:
python3 -c "import os; os.makedirs('artifacts', exist_ok=True)"
cd artifacts
tar xvf ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
- name: Set up Python ${{ inputs.python-version }}
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v4

View file

@ -103,7 +103,6 @@ jobs:
path: nox.${{ inputs.distro-slug }}.tar.*
key: ${{ inputs.cache-prefix }}|testrun-deps|${{ inputs.distro-slug }}|${{ inputs.nox-session }}|${{ matrix.transport }}|${{ hashFiles('requirements/**/*.txt', 'cicd/golden-images.json') }}
# Skip jobs if nox.*.tar.* is already cached
- name: Download Onedir Tarball as an Artifact
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v3

View file

@ -89,7 +89,6 @@ jobs:
path: nox.${{ inputs.distro-slug }}.tar.*
key: ${{ inputs.cache-prefix }}|testrun-deps|${{ inputs.distro-slug }}|${{ matrix.nox-session }}|${{ hashFiles('requirements/**/*.txt', 'cicd/golden-images.json') }}
# Skip jobs if nox.*.tar.* is already cached
- name: Download Onedir Tarball as an Artifact
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v3
@ -187,6 +186,19 @@ jobs:
run: |
tree pkg/artifacts
- name: Download Onedir Tarball as an Artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
path: artifacts/
- name: Decompress Onedir Tarball
shell: bash
run: |
python3 -c "import os; os.makedirs('artifacts', exist_ok=True)"
cd artifacts
tar xvf ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:

View file

@ -90,7 +90,6 @@ jobs:
path: nox.${{ inputs.distro-slug }}.tar.*
key: ${{ inputs.cache-prefix }}|testrun-deps|${{ inputs.distro-slug }}|${{ matrix.nox-session }}|${{ hashFiles('requirements/**/*.txt', 'cicd/golden-images.json') }}
# Skip jobs if nox.*.tar.* is already cached
- name: Download Onedir Tarball as an Artifact
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v3

View file

@ -1762,12 +1762,14 @@ def build(session):
session.run("python", "-m", "twine", "check", "dist/*")
def _pkg_test(session, cmd_args, test_type):
def _pkg_test(session, cmd_args, test_type, onedir=False):
pydir = _get_pydir(session)
junit_report_filename = f"test-results-{test_type}"
runtests_log_filename = f"runtests-{test_type}"
# Install requirements
if _upgrade_pip_setuptools_and_wheel(session):
if onedir and IS_LINUX:
session_run_always(session, "python3", "-m", "relenv", "toolchain", "fetch")
if _upgrade_pip_setuptools_and_wheel(session, onedir=onedir):
if IS_WINDOWS:
file_name = "pkgtests-windows.txt"
else:
@ -1780,6 +1782,10 @@ def _pkg_test(session, cmd_args, test_type):
install_command = ["--progress-bar=off", "-r", requirements_file]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
env = {}
if onedir:
env["ONEDIR_TESTRUN"] = "1"
pytest_args = (
cmd_args[:]
+ [
@ -1788,7 +1794,7 @@ def _pkg_test(session, cmd_args, test_type):
]
+ session.posargs
)
_pytest(session, False, pytest_args)
_pytest(session, False, pytest_args, env=env)
@nox.session(python=_PYTHON_VERSIONS, name="test-pkgs")
@ -1799,6 +1805,21 @@ def test_pkgs(session):
_pkg_test(session, ["pkg/tests/"], "pkg")
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="test-pkgs-onedir",
venv_params=["--system-site-packages"],
)
def test_pkgs_onedir(session):
if not ONEDIR_ARTIFACT_PATH.exists():
session.error(
"The salt onedir artifact, expected to be in '{}', was not found".format(
ONEDIR_ARTIFACT_PATH.relative_to(REPO_ROOT)
)
)
_pkg_test(session, ["pkg/tests/"], "pkg", onedir=True)
@nox.session(python=_PYTHON_VERSIONS, name="test-upgrade-pkgs")
@nox.parametrize("classic", [False, True])
def test_upgrade_pkgs(session, classic):
@ -1823,3 +1844,33 @@ def test_upgrade_pkgs(session, classic):
cmd_args = ["pkg/tests/", "--no-install"] + session.posargs
_pkg_test(session, cmd_args, test_type)
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="test-upgrade-pkgs-onedir",
venv_params=["--system-site-packages"],
)
@nox.parametrize("classic", [False, True])
def test_upgrade_pkgs_onedir(session, classic):
"""
pytest pkg upgrade tests session
"""
test_type = "pkg_upgrade"
cmd_args = [
"pkg/tests/upgrade/test_salt_upgrade.py::test_salt_upgrade",
"--upgrade",
"--no-uninstall",
]
if classic:
cmd_args = cmd_args + ["--classic"]
# Workaround for installing and running classic packages from 3005.1
# They can only run with importlib-metadata<5.0.0.
subprocess.run(["pip3", "install", "importlib-metadata==4.13.0"], check=False)
try:
_pkg_test(session, cmd_args, test_type, onedir=True)
except nox.command.CommandFailed:
sys.exit(1)
cmd_args = ["pkg/tests/", "--no-install"] + session.posargs
_pkg_test(session, cmd_args, test_type, onedir=True)

View file

@ -670,7 +670,7 @@ def pkg_matrix(ctx: Context, distro_slug: str, pkg_type: str):
"""
_matrix = []
sessions = [
"test-pkgs-3",
"test-pkgs-onedir",
]
if (
distro_slug
@ -686,13 +686,13 @@ def pkg_matrix(ctx: Context, distro_slug: str, pkg_type: str):
# we will need to ensure when we release 3006.0
# we allow for 3006.0 jobs to run, because then
# we will have arm64 onedir packages to upgrade from
sessions.append("'test-upgrade-pkgs-3(classic=False)'")
sessions.append("'test-upgrade-pkgs-onedir(classic=False)'")
if (
distro_slug not in ["centosstream-9", "ubuntu-22.04", "ubuntu-22.04-arm64"]
and "MSI" != pkg_type
):
# Packages for these OSs where never built for classic previously
sessions.append("'test-upgrade-pkgs-3(classic=True)'")
sessions.append("'test-upgrade-pkgs-onedir(classic=True)'")
for sess in sessions:
_matrix.append({"nox-session": sess})