Repository navigation
test: add a two-namespace upgrade test - #44
Conversation
Inserting shared mock data into a collection adds an `_id`, and later tests couldn't serialize it. Two more tests lacked an app context. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replaces Travis and `main.yaml`. Tests run in the image. The smoke test uses MongoDB 7, which needs a newer pymongo than FOCA 0.7 pins. Excludes `.env*` from the image build context. Closes #32 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each call has a timeout and follows no redirects. A failure stays with its subscriber, and other than 2xx counts as one. The build stores one result per subscriber, without URLs or tokens. Closes #34 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With builds off, the default, the POST takes one prebuilt image and notifies subscribers. Build requests and PUT get a 403. Registration can be closed by configuration, and a subscription value `*` matches any tag or branch, as registering again won't work then. Closes #33 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Configuration from a Secret, and defaults in the image with no users and no debug mode. Without builds, no updater, shared volume, or rights. Route or Ingress with TLS, ClusterIP services with own selectors, no fixed user IDs, MongoDB 7 and camelCase values. The image runs under any user ID. Closes #35 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Admin users follow the configuration, the probe avoids the database, the build path finds its own namespace, and the README covers moving from the old chart. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shared thread limit let calls that hang keep later subscribers in the queue until the overall wait ended, so these were never called. Each subscriber now gets a thread, and the setting `endpoints.subscriptions.max_per_repository` (default: 100) limits the number of subscriptions per repository, and with it the threads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ages # Conflicts: # pubgrade/errors/exceptions.py # pubgrade/modules/endpoints/subscriptions.py # tests/pubgrade/endpoints/test_subscriptions.py
# Conflicts: # pubgrade/config.yaml
One publish upgrades Deployments in two namespaces of a throwaway k3s cluster, with Pubgrade from its chart and sidecars built from the branch `master` of Pubgrade-Sidecar. Also covers an unreachable subscriber and a tag that doesn't exist. Runs in CI as the job `Upgrade test`, part of the gate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR adds and gates a two-namespace k3s upgrade test while supplying the surrounding Helm, container, CI, API, notification, and configuration changes needed to exercise prebuilt-image fan-out, isolated sidecars, and failure reporting end to end. Sequence diagram for prebuilt image fan-out upgradessequenceDiagram
participant CI
participant Pubgrade
participant SidecarA as Sidecar_namespace_a
participant SidecarB as Sidecar_namespace_b
participant DeploymentA as Deployment_namespace_a
participant DeploymentB as Deployment_namespace_b
CI->>Pubgrade: POST /repositories/{repo_id}/builds
Pubgrade->>Pubgrade: validate_prebuilt_image(build_data)
Pubgrade->>Pubgrade: notify_all_subscriptions(subscription_ids, image, build_id)
par Notify namespace A
Pubgrade->>SidecarA: PUT callback_url
SidecarA-->>Pubgrade: 2xx response
SidecarA->>DeploymentA: Roll out image tag
and Notify namespace B
Pubgrade->>SidecarB: PUT callback_url
SidecarB-->>Pubgrade: 2xx response
SidecarB->>DeploymentB: Roll out image tag
end
Pubgrade-->>CI: Build status with notifications
Sequence diagram for notification failure reportingsequenceDiagram
participant CI
participant Pubgrade
participant ReachableSidecar
participant UnreachableSidecar
CI->>Pubgrade: POST /repositories/{repo_id}/builds
Pubgrade->>Pubgrade: notify_all_subscriptions(subscription_ids, image, build_id)
par Notify reachable subscriber
Pubgrade->>ReachableSidecar: PUT callback_url
ReachableSidecar-->>Pubgrade: 2xx response
and Notify unreachable subscriber
Pubgrade->>UnreachableSidecar: PUT callback_url
UnreachableSidecar-->>Pubgrade: Request timeout or error
end
Pubgrade-->>CI: Build status with delivered and failed notifications
Flow diagram for the gated upgrade testflowchart TD
Checkout[Check out repository] --> Helm[Set up Helm]
Helm --> Upgrade[Run tests/e2e/upgrade.sh]
Upgrade --> Cluster[Start throwaway k3s cluster]
Cluster --> Install[Install Pubgrade and MongoDB from Helm]
Install --> Namespaces[Create two namespaces with sidecars and Deployments]
Namespaces --> Publish[Publish one tagged prebuilt image]
Publish --> Rollouts[Verify both Deployments roll out]
Rollouts --> FailurePaths[Verify unreachable subscriber and nonexistent tag failures]
FailurePaths --> Gate[CI passed gate]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sidecars now accept a notification with a 202 and roll out in the background, so a missing tag only shows in their report, after retries. The test reads that report, and the README says what `delivered` means. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Threads per notification stay within the limit of subscriptions, also for lists longer than that. Completing a build needs the token of the repository that the build belongs to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/e2e/upgrade.sh" line_range="16" />
<code_context>
+# shellcheck source=tests/e2e/cluster.sh
+source "$(dirname "$0")/cluster.sh"
+
+SIDECAR_REPO="https://github.com/elixir-cloud-aai/Pubgrade-Sidecar.git#master"
+# A small image on Docker Hub that stays up, as the sidecar checks that tags
+# exist there
</code_context>
<issue_to_address>
**Unpinned sidecar breaks or compromises CI**
When the upstream `master` branch changes incompatibly, disappears, or is compromised, `docker build` fetches and executes the current branch's Dockerfile, so an incompatible change or removal breaks the upgrade job without a Pubgrade change, while a compromised branch runs code on the CI runner.
Pin `SIDECAR_REPO` to a reviewed immutable commit.
</issue_to_address>
### Comment 2
<location path="tests/e2e/upgrade.sh" line_range="228" />
<code_context>
+jq -e --arg id "${unreachable}" \
+ '.status == "FAILED" and (.notifications[] | select(.subscription_id == $id) | .result == "failed")' \
+ <<< "${result}" > /dev/null || fail "The unreachable subscriber wasn't reported"
+if grep -Eq 'nobody|callback_url|access_token' <<< "${result}"; then
+ fail "The public build shows URLs or tokens"
+fi
</code_context>
<issue_to_address>
**Secret leaks evade assertion**
When the public build response leaks callback URLs or tokens under other field names, the `upgrade.sh` check only searches for the literals `nobody`, `callback_url`, and `access_token`, so a response that exposes the callback URLs and tokens under neutral keys such as `url` and `token` passes the test.
Assert that each callback URL and token created by the test is absent from the response.
</issue_to_address>
### Comment 3
<location path="tests/e2e/cluster.sh" line_range="22-23" />
<code_context>
+
+# Remove the cluster, with its network and volume
+cluster_down() {
+ docker rm --force --volumes "${E2E_NAME}" > /dev/null 2>&1 || true
+ docker network rm "${E2E_NAME}" > /dev/null 2>&1 || true
+}
+
</code_context>
<issue_to_address>
**Preexisting Docker resources are deleted**
When a user already has a container or network named by `E2E_NAME` (by default, `pubgrade-e2e`), `cluster_up` calls `cluster_down`, and `docker rm --force --volumes` deletes the named container and its volumes before the test starts; the user loses unrelated local state.
Use a unique test-run name and refuse to remove resources unless the script can verify that it created them.
</issue_to_address>Linked issues
#36 test: add a two-namespace upgrade test · 6 of 6 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Run a local k3s cluster with Pubgrade installed from its chart and two namespaces, each with a test Deployment and a Pubgrade-Sidecar instance. | ✅ Met | The upgrade script starts a throwaway k3s cluster, installs Pubgrade from helm/, and creates both sites with a Deployment and sidecar; it builds the sidecar from the master branch by default. |
| 2 | Register a repository and subscriptions, publish one prebuilt image, and check that both Deployments roll out to the new image. | ✅ Met | tests/e2e/upgrade.sh registers the repository and both subscriptions, makes one publish request, and waits for each Deployment to run the new image. |
| 3 | Cover an unreachable sidecar and a tag that doesn't exist. | ✅ Met | The script checks that the unreachable subscriber is reported as failed while both sites roll out, and that a missing tag is reported as failed without changing either Deployment's image. |
| 4 | Add an upgrade / Upgrade test CI job as part of the gate. |
✅ Met | The workflow defines the Upgrade test job and includes upgrade in the CI passed gate's dependencies. |
| 5 | Add a short description in the README. | ✅ Met | The Development section describes the test, its prerequisites, its two-namespace upgrade and failure-path coverage, and how to supply a local sidecar image. |
| 6 | The test passes locally and in CI, and covers the MongoDB version the chart uses by default. | ✅ Met | The supplied verification reports local and CI passes; the test installs the chart with its default MongoDB image, mongo:7.0. |
Sourcery assessment
Needs a human reviewer. 3 findings to address first, and at startup, the configured admin list replaces the stored list, so a missing or incorrect Secret can revoke admin access; restoring the configuration can restore those users. The documented move from chart 0.1 also requires replacing the MongoDB volume, so existing database records are lost and reverting the chart does not bring them back.
Blocking findings: tests/e2e/upgrade.sh:16, tests/e2e/upgrade.sh:228, tests/e2e/cluster.sh:23
Image references follow Docker's rules, and requests without images or image names get a 400 instead of a server error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # tests/pubgrade/endpoints/test_builds.py
MongoDB listens on the configured port, and the builds' Role has no rights on Services, which nothing uses. The README names the storage class that builds need, and says to use HTTPS for callbacks outside the cluster. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test looks for the actual tokens in public builds, not only for field names, and by default no longer reuses the name of existing containers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Push both images by digest in the environment dev-images, scan exactly those digests, then attest, sign with Sigstore and tag them, as cloud-registry does. Report unit test coverage to Codecov. Drop the date tag, which the other repos don't publish. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Always write the coverage report and hand it to the host user, also when tests fail. Document the environment, secrets and variable that publishing needs, and how to verify an image's signature. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .github/workflows/ci.yml
…images # Conflicts: # tests/smoke.sh
There was a problem hiding this comment.
Linked issues
#36 test: add a two-namespace upgrade test · 3 of 5 met · 1 to check by hand
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Run a local k3s test with Pubgrade from its chart and two namespaces, each with a Deployment and sidecar from Pubgrade-Sidecar's master branch. | 🟡 Partly met | The test creates the cluster, chart installation, and two namespace setups, but builds the sidecar from the dev branch. |
| 2 | Register a repository and subscriptions, publish one prebuilt image, and check that both Deployments roll out. | ✅ Met | The script publishes once and checks each namespace's Deployment image and rollout. |
| 3 | Cover an unreachable subscriber and a tag that doesn't exist. | ✅ Met | The test checks the unreachable subscriber's failed result while both sites roll out, then checks that a missing tag leaves the Deployments unchanged and is reported as failed. |
| 4 | Add an upgrade / Upgrade test CI job as part of the gate, and a short README description. |
✅ Met | The job runs the test, is included in the publish and gate dependencies, and the README describes the test. |
| 5 | Pass locally and in CI, and cover the MongoDB version used by the chart by default. | 👀 Check by hand (runtime) | Confirm the reported local and CI runs pass; the test installs the chart without overriding its default MongoDB image. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #44 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 669 669
=========================================
Hits 669 669 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rade # Conflicts: # .github/workflows/ci.yml # README.md
Closes #36
Stacked on #37 and the branches of #34, #33 and #35. Until those are merged, this diff against
devalso shows their commits; review onlytests/e2e/, the jobupgradeand the README note. The base isdevso that CI runs.Light lane: this adds a test script and a CI job, without touching secrets, permissions or the release workflow.
Summary
tests/e2e/upgrade.sh: a throwaway k3s cluster with Pubgrade and MongoDB from the chart, two namespaces with a Deployment and a sidecar each. One publish rolls out both Deployments.masterof Pubgrade-Sidecar, as no image of it is published yet;SIDECAR_IMAGEcan name a local one.upgrade/Upgrade test, part of the gate; README note.Verification
tests/e2e/upgrade.shlocally: passed, in about 3 minutes; publishing took about 1 s, and both namespaces had rolled out within about 5 s. All containers and networks were removed afterwards.Upgrade testandCI passed.Declined review findings
masterand fail when the two stop working together. It did so once already, when the sidecar's notifications became asynchronous.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Add a Kubernetes end-to-end upgrade test covering successful multi-namespace rollouts and failure handling, and run it in CI.
New Features:
Enhancements:
CI:
Documentation:
Tests: