Skip to content

Commit 0bd0119

Browse files
authored
Disabling the migration reindex yaml rest tests unless feature is available (#118382) (#118392)
This disables the migration reindex yaml rest tests when the feature flag is not available, so that the build doesn't fail in release mode, like: ``` ./gradlew ":x-pack:plugin:yamlRestTest" --tests "org.elasticsearch.xpack.test.rest.XPackRestIT.test {p0=migrate/*}" -Dtests.seed=28C1E85204B9DCAE -Dbuild.snapshot=false -Dtests.jvm.argline="-Dbuild.snapshot=false" -Dlicense.key=x-pack/license-tools/src/test/resources/public.key -Dtests.locale=bn-BD -Dtests.timezone=America/Dawson -Druntime.java=23 ```
1 parent 1e75943 commit 0bd0119

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/rest/RestMigrationReindexAction.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamResponse;
2121

2222
import java.io.IOException;
23+
import java.util.Collections;
24+
import java.util.HashSet;
2325
import java.util.List;
26+
import java.util.Set;
2427

2528
import static org.elasticsearch.rest.RestRequest.Method.POST;
29+
import static org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.REINDEX_DATA_STREAM_FEATURE_FLAG;
2630

2731
public class RestMigrationReindexAction extends BaseRestHandler {
32+
public static final String MIGRATION_REINDEX_CAPABILITY = "migration_reindex";
2833

2934
@Override
3035
public String getName() {
@@ -49,6 +54,15 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
4954
);
5055
}
5156

57+
@Override
58+
public Set<String> supportedCapabilities() {
59+
Set<String> capabilities = new HashSet<>();
60+
if (REINDEX_DATA_STREAM_FEATURE_FLAG.isEnabled()) {
61+
capabilities.add(MIGRATION_REINDEX_CAPABILITY);
62+
}
63+
return Collections.unmodifiableSet(capabilities);
64+
}
65+
5266
static class ReindexDataStreamRestToXContentListener extends RestBuilderListener<ReindexDataStreamResponse> {
5367

5468
ReindexDataStreamRestToXContentListener(RestChannel channel) {

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migrate/10_reindex.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ setup:
66

77
---
88
"Test Reindex With Unsupported Mode":
9+
- requires:
10+
reason: "migration reindex is behind a feature flag"
11+
test_runner_features: [capabilities]
12+
capabilities:
13+
- method: POST
14+
path: /_migration/reindex
15+
capabilities: [migration_reindex]
916
- do:
1017
catch: /illegal_argument_exception/
1118
migrate.reindex:
@@ -19,6 +26,13 @@ setup:
1926
2027
---
2128
"Test Reindex With Nonexistent Data Stream":
29+
- requires:
30+
reason: "migration reindex is behind a feature flag"
31+
test_runner_features: [capabilities]
32+
capabilities:
33+
- method: POST
34+
path: /_migration/reindex
35+
capabilities: [migration_reindex]
2236
- do:
2337
catch: /resource_not_found_exception/
2438
migrate.reindex:
@@ -44,6 +58,13 @@ setup:
4458
4559
---
4660
"Test Reindex With Bad Data Stream Name":
61+
- requires:
62+
reason: "migration reindex is behind a feature flag"
63+
test_runner_features: [capabilities]
64+
capabilities:
65+
- method: POST
66+
path: /_migration/reindex
67+
capabilities: [migration_reindex]
4768
- do:
4869
catch: /illegal_argument_exception/
4970
migrate.reindex:
@@ -57,6 +78,13 @@ setup:
5778
5879
---
5980
"Test Reindex With Existing Data Stream":
81+
- requires:
82+
reason: "migration reindex is behind a feature flag"
83+
test_runner_features: [capabilities]
84+
capabilities:
85+
- method: POST
86+
path: /_migration/reindex
87+
capabilities: [migration_reindex]
6088
- do:
6189
indices.put_index_template:
6290
name: my-template1

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/migrate/20_reindex_status.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,27 @@ setup:
66

77
---
88
"Test get reindex status with nonexistent task id":
9+
- requires:
10+
reason: "migration reindex is behind a feature flag"
11+
test_runner_features: [capabilities]
12+
capabilities:
13+
- method: POST
14+
path: /_migration/reindex
15+
capabilities: [migration_reindex]
916
- do:
1017
catch: /resource_not_found_exception/
1118
migrate.get_reindex_status:
1219
index: "does_not_exist"
1320

1421
---
1522
"Test Reindex With Existing Data Stream":
23+
- requires:
24+
reason: "migration reindex is behind a feature flag"
25+
test_runner_features: [capabilities]
26+
capabilities:
27+
- method: POST
28+
path: /_migration/reindex
29+
capabilities: [migration_reindex]
1630
- do:
1731
indices.put_index_template:
1832
name: my-template1

0 commit comments

Comments
 (0)