@@ -11,6 +11,8 @@ import (
1111 "math/rand"
1212 "testing"
1313
14+ "github.com/cockroachdb/cockroach/pkg/build"
15+ "github.com/cockroachdb/cockroach/pkg/clusterversion"
1416 "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
1517 "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
1618 "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/clusterupgrade"
@@ -477,3 +479,37 @@ func TestSupportsSkipUpgradeTo(t *testing.T) {
477479 expect (v , false )
478480 }
479481}
482+
483+ // Regression test for #157852.
484+ // This tests that our skip upgrade logic does not break when we are in the middle
485+ // of the version bump process. We bump the current version and the minSupportedVersion
486+ // separately, so we want to make sure that:
487+ // 1. supportsSkipUpgradeTo does not let us perform a skip upgrade from a non supportedVersion.
488+ // This edge case happens if we bump the minSupportedVersion first and there is only 1 supported
489+ // previous release in the current series despite being a .2 or .4 release.
490+ // 2. supportsSkipUpgradeTo does not let us perform a skip upgrade over a .2 or .4 release.
491+ // This edge case happens if we bump the current version first and there could be 3 supported
492+ // previous releases in the current series.
493+ func TestSupportsSkipCurrentVersion (t * testing.T ) {
494+ mvt := newTest ()
495+
496+ // Case 1: If the minimumSupportedVersion on the current release says there is only 1 supported
497+ // previous release, then it doesn't matter if the previous release is an innovation or not,
498+ // we can't skip over it.
499+ numSupportedVersions := len (clusterversion .SupportedPreviousReleases ())
500+
501+ // Case 2: If the current release is an innovation release, it means the previous release
502+ // is _not_ an innovation, i.e. we can't skip over it.
503+ currentRelease := clusterversion .Latest .ReleaseSeries ()
504+ isInnovationRelease := currentRelease .Minor == 1 || currentRelease .Minor == 3
505+
506+ // We can only perform a skip upgrade to the current version if it's not an innovation and
507+ // there are multiple supported previous versions.
508+ expected := ! isInnovationRelease && numSupportedVersions > 1
509+
510+ // N.B. The predecessor is only used to determine if we should skip over the
511+ // mixedversion test's minimum supported version, and not relevant for this test.
512+ pred := clusterupgrade .MustParseVersion ("24.2.1" )
513+ actual := mvt .supportsSkipUpgradeTo (pred , & clusterupgrade.Version {Version : version .MustParse (build .BinaryVersion ())})
514+ require .Equal (t , expected , actual )
515+ }
0 commit comments