Skip to content
Merged
Show file tree
Hide file tree
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 @@ -89,6 +89,7 @@ void standardMapping(XContentBuilder builder) throws IOException {
}

void logsDbSettings(Settings.Builder builder) {
builder.put("index.mode", "logsdb");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed this oversight, it only impacted reindex tests.

if (keepArraySource) {
builder.put(Mapper.SYNTHETIC_SOURCE_KEEP_INDEX_SETTING.getKey(), "arrays");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@

package org.elasticsearch.xpack.logsdb.qa;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import static org.hamcrest.Matchers.equalTo;

/**
* This test compares behavior of a logsdb data stream and a standard index mode data stream
Expand Down Expand Up @@ -52,27 +45,4 @@ public void baselineMappings(XContentBuilder builder) throws IOException {
public void contenderMappings(XContentBuilder builder) throws IOException {
dataGenerationHelper.standardMapping(builder);
}

@Override
public Response indexContenderDocuments(CheckedSupplier<List<XContentBuilder>, IOException> documentsSupplier) throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method exists in a base class, just a clean up.

var reindexRequest = new Request("POST", "/_reindex?refresh=true");
reindexRequest.setJsonEntity(String.format(Locale.ROOT, """
{
"source": {
"index": "%s"
},
"dest": {
"index": "%s",
"op_type": "create"
}
}
""", getBaselineDataStreamName(), getContenderDataStreamName()));
var response = client.performRequest(reindexRequest);
assertOK(response);

var body = entityAsMap(response);
assertThat("encountered failures when performing reindex:\n " + body, body.get("failures"), equalTo(List.of()));

return response;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.logsdb.qa;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;

/**
* This test compares behavior of a standard mode data stream and a logsdb data stream using stored source.
* There should be no differences between such two data streams.
*/
public class LogsDbVersusReindexedIntoStoredSourceChallengeRestIT extends ReindexChallengeRestIT {
public String getBaselineDataStreamName() {
return "logs-apache-baseline";
}

public String getContenderDataStreamName() {
return "logs-apache-reindexed";
}

@Override
public void baselineSettings(Settings.Builder builder) {
dataGenerationHelper.logsDbSettings(builder);
}

@Override
public void contenderSettings(Settings.Builder builder) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we should just create base classes like

SyntheticSourceAbstractChallengeRestTest
DisableSourceAbstractChallengeRestTest
StoredSourceAbstractChallengeRestTest

where the setting is applied and we can just inherit from them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that sometimes baseline has stored source and sometimes the contender.

dataGenerationHelper.logsDbSettings(builder);
builder.put("index.mapping.source.mode", "stored");
}

@Override
public void baselineMappings(XContentBuilder builder) throws IOException {
dataGenerationHelper.logsDbMapping(builder);
}

@Override
public void contenderMappings(XContentBuilder builder) throws IOException {
dataGenerationHelper.logsDbMapping(builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@

package org.elasticsearch.xpack.logsdb.qa;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import static org.hamcrest.Matchers.equalTo;

/**
* This test compares behavior of a logsdb data stream and a data stream containing
Expand Down Expand Up @@ -52,27 +45,4 @@ public void baselineMappings(XContentBuilder builder) throws IOException {
public void contenderMappings(XContentBuilder builder) throws IOException {
dataGenerationHelper.logsDbMapping(builder);
}

@Override
public Response indexContenderDocuments(CheckedSupplier<List<XContentBuilder>, IOException> documentsSupplier) throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method exists in a base class, just a clean up.

var reindexRequest = new Request("POST", "/_reindex?refresh=true");
reindexRequest.setJsonEntity(String.format(Locale.ROOT, """
{
"source": {
"index": "%s"
},
"dest": {
"index": "%s",
"op_type": "create"
}
}
""", getBaselineDataStreamName(), getContenderDataStreamName()));
var response = client.performRequest(reindexRequest);
assertOK(response);

var body = entityAsMap(response);
assertThat("encountered failures when performing reindex:\n " + body, body.get("failures"), equalTo(List.of()));

return response;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.logsdb.qa;

import org.elasticsearch.common.settings.Settings;

/**
* This test compares behavior of a standard mode data stream and a logsdb data stream using stored source.
* There should be no differences between such two data streams.
*/
public class StandardVersusLogsStoredSourceChallengeRestIT extends StandardVersusLogsIndexModeRandomDataChallengeRestIT {
@Override
public void contenderSettings(Settings.Builder builder) {
super.contenderSettings(builder);
builder.put("index.mapping.source.mode", "stored");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.logsdb.qa;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;

/**
* This test compares behavior of a logsdb data stream using stored source and a logsdb data stream
* containing data reindexed from initial data stream.
* There should be no differences between such two data streams.
*/
public class StoredSourceLogsDbVersusReindexedLogsDbChallengeRestIT extends ReindexChallengeRestIT {
public String getBaselineDataStreamName() {
return "logs-apache-baseline";
}

public String getContenderDataStreamName() {
return "logs-apache-reindexed";
}

@Override
public void baselineSettings(Settings.Builder builder) {
dataGenerationHelper.logsDbSettings(builder);
builder.put("index.mapping.source.mode", "stored");
}

@Override
public void contenderSettings(Settings.Builder builder) {
dataGenerationHelper.logsDbSettings(builder);
}

@Override
public void baselineMappings(XContentBuilder builder) throws IOException {
dataGenerationHelper.logsDbMapping(builder);
}

@Override
public void contenderMappings(XContentBuilder builder) throws IOException {
dataGenerationHelper.logsDbMapping(builder);
}
}