michaelsembwever commented on code in PR #2336:
URL: https://github.com/apache/cassandra/pull/2336#discussion_r1195124086


##########
test/distributed/org/apache/cassandra/distributed/upgrade/UpgradeTestBase.java:
##########
@@ -176,83 +179,177 @@ public TestCase nodes(int nodeCount)
             return this;
         }
 
-        /** performs all supported upgrade paths that exist in between from 
and end on CURRENT (inclusive)
-         * {@code upgradesToCurrentFrom(3.0); // produces: 3.0 -> CURRENT, 
3.11 -> CURRENT, …}
-         **/
-        public TestCase upgradesToCurrentFrom(Semver from)
+        /**
+         * @param minimalSupportedVersion the minimal version that this test 
case is applicable for
+         *
+         * This function sets the lower bound of test case's applicability
+         * the test case will run (see {@link #run}) all supported direct 
upgrades source -> target
+         * such that:
+         * - source >= minimalSupportedVersion
+         * - source == CURRENT or target == CURRENT
+         *
+         * example:
+         * with CURRENT = v50 and minimalSupportedVersion = v30 the test case 
will run:
+         * - v40 -> v50
+         * - v41 -> v50
+         * with CURRENT = v41 and minimalSupportedVersion = v30 the test case 
will run:
+         * - v30 -> v41
+         * - v3x -> v41
+         * - v40 -> v41
+         * with CURRENT = v3x and minimalSupportedVersion = v30 the test case 
will run:
+         * - v30 -> v3x
+         */
+        public TestCase minimalApplicableVersion(Semver 
minimalSupportedVersion)
         {
-            return upgradesTo(from, CURRENT);
+            this.minimalApplicableVersion = minimalSupportedVersion;
+            addUpgrades();
+            return this;
         }
 
         /**
-         * performs all supported upgrade paths to the "to" target; example
-         * {@code upgradesTo(3.0, 4.0); // produces: 3.0 -> 4.0, 3.11 -> 4.0}
+         * @param minimalSupportedVersion the minimal version that this test 
case is applicable for
+         * @param maximalSupportedVersion the maximal version that this test 
case is applicable for
+         *
+         * This function sets both the lower and the upper bounds of test 
case's applicability
+         * the test case will run (see {@link #run}) all supported direct 
upgrades source -> target
+         * such that:
+         * - source >= minimalSupportedVersion
+         * - target <= maximalSupportedVersion
+         * - source == CURRENT or target == CURRENT
+         *
+         * example:
+         * with CURRENT = v50, minimalSupportedVersion = v30, and 
maximalSupportedVersion = v41
+         * the test case will not run any upgrades.
+         * with CURRENT = v41, minimalSupportedVersion = v30, and 
maximalSupportedVersion = v41
+         * the test case will run:
+         * - v30 -> v41
+         * - v3x -> v41
+         * - v40 -> v41
          */
-        public TestCase upgradesTo(Semver from, Semver to)
+        public TestCase applicableVersionsRange(Semver 
minimalSupportedVersion, Semver maximalSupportedVersion)
         {
-            List<TestVersions> upgrade = new ArrayList<>();
-            NavigableSet<Semver> vertices = 
sortedVertices(SUPPORTED_UPGRADE_PATHS);
-            for (Semver start : vertices.subSet(from, true, to, false))
-            {
-                // only include pairs that are allowed, and start or end on 
CURRENT
-                if (SUPPORTED_UPGRADE_PATHS.hasEdge(start, to) && 
contains(start, to, CURRENT))
-                    upgrade.add(new TestVersions(versions.getLatest(start), 
Collections.singletonList(versions.getLatest(to))));
-            }
-            logger.info("Adding upgrades of\n{}", 
upgrade.stream().map(TestVersions::toString).collect(Collectors.joining("\n")));
-            this.upgrade.addAll(upgrade);
+            this.minimalApplicableVersion = minimalSupportedVersion;
+            this.maximalApplicableVersion = maximalSupportedVersion;
+            addUpgrades();
             return this;
         }
 
         /**
-         * performs all supported upgrade paths from the "from" target; example
-         * {@code upgradesFrom(4.0, 4.2); // produces: 4.0 -> 4.1, 4.0 -> 4.2}
-         */
-        public TestCase upgradesFrom(Semver from, Semver to)
+         * this is a deprecated, backwards-compatible API for upgrade tests, 
that allows to specify which upgrades to perform
+         *
+         * upgradesToCurrentFrom(Semver from) sets the upgrades to perform to 
be all supported direct upgrades (upgrade
+         * paths with length 1) to the CURRENT version, but omitting versions 
older than the given "from" version
+         *
+         * This intent is best expressed by the newer alternatives:
+         * - appplicableVersionsRange(from, CURRENT)
+         * or, perhaps, depending on the actual case:
+         * - minimalApplicableVersion(from)
+         *
+         * please note, that upgrades that do not involve the CURRENT version 
are not meant to be run in upgrade tests
+         *
+         * Beware, there may be no supported direct upgrade path from -> 
CURRENT, and this is OK.
+         * e.g. when CURRENT == v4
+         * {@code upgradesToCurrentStartingNoEarlierThan(3.0); // produces: 
3.0 -> CURRENT, 3.11 -> CURRENT, …}
+         * and when CURRENT == v5
+         * {@code upgradesToCurrentStartingNoEarlierThan(3.0); // produces: 
4.0 -> CURRENT, 4.1 -> CURRENT, …}
+         * and when CURRENT == v3.11
+         * {@code upgradesToCurrentStartingNoEarlierThan(3.0); // produces: 
3.0 -> CURRENT, …}
+         **/
+        @Deprecated
+        public TestCase upgradesToCurrentFrom(Semver from)

Review Comment:
   in this class we don't need to go through the deprecation cycle.
   
   it would be better to apply the patch to all branches to avoid this problem.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to