From 2d8faa875c25c3173caac70596103af94a050dc6 Mon Sep 17 00:00:00 2001
From: Fang Xing <155562079+fang-xing-esql@users.noreply.github.com>
Date: Wed, 8 May 2024 10:31:57 -0400
Subject: [PATCH 001/119] [ES|QL] Create MockBigArrays with CircuitBreaker in
AbstractFunctionTestCases (#108195)
* create mockbigarrays with circuit breaker
---
.../compute/data/BytesRefBlockBuilder.java | 4 ---
.../compute/data/X-BlockBuilder.java.st | 4 ---
.../function/AbstractFunctionTestCase.java | 25 ++++++++++++++-----
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java
index 49075789ed4a..6232cbdd2717 100644
--- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java
+++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java
@@ -21,10 +21,6 @@ final class BytesRefBlockBuilder extends AbstractBlockBuilder implements BytesRe
private BytesRefArray values;
- BytesRefBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
- this(estimatedSize, BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
- }
-
BytesRefBlockBuilder(int estimatedSize, BigArrays bigArrays, BlockFactory blockFactory) {
super(blockFactory);
values = new BytesRefArray(Math.max(estimatedSize, 2), bigArrays);
diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st
index 0d3d2293a1bb..8397a0f5274f 100644
--- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st
+++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st
@@ -31,10 +31,6 @@ final class $Type$BlockBuilder extends AbstractBlockBuilder implements $Type$Blo
$if(BytesRef)$
private BytesRefArray values;
- BytesRefBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
- this(estimatedSize, BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
- }
-
BytesRefBlockBuilder(int estimatedSize, BigArrays bigArrays, BlockFactory blockFactory) {
super(blockFactory);
values = new BytesRefArray(Math.max(estimatedSize, 2), bigArrays);
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java
index 1a410c518e9b..1fd7cfe36806 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java
@@ -307,7 +307,13 @@ private Object toJavaObjectUnsignedLongAware(Block block, int position) {
*
*/
public final void testEvaluateBlockWithoutNulls() {
- testEvaluateBlock(driverContext().blockFactory(), driverContext(), false);
+ assumeTrue("no warning is expected", testCase.getExpectedWarnings() == null);
+ try {
+ testEvaluateBlock(driverContext().blockFactory(), driverContext(), false);
+ } catch (CircuitBreakingException ex) {
+ assertThat(ex.getMessage(), equalTo(MockBigArrays.ERROR_MESSAGE));
+ assertFalse("Test data is too large to fit in the memory", true);
+ }
}
/**
@@ -315,7 +321,13 @@ public final void testEvaluateBlockWithoutNulls() {
* some null values inserted between.
*/
public final void testEvaluateBlockWithNulls() {
- testEvaluateBlock(driverContext().blockFactory(), driverContext(), true);
+ assumeTrue("no warning is expected", testCase.getExpectedWarnings() == null);
+ try {
+ testEvaluateBlock(driverContext().blockFactory(), driverContext(), true);
+ } catch (CircuitBreakingException ex) {
+ assertThat(ex.getMessage(), equalTo(MockBigArrays.ERROR_MESSAGE));
+ assertFalse("Test data is too large to fit in the memory", true);
+ }
}
/**
@@ -1543,17 +1555,18 @@ private static void writeToTempDir(String subdir, String str, String extension)
private final List breakers = Collections.synchronizedList(new ArrayList<>());
protected final DriverContext driverContext() {
- MockBigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, ByteSizeValue.ofGb(1));
+ BigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, ByteSizeValue.ofMb(256)).withCircuitBreaking();
CircuitBreaker breaker = bigArrays.breakerService().getBreaker(CircuitBreaker.REQUEST);
breakers.add(breaker);
- return new DriverContext(bigArrays.withCircuitBreaking(), new BlockFactory(breaker, bigArrays));
+ return new DriverContext(bigArrays, new BlockFactory(breaker, bigArrays));
}
protected final DriverContext crankyContext() {
- BigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, new CrankyCircuitBreakerService());
+ BigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, new CrankyCircuitBreakerService())
+ .withCircuitBreaking();
CircuitBreaker breaker = bigArrays.breakerService().getBreaker(CircuitBreaker.REQUEST);
breakers.add(breaker);
- return new DriverContext(bigArrays.withCircuitBreaking(), new BlockFactory(breaker, bigArrays));
+ return new DriverContext(bigArrays, new BlockFactory(breaker, bigArrays));
}
@After
From e2c19f2ac8127f12eba7d045064cb1d580d8e64e Mon Sep 17 00:00:00 2001
From: Carlos Delgado <6339205+carlosdelest@users.noreply.github.com>
Date: Wed, 8 May 2024 17:24:25 +0200
Subject: [PATCH 002/119] Fix semantic text for non snapshot tests (#108372)
---
x-pack/plugin/inference/build.gradle | 8 ++++++++
x-pack/plugin/ml/build.gradle | 7 -------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/x-pack/plugin/inference/build.gradle b/x-pack/plugin/inference/build.gradle
index 0aef8601ffcc..3e2171d0654d 100644
--- a/x-pack/plugin/inference/build.gradle
+++ b/x-pack/plugin/inference/build.gradle
@@ -4,6 +4,8 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
+import org.elasticsearch.gradle.internal.info.BuildParams
+
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
@@ -36,6 +38,12 @@ dependencies {
api "com.ibm.icu:icu4j:${versions.icu4j}"
}
+if (BuildParams.isSnapshotBuild() == false) {
+ tasks.named("test").configure {
+ systemProperty 'es.semantic_text_feature_flag_enabled', 'true'
+ }
+}
+
tasks.named('yamlRestTest') {
usesDefaultDistribution()
}
diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle
index 26f5ea053771..f42dcc6179d0 100644
--- a/x-pack/plugin/ml/build.gradle
+++ b/x-pack/plugin/ml/build.gradle
@@ -1,6 +1,5 @@
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.internal.dra.DraResolvePlugin
-import org.elasticsearch.gradle.internal.info.BuildParams
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
@@ -115,12 +114,6 @@ artifacts {
archives tasks.named("jar")
}
-if (BuildParams.isSnapshotBuild() == false) {
- tasks.named("test").configure {
- systemProperty 'es.semantic_text_feature_flag_enabled', 'true'
- }
-}
-
tasks.register("extractNativeLicenses", Copy) {
dependsOn configurations.nativeBundle
into "${buildDir}/extractedNativeLicenses"
From 2f94aeea0c8dfe1f448381171f80fa6ffbbcfaa5 Mon Sep 17 00:00:00 2001
From: Mark Vieira
Date: Wed, 8 May 2024 08:25:44 -0700
Subject: [PATCH 003/119] Refactor rolling upgrade tests to make it easier to
customize (#108393)
---
.../AbstractRollingUpgradeTestCase.java | 54 +++++++++++++++++++
.../upgrades/ClusterFeatureMigrationIT.java | 2 +-
.../upgrades/DesiredNodesUpgradeIT.java | 2 +-
.../elasticsearch/upgrades/DownsampleIT.java | 2 +-
.../upgrades/FeatureUpgradeIT.java | 2 +-
.../elasticsearch/upgrades/FieldCapsIT.java | 2 +-
.../upgrades/HealthNodeUpgradeIT.java | 2 +-
.../IgnoredMetaFieldRollingUpgradeIT.java | 2 +-
.../elasticsearch/upgrades/IndexingIT.java | 2 +-
.../ParameterizedRollingUpgradeTestCase.java | 49 ++++-------------
.../upgrades/SnapshotBasedRecoveryIT.java | 2 +-
.../upgrades/SystemIndicesUpgradeIT.java | 2 +-
.../org/elasticsearch/upgrades/TsdbIT.java | 2 +-
.../UpgradeWithOldIndexSettingsIT.java | 2 +-
.../upgrades/VectorSearchIT.java | 2 +-
.../org/elasticsearch/upgrades/XPackIT.java | 2 +-
.../application/InferenceUpgradeTestCase.java | 4 +-
17 files changed, 80 insertions(+), 55 deletions(-)
create mode 100644 qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java
new file mode 100644
index 000000000000..4837afbf6ccd
--- /dev/null
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.upgrades;
+
+import com.carrotsearch.randomizedtesting.annotations.Name;
+
+import org.elasticsearch.core.SuppressForbidden;
+import org.elasticsearch.test.cluster.ElasticsearchCluster;
+import org.elasticsearch.test.cluster.FeatureFlag;
+import org.elasticsearch.test.cluster.local.distribution.DistributionType;
+import org.junit.ClassRule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestRule;
+
+import java.util.function.Supplier;
+
+public abstract class AbstractRollingUpgradeTestCase extends ParameterizedRollingUpgradeTestCase {
+
+ private static final TemporaryFolder repoDirectory = new TemporaryFolder();
+
+ private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
+ .distribution(DistributionType.DEFAULT)
+ .version(getOldClusterTestVersion())
+ .nodes(NODE_NUM)
+ .setting("path.repo", new Supplier<>() {
+ @Override
+ @SuppressForbidden(reason = "TemporaryFolder only has io.File methods, not nio.File")
+ public String get() {
+ return repoDirectory.getRoot().getPath();
+ }
+ })
+ .setting("xpack.security.enabled", "false")
+ .feature(FeatureFlag.TIME_SERIES_MODE)
+ .build();
+
+ @ClassRule
+ public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
+
+ protected AbstractRollingUpgradeTestCase(@Name("upgradedNodes") int upgradedNodes) {
+ super(upgradedNodes);
+ }
+
+ @Override
+ protected ElasticsearchCluster getUpgradeCluster() {
+ return cluster;
+ }
+}
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java
index 0487b282179a..73abb634dfd7 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java
@@ -24,7 +24,7 @@
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasSize;
-public class ClusterFeatureMigrationIT extends ParameterizedRollingUpgradeTestCase {
+public class ClusterFeatureMigrationIT extends AbstractRollingUpgradeTestCase {
@Before
public void checkMigrationVersion() {
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
index 73d91ac41fcb..c7f99b3525f7 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
@@ -33,7 +33,7 @@
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
-public class DesiredNodesUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class DesiredNodesUpgradeIT extends AbstractRollingUpgradeTestCase {
private final int desiredNodesVersion;
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java
index 757f793ac4c4..488cd966ed65 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java
@@ -25,7 +25,7 @@
import static org.hamcrest.Matchers.equalTo;
-public class DownsampleIT extends ParameterizedRollingUpgradeTestCase {
+public class DownsampleIT extends AbstractRollingUpgradeTestCase {
private static final String FIXED_INTERVAL = "1h";
private String index;
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java
index 4fe45c05b157..fc77eef0ae8b 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java
@@ -23,7 +23,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
-public class FeatureUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class FeatureUpgradeIT extends AbstractRollingUpgradeTestCase {
public FeatureUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java
index 860cd2c0e861..306447d8cc2c 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java
@@ -40,7 +40,7 @@
* the co-ordinating node if older nodes were included in the system
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/103473")
-public class FieldCapsIT extends ParameterizedRollingUpgradeTestCase {
+public class FieldCapsIT extends AbstractRollingUpgradeTestCase {
public FieldCapsIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java
index 0f210ee4b245..6647cb413c9f 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java
@@ -20,7 +20,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
-public class HealthNodeUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class HealthNodeUpgradeIT extends AbstractRollingUpgradeTestCase {
public HealthNodeUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java
index 874fac615b9b..1477e2b63cf0 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java
@@ -26,7 +26,7 @@
import java.util.Locale;
import java.util.Map;
-public class IgnoredMetaFieldRollingUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class IgnoredMetaFieldRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
private static final String TERMS_AGG_QUERY = Strings.format("""
{
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java
index 82485130f05c..157e2293b69a 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java
@@ -51,7 +51,7 @@
* xpack rolling restart tests. We should work on a way to remove this
* duplication but for now we have no real way to share code.
*/
-public class IndexingIT extends ParameterizedRollingUpgradeTestCase {
+public class IndexingIT extends AbstractRollingUpgradeTestCase {
public IndexingIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java
index 63ed54d05adf..d5f645c387d6 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java
@@ -14,74 +14,45 @@
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
-import org.elasticsearch.test.cluster.FeatureFlag;
-import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.test.rest.TestFeatureService;
import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestRule;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.function.Supplier;
import java.util.stream.IntStream;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase {
+ protected static final int NODE_NUM = 3;
private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version");
-
- private static final TemporaryFolder repoDirectory = new TemporaryFolder();
-
- private static final int NODE_NUM = 3;
-
- private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
- .distribution(DistributionType.DEFAULT)
- .version(getOldClusterTestVersion())
- .nodes(NODE_NUM)
- .setting("path.repo", new Supplier<>() {
- @Override
- @SuppressForbidden(reason = "TemporaryFolder only has io.File methods, not nio.File")
- public String get() {
- return repoDirectory.getRoot().getPath();
- }
- })
- .setting("xpack.security.enabled", "false")
- .feature(FeatureFlag.TIME_SERIES_MODE)
- .build();
-
- @ClassRule
- public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
-
- @ParametersFactory(shuffle = false)
- public static Iterable