|
15 | 15 | import org.elasticsearch.common.time.FormatNames; |
16 | 16 | import org.elasticsearch.common.util.concurrent.ThreadContext; |
17 | 17 | import org.elasticsearch.common.xcontent.support.XContentMapValues; |
| 18 | +import org.elasticsearch.core.Booleans; |
18 | 19 | import org.elasticsearch.index.IndexSettings; |
19 | 20 | import org.elasticsearch.test.cluster.ElasticsearchCluster; |
| 21 | +import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder; |
20 | 22 | import org.elasticsearch.test.cluster.local.distribution.DistributionType; |
21 | 23 | import org.elasticsearch.test.rest.ESRestTestCase; |
22 | 24 | import org.hamcrest.Matchers; |
|
29 | 31 |
|
30 | 32 | import static org.hamcrest.Matchers.anyOf; |
31 | 33 | import static org.hamcrest.Matchers.equalTo; |
| 34 | +import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
32 | 35 |
|
33 | 36 | public class LogsdbRestIT extends ESRestTestCase { |
34 | 37 |
|
35 | | - private static final String USER = "test_admin"; |
| 38 | + private static final String USER = "x_pack_rest_user"; |
36 | 39 | private static final String PASS = "x-pack-test-password"; |
37 | 40 |
|
38 | 41 | @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 | + } |
45 | 57 |
|
46 | 58 | @Override |
47 | 59 | protected String getTestRestCluster() { |
@@ -463,7 +475,7 @@ public void testSyntheticSourceRuntimeFieldQueries() throws IOException { |
463 | 475 |
|
464 | 476 | var shardsHeader = (Map<?, ?>) searchResponseBody.get("_shards"); |
465 | 477 | assertThat(shardsHeader.get("failed"), equalTo(0)); |
466 | | - assertThat(shardsHeader.get("successful"), equalTo(1)); |
| 478 | + assertThat((Integer) shardsHeader.get("successful"), greaterThanOrEqualTo(1)); |
467 | 479 | assertThat(shardsHeader.get("skipped"), equalTo(0)); |
468 | 480 | } |
469 | 481 | } |
0 commit comments