refactor(e2e): make the fixture minimal and take the images from it - #2308
refactor(e2e): make the fixture minimal and take the images from it#2308vyncint wants to merge 3 commits into
Conversation
|
This is the shape I was arguing for, and the two measurements are what make it convincing rather than a matter of taste.
Keeping Two things, neither blocking.
The image constants are duplicated, and a test is holding the two copies equal. That predates this PR — the constants arrived with Ordering, since all three of your open PRs are disjoint: this one is worth landing before the next migration batch, so batch 3 is written against the final shape rather than reworked into it. It does not need to wait for #2306, which shares no files with it. |
The defaulted builders were declined by both suites that could have used them, because their defaults inject fields those suites do not have: Network.Keepalive, Resources, BufferVolumeMetrics, Workers. Only ControlNamespace appears in all 17 Logging literals, so a builder that fills anything else is hiding a divergence rather than sharing a default.Logging returns the smallest valid object now and a suite states the rest. WithFluentbit, WithFluentd, FluentdSpec, Workers, Drain, Buffer, Timekey, TimekeyWait, HTTPOutput and Flow are gone, none of which had a caller.What is left is what does not vary: the images, and the tenancy constructors that two suites already use. Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
81 image literals across eight suites, all of them the same repository and tag, none overridden anywhere. TestImageHelpersMatchTheLiterals pins each helper against the literal it replaces, so the sweep cannot change which image a suite runs.The four suites in flight elsewhere are left for their own changes to avoid a conflict. Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
…stants Logging had no caller after the inversion, and a seven line minimal constructor is trivially re-added by whichever migration wants one; left in place it invites the next person to guess at its intent. Flow, HTTPOutput and Buffer went with the inversion itself, and ReceiverURL and TenantReceiverURL are both used by tenancy, so nothing exported here is now without a caller.The image constants are duplicated from common with a test holding them equal. That is unavoidable while the unmigrated suites reference common's copies, so the condition for removing both is written beside them rather than left implicit. Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
924698e to
d057e1d
Compare
|
We converged on this by measurement rather than up front, so it is worth writing the rule down now that three PRs have tested it. The rule: extract a value when it is identical across all callers and no test asserts it. Otherwise it stays in the suite. Checked against every candidate in this module:
That predicts every outcome we reached the slow way, including the two builders you declined in #2306 and the ones you measured out here. It also explains why the defaulted builders failed: they extracted on resemblance rather than identity, so a default landed in callers that diverged. Worth keeping as the admission test for anything the next batches want to extract. Two things the rule flags that are still open.
Where that leaves the packages. No CR builders. The This supersedes §4 of #2291, which sketched |
Takes the suggestion from #2306: minimal rather than defaulted, and extract only what does not vary.
Inverted
The defaulted builders are gone —
WithFluentbit,WithFluentd,FluentdSpec,Workers,Drain,Buffer,Timekey,TimekeyWait,HTTPOutput,Flow. None had a caller, and both suites that could have used one declined it because its defaults inject fields they do not have.Two measurements settled the shape rather than assumption. Only
ControlNamespaceappears in all 17Loggingliterals — evenEnableRecreateWorkloadOnImmutableFieldChangeis 12 of 17, so the old builder was already injecting a divergence into a third of its callers.Loggingitself is gone too. A seven line minimal constructor with no caller invites the next person to guess at its intent, and whichever migration wants one can add it back. Nothing exported here is now without a caller:ReceiverURLandTenantReceiverURLare both used bytenancy.go.tenancy.gostays. It is a whole-scenario constructor rather than a defaulted builder over divergent fields, it has two callers, andTestBuildersMatchCommonpins it equal tocommon.Extracted
99 image literals across the module split 91
v1beta1.ImageSpecand 8v1beta1.BasicImageSpecin three suites, which is whyBasicis a converter rather than a second name per image. Nothing overrides an image: there is not one hardcodedRepository:orTag:anywhere in the suites.81 of those literals are swept here, across eight suites.
TestImageHelpersMatchTheLiteralspins each helper against the literal it replaces, so the sweep cannot change which image a suite runs. The four suites with changes in flight are left alone to avoid a conflict; they pick the helpers up with their own.The constants themselves are duplicated from
common, withTestImageNamesMatchCommonholding the two equal. That is unavoidable while the unmigrated suites referencecommon's copies, and this is the PR that makes 81 call sites depend on the fixture's, so the condition for removing both is now written beside them: when the last suite stops usingcommon's, the duplicates and the test go andfixtureis the only source.One test earned its removal.
TestTenancyAggregatorDivergesFromTheDefaultcompared the tenancy spec againstFluentdSpec(); with no default to diverge from the comparison means nothing, so it asserts the spec's own properties and is named for what it does.Not folded in
The two things flagged as separate stay separate: the e2e-framework helm binary that
watch-selectorneeds and no Makefile installs, and whether the syslog-ng spec is the one case for testdata YAML.Verification
make checkpasses,golangci-lint run --max-same-issues=0 --max-issues-per-linter=0ine2e/reports 0 issues, and both commits build, vet and test on their own. The sweep is mechanical and its equivalence is asserted rather than assumed; no suite behaviour changes, so there is nothing here a cluster run would exercise that the unit tests do not.