Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;

import org.elasticsearch.search.SearchModule;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.After;
Expand All @@ -58,10 +59,12 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;

import java.util.Set;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;

import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.core.Is.is;

Expand Down Expand Up @@ -152,7 +155,7 @@ public void removePipelines() throws IOException {
deletePipeline(ContinuousTestCase.INGEST_PIPELINE);
}

@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/66410")

public void testContinousEvents() throws Exception {
String sourceIndexName = ContinuousTestCase.CONTINUOUS_EVENTS_SOURCE_INDEX;
DecimalFormat numberFormat = new DecimalFormat("000", new DecimalFormatSymbols(Locale.ROOT));
Expand Down Expand Up @@ -301,6 +304,8 @@ public void testContinousEvents() throws Exception {
* index sorting, triggers query optimizations.
*/
private void putIndex(String indexName, String dateType, boolean isDataStream) throws IOException {
List<String> sortedFields = Collections.emptyList();

// create mapping and settings
try (XContentBuilder builder = jsonBuilder()) {
builder.startObject();
Expand All @@ -310,9 +315,8 @@ private void putIndex(String indexName, String dateType, boolean isDataStream) t
if (randomBoolean()) {
builder.field("codec", "best_compression");
}
// TODO: crashes with assertions enabled in lucene
if (false && randomBoolean()) {
List<String> sortedFields = new ArrayList<>(
if (randomBoolean()) {
sortedFields = new ArrayList<>(
// note: no index sort for geo_point
randomUnique(() -> randomFrom("event", "metric", "run", "timestamp"), randomIntBetween(1, 3))
);
Expand All @@ -336,11 +340,16 @@ private void putIndex(String indexName, String dateType, boolean isDataStream) t
}
builder.endObject();

// gh#72741 : index sort does not support unsigned_long
final String metricType = sortedFields.contains("metric")
? randomFrom("integer", "long")
: randomFrom("integer", "long", "unsigned_long");

builder.startObject("event")
.field("type", "keyword")
.endObject()
.startObject("metric")
.field("type", randomFrom("integer", "long", "unsigned_long"))
.field("type", metricType)
.endObject()
.startObject("location")
.field("type", "geo_point")
Expand Down Expand Up @@ -397,8 +406,8 @@ private void putIndex(String indexName, String dateType, boolean isDataStream) t
.endObject()
.endObject();

// random overlay of existing field
if (randomBoolean()) {
// random overlay of existing field, only if its not part of sorted fields
if (sortedFields.contains("metric") == false && randomBoolean()) {
if (randomBoolean()) {
builder.startObject("metric").field("type", "long").endObject();
} else {
Expand Down Expand Up @@ -475,6 +484,7 @@ private void createOrUpdatePipeline(String field, int run) throws IOException {
putPipeline(new PutPipelineRequest(ContinuousTestCase.INGEST_PIPELINE, BytesReference.bytes(pipeline), XContentType.JSON))
.isAcknowledged()
);

}

private GetTransformStatsResponse getTransformStats(String id) throws IOException {
Expand Down Expand Up @@ -538,18 +548,21 @@ private void refreshIndex(String index) throws IOException {
private AcknowledgedResponse putTransform(TransformConfig config) throws IOException {
try (RestHighLevelClient restClient = new TestRestHighLevelClient()) {
return restClient.transform().putTransform(new PutTransformRequest(config), RequestOptions.DEFAULT);

}
}

private org.elasticsearch.action.support.master.AcknowledgedResponse putPipeline(PutPipelineRequest pipeline) throws IOException {
try (RestHighLevelClient restClient = new TestRestHighLevelClient()) {
return restClient.ingest().putPipeline(pipeline, RequestOptions.DEFAULT);

}
}

private org.elasticsearch.action.support.master.AcknowledgedResponse deletePipeline(String id) throws IOException {
try (RestHighLevelClient restClient = new TestRestHighLevelClient()) {
return restClient.ingest().deletePipeline(new DeletePipelineRequest(id), RequestOptions.DEFAULT);

}
}

Expand All @@ -562,6 +575,7 @@ private GetTransformResponse getTransforms() throws IOException {
private StartTransformResponse startTransform(String id) throws IOException {
try (RestHighLevelClient restClient = new TestRestHighLevelClient()) {
return restClient.transform().startTransform(new StartTransformRequest(id), RequestOptions.DEFAULT);

}
}

Expand All @@ -570,6 +584,7 @@ private StopTransformResponse stopTransform(String id, boolean waitForCompletion
try (RestHighLevelClient restClient = new TestRestHighLevelClient()) {
return restClient.transform()
.stopTransform(new StopTransformRequest(id, waitForCompletion, timeout, waitForCheckpoint), RequestOptions.DEFAULT);

}
}

Expand All @@ -578,6 +593,7 @@ private AcknowledgedResponse deleteTransform(String id, boolean force) throws IO
DeleteTransformRequest deleteRequest = new DeleteTransformRequest(id);
deleteRequest.setForce(force);
return restClient.transform().deleteTransform(deleteRequest, RequestOptions.DEFAULT);

}
}

Expand All @@ -599,4 +615,4 @@ private static class TestRestHighLevelClient extends RestHighLevelClient {
super(client(), restClient -> {}, X_CONTENT_ENTRIES);
}
}
}
}