Skip to content

Commit 6365423

Browse files
authored
Tweak LogsdbRestIT so that it can be included in serverless stateful qa module. (#138670)
1 parent f8c98fd commit 6365423

File tree

1 file changed

+20
-8
lines changed
  • x-pack/plugin/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb

1 file changed

+20
-8
lines changed

x-pack/plugin/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/LogsdbRestIT.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import org.elasticsearch.common.time.FormatNames;
1616
import org.elasticsearch.common.util.concurrent.ThreadContext;
1717
import org.elasticsearch.common.xcontent.support.XContentMapValues;
18+
import org.elasticsearch.core.Booleans;
1819
import org.elasticsearch.index.IndexSettings;
1920
import org.elasticsearch.test.cluster.ElasticsearchCluster;
21+
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
2022
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2123
import org.elasticsearch.test.rest.ESRestTestCase;
2224
import org.hamcrest.Matchers;
@@ -29,19 +31,29 @@
2931

3032
import static org.hamcrest.Matchers.anyOf;
3133
import static org.hamcrest.Matchers.equalTo;
34+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
3235

3336
public class LogsdbRestIT extends ESRestTestCase {
3437

35-
private static final String USER = "test_admin";
38+
private static final String USER = "x_pack_rest_user";
3639
private static final String PASS = "x-pack-test-password";
3740

3841
@ClassRule
39-
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
40-
.distribution(DistributionType.DEFAULT)
41-
.user(USER, PASS, "superuser", false)
42-
.setting("xpack.security.autoconfiguration.enabled", "false")
43-
.setting("xpack.license.self_generated.type", "trial")
44-
.build();
42+
public static final ElasticsearchCluster cluster = createCluster();
43+
44+
private static ElasticsearchCluster createCluster() {
45+
LocalClusterSpecBuilder<ElasticsearchCluster> clusterBuilder = ElasticsearchCluster.local()
46+
.distribution(DistributionType.DEFAULT)
47+
.setting("xpack.security.enabled", "true")
48+
.user(USER, PASS)
49+
.keystore("bootstrap.password", "x-pack-test-password")
50+
.setting("xpack.license.self_generated.type", "trial");
51+
boolean setNodes = Booleans.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true"));
52+
if (setNodes) {
53+
clusterBuilder.nodes(1);
54+
}
55+
return clusterBuilder.build();
56+
}
4557

4658
@Override
4759
protected String getTestRestCluster() {
@@ -463,7 +475,7 @@ public void testSyntheticSourceRuntimeFieldQueries() throws IOException {
463475

464476
var shardsHeader = (Map<?, ?>) searchResponseBody.get("_shards");
465477
assertThat(shardsHeader.get("failed"), equalTo(0));
466-
assertThat(shardsHeader.get("successful"), equalTo(1));
478+
assertThat((Integer) shardsHeader.get("successful"), greaterThanOrEqualTo(1));
467479
assertThat(shardsHeader.get("skipped"), equalTo(0));
468480
}
469481
}

0 commit comments

Comments
 (0)