refactor(test/blackbox): extract shared push/pull helpers#4132
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4132 +/- ##
==========================================
- Coverage 91.58% 91.55% -0.04%
==========================================
Files 200 200
Lines 29356 29356
==========================================
- Hits 26886 26877 -9
- Misses 1590 1598 +8
- Partials 880 881 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the blackbox BATS push/pull-style test suites by extracting shared logic into reusable helper scripts, reducing duplication across the standard, FIPS140, upgrade, and authenticated variants.
Changes:
- Introduces shared helper libraries for push/pull flows (
helpers_pushpull.bash) and authenticated flows (helpers_pushpull_authn.bash) and rewires existing BATS files to use them. - Simplifies
helpers_upgrade.bashby delegating common push/pull operations to the shared helpers. - Splits out an explicit “delete image index” test case in the relevant suites.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/blackbox/upgrade.bats | Uses shared pagination helper and adds a delete-image-index test hook. |
| test/blackbox/upgrade_minimal.bats | Adds a delete-image-index test hook. |
| test/blackbox/pushpull.bats | Switches to shared push/pull helpers and adds delete-image-index coverage. |
| test/blackbox/pushpull_authn.bats | Switches to shared authenticated push/pull helpers. |
| test/blackbox/helpers_upgrade.bash | Delegates common push/pull operations to helpers_pushpull. |
| test/blackbox/helpers_pushpull.bash | New shared helper library for push/pull-style blackbox tests. |
| test/blackbox/helpers_pushpull_authn.bash | New shared helper library for authenticated push/pull blackbox tests. |
| test/blackbox/fips140.bats | Switches to shared push/pull helpers (FIPS mode). |
| test/blackbox/fips140_authn.bats | Switches to shared authenticated helpers (FIPS mode) and deduplicates auth/push/pull logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aac36e8 to
b28744a
Compare
b28744a to
521f9d3
Compare
Move duplicated push/pull/regclient/oras/helm helper functions out of fips140.bats, pushpull.bats and helpers_upgrade.bash into a single helpers_pushpull.bash, then have all three suites load from there. The helpers now share verify_prerequisites, get_zot_port, common assertion helpers (catalog/tag presence, OCI index ref name) and the regclient pagination listing. helpers_upgrade.bash keeps only the test_release_* and test_new_* wrappers that compose those helpers. Net effect: ~1000 lines of duplicated test scaffolding removed across the four files; behavior of the existing test cases is preserved. Refs: project-zot#3727 Signed-off-by: Akash Kumar <meakash7902@gmail.com>
…lpers Build on the shared helpers_pushpull.bash to remove more duplicated blackbox scaffolding: - Add pushpull_setup_file/pushpull_teardown/pushpull_teardown_file keyed on PUSHPULL_FIPS_MODE so pushpull.bats and fips140.bats only set the flag and delegate lifecycle, instead of each carrying a near-identical setup_file/teardown. - Add helpers_pushpull_authn.bash (loaded by pushpull_authn.bats and fips140_authn.bats) for shared htpasswd setup, FIPS vs non-FIPS config and teardown, and the regclient/OCI/ML test helpers; both authn suites collapse to one-line @test bodies keyed on PUSHPULL_AUTHN_FIPS_MODE. - Make each authn helper self-sufficient by performing its own regctl login, removing the hidden dependency on the first test having logged in. - Split the implicit manifest delete out of helper_pull_image_index_and_delete into a standalone helper_delete_manifest, surfaced as its own "delete image index" @test in the pushpull, fips140 and upgrade suites, so the delete is explicit and no longer an order-fragile side effect of a pull. Refs: project-zot#3727 Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Set org.opencontainers.image.title on oras artifact push and verify pull both via oras pull and manifest/blob fetch. Add retry_until_success and use it for periodic notation/cosign signature sync checks on slow CI. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Use curl --fail for manifest deletes so HTTP errors fail the test. Remove the duplicate regctl --format flag in helper_push_manifest_with_regclient. Harden helper_authn_ml_artifacts with run and status checks, using a binary-safe shell redirect for the ONNX artifact round-trip. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
34bf877 to
c9a0621
Compare
c9a0621 to
746d03f
Compare
Write oras artifact and docker build files under BATS_TEST_TMPDIR instead of the test working directory, and check git/docker in verify_prerequisites for clearer failures when running bats directly. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
746d03f to
423a3f5
Compare
vrajashkr
left a comment
There was a problem hiding this comment.
Looks good overall. Thanks for taking a look at this. Left some questions and comments.
|
We could consider adding "Closes" for issue #3727 |
Drop the FIPS vs non-FIPS split between zot-log.json and zot.log in pushpull, authn, and upgrade helpers. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Replace repeated command -v checks with a single loop over curl, jq, git, and docker. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Call helper_* directly from upgrade.bats and upgrade_minimal.bats, load helpers_pushpull in those suites, and move teardown there. Remove helpers_upgrade.bash now that the release/new wrappers are gone. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Drop parameter defaults from shared push/pull helpers and pass image, repository, and pagination values explicitly at each call site. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Rename helper_push_docker_image to helper_build_docker_image_push_and_pull and update test titles to reflect build plus expected push/pull failures without the docker compatibility extension. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
regctl persists login and TLS settings on disk, so push/pull blackbox tests could leak state into ~/.regctl/config.json across suites. Point REGCTL_CONFIG at BATS_FILE_TMPDIR for pushpull, authn, and upgrade suites, configure TLS once in authn setup, and drop redundant logout and per-login TLS setup. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Touch zot-log.json during upgrade setup and only cat it in teardown when the file exists, so a missing log cannot mask the underlying test failure. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
See commit messages. Closes #3727.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.