Skip to content

Commit 8d3e221

Browse files
committed
Add capabilities to avoid failing on bwc tests
1 parent eaeaaf7 commit 8d3e221

File tree

5 files changed

+78
-19
lines changed

5 files changed

+78
-19
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/10_synonyms_put.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ setup:
6767

6868
---
6969
"Timeout can be specified":
70+
71+
- requires:
72+
test_runner_features: [ capabilities ]
73+
capabilities:
74+
- method: PUT
75+
path: /_synonyms/{rule_id}
76+
capabilities: [ put_synonyms_timeout ]
77+
reason: "synonyms timeout capability needed"
78+
7079
- do:
7180
synonyms.put_synonym:
7281
id: test-update-synonyms
@@ -81,6 +90,16 @@ setup:
8190
- match: { reload_analyzers_details._shards.total: 0 }
8291
- length: { reload_analyzers_details.reload_details: 0 }
8392

93+
# Validate timeout values
94+
- do:
95+
catch: /as a time value:\ negative durations are not supported/
96+
synonyms.put_synonym:
97+
id: test-update-synonyms
98+
timeout: -100s
99+
body:
100+
synonyms_set:
101+
- synonyms: "bye, goodbye"
102+
84103
---
85104
"Validation fails tests":
86105
- do:
@@ -123,12 +142,3 @@ setup:
123142
synonyms_set:
124143
- synonyms: "bye, goodbye, "
125144

126-
- do:
127-
catch: /as a time value:\ negative durations are not supported/
128-
synonyms.put_synonym:
129-
id: test-update-synonyms
130-
timeout: -100s
131-
body:
132-
synonyms_set:
133-
- synonyms: "bye, goodbye"
134-

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/50_synonym_rule_put.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ setup:
8282

8383
---
8484
"Timeout can be specified":
85+
- requires:
86+
test_runner_features: [ capabilities ]
87+
capabilities:
88+
- method: PUT
89+
path: /_synonyms/{set_id}/{rule_id}
90+
capabilities: [ put_synonyms_timeout ]
91+
reason: "synonyms timeout capability needed"
92+
8593
- do:
8694
synonyms.put_synonym_rule:
8795
set_id: "test-synonyms"
@@ -94,6 +102,17 @@ setup:
94102
- match: { reload_analyzers_details._shards.total: 0 }
95103
- length: { reload_analyzers_details.reload_details: 0 }
96104

105+
# Validates timeout values
106+
- do:
107+
catch: /as a time value:\ negative durations are not supported/
108+
synonyms.put_synonym_rule:
109+
set_id: "test-synonyms"
110+
rule_id: "test-id-0"
111+
timeout: -100s
112+
body:
113+
synonyms_set:
114+
- synonyms: "bye, goodbye"
115+
97116
---
98117
"Validation failure tests":
99118
- do:
@@ -135,13 +154,3 @@ setup:
135154
rule_id: "test-id-0"
136155
body:
137156
synonyms: "bye, goodbye, "
138-
139-
- do:
140-
catch: /as a time value:\ negative durations are not supported/
141-
synonyms.put_synonym_rule:
142-
set_id: "test-synonyms"
143-
rule_id: "test-id-0"
144-
timeout: -100s
145-
body:
146-
synonyms_set:
147-
- synonyms: "bye, goodbye"

server/src/main/java/org/elasticsearch/rest/action/synonyms/RestPutSynonymRuleAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.io.IOException;
2323
import java.util.List;
24+
import java.util.Set;
2425

2526
import static org.elasticsearch.action.synonyms.PutSynonymRuleAction.DEFAULT_TIMEOUT;
2627
import static org.elasticsearch.rest.RestRequest.Method.PUT;
@@ -53,4 +54,9 @@ protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient
5354
new RestToXContentListener<>(channel, SynonymUpdateResponse::status, r -> null)
5455
);
5556
}
57+
58+
@Override
59+
public Set<String> supportedCapabilities() {
60+
return SynonymPutCapabilities.CAPABILITIES;
61+
}
5662
}

server/src/main/java/org/elasticsearch/rest/action/synonyms/RestPutSynonymsAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.io.IOException;
2323
import java.util.List;
24+
import java.util.Set;
2425

2526
import static org.elasticsearch.action.synonyms.PutSynonymRuleAction.DEFAULT_TIMEOUT;
2627
import static org.elasticsearch.rest.RestRequest.Method.PUT;
@@ -52,4 +53,9 @@ protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient
5253
new RestToXContentListener<>(channel, SynonymUpdateResponse::status, r -> null)
5354
);
5455
}
56+
57+
@Override
58+
public Set<String> supportedCapabilities() {
59+
return SynonymPutCapabilities.CAPABILITIES;
60+
}
5561
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.rest.action.synonyms;
11+
12+
import java.util.Set;
13+
14+
/**
15+
* A {@link Set} of "capabilities" supported by the {@link RestPutSynonymsAction} and {@link RestPutSynonymRuleAction}.
16+
*/
17+
public final class SynonymPutCapabilities {
18+
19+
private SynonymPutCapabilities() {
20+
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
21+
}
22+
23+
private static final String PUT_SYNONYMS_TIMEOUT = "put_synonyms_timeout";
24+
25+
public static final Set<String> CAPABILITIES = Set.of(
26+
PUT_SYNONYMS_TIMEOUT
27+
);
28+
}

0 commit comments

Comments
 (0)