Teach the pre-release metadata test about a second beta (#2869)

The second beta's preparation pull request (v6.6.0-beta.2) failed
Backend tests: TestCurrentPrereleasePacketTracksInstallMetadata said the
changelog is missing "This changelog describes the changes since
`v6.5.0`". The release metadata tool correctly wrote the changelog as
the changes since the previous beta, `v6.6.0-beta.1`. The test's
previousPrereleaseVersion helper only understood -rc.N, so for beta.2 it
reported no predecessor and the test fell back to the previous stable.

The helper now names the predecessor in the pre-release's own stage,
alpha, beta or rc, N-1, as the tool does: rc.2 follows rc.1, beta.2
follows beta.1, and the first of a stage has none even when an earlier
stage shipped. A table test pins it, because beta.1 passed without ever
exercising the second-beta case.

Checked on pulse-dev against the actual beta.2 preparation snapshot with
this change: the whole installer test package passes (343 s) and so do
all 71 release policy tests. Against main, the new table test and the
metadata tests pass.

The release train now cuts a beta every two days before the candidate,
so every beta after the first goes through this path.
This commit is contained in:
rcourtman
2026-10-12 14:09:14 +01:00
committed by GitHub
+38 -7
View File
@@ -283,16 +283,47 @@ func TestStablePatchPromotedPrereleaseDetectsSameVersionCandidate(t *testing.T)
}
}
// previousPrereleaseVersion names the predecessor of a numbered pre-release in its own
// stage, as the release metadata tool does: rc.2 follows rc.1 and beta.2 follows beta.1.
// The first of a stage has none, even when an earlier stage shipped.
func previousPrereleaseVersion(version string) (string, bool) {
base, suffix, ok := strings.Cut(version, "-rc.")
if !ok {
return "", false
for _, stage := range []string{"alpha", "beta", "rc"} {
base, suffix, ok := strings.Cut(version, "-"+stage+".")
if !ok {
continue
}
number, err := strconv.Atoi(suffix)
if err != nil || number <= 1 {
return "", false
}
return fmt.Sprintf("%s-%s.%d", base, stage, number-1), true
}
rc, err := strconv.Atoi(suffix)
if err != nil || rc <= 1 {
return "", false
return "", false
}
// The release train cuts several betas before its candidate. The second beta's changelog
// is written as the changes since the first, so the checks that read it must expect that.
func TestPreviousPrereleaseVersionFollowsItsOwnStage(t *testing.T) {
for _, tc := range []struct {
version, want string
ok bool
}{
{"6.6.0-rc.2", "6.6.0-rc.1", true},
{"6.6.0-rc.12", "6.6.0-rc.11", true},
{"6.6.0-beta.2", "6.6.0-beta.1", true},
{"6.6.0-beta.7", "6.6.0-beta.6", true},
{"6.6.0-alpha.3", "6.6.0-alpha.2", true},
{"6.6.0-beta.1", "", false},
{"6.6.0-rc.1", "", false},
{"6.6.0-alpha.1", "", false},
{"6.6.0-beta.x", "", false},
{"6.6.0", "", false},
} {
got, ok := previousPrereleaseVersion(tc.version)
if got != tc.want || ok != tc.ok {
t.Errorf("previousPrereleaseVersion(%q) = %q, %v; want %q, %v", tc.version, got, ok, tc.want, tc.ok)
}
}
return fmt.Sprintf("%s-rc.%d", base, rc-1), true
}
func TestInstallDockerScriptUsesConfiguredImageRepoDefault(t *testing.T) {