Skip to content

Commit 148ceb2

Browse files
committed
fix tests to not try and parse versions (unsupported for BWC and serverless)
1 parent abb40e6 commit 148ceb2

File tree

14 files changed

+75
-89
lines changed

14 files changed

+75
-89
lines changed

qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedFullClusterRestartTestCase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ public boolean isRunningAgainstOldCluster() {
134134
return requestedUpgradeStatus == OLD;
135135
}
136136

137-
public static String getOldClusterVersion() {
137+
/**
138+
* The version of the "old" (initial) cluster. It is an opaque string, do not even think about parsing it for version
139+
* comparison. Use (test) cluster features and {@link ParameterizedFullClusterRestartTestCase#oldClusterHasFeature} instead.
140+
*/
141+
protected static String getOldClusterVersion() {
138142
return System.getProperty("tests.bwc.main.version", OLD_CLUSTER_VERSION);
139143
}
140144

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ public abstract class AbstractRollingUpgradeTestCase extends ParameterizedRollin
3030
private static final ElasticsearchCluster cluster = buildCluster();
3131

3232
private static ElasticsearchCluster buildCluster() {
33-
Version oldVersion = Version.fromString(OLD_CLUSTER_VERSION);
3433
var cluster = ElasticsearchCluster.local()
3534
.distribution(DistributionType.DEFAULT)
36-
.version(getOldClusterTestVersion())
35+
.version(getOldClusterVersion())
3736
.nodes(NODE_NUM)
3837
.setting("path.repo", new Supplier<>() {
3938
@Override
@@ -47,7 +46,7 @@ public String get() {
4746

4847
// Avoid triggering bogus assertion when serialized parsed mappings don't match with original mappings, because _source key is
4948
// inconsistent
50-
if (oldVersion.before(Version.fromString("8.18.0"))) {
49+
if (Version.fromString(getOldClusterVersion()).before(Version.fromString("8.18.0"))) {
5150
cluster.jvmArg("-da:org.elasticsearch.index.mapper.DocumentMapper");
5251
cluster.jvmArg("-da:org.elasticsearch.index.mapper.MapperService");
5352
}

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ public abstract class AbstractRollingUpgradeWithSecurityTestCase extends Paramet
3535
private static final ElasticsearchCluster cluster = buildCluster();
3636

3737
private static ElasticsearchCluster buildCluster() {
38-
Version oldVersion = Version.fromString(OLD_CLUSTER_VERSION);
3938
var cluster = ElasticsearchCluster.local()
4039
.distribution(DistributionType.DEFAULT)
41-
.version(getOldClusterTestVersion())
40+
.version(getOldClusterVersion())
4241
.nodes(NODE_NUM)
4342
.user(USER, PASS)
4443
.setting("xpack.security.autoconfiguration.enabled", "false")
@@ -52,7 +51,7 @@ public String get() {
5251

5352
// Avoid triggering bogus assertion when serialized parsed mappings don't match with original mappings, because _source key is
5453
// inconsistent
55-
if (oldVersion.before(Version.fromString("8.18.0"))) {
54+
if (Version.fromString(getOldClusterVersion()).before(Version.fromString("8.18.0"))) {
5655
cluster.jvmArg("-da:org.elasticsearch.index.mapper.DocumentMapper");
5756
cluster.jvmArg("-da:org.elasticsearch.index.mapper.MapperService");
5857
}

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DenseVectorMappingUpdateIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public DenseVectorMappingUpdateIT(@Name("upgradedNodes") int upgradedNodes) {
8282
}
8383

8484
public void testDenseVectorMappingUpdateOnOldCluster() throws IOException {
85-
if (getOldClusterTestVersion().after(Version.V_8_7_0.toString())) {
85+
if (oldClusterHasFeature("gte_v8.7.1")) {
8686
String indexName = "test_index";
8787
if (isOldCluster()) {
8888
Request createIndex = new Request("PUT", "/" + indexName);

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsUpgradeIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1818
import org.elasticsearch.test.cluster.FeatureFlag;
1919
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
20-
import org.elasticsearch.test.cluster.util.Version;
2120
import org.elasticsearch.test.cluster.util.resource.Resource;
2221
import org.elasticsearch.test.junit.RunnableTestRuleAdapter;
2322
import org.junit.ClassRule;
@@ -34,7 +33,7 @@
3433
public class FileSettingsUpgradeIT extends ParameterizedRollingUpgradeTestCase {
3534

3635
private static final RunnableTestRuleAdapter versionLimit = new RunnableTestRuleAdapter(
37-
() -> assumeTrue("Only valid when upgrading from pre-file settings", getOldClusterTestVersion().before(new Version(8, 4, 0)))
36+
() -> assumeFalse("Only valid when upgrading from pre-file settings", oldClusterHasFeature("gte_v8.4.0"))
3837
);
3938

4039
private static final String settingsJSON = """
@@ -54,7 +53,7 @@ public class FileSettingsUpgradeIT extends ParameterizedRollingUpgradeTestCase {
5453

5554
private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
5655
.distribution(DistributionType.DEFAULT)
57-
.version(getOldClusterTestVersion())
56+
.version(getOldClusterVersion())
5857
.nodes(NODE_NUM)
5958
.setting("path.repo", new Supplier<>() {
6059
@Override

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsUsageRollingUpgradeIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public LogsUsageRollingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
3030
}
3131

3232
public void testUsage() throws Exception {
33-
assumeTrue("logsdb.prior_logs_usage only gets set in 8.x", getOldClusterTestVersion().before("9.0.0"));
33+
assumeFalse("logsdb.prior_logs_usage only gets set in 8.x", oldClusterHasFeature("gte_v9.0.0"));
3434
String dataStreamName = "logs-mysql-error";
3535
if (isOldCluster()) {
3636
bulkIndex(dataStreamName, 4, 256, Instant.now());

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase {
3838
protected static final int NODE_NUM = 3;
39-
protected static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version");
39+
private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version");
4040
private static final Set<Integer> upgradedNodes = new HashSet<>();
4141
private static TestFeatureService oldClusterTestFeatureService = null;
4242
private static boolean upgradeFailed = false;
@@ -127,11 +127,6 @@ public static void resetNodes() {
127127
upgradeFailed = false;
128128
}
129129

130-
@Deprecated // Use the new testing framework and oldClusterHasFeature(feature) instead
131-
protected static String getOldClusterVersion() {
132-
return OLD_CLUSTER_VERSION;
133-
}
134-
135130
protected static boolean oldClusterHasFeature(String featureId) {
136131
assert oldClusterTestFeatureService != null;
137132
return oldClusterTestFeatureService.clusterHasFeature(featureId);
@@ -146,8 +141,12 @@ protected static IndexVersion getOldClusterIndexVersion() {
146141
return oldIndexVersion;
147142
}
148143

149-
protected static Version getOldClusterTestVersion() {
150-
return Version.fromString(OLD_CLUSTER_VERSION);
144+
/**
145+
* The version of the "old" (initial) cluster. It is an opaque string, do not even think about parsing it for version
146+
* comparison. Use (test) cluster features and {@link ParameterizedRollingUpgradeTestCase#oldClusterHasFeature} instead.
147+
*/
148+
protected static String getOldClusterVersion() {
149+
return System.getProperty("tests.bwc.main.version", OLD_CLUSTER_VERSION);
151150
}
152151

153152
protected static boolean isOldClusterVersion(String nodeVersion) {

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public SourceModeRollingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
2727
}
2828

2929
public void testConfigureStoredSourceBeforeIndexCreationLegacy() throws IOException {
30-
assumeTrue("testing deprecation warnings and deprecation migrations", getOldClusterTestVersion().before("9.0.0"));
30+
assumeFalse("testing deprecation warnings and deprecation migrations", oldClusterHasFeature("gte_v9.0.0"));
3131
String templateName = "logs@custom";
3232
if (isOldCluster()) {
3333
var storedSourceMapping = """
@@ -56,7 +56,7 @@ public void testConfigureStoredSourceBeforeIndexCreationLegacy() throws IOExcept
5656
}
5757

5858
public void testConfigureStoredSourceWhenIndexIsCreatedLegacy() throws IOException {
59-
assumeTrue("testing deprecation warnings and deprecation migrations", getOldClusterTestVersion().before("9.0.0"));
59+
assumeFalse("testing deprecation warnings and deprecation migrations", oldClusterHasFeature("gte_v9.0.0"));
6060
String templateName = "logs@custom";
6161
if (isOldCluster()) {
6262
var storedSourceMapping = """

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/VectorSearchIT.java

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ public VectorSearchIT(@Name("upgradedNodes") int upgradedNodes) {
3737
private static final String BBQ_INDEX_NAME = "bbq_vector_index";
3838
private static final String FLAT_QUANTIZED_INDEX_NAME = "flat_quantized_vector_index";
3939
private static final String FLAT_BBQ_INDEX_NAME = "flat_bbq_vector_index";
40-
private static final String FLOAT_VECTOR_SEARCH_VERSION = "8.4.0";
41-
private static final String BYTE_VECTOR_SEARCH_VERSION = "8.6.0";
42-
private static final String QUANTIZED_VECTOR_SEARCH_VERSION = "8.12.1";
43-
private static final String FLAT_QUANTIZED_VECTOR_SEARCH_VERSION = "8.13.0";
44-
private static final String BBQ_VECTOR_SEARCH_VERSION = "8.18.0";
40+
41+
// TODO: replace these with proper test features
42+
private static final String FLOAT_VECTOR_SEARCH_TEST_FEATURE = "gte_v8.4.0";
43+
private static final String BYTE_VECTOR_SEARCH_TEST_FEATURE = "gte_v8.6.0";
44+
private static final String QUANTIZED_VECTOR_SEARCH_TEST_FEATURE = "gte_v8.12.1";
45+
private static final String FLAT_QUANTIZED_VECTOR_SEARCH_TEST_FEATURE = "gte_v8.13.0";
46+
private static final String BBQ_VECTOR_SEARCH_TEST_FEATURE = "gte_v.18.0";
4547

4648
public void testScriptByteVectorSearch() throws Exception {
47-
assumeTrue("byte vector search is not supported on this version", getOldClusterTestVersion().onOrAfter(BYTE_VECTOR_SEARCH_VERSION));
49+
assumeTrue("byte vector search is not supported on this version", oldClusterHasFeature(BYTE_VECTOR_SEARCH_TEST_FEATURE));
4850
if (isOldCluster()) {
4951
// create index and index 10 random floating point vectors
5052
String mapping = """
@@ -91,10 +93,7 @@ public void testScriptByteVectorSearch() throws Exception {
9193
}
9294

9395
public void testScriptVectorSearch() throws Exception {
94-
assumeTrue(
95-
"Float vector search is not supported on this version",
96-
getOldClusterTestVersion().onOrAfter(FLOAT_VECTOR_SEARCH_VERSION)
97-
);
96+
assumeTrue("Float vector search is not supported on this version", oldClusterHasFeature(FLOAT_VECTOR_SEARCH_TEST_FEATURE));
9897
if (isOldCluster()) {
9998
// create index and index 10 random floating point vectors
10099
String mapping = """
@@ -140,10 +139,7 @@ public void testScriptVectorSearch() throws Exception {
140139
}
141140

142141
public void testFloatVectorSearch() throws Exception {
143-
assumeTrue(
144-
"Float vector search is not supported on this version",
145-
getOldClusterTestVersion().onOrAfter(FLOAT_VECTOR_SEARCH_VERSION)
146-
);
142+
assumeTrue("Float vector search is not supported on this version", oldClusterHasFeature(FLOAT_VECTOR_SEARCH_TEST_FEATURE));
147143
if (isOldCluster()) {
148144
String mapping = """
149145
{
@@ -215,7 +211,7 @@ public void testFloatVectorSearch() throws Exception {
215211
}
216212

217213
public void testByteVectorSearch() throws Exception {
218-
assumeTrue("Byte vector search is not supported on this version", getOldClusterTestVersion().onOrAfter(BYTE_VECTOR_SEARCH_VERSION));
214+
assumeTrue("Byte vector search is not supported on this version", oldClusterHasFeature(BYTE_VECTOR_SEARCH_TEST_FEATURE));
219215
if (isOldCluster()) {
220216
String mapping = """
221217
{
@@ -288,10 +284,7 @@ public void testByteVectorSearch() throws Exception {
288284
}
289285

290286
public void testQuantizedVectorSearch() throws Exception {
291-
assumeTrue(
292-
"Quantized vector search is not supported on this version",
293-
getOldClusterTestVersion().onOrAfter(QUANTIZED_VECTOR_SEARCH_VERSION)
294-
);
287+
assumeTrue("Quantized vector search is not supported on this version", oldClusterHasFeature(QUANTIZED_VECTOR_SEARCH_TEST_FEATURE));
295288
if (isOldCluster()) {
296289
String mapping = """
297290
{
@@ -364,7 +357,7 @@ public void testQuantizedVectorSearch() throws Exception {
364357
public void testFlatQuantizedVectorSearch() throws Exception {
365358
assumeTrue(
366359
"Quantized vector search is not supported on this version",
367-
getOldClusterTestVersion().onOrAfter(FLAT_QUANTIZED_VECTOR_SEARCH_VERSION)
360+
oldClusterHasFeature(FLAT_QUANTIZED_VECTOR_SEARCH_TEST_FEATURE)
368361
);
369362
if (isOldCluster()) {
370363
String mapping = """
@@ -434,10 +427,7 @@ public void testFlatQuantizedVectorSearch() throws Exception {
434427
}
435428

436429
public void testBBQVectorSearch() throws Exception {
437-
assumeTrue(
438-
"Quantized vector search is not supported on this version",
439-
getOldClusterTestVersion().onOrAfter(BBQ_VECTOR_SEARCH_VERSION)
440-
);
430+
assumeTrue("Quantized vector search is not supported on this version", oldClusterHasFeature(BBQ_VECTOR_SEARCH_TEST_FEATURE));
441431
if (isOldCluster()) {
442432
String mapping = """
443433
{
@@ -518,10 +508,7 @@ public void testBBQVectorSearch() throws Exception {
518508
}
519509

520510
public void testFlatBBQVectorSearch() throws Exception {
521-
assumeTrue(
522-
"Quantized vector search is not supported on this version",
523-
getOldClusterTestVersion().onOrAfter(BBQ_VECTOR_SEARCH_VERSION)
524-
);
511+
assumeTrue("Quantized vector search is not supported on this version", oldClusterHasFeature(BBQ_VECTOR_SEARCH_TEST_FEATURE));
525512
if (isOldCluster()) {
526513
String mapping = """
527514
{

x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/AzureOpenAiServiceUpgradeIT.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
public class AzureOpenAiServiceUpgradeIT extends InferenceUpgradeTestCase {
2828

29-
private static final String OPEN_AI_AZURE_EMBEDDINGS_ADDED = "8.14.0";
29+
private static final String OPEN_AI_AZURE_EMBEDDINGS_ADDED_FEATURE = "gte_v8.14.0";
3030

3131
private static MockWebServer openAiEmbeddingsServer;
3232

@@ -48,10 +48,9 @@ public static void shutdown() {
4848
@SuppressWarnings("unchecked")
4949
@AwaitsFix(bugUrl = "Cannot set the URL in the tests")
5050
public void testOpenAiEmbeddings() throws IOException {
51-
var openAiEmbeddingsSupported = getOldClusterTestVersion().onOrAfter(OPEN_AI_AZURE_EMBEDDINGS_ADDED);
52-
// `gte_v` indicates that the cluster version is Greater Than or Equal to MODELS_RENAMED_TO_ENDPOINTS
53-
String oldClusterEndpointIdentifier = oldClusterHasFeature("gte_v" + MODELS_RENAMED_TO_ENDPOINTS) ? "endpoints" : "models";
54-
assumeTrue("Azure OpenAI embedding service added in " + OPEN_AI_AZURE_EMBEDDINGS_ADDED, openAiEmbeddingsSupported);
51+
var openAiEmbeddingsSupported = oldClusterHasFeature(OPEN_AI_AZURE_EMBEDDINGS_ADDED_FEATURE);
52+
String oldClusterEndpointIdentifier = oldClusterHasFeature(MODELS_RENAMED_TO_ENDPOINTS_FEATURE) ? "endpoints" : "models";
53+
assumeTrue("Azure OpenAI embedding service supported", openAiEmbeddingsSupported);
5554

5655
final String oldClusterId = "old-cluster-embeddings";
5756
final String upgradedClusterId = "upgraded-cluster-embeddings";

0 commit comments

Comments
 (0)