mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add a separate test to show system information and test plan.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
0caa4c4447
commit
d0cc319882
4 changed files with 92 additions and 3 deletions
11
.github/workflows/test-action-macos.yml
vendored
11
.github/workflows/test-action-macos.yml
vendored
|
@ -192,11 +192,22 @@ jobs:
|
|||
echo NOX_SESSION=${{ inputs.nox-session}}-tcp-3 >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Show System Info & Test Plan
|
||||
env:
|
||||
SKIP_REQUIREMENTS_INSTALL: "1"
|
||||
PRINT_TEST_SELECTION: "1"
|
||||
PRINT_TEST_PLAN_ONLY: "1"
|
||||
PRINT_SYSTEM_INFO: "1"
|
||||
SKIP_INITIAL_GH_ACTIONS_FAILURES: "1"
|
||||
run: |
|
||||
sudo -E nox -e ${{ env.NOX_SESSION }} -- ${{ matrix.tests-chunk }}
|
||||
|
||||
- name: Run Tests
|
||||
id: run-tests
|
||||
env:
|
||||
SKIP_REQUIREMENTS_INSTALL: "1"
|
||||
PRINT_TEST_SELECTION: "0"
|
||||
PRINT_TEST_PLAN_ONLY: "0"
|
||||
PRINT_SYSTEM_INFO: "0"
|
||||
RERUN_FAILURES: "1"
|
||||
SKIP_INITIAL_GH_ACTIONS_FAILURES: "1"
|
||||
|
|
7
.github/workflows/test-action.yml
vendored
7
.github/workflows/test-action.yml
vendored
|
@ -209,10 +209,15 @@ jobs:
|
|||
run: |
|
||||
tools --timestamps vm decompress-dependencies ${{ inputs.distro-slug }}
|
||||
|
||||
- name: Show System Info & Test Plan
|
||||
run: |
|
||||
tools --timestamps --no-output-timeout-secs=18000 vm testplan --skip-requirements-install \
|
||||
--nox-session=${{ env.NOX_SESSION }} ${{ inputs.distro-slug }} ${{ matrix.tests-chunk }}
|
||||
|
||||
- name: Run Tests
|
||||
id: run-tests
|
||||
run: |
|
||||
tools --timestamps --no-output-timeout-secs=18000 vm test --print-tests-selection --skip-requirements-install \
|
||||
tools --timestamps --no-output-timeout-secs=18000 vm test --skip-requirements-install \
|
||||
--nox-session=${{ env.NOX_SESSION }} --rerun-failures ${{ inputs.distro-slug }} ${{ matrix.tests-chunk }}
|
||||
|
||||
- name: Combine Coverage Reports
|
||||
|
|
14
noxfile.py
14
noxfile.py
|
@ -49,6 +49,11 @@ if PRINT_TEST_SELECTION is None:
|
|||
PRINT_TEST_SELECTION = CI_RUN
|
||||
else:
|
||||
PRINT_TEST_SELECTION = PRINT_TEST_SELECTION == "1"
|
||||
PRINT_TEST_PLAN_ONLY = os.environ.get("PRINT_TEST_PLAN_ONLY")
|
||||
if PRINT_TEST_PLAN_ONLY is None:
|
||||
PRINT_TEST_PLAN_ONLY = PRINT_TEST_SELECTION
|
||||
else:
|
||||
PRINT_TEST_PLAN_ONLY = PRINT_TEST_PLAN_ONLY == "1"
|
||||
PRINT_SYSTEM_INFO = os.environ.get("PRINT_SYSTEM_INFO")
|
||||
if PRINT_SYSTEM_INFO is None:
|
||||
PRINT_SYSTEM_INFO = CI_RUN
|
||||
|
@ -963,11 +968,14 @@ def pytest_tornado(session, coverage):
|
|||
session.notify(session_name.replace("pytest-", "test-"))
|
||||
|
||||
|
||||
def _pytest(session, coverage, cmd_args):
|
||||
def _pytest(session, coverage, cmd_args, env=None):
|
||||
# Create required artifacts directories
|
||||
_create_ci_directories()
|
||||
|
||||
env = {"CI_RUN": "1" if CI_RUN else "0"}
|
||||
if env is None:
|
||||
env = {}
|
||||
|
||||
env["CI_RUN"] = "1" if CI_RUN else "0"
|
||||
|
||||
args = [
|
||||
"--rootdir",
|
||||
|
@ -996,6 +1004,8 @@ def _pytest(session, coverage, cmd_args):
|
|||
session.run(
|
||||
"python", "-m", "pytest", *(args + ["--collect-only", "-qqq"]), env=env
|
||||
)
|
||||
if PRINT_TEST_PLAN_ONLY:
|
||||
return
|
||||
|
||||
if coverage is True:
|
||||
_run_with_coverage(
|
||||
|
|
63
tools/vm.py
63
tools/vm.py
|
@ -248,12 +248,15 @@ def test(
|
|||
"""
|
||||
vm = VM(ctx=ctx, name=name, region_name=ctx.parser.options.region)
|
||||
env = {
|
||||
"PRINT_TEST_PLAN_ONLY": "0",
|
||||
"SKIP_INITIAL_GH_ACTIONS_FAILURES": "1",
|
||||
}
|
||||
if rerun_failures:
|
||||
env["RERUN_FAILURES"] = "1"
|
||||
if print_tests_selection:
|
||||
env["PRINT_TEST_SELECTION"] = "1"
|
||||
else:
|
||||
env["PRINT_TEST_SELECTION"] = "0"
|
||||
if skip_code_coverage:
|
||||
env["SKIP_CODE_COVERAGE"] = "1"
|
||||
else:
|
||||
|
@ -273,6 +276,66 @@ def test(
|
|||
)
|
||||
|
||||
|
||||
@vm.command(
|
||||
arguments={
|
||||
"name": {
|
||||
"help": "The VM Name",
|
||||
"metavar": "VM_NAME",
|
||||
},
|
||||
"nox_session": {
|
||||
"flags": [
|
||||
"-e",
|
||||
"--nox-session",
|
||||
],
|
||||
"help": "The nox session name to run in the VM",
|
||||
},
|
||||
"nox_session_args": {
|
||||
"help": "Extra CLI arguments to pass to pytest",
|
||||
"nargs": "*",
|
||||
"metavar": "NOX_SESSION_ARGS",
|
||||
},
|
||||
"skip_requirements_install": {
|
||||
"help": "Skip requirements installation",
|
||||
"action": "store_true",
|
||||
"flags": [
|
||||
"--sri",
|
||||
"--skip-requirements-install",
|
||||
],
|
||||
},
|
||||
}
|
||||
)
|
||||
def testplan(
|
||||
ctx: Context,
|
||||
name: str,
|
||||
nox_session_args: list[str] = None,
|
||||
nox_session: str = "ci-test-3",
|
||||
skip_requirements_install: bool = False,
|
||||
):
|
||||
"""
|
||||
Run test in the VM.
|
||||
"""
|
||||
vm = VM(ctx=ctx, name=name, region_name=ctx.parser.options.region)
|
||||
env = {
|
||||
"PRINT_TEST_SELECTION": "1",
|
||||
"PRINT_TEST_PLAN_ONLY": "1",
|
||||
"SKIP_CODE_COVERAGE": "1",
|
||||
"SKIP_INITIAL_GH_ACTIONS_FAILURES": "1",
|
||||
}
|
||||
if (
|
||||
skip_requirements_install
|
||||
or os.environ.get("SKIP_REQUIREMENTS_INSTALL", "0") == "1"
|
||||
):
|
||||
env["SKIP_REQUIREMENTS_INSTALL"] = "1"
|
||||
if "photonos" in name:
|
||||
skip_known_failures = os.environ.get("SKIP_INITIAL_PHOTONOS_FAILURES", "1")
|
||||
env["SKIP_INITIAL_PHOTONOS_FAILURES"] = skip_known_failures
|
||||
vm.run_nox(
|
||||
nox_session=nox_session,
|
||||
session_args=nox_session_args,
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
@vm.command(
|
||||
name="install-dependencies",
|
||||
arguments={
|
||||
|
|
Loading…
Add table
Reference in a new issue