Skip to content

refactor(e2e): single-source the k3d bring-up prelude (#541 review) - #550

Merged
LukasWodka merged 1 commit into
developfrom
refactor/e2e-common-prelude
Aug 3, 2026
Merged

refactor(e2e): single-source the k3d bring-up prelude (#541 review)#550
LukasWodka merged 1 commit into
developfrom
refactor/e2e-common-prelude

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Single-source the e2e k3d bring-up prelude

Addresses @saqlainsyed007's review on #541 (thread on scripts/tests/e2e-seal-check.sh:36): the bring-up prelude was copy-pasted near-verbatim across scripts/tests/e2e-*.sh, and multiple Bugbot rounds had to edit every copy in lockstep or they'd drift.

What's extracted → scripts/tests/lib/e2e-common.sh

Two functions — the parts that were byte-identical and drift-prone:

  • e2e_isolate_env <name>USER + CLUSTER_NAME default + TRACEBLOC_NO_AUTOSTART (the distinct default is the arg, still env-overridable).
  • e2e_install_prereqshas docker + umask 022 + install_{kubectl,k3d,helm} (the sequence the Bugbot rounds kept changing).

e2e-cluster / e2e-proxy / e2e-journey / e2e-auto-upgrade now source the lib and call these; each keeps its own CLUSTER_NAME and test logic. e2e-auto-upgrade keeps its extra has jq guard right before the call.

Deliberately not unified (unifying would change behavior)

  • The sub-lib source sete2e-proxy/e2e-journey source common+setup-linux+cluster only; e2e-cluster/e2e-auto-upgrade also source preflight (which has top-level PF_* side effects). ⚠️Both proxy and journey call create_cluster — which uses _pf_recheck_runtime_mem, defined only in preflight.sh — without sourcing it. That's a pre-existing inconsistency worth a separate look; I did not change it here.
  • cleanup/trap bodies — each reaps its own extra resources (a squid container, work dirs) beyond the k3d cluster.
  • CHART_DIR — only the chart-installing scripts set it.

Scope note

e2e-seal-check.sh lives on the still-open #541 branch, not develop, so it's not touched here (keeps this PR non-stacked). It adopts the lib as a fast-follow once both land.

Verified

  • Added the lib to both shellcheck gates: installer-tests.yaml and the requiredstandard-checks.yml Lint.
  • shellcheck --severity=error (the gate) and--severity=warning clean on all 5 files; bash -n ok.
  • Net −20 lines of duplication. The live e2e-cluster / e2e-proxy / e2e-journey / upgrade-e2e CI jobs exercise the refactored scripts on this PR.

Targets develop.

🤖 Generated with Claude Code


Note

Low Risk
Test-harness refactor with no production installer behavior change; existing e2e CI jobs exercise the updated scripts.

Overview
Centralizes the duplicated k3d e2e bring-up prelude in scripts/tests/lib/e2e-common.sh: e2e_isolate_env sets USER, a per-script default CLUSTER_NAME, and TRACEBLOC_NO_AUTOSTART; e2e_install_prereqs checks Docker, sets umask, and runs install_kubectl / install_k3d / install_helm.

e2e-cluster, e2e-proxy, e2e-journey, and e2e-auto-upgrade now source that lib instead of inlining the same blocks (each still passes its own cluster name; auto-upgrade keeps its separate jq check).

CI Lint and installer-tests shellcheck steps include the new file. .gitignore adds !scripts/tests/lib/ so the test lib is not swallowed by the existing lib/ ignore rule.

Reviewed by Cursor Bugbot for commit a2b2be3. Bugbot is set up for automated code reviews on this repo. Configure here.

@LukasWodkaLukasWodka self-assigned this Aug 3, 2026
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f709559. Configure here.

Comment threadscripts/tests/e2e-cluster.sh

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f709559. Configure here.

Comment threadscripts/tests/e2e-cluster.sh

@saqlainsyed007saqlainsyed007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: the extracted lib scripts/tests/lib/e2e-common.sh is never committed

The entire refactor pivots on a new shared file, but that file is not part of this commit. git show --stat f709559 lists only the 6 modified files and adds nothing new; git cat-file -e HEAD:scripts/tests/lib/e2e-common.shdoes not exist in HEAD. There is no e2e-common.sh anywhere in the tree. This looks like a missing git add of the newly-created lib.

Consequences — this is not behavior-preserving, it is a hard break of every call site:

  1. Runtime abort in all 4 scripts.e2e-cluster.sh:26, e2e-proxy.sh:28, e2e-journey.sh:48, e2e-auto-upgrade.sh:51 each do source "$HERE/lib/e2e-common.sh". Under the set -euo pipefail at the top of each script, sourcing a missing file fails immediately (No such file or directory, non-zero) and the script exits before ever reaching create_cluster. The e2e-cluster / e2e-proxy / e2e-journey / upgrade-e2e CI jobs all die at bring-up. Even if the source somehow continued, e2e_isolate_env and e2e_install_prereqs are undefined → the isolation env (CLUSTER_NAME/USER/TRACEBLOC_NO_AUTOSTART) and the docker-check/umask/tool-installs are silently lost, so the seal-check/egress posture the #541 review depends on is gone.
  2. Both shellcheck gates fail on a missing path.standard-checks.yml:47 and installer-tests.yaml:70,74 now pass scripts/tests/lib/e2e-common.sh to shellcheck; with the file absent, shellcheck errors openBinaryFile: does not exist, breaking the required Lint. This contradicts the PR's "shellcheck clean on all 5 files" / "CI exercises the refactored scripts" claims — those can only have passed against an uncommitted local file.

Fix:git add scripts/tests/lib/e2e-common.sh and push. I could not review the actual behavior-preservation of e2e_isolate_env / e2e_install_prereqs (dropped flags, ordering, env defaults, has docker guard, umask 022) because the file isn't in the PR — please re-request review once the lib is committed so the extracted bodies can be diffed against the former inline copies.

Verdict: REQUEST_CHANGES.

Comment threadscripts/tests/e2e-cluster.sh
Comment thread.github/workflows/installer-tests.yaml Outdated
Saqlain flagged (PR #541, thread on e2e-seal-check.sh:36) that the bring-up
prelude is copy-pasted near-verbatim across scripts/tests/e2e-*.sh, and
multiple Bugbot rounds have had to edit every copy in lockstep. Extract the two
truly-identical, drift-prone blocks into scripts/tests/lib/e2e-common.sh:
- e2e_isolate_env <name> — USER + CLUSTER_NAME default + TRACEBLOC_NO_AUTOSTART
- e2e_install_prereqs — has docker + umask + install_{kubectl,k3d,helm}
e2e-cluster / e2e-proxy / e2e-journey / e2e-auto-upgrade now source the lib and
call these; each keeps its own CLUSTER_NAME default (passed as the arg) and its
distinct logic. auto-upgrade keeps its extra `has jq` guard before the call.
Deliberately NOT unified (would change behavior): the sub-lib `source` set
(proxy/journey source 3 libs, not preflight — a pre-existing inconsistency,
flagged not fixed), the cleanup/trap bodies (each reaps its own squid/work
dirs), and CHART_DIR (only the chart-installing scripts). e2e-seal-check.sh
(open on #541) adopts the lib as a fast-follow once both land — kept non-stacked.
Added the lib to both shellcheck gates (installer-tests + the required
standard-checks Lint). shellcheck --severity=error/warning clean; bash -n ok.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka
LukasWodkaforce-pushed the refactor/e2e-common-prelude branch from f709559 to a2b2be3CompareAugust 3, 2026 13:22
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

Force-pushed the fix: the new scripts/tests/lib/e2e-common.sh was silently dropped by git add -A because .gitignore's lib/ pattern (only !scripts/lib/ was excepted) ignored scripts/tests/lib/. Added !scripts/tests/lib/, committed the lib, and rebased onto develop (which resolves the workflow-file conflicts from #541 — both lists now have seal-check + e2e-common). shellcheck error-clean. bugbot run

@saqlainsyed007saqlainsyed007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of a2b2be3 (prior REQUEST_CHANGES was review 4844149284 at f709559).

Prior blocker RESOLVED. The one root-cause finding — the extracted shared file scripts/tests/lib/e2e-common.sh was never git added — is fixed: the file is now committed and tracked in the tree at this SHA, appears in the PR file list (ADDED, +51), and .gitignore now carries !scripts/tests/lib/ (mirroring the existing !scripts/lib/) so the dir is no longer swallowed by the lib/ ignore. Every source "$HERE/lib/e2e-common.sh" now resolves, so set -euo pipefail no longer aborts the four callers, and both shellcheck lists reference a file that exists.

Behavior preservation now verifiable — and faithful.

  • e2e_isolate_env <name> reproduces the old inline block exactly (export USER="${USER:-$(id -un)}", export CLUSTER_NAME="${CLUSTER_NAME:-$1}", export TRACEBLOC_NO_AUTOSTART=1). Each caller passes its own former default — e2e-cluster tbe2e, e2e-journey tbe2e-journey, e2e-proxy tbproxy, e2e-auto-upgrade tbupg — and env override is preserved.
  • e2e_install_prereqs reproduces the old block byte-for-byte: has docker || error, umask 022, install_kubectl/install_k3d/install_helm.
  • Sourcing/ordering is correct in all four: the lib is sourced first (functions only, no side effects, no set -e — right for a sourced lib), e2e_isolate_env runs, then common.sh + setup-linux.sh + cluster.sh are sourced, and e2e_install_prereqs is called only afterward, so has/error/install_* resolve at call time.
  • Correctly NOT unified: preflight.sh is still sourced only by e2e-cluster + e2e-auto-upgrade (the pre-existing proxy/journey inconsistency is flagged in the lib header, not silently "fixed"); each script keeps its own cleanup/trap cleanup EXIT; CHART_DIR stays local to auto-upgrade.
  • e2e-auto-upgrade keeps its extra has jq || error guard. (Minor, non-blocking: it now runs just before the docker check inside e2e_install_prereqs rather than just after it — both are fail-fast guards, so behavior is unchanged.)
  • e2e-seal-check.sh is deliberately untouched (fast-follow per the description) and still carries its own inline prelude, so nothing is half-migrated or double-brought-up. The #541 seal-check/egress posture is unaffected.

Verification I ran at this SHA:git cat-file -e HEAD:scripts/tests/lib/e2e-common.sh (exists); bash -n clean on the lib + all four callers; shellcheck --severity=errorclean across the lib, the four callers, and e2e-seal-check (the required standard-checks Lint gate), and --severity=warning clean too. Both workflow shellcheck lists now include scripts/tests/lib/e2e-common.sh.

No blocking issues and no behavior regressions. Approving.

@LukasWodka
LukasWodka merged commit 489ecd1 into developAug 3, 2026
46 checks passed
LukasWodka added a commit that referenced this pull request Aug 3, 2026
…ollow) (#566)
Promised on the #541 review threads, now that #550 (the shared lib) and #541
(the seal-check script) are both on develop:
- e2e-seal-check.sh now sources scripts/tests/lib/e2e-common.sh and uses
e2e_isolate_env / e2e_install_prereqs, matching the other e2e-*.sh (drops the
inlined isolation-env + install block). Keeps its own NS=$CLUSTER_NAME and
local fail() for its assertions.
- Harden the positive control (Saqlain nit): pin networkPolicy.training.
enforcementProbeHost to a single $HOST var the install passes AND the positive
control targets, so the probe and the control can never drift onto different
hosts (was: HOST hardcoded while the probe used the chart default).
shellcheck --severity=error/warning clean; helm template renders the probe Job
with HOST=1.1.1.1 pinned.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

/fr-pass

@LukasWodka
LukasWodka deleted the refactor/e2e-common-prelude branch August 14, 2026 13:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@LukasWodka@saqlainsyed007