ci(molecule): isolate runs per run and drop the push trigger on main

Two Molecule runs could not overlap on one Docker daemon because every
scenario's container name was fixed; only the runner's single slot kept
them apart. Each platform is now named and labelled by KAMINO_RUN_ID
(run id and attempt, "local" outside CI), the run script expands those
names with molecule's own interpolator before removing them, and the
workflow removes its own containers by label and only sweeps labelled
leftovers older than the job timeout, so a run still going is never hit.
Non-pull-request runs get a concurrency group of their own.

Push to main no longer triggers Molecule, Lint or Build: a merged pull
request was already tested, and the nightly and manual Molecule runs
cover every scenario. Build keeps its v* tag trigger.

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Defame1297 committed 2026-11-24 09:35:03 +00:00
1 parent 33fc3fd3a5
commit 96cb9246c6
23 files changed
+223 -160

No files matched your search

+21 -20
View File
@@ -57,9 +57,9 @@ issue.
`.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections. `.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections.
*Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds. *Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds.
*Held:* control: the "Check the baked tooling against the pins" step. *Held:* control: the "Check the baked tooling against the pins" step.
- **Triggers:** both run on pull requests to `main`, on push to `main` until #166 removes that - **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
trigger, and on manual dispatch; Build also runs on `v*` tags, where it checks the tag against `v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
`galaxy.yml`. *Why:* the tag is what consumers install. *Held:* review. install. *Held:* review.
## Molecule ## Molecule
@@ -79,29 +79,30 @@ issue.
belongs there only if no scenario reads it.** *Why:* a file a scenario reads but the selector belongs there only if no scenario reads it.** *Why:* a file a scenario reads but the selector
ignores would let a breaking change through untested. *Held:* review. ignores would let a breaking change through untested. *Held:* review.
- **Every scenario runs on a manual dispatch and in the nightly run (04:43 UTC, after - **Every scenario runs on a manual dispatch and in the nightly run (04:43 UTC, after
Renovate's).** A push to `main` that touches the `push:` `paths:` list runs every scenario Renovate's).** A push to `main` runs no Molecule. *Why:* a pull request runs only its
too, until #166 removes that trigger. *Why:* a pull request runs only its selection, so selection, so drift in the other roles shows up here. *Held:* review.
drift in the other roles shows up here. *Held:* review. - **A new commit cancels the pull request's running Molecule run; every other run has a
- **A new commit cancels the pull request's running Molecule run, and the run step first removes concurrency group of its own.** Runs may overlap on the runner's Docker daemon: every container
the containers a cancelled run left.** The scenarios of one run overlap is named and labelled by its run (`KAMINO_RUN_ID`). The job first removes labelled containers
(`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time), so no two scenarios may share a older than its timeout, which a cancelled run left, and finally its own. The scenarios of one
platform name. Two runs never overlap only because the runner has a single slot, and the run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time), so no two
scenarios' container names are fixed; raising the runner's capacity needs per-run container scenarios may share a platform name. *Why:* a cancelled run is killed before it can remove its
names first (#166). *Why:* a cancelled run is killed before it can remove its instances, and instances, and a younger container may belong to a run still going. *Held:* review; the names
two overlapping scenarios or runs would collide on the same names. *Held:* review; that no two and labels are held by the test the `test_sequence` rule below names.
scenarios share a platform name is held by the test the `test_sequence` rule below names.
- **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.
*Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core *Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core
before it automerges. *Held:* control: the pin comparison in `molecule.yml`. before it automerges. *Held:* control: the pin comparison in `molecule.yml`.
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy` - **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
steps, and names its platforms literally in its `molecule.yml`;** copy it into a new scenario. steps, names each platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
*Why:* the workflow clears stale containers first and removes each scenario's containers by `net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"` in its `molecule.yml`;** copy it into
those names as soon as it ends, which skips the driver's destroy wait, and the molecule state a new scenario. *Why:* the run script removes each scenario's containers by those names as soon
lives in each scenario's own `ANSIBLE_HOME` in the job tree, so a killed run leaves none as it ends, which skips the driver's destroy wait, the workflow finds a run's containers by the
behind. *Held:* control: `tests/scripts/test_run_molecule_scenarios.py` fails a `destroy` in a label, and the molecule state lives in each scenario's own `ANSIBLE_HOME` in the job tree, so a
sequence, and a platform name that is not unique or not matched by the stale-container filter. killed run leaves none behind. *Held:* control: `tests/scripts/test_run_molecule_scenarios.py`
fails a `destroy` in a sequence, a platform name that is not unique or not per run, a missing
label, and a workflow that does not filter by it.
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that - **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in `${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
+3 -6
View File
@@ -9,8 +9,6 @@ on: # yamllint disable-line rule:truthy
branches: branches:
- main - main
push: push:
branches:
- main
tags: tags:
- 'v*' - 'v*'
workflow_dispatch: {} workflow_dispatch: {}
@@ -18,11 +16,10 @@ on: # yamllint disable-line rule:truthy
permissions: permissions:
contents: read contents: read
# A newer push to the same pull request cancels the running run; a push to main or a tag # A newer push to the same pull request cancels the running run. A tag's ref differs from every
# never cancels another run. A tag run has its own group, so it never shares one with the # branch's, so a tag run has a group of its own and is never cancelled.
# main run of the same commit.
concurrency: concurrency:
group: build-${{ github.event_name == 'pull_request' && github.ref || (github.ref_type == 'tag' && github.ref || github.sha) }} group: build-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs: jobs:
+3 -7
View File
@@ -12,19 +12,15 @@ on: # yamllint disable-line rule:truthy
pull_request: pull_request:
branches: branches:
- main - main
push:
branches:
- main
workflow_dispatch: {} workflow_dispatch: {}
permissions: permissions:
contents: read contents: read
# A newer push to the same pull request makes the running run obsolete. A push to main is # A newer push to the same pull request makes the running run obsolete; a manual dispatch never
# never cancelled: each merge commit keeps its own result, so its group is the commit SHA. # cancels another run.
# (This workflow has no tag trigger, so no tag branch in the group.)
concurrency: concurrency:
group: lint-${{ github.event_name == 'pull_request' && github.ref || github.sha }} group: lint-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs: jobs:
+33 -38
View File
@@ -20,20 +20,8 @@ on: # yamllint disable-line rule:truthy
pull_request: pull_request:
branches: branches:
- main - main
push:
branches:
- main
paths:
- 'roles/**'
- 'extensions/**'
- 'plugins/**'
- 'meta/**'
- 'galaxy.yml'
- 'requirements.yml'
- '.gitea/workflows/molecule.yml'
# Every scenario, nightly: a pull request runs only the scenarios of the roles it changes, so # Every scenario, nightly: a pull request runs only the scenarios of the roles it changes, so
# drift in the others (a package mirror) would otherwise wait for # drift in the others (a package mirror) would otherwise go unseen. After Renovate's 03:17 run.
# the next push to main. After Renovate's 03:17 run, which can take 30 minutes of the one slot.
schedule: schedule:
- cron: "43 4 * * *" - cron: "43 4 * * *"
workflow_dispatch: {} workflow_dispatch: {}
@@ -41,21 +29,17 @@ on: # yamllint disable-line rule:truthy
permissions: permissions:
contents: read contents: read
# A pull request run is cancelled when a newer commit is pushed to the same pull request (the # A newer push to a pull request cancels its older run; every other run has a group of its own, so
# same rule as lint.yml and build.yml); a run on main is never cancelled, so its group is the # none is cancelled. Runs may overlap on the runner's Docker daemon: every container is named and
# commit SHA. The scenarios of one run overlap (scripts/run_molecule_scenarios.sh), which is safe # labelled by its run (KAMINO_RUN_ID), and no two scenarios share a platform name.
# because no two share a container name; but the names are fixed on the runner's shared Docker
# daemon, so two runs must not overlap. The group no longer guarantees that (it is per pull
# request now): the runner's single slot does. Raise the runner's capacity and this needs
# per-run container names first (#166), or a lock or a shared group again.
concurrency: concurrency:
group: molecule-${{ github.event_name == 'pull_request' && github.ref || github.sha }} group: molecule-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs: jobs:
molecule: molecule:
# Same-repo branches only (bot branches included: a Renovate pin pull request is what tests a new # Same-repo branches only (bot branches included: a Renovate pin pull request is what tests a new
# image); a push to main or a manual dispatch always runs. No paths filter on pull requests, so # image); the nightly run and a manual dispatch always run. No paths filter on pull requests, so
# that Molecule can be a required check: a required check that a pull request never starts would # that Molecule can be a required check: a required check that a pull request never starts would
# block it. A fork pull request is skipped by the guard below. # block it. A fork pull request is skipped by the guard below.
if: >- if: >-
@@ -76,7 +60,9 @@ jobs:
# `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604. # `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604.
MOLECULE_IMAGE_2604: >- MOLECULE_IMAGE_2604: >-
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.6@sha256:d7c216b33d18fa8f1ecbfee8795eb4adc867fe5ad8e7a73b7c67effe301cf771 git.rkdr.net/mortis/molecule-ubuntu2604:0.1.6@sha256:d7c216b33d18fa8f1ecbfee8795eb4adc867fe5ad8e7a73b7c67effe301cf771
# The container molecule runs in, named and labelled by the run so the cleanup step finds it. # Names and labels this run's containers: the scenarios' as `${KAMINO_RUN_ID:-local}-<name>`
# with the label net.rkdr.mortis.molecule-run, and the one molecule runs in.
KAMINO_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}
RUN_CONTAINER: kamino-molecule-${{ github.run_id }}-${{ github.run_attempt }} RUN_CONTAINER: kamino-molecule-${{ github.run_id }}-${{ github.run_attempt }}
steps: steps:
- name: Check the Docker daemon - name: Check the Docker daemon
@@ -101,10 +87,23 @@ jobs:
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; } git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
echo "Checked out $(git rev-parse HEAD)" echo "Checked out $(git rev-parse HEAD)"
# A cancelled run is killed before it can remove its containers. Any labelled container older
# than the job timeout is such a leftover; a younger one may belong to a run still going.
- name: Remove the containers earlier runs left
run: |
# Assigned first so that a failing `docker ps` fails the step instead of looking empty.
ids="$(docker ps -aq --filter 'label=net.rkdr.mortis.molecule-run')"
cutoff="$(date -d '30 minutes ago' +%s)"
for id in $ids; do
# a container removed since the listing is skipped
created="$(docker inspect --format '{{.Created}}' "$id")" || continue
if [ "$(date -d "$created" +%s)" -lt "$cutoff" ]; then docker rm -f "$id"; fi
done
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py # A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
# explains the rules); a push to main and a manual dispatch run all of them, a few at a time. # explains the rules); the nightly run and a manual dispatch run all of them, a few at a time.
# scripts/run_molecule_scenarios.sh runs them and removes each scenario's containers as soon as # scripts/run_molecule_scenarios.sh runs them and removes each scenario's containers as soon as
# it ends; a cancelled run is killed before it can, so the step first removes what one left. # it ends.
- name: Run the scenarios - name: Run the scenarios
working-directory: ac/ansible_collections/mortis/kamino working-directory: ac/ansible_collections/mortis/kamino
env: env:
@@ -112,13 +111,6 @@ jobs:
# The workflow only runs for pull requests to main; lint.yml uses the same constant. # The workflow only runs for pull requests to main; lint.yml uses the same constant.
BASE_REF: origin/main BASE_REF: origin/main
run: | run: |
# The platform names of every scenario, anchored: <role>-instance and image-smoke[-2604].
# Assigned first so that a failing `docker ps` fails the step instead of looking empty.
stale="$(docker ps -aq --filter 'name=^/[a-z0-9-]+-instance$' --filter 'name=^/image-smoke(-2604)?$')"
if [ -n "$stale" ]; then
# shellcheck disable=SC2086 # container ids, one word each
docker rm -f $stale
fi
# The selector comes from the base branch, so a pull request cannot edit the rules it is # The selector comes from the base branch, so a pull request cannot edit the rules it is
# judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that # judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that
# adds it has no base copy yet and uses its own. # adds it has no base copy yet and uses its own.
@@ -144,18 +136,21 @@ jobs:
printf 'root:x:0:0:root:/root:/bin/bash\n%s:x:%s:%s::%s:/bin/bash\n' \ printf 'root:x:0:0:root:/root:/bin/bash\n%s:x:%s:%s::%s:/bin/bash\n' \
"$(id -un)" "$(id -u)" "$(id -g)" "$ac_root/home" > "$ac_root/passwd" "$(id -un)" "$(id -u)" "$(id -g)" "$ac_root/home" > "$ac_root/passwd"
docker run --rm -i --init --name "$RUN_CONTAINER" \ docker run --rm -i --init --name "$RUN_CONTAINER" \
--label "net.rkdr.mortis.molecule-run=$RUN_CONTAINER" \ --label "net.rkdr.mortis.molecule-run=$KAMINO_RUN_ID" \
--user "$(id -u):$(id -g)" --group-add "$sock_gid" \ --user "$(id -u):$(id -g)" --group-add "$sock_gid" \
-v /var/run/docker.sock:/var/run/docker.sock -v "$docker_cli:/usr/local/bin/docker:ro" \ -v /var/run/docker.sock:/var/run/docker.sock -v "$docker_cli:/usr/local/bin/docker:ro" \
-v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \ -v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \
-e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \ -e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \
-e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 \ -e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID \
"$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected" "$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
# A cancelled run can leave the container running when the docker client is killed. # A cancelled run can leave its containers running when the docker client is killed.
- name: Remove the molecule container - name: Remove this run's containers
if: always() if: always()
run: | run: |
if docker container inspect "$RUN_CONTAINER" >/dev/null 2>&1; then # Assigned first so that a failing `docker ps` fails the step instead of looking empty.
docker rm -f "$RUN_CONTAINER" ids="$(docker ps -aq --filter "label=net.rkdr.mortis.molecule-run=$KAMINO_RUN_ID")"
if [ -n "$ids" ]; then
# shellcheck disable=SC2086 # container ids, one word each
docker rm -f $ids
fi fi
@@ -6,7 +6,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: image-smoke-2604 - name: ${KAMINO_RUN_ID:-local}-image-smoke-2604
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE_2604} image: ${MOLECULE_IMAGE_2604}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -26,9 +28,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -6,7 +6,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: image-smoke - name: ${KAMINO_RUN_ID:-local}-image-smoke
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -26,9 +28,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -6,7 +6,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: binary-update-check-instance - name: ${KAMINO_RUN_ID:-local}-binary-update-check-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -26,9 +28,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -6,7 +6,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: binary-update-instance - name: ${KAMINO_RUN_ID:-local}-binary-update-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -26,9 +28,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -11,7 +11,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: cloudflared-instance - name: ${KAMINO_RUN_ID:-local}-cloudflared-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -71,9 +73,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -7,7 +7,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: docker-instance - name: ${KAMINO_RUN_ID:-local}-docker-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -27,9 +29,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -5,7 +5,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: fail2ban-instance - name: ${KAMINO_RUN_ID:-local}-fail2ban-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -25,9 +27,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -11,7 +11,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: gitea-instance - name: ${KAMINO_RUN_ID:-local}-gitea-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -36,9 +38,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -8,7 +8,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: runner-instance - name: ${KAMINO_RUN_ID:-local}-runner-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -46,9 +48,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -5,7 +5,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: network-interfaces-instance - name: ${KAMINO_RUN_ID:-local}-network-interfaces-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -25,9 +27,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -6,7 +6,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: sshd-instance - name: ${KAMINO_RUN_ID:-local}-sshd-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -26,9 +28,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -8,7 +8,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: system-baseline-instance - name: ${KAMINO_RUN_ID:-local}-system-baseline-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -32,9 +34,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -5,7 +5,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: systemd-hardening-instance - name: ${KAMINO_RUN_ID:-local}-systemd-hardening-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -25,9 +27,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -6,7 +6,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: traefik-instance - name: ${KAMINO_RUN_ID:-local}-traefik-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -46,9 +48,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+6 -4
View File
@@ -5,7 +5,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: ufw-instance - name: ${KAMINO_RUN_ID:-local}-ufw-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -25,9 +27,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
@@ -5,7 +5,9 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: user-management-instance - name: ${KAMINO_RUN_ID:-local}-user-management-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE} image: ${MOLECULE_IMAGE}
pre_build_image: true pre_build_image: true
pull: true pull: true
@@ -33,9 +35,9 @@ provisioner:
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
# molecule's default sequence minus both destroys: the workflow removes the container before the # molecule's default sequence minus both destroys: the workflow removes the container as soon as
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait. # this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
# After a local run, run `molecule destroy` yourself. # the driver's poll wait. After a local run, run `molecule destroy` yourself.
test_sequence: test_sequence:
- dependency - dependency
- cleanup - cleanup
+10 -6
View File
@@ -24,19 +24,23 @@ label_of() {
esac esac
} }
# Removes the scenario's containers by the literal platform names in its molecule.yml, in place of # Removes the scenario's containers by the platform names in its molecule.yml, expanded as molecule
# molecule's destroy, which the scenarios leave out: its driver waits about 5.6 s per scenario for # expands them (they carry ${KAMINO_RUN_ID}), in place of molecule's destroy, which the scenarios
# the deletion (about 84 s over 15), and the whole destroy phase measured about 103 s a full run. # leave out: its driver waits about 5.6 s per scenario for the deletion (about 84 s over 15), and
# The ci image has no docker CLI: python3 is the one molecule runs on, with PyYAML and the Docker # the whole destroy phase measured about 103 s a full run. The ci image has no docker CLI: python3
# SDK of molecule's Docker driver. # is the one molecule runs on, with molecule, PyYAML and the Docker SDK of molecule's Docker driver.
remove_instances() { remove_instances() {
python3 -I - "$1/molecule.yml" <<'EOF' python3 -I - "$1/molecule.yml" <<'EOF'
import os
import sys import sys
import docker import docker
import yaml import yaml
from molecule.interpolation import Interpolator, TemplateWithDefaults
names = [p["name"] for p in yaml.safe_load(open(sys.argv[1]))["platforms"]] with open(sys.argv[1]) as f:
text = Interpolator(TemplateWithDefaults, os.environ).interpolate(f.read())
names = [p["name"] for p in yaml.safe_load(text)["platforms"]]
if not names: if not names:
sys.exit("no platform names in " + sys.argv[1]) sys.exit("no platform names in " + sys.argv[1])
containers = docker.from_env().containers containers = docker.from_env().containers
+2 -2
View File
@@ -33,7 +33,7 @@ everything.
Every other case runs everything: a push, a manual dispatch, a scheduled run, no <base-ref>, a git Every other case runs everything: a push, a manual dispatch, a scheduled run, no <base-ref>, a git
failure. failure.
Narrowing is an optimisation, so any doubt resolves to the full set. The scenarios the Narrowing is an optimisation, so any doubt resolves to the full set. The scenarios the
selection skips are not skipped on `main`: the push run after the merge runs them all. selection skips still run on `main`: the nightly run and a manual dispatch run them all.
A changed role that exists but has no scenario is an error, not an empty selection: a new role A changed role that exists but has no scenario is an error, not an empty selection: a new role
without a molecule scenario, or a deleted or renamed scenario, must not pass Molecule with without a molecule scenario, or a deleted or renamed scenario, must not pass Molecule with
@@ -42,7 +42,7 @@ nothing tested. A role whose directory is gone (the role was deleted) selects no
The workflow runs this script from the base branch's copy, not the pull request's, so a pull The workflow runs this script from the base branch's copy, not the pull request's, so a pull
request cannot edit the rules it is judged by (the same reason lint.yml runs request cannot edit the rules it is judged by (the same reason lint.yml runs
check_bot_pr_diff.py from origin/main). No scenario runs the pull request's copy, so this file check_bot_pr_diff.py from origin/main). No scenario runs the pull request's copy, so this file
is on the IGNORED list: its unit tests test it, and the push run after the merge runs it. is on the IGNORED list: its unit tests test it, and the nightly run and a manual dispatch run it.
Exit codes: 0 ok (an empty selection from an all-ignored diff is ok), 1 no scenario exists at Exit codes: 0 ok (an empty selection from an all-ignored diff is ok), 1 no scenario exists at
all, or a changed role has none, 2 bad usage. Notices go to stderr as `::notice::` lines, with all, or a changed role has none, 2 bad usage. Notices go to stderr as `::notice::` lines, with
+55 -17
View File
@@ -5,6 +5,7 @@
Run with: python3 -m unittest discover -s tests/scripts Run with: python3 -m unittest discover -s tests/scripts
""" """
import importlib.util
import os import os
import pathlib import pathlib
import re import re
@@ -21,6 +22,11 @@ import yaml
REPO = pathlib.Path(__file__).resolve().parents[2] REPO = pathlib.Path(__file__).resolve().parents[2]
SCRIPT = REPO / "scripts" / "run_molecule_scenarios.sh" SCRIPT = REPO / "scripts" / "run_molecule_scenarios.sh"
WORKFLOW = REPO / ".gitea" / "workflows" / "molecule.yml" WORKFLOW = REPO / ".gitea" / "workflows" / "molecule.yml"
RUN_ID = "${KAMINO_RUN_ID:-local}"
RUN_LABEL = "net.rkdr.mortis.molecule-run"
# The script expands platform names with molecule's own interpolator, as molecule does.
HAS_MOLECULE = importlib.util.find_spec("molecule") is not None
NEEDS_MOLECULE = "the run script imports molecule to expand platform names"
# Records what each run saw, then behaves as STUB_<scenario label> asks: fail, sleep, hang (and # Records what each run saw, then behaves as STUB_<scenario label> asks: fail, sleep, hang (and
# record its pids), detach (as an ansible worker does, into its own process group, whose orphaned # record its pids), detach (as an ansible worker does, into its own process group, whose orphaned
@@ -94,8 +100,11 @@ def stub_python(where):
).stdout.strip() ).stdout.strip()
site = pathlib.Path(site) site = pathlib.Path(site)
(site / "docker.py").write_text(DOCKER_SDK_STUB) (site / "docker.py").write_text(DOCKER_SDK_STUB)
# PyYAML from the environment running the tests # PyYAML, and molecule when it is there, from the environment running the tests
(site / "outer.pth").write_text(str(pathlib.Path(yaml.__file__).parents[1]) + "\n") outer = {pathlib.Path(yaml.__file__).parents[1]}
if HAS_MOLECULE:
outer.add(pathlib.Path(importlib.util.find_spec("molecule").origin).parents[1])
(site / "outer.pth").write_text("".join(f"{p}\n" for p in outer))
return where / "bin" return where / "bin"
@@ -107,6 +116,11 @@ PLATFORMS = {
} }
def container_names(run_id):
"""Every fixture platform's container name in the run run_id."""
return [f"{run_id}-{n}" for names in PLATFORMS.values() for n in names]
@unittest.skipUnless(shutil.which("bash"), "bash is required") @unittest.skipUnless(shutil.which("bash"), "bash is required")
class RunMoleculeScenariosTest(unittest.TestCase): class RunMoleculeScenariosTest(unittest.TestCase):
@classmethod @classmethod
@@ -126,7 +140,9 @@ class RunMoleculeScenariosTest(unittest.TestCase):
for scenario, names in PLATFORMS.items(): for scenario, names in PLATFORMS.items():
d = self.root / scenario d = self.root / scenario
d.mkdir(parents=True) d.mkdir(parents=True)
platforms = [{"name": n, "image": "${MOLECULE_IMAGE}"} for n in names] platforms = [
{"name": f"{RUN_ID}-{n}", "image": "${MOLECULE_IMAGE}"} for n in names
]
(d / "molecule.yml").write_text(yaml.safe_dump({"platforms": platforms})) (d / "molecule.yml").write_text(yaml.safe_dump({"platforms": platforms}))
bin_dir = self.tmp / "bin" bin_dir = self.tmp / "bin"
bin_dir.mkdir() bin_dir.mkdir()
@@ -163,6 +179,7 @@ class RunMoleculeScenariosTest(unittest.TestCase):
times.setdefault(label, {})[what] = float(stamp) times.setdefault(label, {})[what] = float(stamp)
return {k: (v["start"], v.get("end")) for k, v in times.items()} return {k: (v["start"], v.get("end")) for k, v in times.items()}
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
def test_groups_follow_the_selection_order_with_times(self): def test_groups_follow_the_selection_order_with_times(self):
order = list(PLATFORMS) order = list(PLATFORMS)
proc = self.run_script(order, STUB_alpha_default="sleep") proc = self.run_script(order, STUB_alpha_default="sleep")
@@ -185,6 +202,7 @@ class RunMoleculeScenariosTest(unittest.TestCase):
self.assertIn("Scenarios run: 4", proc.stdout) self.assertIn("Scenarios run: 4", proc.stdout)
self.assertIn(" image-smoke: ", proc.stdout) self.assertIn(" image-smoke: ", proc.stdout)
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
def test_runs_in_lanes_and_isolates_each_scenario(self): def test_runs_in_lanes_and_isolates_each_scenario(self):
order = list(PLATFORMS) order = list(PLATFORMS)
stubs = { stubs = {
@@ -211,13 +229,14 @@ class RunMoleculeScenariosTest(unittest.TestCase):
smoke = next(s for s in starts if s.startswith("image-smoke ")) smoke = next(s for s in starts if s.startswith("image-smoke "))
self.assertIn(f"cwd={self.root} args=test -s image-smoke", smoke) self.assertIn(f"cwd={self.root} args=test -s image-smoke", smoke)
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
def test_a_failure_is_reported_and_its_containers_still_go(self): def test_a_failure_is_reported_and_its_containers_still_go(self):
proc = self.run_script(list(PLATFORMS), STUB_beta_default="fail") proc = self.run_script(list(PLATFORMS), STUB_beta_default="fail")
self.assertEqual(proc.returncode, 1) self.assertEqual(proc.returncode, 1)
self.assertIn("::error::Failed: beta/default\n", proc.stdout) self.assertIn("::error::Failed: beta/default\n", proc.stdout)
self.assertIn("Scenarios run: 4", proc.stdout) self.assertIn("Scenarios run: 4", proc.stdout)
docker = self.docker_log.read_text().splitlines() docker = self.docker_log.read_text().splitlines()
for name in (n for names in PLATFORMS.values() for n in names): for name in container_names("local"):
self.assertIn(f"list {name} all=True", docker) self.assertIn(f"list {name} all=True", docker)
self.assertIn(f"remove {name} force=True", docker) self.assertIn(f"remove {name} force=True", docker)
# a filter match by another name is left alone # a filter match by another name is left alone
@@ -225,12 +244,25 @@ class RunMoleculeScenariosTest(unittest.TestCase):
[line for line in docker if line.endswith("-other force=True")] [line for line in docker if line.endswith("-other force=True")]
) )
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
def test_the_containers_removed_are_the_run_s_own(self):
proc = self.run_script(list(PLATFORMS), KAMINO_RUN_ID="r7")
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
removed = [
line.split()[1]
for line in self.docker_log.read_text().splitlines()
if line.startswith("remove ")
]
self.assertEqual(sorted(removed), sorted(container_names("r7")))
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
def test_molecule_gets_no_stdin(self): def test_molecule_gets_no_stdin(self):
proc = self.run_script(list(PLATFORMS), STUB_alpha_default="stdin") proc = self.run_script(list(PLATFORMS), STUB_alpha_default="stdin")
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr) self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
self.assertIn("stdin of alpha/default: []", proc.stdout) self.assertIn("stdin of alpha/default: []", proc.stdout)
self.assertIn("Scenarios run: 4", proc.stdout) self.assertIn("Scenarios run: 4", proc.stdout)
@unittest.skipUnless(HAS_MOLECULE, NEEDS_MOLECULE)
def test_a_failed_removal_fails_the_scenario(self): def test_a_failed_removal_fails_the_scenario(self):
proc = self.run_script(["roles/alpha/molecule/default"], STUB_RM_FAIL="1") proc = self.run_script(["roles/alpha/molecule/default"], STUB_RM_FAIL="1")
self.assertEqual(proc.returncode, 1) self.assertEqual(proc.returncode, 1)
@@ -326,32 +358,32 @@ def alive(pid):
return stat.rsplit(")", 1)[1].split()[0] != "Z" return stat.rsplit(")", 1)[1].split()[0] != "Z"
def stale_filters(): def label_filters():
"""The name filters of the workflow's stale-container cleanup, as docker matches /<name>.""" """The label filters of the workflow's docker commands, as `--filter label=<key>[=<value>]`."""
workflow = yaml.safe_load(WORKFLOW.read_text()) workflow = yaml.safe_load(WORKFLOW.read_text())
steps = [s for job in workflow["jobs"].values() for s in job.get("steps", [])] steps = [s for job in workflow["jobs"].values() for s in job.get("steps", [])]
run = next(s["run"] for s in steps if s.get("name") == "Run the scenarios") runs = "\n".join(s.get("run", "") for s in steps)
stale = next(line for line in run.splitlines() if line.strip().startswith("stale=")) return re.findall(r"--filter ['\"]?label=([^'\"\s]+)", runs)
return re.findall(r"--filter 'name=([^']+)'", stale)
class ScenarioPlatformNamesTest(unittest.TestCase): class ScenarioPlatformsTest(unittest.TestCase):
"""The run script removes containers by literal platform name, and scenarios run side by side.""" """Scenarios run side by side and runs overlap, so each container is named and labelled by its run."""
def test_platform_names_are_literal_unique_and_cleared_before_a_run(self): def test_platforms_are_named_and_labelled_by_the_run(self):
files = sorted(REPO.glob("roles/*/molecule/*/molecule.yml")) files = sorted(REPO.glob("roles/*/molecule/*/molecule.yml"))
files += sorted(REPO.glob("extensions/molecule/*/molecule.yml")) files += sorted(REPO.glob("extensions/molecule/*/molecule.yml"))
self.assertTrue(files) self.assertTrue(files)
seen = {} seen = {}
stale = stale_filters()
self.assertTrue(stale)
for path in files: for path in files:
where = path.relative_to(REPO)
data = yaml.safe_load(path.read_text()) data = yaml.safe_load(path.read_text())
for platform in data["platforms"]: for platform in data["platforms"]:
name = platform["name"] name = platform["name"]
where = path.relative_to(REPO) self.assertTrue(name.startswith(f"{RUN_ID}-"), f"{where}: {name}")
self.assertTrue( self.assertEqual(
any(re.search(f, f"/{name}") for f in stale), f"{where}: {name}" platform.get("labels", {}).get(RUN_LABEL),
RUN_ID,
f"{where}: {name}",
) )
self.assertNotIn( self.assertNotIn(
name, seen, f"{where} and {seen.get(name)} share {name}" name, seen, f"{where} and {seen.get(name)} share {name}"
@@ -359,6 +391,12 @@ class ScenarioPlatformNamesTest(unittest.TestCase):
seen[name] = where seen[name] = where
self.assertNotIn("destroy", data["scenario"]["test_sequence"], path) self.assertNotIn("destroy", data["scenario"]["test_sequence"], path)
def test_the_workflow_finds_the_containers_by_the_run_label(self):
filters = label_filters()
# the sweep of earlier runs filters by the key, the cleanup of this run by key and value
self.assertIn(RUN_LABEL, filters)
self.assertIn(f"{RUN_LABEL}=$KAMINO_RUN_ID", filters)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()