|
@@ -7,6 +7,8 @@
|
|
*/
|
|
*/
|
|
package org.elasticsearch.upgrades;
|
|
package org.elasticsearch.upgrades;
|
|
|
|
|
|
|
|
+import com.carrotsearch.randomizedtesting.annotations.Name;
|
|
|
|
+
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.elasticsearch.Version;
|
|
import org.elasticsearch.Version;
|
|
import org.elasticsearch.client.Request;
|
|
import org.elasticsearch.client.Request;
|
|
@@ -15,7 +17,6 @@ import org.elasticsearch.client.ResponseException;
|
|
import org.elasticsearch.common.Strings;
|
|
import org.elasticsearch.common.Strings;
|
|
import org.elasticsearch.common.time.DateUtils;
|
|
import org.elasticsearch.common.time.DateUtils;
|
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
|
-import org.elasticsearch.core.Booleans;
|
|
|
|
import org.elasticsearch.index.mapper.DateFieldMapper;
|
|
import org.elasticsearch.index.mapper.DateFieldMapper;
|
|
import org.elasticsearch.test.ListMatcher;
|
|
import org.elasticsearch.test.ListMatcher;
|
|
import org.elasticsearch.xcontent.XContentBuilder;
|
|
import org.elasticsearch.xcontent.XContentBuilder;
|
|
@@ -40,39 +41,36 @@ import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Basic test that indexed documents survive the rolling restart. See
|
|
* Basic test that indexed documents survive the rolling restart. See
|
|
- * {@link RecoveryIT} for much more in depth testing of the mechanism
|
|
|
|
|
|
+ * {@code RecoveryIT} for much more in depth testing of the mechanism
|
|
* by which they survive.
|
|
* by which they survive.
|
|
* <p>
|
|
* <p>
|
|
* This test is an almost exact copy of <code>IndexingIT</code> in the
|
|
* This test is an almost exact copy of <code>IndexingIT</code> in the
|
|
* xpack rolling restart tests. We should work on a way to remove this
|
|
* 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.
|
|
* duplication but for now we have no real way to share code.
|
|
*/
|
|
*/
|
|
-public class IndexingIT extends AbstractRollingTestCase {
|
|
|
|
|
|
+public class IndexingIT extends ParameterizedRollingUpgradeTestCase {
|
|
|
|
+
|
|
|
|
+ public IndexingIT(@Name("upgradedNodes") int upgradedNodes) {
|
|
|
|
+ super(upgradedNodes);
|
|
|
|
+ }
|
|
|
|
|
|
public void testIndexing() throws IOException {
|
|
public void testIndexing() throws IOException {
|
|
- switch (CLUSTER_TYPE) {
|
|
|
|
- case OLD:
|
|
|
|
- break;
|
|
|
|
- case MIXED:
|
|
|
|
- Request waitForYellow = new Request("GET", "/_cluster/health");
|
|
|
|
- waitForYellow.addParameter("wait_for_nodes", "3");
|
|
|
|
- waitForYellow.addParameter("wait_for_status", "yellow");
|
|
|
|
- client().performRequest(waitForYellow);
|
|
|
|
- break;
|
|
|
|
- case UPGRADED:
|
|
|
|
- Request waitForGreen = new Request("GET", "/_cluster/health/test_index,index_with_replicas,empty_index");
|
|
|
|
- waitForGreen.addParameter("wait_for_nodes", "3");
|
|
|
|
- waitForGreen.addParameter("wait_for_status", "green");
|
|
|
|
- // wait for long enough that we give delayed unassigned shards to stop being delayed
|
|
|
|
- waitForGreen.addParameter("timeout", "70s");
|
|
|
|
- waitForGreen.addParameter("level", "shards");
|
|
|
|
- client().performRequest(waitForGreen);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]");
|
|
|
|
|
|
+ if (isMixedCluster()) {
|
|
|
|
+ Request waitForYellow = new Request("GET", "/_cluster/health");
|
|
|
|
+ waitForYellow.addParameter("wait_for_nodes", "3");
|
|
|
|
+ waitForYellow.addParameter("wait_for_status", "yellow");
|
|
|
|
+ client().performRequest(waitForYellow);
|
|
|
|
+ } else if (isUpgradedCluster()) {
|
|
|
|
+ Request waitForGreen = new Request("GET", "/_cluster/health/test_index,index_with_replicas,empty_index");
|
|
|
|
+ waitForGreen.addParameter("wait_for_nodes", "3");
|
|
|
|
+ waitForGreen.addParameter("wait_for_status", "green");
|
|
|
|
+ // wait for long enough that we give delayed unassigned shards to stop being delayed
|
|
|
|
+ waitForGreen.addParameter("timeout", "70s");
|
|
|
|
+ waitForGreen.addParameter("level", "shards");
|
|
|
|
+ client().performRequest(waitForGreen);
|
|
}
|
|
}
|
|
|
|
|
|
- if (CLUSTER_TYPE == ClusterType.OLD) {
|
|
|
|
|
|
+ if (isOldCluster()) {
|
|
Request createTestIndex = new Request("PUT", "/test_index");
|
|
Request createTestIndex = new Request("PUT", "/test_index");
|
|
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
|
|
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
|
|
useIgnoreMultipleMatchingTemplatesWarningsHandler(createTestIndex);
|
|
useIgnoreMultipleMatchingTemplatesWarningsHandler(createTestIndex);
|
|
@@ -95,30 +93,20 @@ public class IndexingIT extends AbstractRollingTestCase {
|
|
}
|
|
}
|
|
|
|
|
|
int expectedCount;
|
|
int expectedCount;
|
|
- switch (CLUSTER_TYPE) {
|
|
|
|
- case OLD:
|
|
|
|
- expectedCount = 5;
|
|
|
|
- break;
|
|
|
|
- case MIXED:
|
|
|
|
- if (Booleans.parseBoolean(System.getProperty("tests.first_round"))) {
|
|
|
|
- expectedCount = 5;
|
|
|
|
- } else {
|
|
|
|
- expectedCount = 10;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case UPGRADED:
|
|
|
|
- expectedCount = 15;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]");
|
|
|
|
|
|
+ if (isOldCluster() || isFirstMixedCluster()) {
|
|
|
|
+ expectedCount = 5;
|
|
|
|
+ } else if (isMixedCluster()) {
|
|
|
|
+ expectedCount = 10;
|
|
|
|
+ } else {
|
|
|
|
+ expectedCount = 15;
|
|
}
|
|
}
|
|
|
|
|
|
assertCount("test_index", expectedCount);
|
|
assertCount("test_index", expectedCount);
|
|
assertCount("index_with_replicas", 5);
|
|
assertCount("index_with_replicas", 5);
|
|
assertCount("empty_index", 0);
|
|
assertCount("empty_index", 0);
|
|
|
|
|
|
- if (CLUSTER_TYPE != ClusterType.OLD) {
|
|
|
|
- bulk("test_index", "_" + CLUSTER_TYPE, 5);
|
|
|
|
|
|
+ if (isOldCluster() == false) {
|
|
|
|
+ bulk("test_index", "_" + (isMixedCluster() ? "MIXED" : "UPGRADED"), 5);
|
|
Request toBeDeleted = new Request("PUT", "/test_index/_doc/to_be_deleted");
|
|
Request toBeDeleted = new Request("PUT", "/test_index/_doc/to_be_deleted");
|
|
toBeDeleted.addParameter("refresh", "true");
|
|
toBeDeleted.addParameter("refresh", "true");
|
|
toBeDeleted.setJsonEntity("{\"f1\": \"delete-me\"}");
|
|
toBeDeleted.setJsonEntity("{\"f1\": \"delete-me\"}");
|
|
@@ -143,82 +131,76 @@ public class IndexingIT extends AbstractRollingTestCase {
|
|
bulk.addParameter("refresh", "true");
|
|
bulk.addParameter("refresh", "true");
|
|
bulk.setJsonEntity(b);
|
|
bulk.setJsonEntity(b);
|
|
|
|
|
|
- switch (CLUSTER_TYPE) {
|
|
|
|
- case OLD -> {
|
|
|
|
- Request createTestIndex = new Request("PUT", "/" + indexName);
|
|
|
|
- createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
|
|
|
|
- client().performRequest(createTestIndex);
|
|
|
|
- }
|
|
|
|
- case MIXED -> {
|
|
|
|
- Request waitForGreen = new Request("GET", "/_cluster/health");
|
|
|
|
- waitForGreen.addParameter("wait_for_nodes", "3");
|
|
|
|
- client().performRequest(waitForGreen);
|
|
|
|
- Version minNodeVersion = minNodeVersion();
|
|
|
|
- if (minNodeVersion.before(Version.V_7_5_0)) {
|
|
|
|
- ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(bulk));
|
|
|
|
- assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
|
|
|
|
- assertThat(
|
|
|
|
- e.getMessage(),
|
|
|
|
- // if request goes to 7.5+ node
|
|
|
|
- either(containsString("optype create not supported for indexing requests without explicit id until"))
|
|
|
|
- // if request goes to < 7.5 node
|
|
|
|
- .or(containsString("an id must be provided if version type or value are set"))
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- client().performRequest(bulk);
|
|
|
|
- }
|
|
|
|
|
|
+ if (isOldCluster()) {
|
|
|
|
+ Request createTestIndex = new Request("PUT", "/" + indexName);
|
|
|
|
+ createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
|
|
|
|
+ client().performRequest(createTestIndex);
|
|
|
|
+ } else if (isMixedCluster()) {
|
|
|
|
+ Request waitForGreen = new Request("GET", "/_cluster/health");
|
|
|
|
+ waitForGreen.addParameter("wait_for_nodes", "3");
|
|
|
|
+ client().performRequest(waitForGreen);
|
|
|
|
+ Version minNodeVersion = minNodeVersion();
|
|
|
|
+ if (minNodeVersion.before(Version.V_7_5_0)) {
|
|
|
|
+ ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(bulk));
|
|
|
|
+ assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
|
|
|
|
+ assertThat(
|
|
|
|
+ e.getMessage(),
|
|
|
|
+ // if request goes to 7.5+ node
|
|
|
|
+ either(containsString("optype create not supported for indexing requests without explicit id until"))
|
|
|
|
+ // if request goes to < 7.5 node
|
|
|
|
+ .or(containsString("an id must be provided if version type or value are set"))
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ client().performRequest(bulk);
|
|
}
|
|
}
|
|
- case UPGRADED -> client().performRequest(bulk);
|
|
|
|
- default -> throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]");
|
|
|
|
|
|
+ } else if (isUpgradedCluster()) {
|
|
|
|
+ client().performRequest(bulk);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void testDateNanosFormatUpgrade() throws IOException {
|
|
public void testDateNanosFormatUpgrade() throws IOException {
|
|
final String indexName = "test_date_nanos";
|
|
final String indexName = "test_date_nanos";
|
|
- switch (CLUSTER_TYPE) {
|
|
|
|
- case OLD -> {
|
|
|
|
- Request createIndex = new Request("PUT", "/" + indexName);
|
|
|
|
- XContentBuilder mappings = XContentBuilder.builder(XContentType.JSON.xContent())
|
|
|
|
- .startObject()
|
|
|
|
- .startObject("mappings")
|
|
|
|
- .startObject("properties")
|
|
|
|
- .startObject("date")
|
|
|
|
- .field("type", "date")
|
|
|
|
- .endObject()
|
|
|
|
- .startObject("date_nanos")
|
|
|
|
- .field("type", "date_nanos")
|
|
|
|
- .endObject()
|
|
|
|
- .endObject()
|
|
|
|
- .endObject()
|
|
|
|
- .endObject();
|
|
|
|
- createIndex.setJsonEntity(Strings.toString(mappings));
|
|
|
|
- client().performRequest(createIndex);
|
|
|
|
- Request index = new Request("POST", "/" + indexName + "/_doc/");
|
|
|
|
- XContentBuilder doc = XContentBuilder.builder(XContentType.JSON.xContent())
|
|
|
|
- .startObject()
|
|
|
|
- .field("date", "2015-01-01T12:10:30.123456789Z")
|
|
|
|
- .field("date_nanos", "2015-01-01T12:10:30.123456789Z")
|
|
|
|
- .endObject();
|
|
|
|
- index.addParameter("refresh", "true");
|
|
|
|
- index.setJsonEntity(Strings.toString(doc));
|
|
|
|
- client().performRequest(index);
|
|
|
|
- }
|
|
|
|
- case UPGRADED -> {
|
|
|
|
- Request search = new Request("POST", "/" + indexName + "/_search");
|
|
|
|
- XContentBuilder query = XContentBuilder.builder(XContentType.JSON.xContent())
|
|
|
|
- .startObject()
|
|
|
|
- .array("fields", new String[] { "date", "date_nanos" })
|
|
|
|
- .endObject();
|
|
|
|
- search.setJsonEntity(Strings.toString(query));
|
|
|
|
- Map<String, Object> response = entityAsMap(client().performRequest(search));
|
|
|
|
- Map<?, ?> bestHit = (Map<?, ?>) ((List<?>) (XContentMapValues.extractValue("hits.hits", response))).get(0);
|
|
|
|
- List<?> date = (List<?>) XContentMapValues.extractValue("fields.date", bestHit);
|
|
|
|
- assertThat(date.size(), equalTo(1));
|
|
|
|
- assertThat(date.get(0), equalTo("2015-01-01T12:10:30.123Z"));
|
|
|
|
- List<?> dateNanos = (List<?>) XContentMapValues.extractValue("fields.date_nanos", bestHit);
|
|
|
|
- assertThat(dateNanos.size(), equalTo(1));
|
|
|
|
- assertThat(dateNanos.get(0), equalTo("2015-01-01T12:10:30.123456789Z"));
|
|
|
|
- }
|
|
|
|
|
|
+ if (isOldCluster()) {
|
|
|
|
+ Request createIndex = new Request("PUT", "/" + indexName);
|
|
|
|
+ XContentBuilder mappings = XContentBuilder.builder(XContentType.JSON.xContent())
|
|
|
|
+ .startObject()
|
|
|
|
+ .startObject("mappings")
|
|
|
|
+ .startObject("properties")
|
|
|
|
+ .startObject("date")
|
|
|
|
+ .field("type", "date")
|
|
|
|
+ .endObject()
|
|
|
|
+ .startObject("date_nanos")
|
|
|
|
+ .field("type", "date_nanos")
|
|
|
|
+ .endObject()
|
|
|
|
+ .endObject()
|
|
|
|
+ .endObject()
|
|
|
|
+ .endObject();
|
|
|
|
+ createIndex.setJsonEntity(Strings.toString(mappings));
|
|
|
|
+ client().performRequest(createIndex);
|
|
|
|
+ Request index = new Request("POST", "/" + indexName + "/_doc/");
|
|
|
|
+ XContentBuilder doc = XContentBuilder.builder(XContentType.JSON.xContent())
|
|
|
|
+ .startObject()
|
|
|
|
+ .field("date", "2015-01-01T12:10:30.123456789Z")
|
|
|
|
+ .field("date_nanos", "2015-01-01T12:10:30.123456789Z")
|
|
|
|
+ .endObject();
|
|
|
|
+ index.addParameter("refresh", "true");
|
|
|
|
+ index.setJsonEntity(Strings.toString(doc));
|
|
|
|
+ client().performRequest(index);
|
|
|
|
+ } else if (isUpgradedCluster()) {
|
|
|
|
+ Request search = new Request("POST", "/" + indexName + "/_search");
|
|
|
|
+ XContentBuilder query = XContentBuilder.builder(XContentType.JSON.xContent())
|
|
|
|
+ .startObject()
|
|
|
|
+ .array("fields", new String[] { "date", "date_nanos" })
|
|
|
|
+ .endObject();
|
|
|
|
+ search.setJsonEntity(Strings.toString(query));
|
|
|
|
+ Map<String, Object> response = entityAsMap(client().performRequest(search));
|
|
|
|
+ Map<?, ?> bestHit = (Map<?, ?>) ((List<?>) (XContentMapValues.extractValue("hits.hits", response))).get(0);
|
|
|
|
+ List<?> date = (List<?>) XContentMapValues.extractValue("fields.date", bestHit);
|
|
|
|
+ assertThat(date.size(), equalTo(1));
|
|
|
|
+ assertThat(date.get(0), equalTo("2015-01-01T12:10:30.123Z"));
|
|
|
|
+ List<?> dateNanos = (List<?>) XContentMapValues.extractValue("fields.date_nanos", bestHit);
|
|
|
|
+ assertThat(dateNanos.size(), equalTo(1));
|
|
|
|
+ assertThat(dateNanos.get(0), equalTo("2015-01-01T12:10:30.123456789Z"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -247,51 +229,45 @@ public class IndexingIT extends AbstractRollingTestCase {
|
|
}
|
|
}
|
|
|
|
|
|
public void testTsdb() throws IOException {
|
|
public void testTsdb() throws IOException {
|
|
- assumeTrue("indexing time series indices changed in 8.2.0", UPGRADE_FROM_VERSION.onOrAfter(Version.V_8_2_0));
|
|
|
|
|
|
+ assumeTrue("indexing time series indices changed in 8.2.0", getOldClusterVersion().onOrAfter(Version.V_8_2_0));
|
|
|
|
|
|
StringBuilder bulk = new StringBuilder();
|
|
StringBuilder bulk = new StringBuilder();
|
|
- switch (CLUSTER_TYPE) {
|
|
|
|
- case OLD -> {
|
|
|
|
- createTsdbIndex();
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[0], TSDB_TIMES[1], 0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[0], TSDB_TIMES[1], -0.1);
|
|
|
|
- bulk("tsdb", bulk.toString());
|
|
|
|
- assertTsdbAgg(closeTo(215.95, 0.005), closeTo(-215.95, 0.005));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- case MIXED -> {
|
|
|
|
- if (FIRST_MIXED_ROUND) {
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[1], TSDB_TIMES[2], 0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[1], TSDB_TIMES[2], -0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(2), TSDB_TIMES[0], TSDB_TIMES[2], 1.1);
|
|
|
|
- bulk("tsdb", bulk.toString());
|
|
|
|
- assertTsdbAgg(closeTo(217.45, 0.005), closeTo(-217.45, 0.005), closeTo(2391.95, 0.005));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[2], TSDB_TIMES[3], 0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[2], TSDB_TIMES[3], -0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(2), TSDB_TIMES[2], TSDB_TIMES[3], 1.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(3), TSDB_TIMES[0], TSDB_TIMES[3], 10);
|
|
|
|
- bulk("tsdb", bulk.toString());
|
|
|
|
- assertTsdbAgg(closeTo(218.95, 0.005), closeTo(-218.95, 0.005), closeTo(2408.45, 0.005), closeTo(21895, 0.5));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- case UPGRADED -> {
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[3], TSDB_TIMES[4], 0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[3], TSDB_TIMES[4], -0.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(2), TSDB_TIMES[3], TSDB_TIMES[4], 1.1);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(3), TSDB_TIMES[3], TSDB_TIMES[4], 10);
|
|
|
|
- tsdbBulk(bulk, TSDB_DIMS.get(4), TSDB_TIMES[0], TSDB_TIMES[4], -5);
|
|
|
|
- bulk("tsdb", bulk.toString());
|
|
|
|
- assertTsdbAgg(
|
|
|
|
- closeTo(220.45, 0.005),
|
|
|
|
- closeTo(-220.45, 0.005),
|
|
|
|
- closeTo(2424.95, 0.005),
|
|
|
|
- closeTo(22045, 0.5),
|
|
|
|
- closeTo(-11022.5, 0.5)
|
|
|
|
- );
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if (isOldCluster()) {
|
|
|
|
+ createTsdbIndex();
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[0], TSDB_TIMES[1], 0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[0], TSDB_TIMES[1], -0.1);
|
|
|
|
+ bulk("tsdb", bulk.toString());
|
|
|
|
+ assertTsdbAgg(closeTo(215.95, 0.005), closeTo(-215.95, 0.005));
|
|
|
|
+ return;
|
|
|
|
+ } else if (isFirstMixedCluster()) {
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[1], TSDB_TIMES[2], 0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[1], TSDB_TIMES[2], -0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(2), TSDB_TIMES[0], TSDB_TIMES[2], 1.1);
|
|
|
|
+ bulk("tsdb", bulk.toString());
|
|
|
|
+ assertTsdbAgg(closeTo(217.45, 0.005), closeTo(-217.45, 0.005), closeTo(2391.95, 0.005));
|
|
|
|
+
|
|
|
|
+ } else if (isMixedCluster()) {
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[2], TSDB_TIMES[3], 0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[2], TSDB_TIMES[3], -0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(2), TSDB_TIMES[2], TSDB_TIMES[3], 1.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(3), TSDB_TIMES[0], TSDB_TIMES[3], 10);
|
|
|
|
+ bulk("tsdb", bulk.toString());
|
|
|
|
+ assertTsdbAgg(closeTo(218.95, 0.005), closeTo(-218.95, 0.005), closeTo(2408.45, 0.005), closeTo(21895, 0.5));
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(0), TSDB_TIMES[3], TSDB_TIMES[4], 0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(1), TSDB_TIMES[3], TSDB_TIMES[4], -0.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(2), TSDB_TIMES[3], TSDB_TIMES[4], 1.1);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(3), TSDB_TIMES[3], TSDB_TIMES[4], 10);
|
|
|
|
+ tsdbBulk(bulk, TSDB_DIMS.get(4), TSDB_TIMES[0], TSDB_TIMES[4], -5);
|
|
|
|
+ bulk("tsdb", bulk.toString());
|
|
|
|
+ assertTsdbAgg(
|
|
|
|
+ closeTo(220.45, 0.005),
|
|
|
|
+ closeTo(-220.45, 0.005),
|
|
|
|
+ closeTo(2424.95, 0.005),
|
|
|
|
+ closeTo(22045, 0.5),
|
|
|
|
+ closeTo(-11022.5, 0.5)
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -361,67 +337,60 @@ public class IndexingIT extends AbstractRollingTestCase {
|
|
}
|
|
}
|
|
|
|
|
|
public void testSyntheticSource() throws IOException {
|
|
public void testSyntheticSource() throws IOException {
|
|
- assumeTrue("added in 8.4.0", UPGRADE_FROM_VERSION.onOrAfter(Version.V_8_4_0));
|
|
|
|
-
|
|
|
|
- switch (CLUSTER_TYPE) {
|
|
|
|
- case OLD -> {
|
|
|
|
- Request createIndex = new Request("PUT", "/synthetic");
|
|
|
|
- XContentBuilder indexSpec = XContentBuilder.builder(XContentType.JSON.xContent()).startObject();
|
|
|
|
- indexSpec.startObject("mappings");
|
|
|
|
- {
|
|
|
|
- indexSpec.startObject("_source").field("mode", "synthetic").endObject();
|
|
|
|
- indexSpec.startObject("properties").startObject("kwd").field("type", "keyword").endObject().endObject();
|
|
|
|
- }
|
|
|
|
- indexSpec.endObject();
|
|
|
|
- createIndex.setJsonEntity(Strings.toString(indexSpec.endObject()));
|
|
|
|
- client().performRequest(createIndex);
|
|
|
|
- bulk("synthetic", """
|
|
|
|
- {"index": {"_index": "synthetic", "_id": "old"}}
|
|
|
|
- {"kwd": "old", "int": -12}
|
|
|
|
- """);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case MIXED -> {
|
|
|
|
- if (FIRST_MIXED_ROUND) {
|
|
|
|
- bulk("synthetic", """
|
|
|
|
- {"index": {"_index": "synthetic", "_id": "mixed_1"}}
|
|
|
|
- {"kwd": "mixed_1", "int": 22}
|
|
|
|
- """);
|
|
|
|
- } else {
|
|
|
|
- bulk("synthetic", """
|
|
|
|
- {"index": {"_index": "synthetic", "_id": "mixed_2"}}
|
|
|
|
- {"kwd": "mixed_2", "int": 33}
|
|
|
|
- """);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case UPGRADED -> {
|
|
|
|
- bulk("synthetic", """
|
|
|
|
- {"index": {"_index": "synthetic", "_id": "new"}}
|
|
|
|
- {"kwd": "new", "int": 21341325}
|
|
|
|
- """);
|
|
|
|
|
|
+ assumeTrue("added in 8.4.0", getOldClusterVersion().onOrAfter(Version.V_8_4_0));
|
|
|
|
+
|
|
|
|
+ if (isOldCluster()) {
|
|
|
|
+ Request createIndex = new Request("PUT", "/synthetic");
|
|
|
|
+ XContentBuilder indexSpec = XContentBuilder.builder(XContentType.JSON.xContent()).startObject();
|
|
|
|
+ indexSpec.startObject("mappings");
|
|
|
|
+ {
|
|
|
|
+ indexSpec.startObject("_source").field("mode", "synthetic").endObject();
|
|
|
|
+ indexSpec.startObject("properties").startObject("kwd").field("type", "keyword").endObject().endObject();
|
|
}
|
|
}
|
|
|
|
+ indexSpec.endObject();
|
|
|
|
+ createIndex.setJsonEntity(Strings.toString(indexSpec.endObject()));
|
|
|
|
+ client().performRequest(createIndex);
|
|
|
|
+ bulk("synthetic", """
|
|
|
|
+ {"index": {"_index": "synthetic", "_id": "old"}}
|
|
|
|
+ {"kwd": "old", "int": -12}
|
|
|
|
+ """);
|
|
|
|
+ } else if (isFirstMixedCluster()) {
|
|
|
|
+ bulk("synthetic", """
|
|
|
|
+ {"index": {"_index": "synthetic", "_id": "mixed_1"}}
|
|
|
|
+ {"kwd": "mixed_1", "int": 22}
|
|
|
|
+ """);
|
|
|
|
+ } else if (isMixedCluster()) {
|
|
|
|
+ bulk("synthetic", """
|
|
|
|
+ {"index": {"_index": "synthetic", "_id": "mixed_2"}}
|
|
|
|
+ {"kwd": "mixed_2", "int": 33}
|
|
|
|
+ """);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ bulk("synthetic", """
|
|
|
|
+ {"index": {"_index": "synthetic", "_id": "new"}}
|
|
|
|
+ {"kwd": "new", "int": 21341325}
|
|
|
|
+ """);
|
|
}
|
|
}
|
|
|
|
|
|
assertMap(
|
|
assertMap(
|
|
entityAsMap(client().performRequest(new Request("GET", "/synthetic/_doc/old"))),
|
|
entityAsMap(client().performRequest(new Request("GET", "/synthetic/_doc/old"))),
|
|
matchesMap().extraOk().entry("_source", matchesMap().entry("kwd", "old").entry("int", -12))
|
|
matchesMap().extraOk().entry("_source", matchesMap().entry("kwd", "old").entry("int", -12))
|
|
);
|
|
);
|
|
- if (CLUSTER_TYPE == ClusterType.OLD) {
|
|
|
|
|
|
+ if (isOldCluster()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
assertMap(
|
|
assertMap(
|
|
entityAsMap(client().performRequest(new Request("GET", "/synthetic/_doc/mixed_1"))),
|
|
entityAsMap(client().performRequest(new Request("GET", "/synthetic/_doc/mixed_1"))),
|
|
matchesMap().extraOk().entry("_source", matchesMap().entry("kwd", "mixed_1").entry("int", 22))
|
|
matchesMap().extraOk().entry("_source", matchesMap().entry("kwd", "mixed_1").entry("int", 22))
|
|
);
|
|
);
|
|
- if (CLUSTER_TYPE == ClusterType.MIXED && FIRST_MIXED_ROUND) {
|
|
|
|
|
|
+ if (isFirstMixedCluster()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
assertMap(
|
|
assertMap(
|
|
entityAsMap(client().performRequest(new Request("GET", "/synthetic/_doc/mixed_2"))),
|
|
entityAsMap(client().performRequest(new Request("GET", "/synthetic/_doc/mixed_2"))),
|
|
matchesMap().extraOk().entry("_source", matchesMap().entry("kwd", "mixed_2").entry("int", 33))
|
|
matchesMap().extraOk().entry("_source", matchesMap().entry("kwd", "mixed_2").entry("int", 33))
|
|
);
|
|
);
|
|
- if (CLUSTER_TYPE == ClusterType.MIXED) {
|
|
|
|
|
|
+ if (isMixedCluster()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
assertMap(
|
|
assertMap(
|