ci(molecule): say what a scenario time limit leaves running
A reader of the time limit needs to know its limits: on expiry only molecule is signalled, so its ansible-playbook and workers run until the run container ends, and the run-label cleanup step removes anything they recreate. The default's reasoning holds at the default 2 lanes, and the variable is for local runs and tests only. The timeout test now runs on one lane, so beta running proves the stalled lane was freed. The workflows rule gives the limit its reason and names the two tests that hold it. Refs #474 Assisted-by: Claude Code
This commit is contained in:
1 parent
41820fd9a7
commit
258cbaf516
3 files changed
+22
-14
No files matched your search
@@ -112,15 +112,18 @@ issue.
|
|||||||
older than its timeout, which a cancelled run left, and finally its own. The scenarios of one
|
older than its timeout, which a cancelled run left, and finally its own. The scenarios of one
|
||||||
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 2 unless a manual
|
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 2 unless a manual
|
||||||
dispatch sets its `lanes` input), so no two scenarios may share a platform name. They start
|
dispatch sets its `lanes` input), so no two scenarios may share a platform name. They start
|
||||||
longest first by the script's list of last full-run times, an unlisted one first; one still
|
longest first by the script's list of last full-run times, an unlisted one first; the logs stay
|
||||||
running after 30 min fails on its own; the logs stay in selection order. *Why:* a cancelled run is killed before it can remove its instances, a
|
in selection order. A scenario still running at the script's per-scenario limit is stopped and
|
||||||
younger container may belong to a run still going, and a long scenario started late sets the
|
fails. *Why:* a cancelled run is killed before it can remove its instances, a younger container
|
||||||
end of the run. *Held:* review; control: the start order by
|
may belong to a run still going, a long scenario started late sets the end of the run, and a
|
||||||
`test_the_longest_scenarios_start_first` and the input by `LanesInputTest`, both in
|
hang that fails alone inside the job timeout still lets every scenario's log print. *Held:*
|
||||||
`tests/scripts/test_run_molecule_scenarios.py`; control:
|
review; control: the start order by `test_the_longest_scenarios_start_first` and the input by
|
||||||
the names and labels by the test the `test_sequence` rule below names, and the sweep's age bound
|
`LanesInputTest`, both in `tests/scripts/test_run_molecule_scenarios.py`; control: the names and
|
||||||
equal to the job timeout by `test_the_sweep_spares_containers_younger_than_the_job_timeout` in
|
labels by the test the `test_sequence` rule below names, and the sweep's age bound equal to the
|
||||||
`tests/scripts/test_run_molecule_scenarios.py`.
|
job timeout by `test_the_sweep_spares_containers_younger_than_the_job_timeout` in
|
||||||
|
`tests/scripts/test_run_molecule_scenarios.py`; control: the limit by
|
||||||
|
`test_a_scenario_past_its_time_limit_fails_alone` and
|
||||||
|
`test_the_default_time_limit_is_inside_the_job_timeout`, in the same file.
|
||||||
- **Molecule tests the pull request's pins, as Lint and Build do.** It runs molecule in the pinned
|
- **Molecule tests the pull request's pins, as Lint and Build do.** It runs molecule in the pinned
|
||||||
`ci` image and, when a pin file differs from `/opt/ci-pins.sha256`, installs the pull request's
|
`ci` image and, when a pin file differs from `/opt/ci-pins.sha256`, installs the pull request's
|
||||||
tools and the collections of `requirements.yml` and `extensions/molecule/requirements.yml` first.
|
tools and the collections of `requirements.yml` and `extensions/molecule/requirements.yml` first.
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
# stdin, MOLECULE_LANES (default 2, also when empty) at a time, longest first, each with its own
|
# stdin, MOLECULE_LANES (default 2, also when empty) at a time, longest first, each with its own
|
||||||
# log and ANSIBLE_HOME under <work-dir>/<n>/ (no collection is installed there:
|
# log and ANSIBLE_HOME under <work-dir>/<n>/ (no collection is installed there:
|
||||||
# .config/molecule/config.yml sets prerun false). A scenario still running after
|
# .config/molecule/config.yml sets prerun false). A scenario still running after
|
||||||
# MOLECULE_SCENARIO_TIMEOUT seconds (default 1800, also when empty) is stopped and fails.
|
# MOLECULE_SCENARIO_TIMEOUT seconds (default 1800, also when empty) is stopped and fails; the
|
||||||
|
# variable is for local runs and tests: the workflow does not pass it into the ci container.
|
||||||
# Exit 1 on a failure.
|
# Exit 1 on a failure.
|
||||||
#
|
#
|
||||||
# scripts/run_molecule_scenarios.sh <work-dir> < scenario-dirs
|
# scripts/run_molecule_scenarios.sh <work-dir> < scenario-dirs
|
||||||
@@ -15,8 +16,8 @@ if ! [[ "$lanes" =~ ^[1-9][0-9]*$ ]]; then
|
|||||||
echo "MOLECULE_LANES must be a positive integer, not '$lanes'" >&2
|
echo "MOLECULE_LANES must be a positive integer, not '$lanes'" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
# 1800: the longest scenario takes about 8.5 min, and two hung ones plus the rest still end inside
|
# 1800: the longest scenario takes about 8.5 min, and at the default 2 lanes two hung ones plus the
|
||||||
# the job's 90 min, so a hang fails on its own with its log printed.
|
# rest still end inside the job's 90 min, so a hang fails on its own with its log printed.
|
||||||
limit="${MOLECULE_SCENARIO_TIMEOUT:-1800}"
|
limit="${MOLECULE_SCENARIO_TIMEOUT:-1800}"
|
||||||
if ! [[ "$limit" =~ ^[1-9][0-9]*$ ]]; then
|
if ! [[ "$limit" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
echo "MOLECULE_SCENARIO_TIMEOUT must be a positive integer, not '$limit'" >&2
|
echo "MOLECULE_SCENARIO_TIMEOUT must be a positive integer, not '$limit'" >&2
|
||||||
@@ -71,7 +72,9 @@ run_one() {
|
|||||||
# a role scenario runs from its role's directory, as molecule expects
|
# a role scenario runs from its role's directory, as molecule expects
|
||||||
case "$dir" in roles/*) cd "${dir%/molecule/*}" || exit 1 ;; esac
|
case "$dir" in roles/*) cd "${dir%/molecule/*}" || exit 1 ;; esac
|
||||||
# --foreground keeps timeout and molecule in this script's process group, so a cancel that
|
# --foreground keeps timeout and molecule in this script's process group, so a cancel that
|
||||||
# kills the group still reaches them; on expiry it signals molecule alone, not its children.
|
# kills the group still reaches them. On expiry it signals molecule alone: its ansible-playbook
|
||||||
|
# and workers run on until the run container ends, and the workflow's "Remove this run's
|
||||||
|
# containers" step removes any container they recreate late.
|
||||||
timeout --foreground --kill-after=30 "$limit" molecule test -s "${dir##*/}"
|
timeout --foreground --kill-after=30 "$limit" molecule test -s "${dir##*/}"
|
||||||
) >"$out/log" 2>&1 </dev/null || rc=$?
|
) >"$out/log" 2>&1 </dev/null || rc=$?
|
||||||
# 124 after TERM, 137 when the KILL of --kill-after was needed
|
# 124 after TERM, 137 when the KILL of --kill-after was needed
|
||||||
|
|||||||
@@ -334,9 +334,11 @@ class RunMoleculeScenariosTest(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
|
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
|
||||||
def test_a_scenario_past_its_time_limit_fails_alone(self):
|
def test_a_scenario_past_its_time_limit_fails_alone(self):
|
||||||
|
# one lane, and alpha first (both unlisted, so the selection order holds): beta runs only
|
||||||
|
# if the stalled lane is freed
|
||||||
proc = self.run_script(
|
proc = self.run_script(
|
||||||
["roles/alpha/molecule/default", "roles/beta/molecule/default"],
|
["roles/alpha/molecule/default", "roles/beta/molecule/default"],
|
||||||
MOLECULE_SCENARIO_TIMEOUT="2", STUB_alpha_default="stall",
|
MOLECULE_LANES="1", MOLECULE_SCENARIO_TIMEOUT="2", STUB_alpha_default="stall",
|
||||||
) # fmt: skip
|
) # fmt: skip
|
||||||
self.assertEqual(proc.returncode, 1)
|
self.assertEqual(proc.returncode, 1)
|
||||||
self.assertIn("::error::Failed: alpha/default\n", proc.stdout)
|
self.assertIn("::error::Failed: alpha/default\n", proc.stdout)
|
||||||
|
|||||||
Reference in new issue
Block a user