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 @@ -16,6 +16,9 @@
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.Randomness;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
Expand Down Expand Up @@ -52,12 +55,16 @@ public class MultiClustersIT extends ESRestTestCase {
static List<Document> localStandardDocs = null;
static List<Document> remoteStandardDocs = null;

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

public static ElasticsearchCluster remoteCluster = ElasticsearchCluster.local()
.name("remote_cluster")
.distribution(DistributionType.DEFAULT)
.module("data-streams")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
.build();
Expand All @@ -67,7 +74,8 @@ public class MultiClustersIT extends ESRestTestCase {
.distribution(DistributionType.DEFAULT)
.module("data-streams")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
.setting("node.roles", "[data,ingest,master,remote_cluster_client]")
Expand All @@ -89,6 +97,11 @@ private RestClient remoteClusterClient() throws IOException {
return buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[0]));
}

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

private record Document(long timestamp, String cluster, String hostName, long pid, String method, long messageId, String message) {

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package org.elasticsearch.xpack.logsdb;

import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
Expand All @@ -18,11 +21,15 @@

public class LogsdbWithBasicRestIT extends ESRestTestCase {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.systemProperty("es.mapping.synthetic_source_fallback_to_stored_source.cutoff_date_restricted_override", "2027-12-31T23:59")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("cluster.logsdb.enabled", "true")
.build();

Expand All @@ -31,6 +38,11 @@ protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testCustomCutoffDateUsage() throws IOException {
var response = getAsMap("/_xpack/usage");
Map<?, ?> usage = (Map<?, ?>) response.get("logsdb");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@
package org.elasticsearch.xpack.logsdb;

import org.elasticsearch.client.Request;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.junit.ClassRule;

import java.io.IOException;

public abstract class DataStreamLicenseChangeTestCase extends LogsIndexModeRestTestIT {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.module("data-streams")
.module("x-pack-stack")
.setting("cluster.logsdb.enabled", "true")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "basic")
.build();

Expand All @@ -30,6 +38,11 @@ protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

protected static void startBasic() throws IOException {
Request startTrial = new Request("POST", "/_license/start_basic");
startTrial.addParameter("acknowledge", "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
Expand All @@ -36,6 +39,10 @@
import static org.hamcrest.Matchers.is;

public class LogsDbSourceModeMigrationIT extends LogsIndexModeRestTestIT {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

public static final String INDEX_TEMPLATE = """
{
"index_patterns": ["my-logs-*-*"],
Expand Down Expand Up @@ -108,7 +115,8 @@ public class LogsDbSourceModeMigrationIT extends LogsIndexModeRestTestIT {
.module("mapper-extras")
.module("x-pack-aggregate-metric")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.otel_data.registry.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
Expand All @@ -127,6 +135,11 @@ public void setup() {

private RestClient client;

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testSwitchFromStoredToSyntheticSource() throws IOException {
assertOK(putComponentTemplate(client, "my-logs-mapping", MAPPING_COMPONENT_TEMPLATE));
assertOK(putComponentTemplate(client, "my-logs-original-source", STORED_SOURCE_COMPONENT_TEMPLATE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.junit.Before;
Expand All @@ -27,6 +29,10 @@

@SuppressWarnings("unchecked")
public class LogsIndexModeCustomSettingsIT extends LogsIndexModeRestTestIT {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

@ClassRule()
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
Expand All @@ -35,7 +41,8 @@ public class LogsIndexModeCustomSettingsIT extends LogsIndexModeRestTestIT {
.module("mapper-extras")
.module("x-pack-aggregate-metric")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.otel_data.registry.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
Expand All @@ -54,6 +61,11 @@ public void setup() throws Exception {

private RestClient client;

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testOverrideIndexSorting() throws IOException {
var indexSortOverrideTemplate = """
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
package org.elasticsearch.xpack.logsdb;

import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
Expand All @@ -22,6 +25,9 @@

public class LogsIndexModeDisabledRestTestIT extends LogsIndexModeRestTestIT {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

private static final String MAPPINGS = """
{
"template": {
Expand All @@ -46,7 +52,8 @@ public class LogsIndexModeDisabledRestTestIT extends LogsIndexModeRestTestIT {
.module("mapper-extras")
.module("x-pack-aggregate-metric")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "trial")
.build();

Expand All @@ -63,6 +70,11 @@ public void setup() throws Exception {

private RestClient client;

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testLogsSettingsIndexModeEnabledByDefault() throws IOException {
assertOK(createDataStream(client, "logs-custom-dev"));
final String indexMode = (String) getSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
Expand All @@ -24,6 +27,9 @@

public class LogsIndexModeEnabledRestTestIT extends LogsIndexModeRestTestIT {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

@ClassRule()
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
Expand All @@ -32,7 +38,8 @@ public class LogsIndexModeEnabledRestTestIT extends LogsIndexModeRestTestIT {
.module("mapper-extras")
.module("x-pack-aggregate-metric")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
.build();
Expand Down Expand Up @@ -176,6 +183,11 @@ public void setup() throws Exception {
"host": { "cloud_region" : "us-west", "availability_zone" : "us-west-4b", "name" : "fdfgf-881197" } }
""";

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testCreateDataStream() throws IOException {
assertOK(putComponentTemplate(client, "logs@custom", MAPPINGS));
assertOK(createDataStream(client, "logs-custom-dev"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.FormatNames;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
Expand All @@ -33,11 +35,15 @@

public class PatternTextBasicRestIT extends ESRestTestCase {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.setting("xpack.license.self_generated.type", "trial")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.build();

@Override
Expand All @@ -56,6 +62,11 @@ public PatternTextBasicRestIT(boolean disableTemplating) {
this.disableTemplating = disableTemplating;
}

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

@SuppressWarnings("unchecked")
public void testBulkInsertThenMatchAllSource() throws IOException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
Expand All @@ -36,12 +38,17 @@
* @see <a href="https://github.com/elastic/elasticsearch/issues/121149">GitHub issue 121149</a>
*/
public class DatafeedRemoteClusterClientIT extends ESRestTestCase {

private static final String USER = "test_admin";
private static final String PASS = "x-pack-test-password";

public static ElasticsearchCluster remoteCluster = ElasticsearchCluster.local()
.name("remote_cluster")
.distribution(DistributionType.DEFAULT)
.module("data-streams")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
.build();
Expand All @@ -51,7 +58,8 @@ public class DatafeedRemoteClusterClientIT extends ESRestTestCase {
.distribution(DistributionType.DEFAULT)
.module("data-streams")
.module("x-pack-stack")
.setting("xpack.security.enabled", "false")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user(USER, PASS)
.setting("xpack.license.self_generated.type", "trial")
.setting("cluster.logsdb.enabled", "true")
.setting("node.roles", "[data,ingest,master,ml]") // remote_cluster_client not included
Expand All @@ -73,6 +81,11 @@ private RestClient remoteClusterClient() throws IOException {
return buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[0]));
}

protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testSource() throws IOException {
String localIndex = "local_index";
String remoteIndex = "remote_index";
Expand Down