Skip to content

Commit d0cf376

Browse files
committed
Merge branch 'master' into replicated-closed-indices
2 parents 4db7fd9 + 222dc3e commit d0cf376

File tree

74 files changed

+1295
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1295
-361
lines changed
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client;
21+
22+
import org.apache.http.client.methods.HttpDelete;
23+
import org.apache.http.client.methods.HttpGet;
24+
import org.apache.http.client.methods.HttpPost;
25+
import org.apache.http.client.methods.HttpPut;
26+
import org.elasticsearch.action.support.ActiveShardCount;
27+
import org.elasticsearch.client.ccr.CcrStatsRequest;
28+
import org.elasticsearch.client.ccr.DeleteAutoFollowPatternRequest;
29+
import org.elasticsearch.client.ccr.FollowConfig;
30+
import org.elasticsearch.client.ccr.FollowInfoRequest;
31+
import org.elasticsearch.client.ccr.FollowStatsRequest;
32+
import org.elasticsearch.client.ccr.GetAutoFollowPatternRequest;
33+
import org.elasticsearch.client.ccr.PauseFollowRequest;
34+
import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest;
35+
import org.elasticsearch.client.ccr.PutFollowRequest;
36+
import org.elasticsearch.client.ccr.ResumeFollowRequest;
37+
import org.elasticsearch.client.ccr.UnfollowRequest;
38+
import org.elasticsearch.common.unit.ByteSizeValue;
39+
import org.elasticsearch.common.unit.TimeValue;
40+
import org.elasticsearch.test.ESTestCase;
41+
42+
import java.util.Arrays;
43+
import java.util.Locale;
44+
45+
import static org.hamcrest.Matchers.equalTo;
46+
import static org.hamcrest.Matchers.nullValue;
47+
48+
public class CcrRequestConvertersTests extends ESTestCase {
49+
50+
public void testPutFollow() throws Exception {
51+
PutFollowRequest putFollowRequest = new PutFollowRequest(randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4),
52+
randomBoolean() ? randomFrom(ActiveShardCount.NONE, ActiveShardCount.ONE, ActiveShardCount.DEFAULT, ActiveShardCount.ALL) : null
53+
);
54+
randomizeRequest(putFollowRequest);
55+
Request result = CcrRequestConverters.putFollow(putFollowRequest);
56+
assertThat(result.getMethod(), equalTo(HttpPut.METHOD_NAME));
57+
assertThat(result.getEndpoint(), equalTo("/" + putFollowRequest.getFollowerIndex() + "/_ccr/follow"));
58+
if (putFollowRequest.waitForActiveShards() != null && putFollowRequest.waitForActiveShards() != ActiveShardCount.DEFAULT) {
59+
String expectedValue = putFollowRequest.waitForActiveShards().toString().toLowerCase(Locale.ROOT);
60+
assertThat(result.getParameters().get("wait_for_active_shards"), equalTo(expectedValue));
61+
} else {
62+
assertThat(result.getParameters().size(), equalTo(0));
63+
}
64+
RequestConvertersTests.assertToXContentBody(putFollowRequest, result.getEntity());
65+
}
66+
67+
public void testPauseFollow() {
68+
PauseFollowRequest pauseFollowRequest = new PauseFollowRequest(randomAlphaOfLength(4));
69+
Request result = CcrRequestConverters.pauseFollow(pauseFollowRequest);
70+
assertThat(result.getMethod(), equalTo(HttpPost.METHOD_NAME));
71+
assertThat(result.getEndpoint(), equalTo("/" + pauseFollowRequest.getFollowerIndex() + "/_ccr/pause_follow"));
72+
assertThat(result.getParameters().size(), equalTo(0));
73+
assertThat(result.getEntity(), nullValue());
74+
}
75+
76+
public void testResumeFollow() throws Exception {
77+
ResumeFollowRequest resumeFollowRequest = new ResumeFollowRequest(randomAlphaOfLength(4));
78+
Request result = CcrRequestConverters.resumeFollow(resumeFollowRequest);
79+
assertThat(result.getMethod(), equalTo(HttpPost.METHOD_NAME));
80+
assertThat(result.getEndpoint(), equalTo("/" + resumeFollowRequest.getFollowerIndex() + "/_ccr/resume_follow"));
81+
assertThat(result.getParameters().size(), equalTo(0));
82+
RequestConvertersTests.assertToXContentBody(resumeFollowRequest, result.getEntity());
83+
}
84+
85+
public void testUnfollow() {
86+
UnfollowRequest pauseFollowRequest = new UnfollowRequest(randomAlphaOfLength(4));
87+
Request result = CcrRequestConverters.unfollow(pauseFollowRequest);
88+
assertThat(result.getMethod(), equalTo(HttpPost.METHOD_NAME));
89+
assertThat(result.getEndpoint(), equalTo("/" + pauseFollowRequest.getFollowerIndex() + "/_ccr/unfollow"));
90+
assertThat(result.getParameters().size(), equalTo(0));
91+
assertThat(result.getEntity(), nullValue());
92+
}
93+
94+
public void testPutAutofollowPattern() throws Exception {
95+
PutAutoFollowPatternRequest putAutoFollowPatternRequest = new PutAutoFollowPatternRequest(randomAlphaOfLength(4),
96+
randomAlphaOfLength(4), Arrays.asList(generateRandomStringArray(4, 4, false)));
97+
if (randomBoolean()) {
98+
putAutoFollowPatternRequest.setFollowIndexNamePattern(randomAlphaOfLength(4));
99+
}
100+
randomizeRequest(putAutoFollowPatternRequest);
101+
102+
Request result = CcrRequestConverters.putAutoFollowPattern(putAutoFollowPatternRequest);
103+
assertThat(result.getMethod(), equalTo(HttpPut.METHOD_NAME));
104+
assertThat(result.getEndpoint(), equalTo("/_ccr/auto_follow/" + putAutoFollowPatternRequest.getName()));
105+
assertThat(result.getParameters().size(), equalTo(0));
106+
RequestConvertersTests.assertToXContentBody(putAutoFollowPatternRequest, result.getEntity());
107+
}
108+
109+
public void testDeleteAutofollowPattern() throws Exception {
110+
DeleteAutoFollowPatternRequest deleteAutoFollowPatternRequest = new DeleteAutoFollowPatternRequest(randomAlphaOfLength(4));
111+
112+
Request result = CcrRequestConverters.deleteAutoFollowPattern(deleteAutoFollowPatternRequest);
113+
assertThat(result.getMethod(), equalTo(HttpDelete.METHOD_NAME));
114+
assertThat(result.getEndpoint(), equalTo("/_ccr/auto_follow/" + deleteAutoFollowPatternRequest.getName()));
115+
assertThat(result.getParameters().size(), equalTo(0));
116+
assertThat(result.getEntity(), nullValue());
117+
}
118+
119+
public void testGetAutofollowPattern() throws Exception {
120+
GetAutoFollowPatternRequest deleteAutoFollowPatternRequest = new GetAutoFollowPatternRequest(randomAlphaOfLength(4));
121+
122+
Request result = CcrRequestConverters.getAutoFollowPattern(deleteAutoFollowPatternRequest);
123+
assertThat(result.getMethod(), equalTo(HttpGet.METHOD_NAME));
124+
assertThat(result.getEndpoint(), equalTo("/_ccr/auto_follow/" + deleteAutoFollowPatternRequest.getName()));
125+
assertThat(result.getParameters().size(), equalTo(0));
126+
assertThat(result.getEntity(), nullValue());
127+
}
128+
129+
public void testGetCcrStats() throws Exception {
130+
CcrStatsRequest ccrStatsRequest = new CcrStatsRequest();
131+
Request result = CcrRequestConverters.getCcrStats(ccrStatsRequest);
132+
assertThat(result.getMethod(), equalTo(HttpGet.METHOD_NAME));
133+
assertThat(result.getEndpoint(), equalTo("/_ccr/stats"));
134+
assertThat(result.getParameters().size(), equalTo(0));
135+
assertThat(result.getEntity(), nullValue());
136+
}
137+
138+
public void testGetFollowStats() throws Exception {
139+
FollowStatsRequest followStatsRequest = new FollowStatsRequest(randomAlphaOfLength(4));
140+
Request result = CcrRequestConverters.getFollowStats(followStatsRequest);
141+
assertThat(result.getMethod(), equalTo(HttpGet.METHOD_NAME));
142+
assertThat(result.getEndpoint(), equalTo("/" + followStatsRequest.getFollowerIndex() + "/_ccr/stats"));
143+
assertThat(result.getParameters().size(), equalTo(0));
144+
assertThat(result.getEntity(), nullValue());
145+
}
146+
147+
public void testGetFollowInfo() throws Exception {
148+
FollowInfoRequest followInfoRequest = new FollowInfoRequest(randomAlphaOfLength(4));
149+
Request result = CcrRequestConverters.getFollowInfo(followInfoRequest);
150+
assertThat(result.getMethod(), equalTo(HttpGet.METHOD_NAME));
151+
assertThat(result.getEndpoint(), equalTo("/" + followInfoRequest.getFollowerIndex() + "/_ccr/info"));
152+
assertThat(result.getParameters().size(), equalTo(0));
153+
assertThat(result.getEntity(), nullValue());
154+
}
155+
156+
private static void randomizeRequest(FollowConfig request) {
157+
if (randomBoolean()) {
158+
request.setMaxOutstandingReadRequests(randomIntBetween(0, Integer.MAX_VALUE));
159+
}
160+
if (randomBoolean()) {
161+
request.setMaxOutstandingWriteRequests(randomIntBetween(0, Integer.MAX_VALUE));
162+
}
163+
if (randomBoolean()) {
164+
request.setMaxReadRequestOperationCount(randomIntBetween(0, Integer.MAX_VALUE));
165+
}
166+
if (randomBoolean()) {
167+
request.setMaxReadRequestSize(new ByteSizeValue(randomNonNegativeLong()));
168+
}
169+
if (randomBoolean()) {
170+
request.setMaxWriteBufferCount(randomIntBetween(0, Integer.MAX_VALUE));
171+
}
172+
if (randomBoolean()) {
173+
request.setMaxWriteBufferSize(new ByteSizeValue(randomNonNegativeLong()));
174+
}
175+
if (randomBoolean()) {
176+
request.setMaxWriteRequestOperationCount(randomIntBetween(0, Integer.MAX_VALUE));
177+
}
178+
if (randomBoolean()) {
179+
request.setMaxWriteRequestSize(new ByteSizeValue(randomNonNegativeLong()));
180+
}
181+
if (randomBoolean()) {
182+
request.setMaxRetryDelay(new TimeValue(randomNonNegativeLong()));
183+
}
184+
if (randomBoolean()) {
185+
request.setReadPollTimeout(new TimeValue(randomNonNegativeLong()));
186+
}
187+
}
188+
189+
}

dev-tools/es_release_notes.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ sub dump_issues {
8787
:pull: https://github.com/${User_Repo}pull/
8888
8989
[[release-notes-$version]]
90-
== $version Release Notes
90+
== {es} version $version
9191
9292
coming[$version]
9393
94-
Also see <<breaking-changes-$branch>>.
94+
Also see <<breaking-changes-$branch,Breaking changes in $branch>>.
9595
9696
ASCIIDOC
9797

libs/dissect/src/test/java/org/elasticsearch/dissect/DissectParserTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
import org.elasticsearch.test.ESTestCase;
2525
import org.hamcrest.CoreMatchers;
2626
import org.hamcrest.Matchers;
27+
import org.mockito.internal.util.collections.Sets;
2728

2829
import java.util.ArrayList;
2930
import java.util.Arrays;
30-
import java.util.Collections;
3131
import java.util.Iterator;
3232
import java.util.List;
3333
import java.util.Map;
@@ -112,7 +112,7 @@ public void testBasicMatch() {
112112
String delimiterFirstInput = "";
113113
String delimiterFirstPattern = "";
114114
//parallel arrays
115-
List<String> expectedKeys = Arrays.asList(generateRandomStringArray(100, 10, false, false));
115+
List<String> expectedKeys = new ArrayList<>(Sets.newSet(generateRandomStringArray(100, 10, false, false)));
116116
List<String> expectedValues = new ArrayList<>(expectedKeys.size());
117117
for (String key : expectedKeys) {
118118
String value = randomAsciiAlphanumOfLengthBetween(1, 100);
@@ -127,7 +127,6 @@ public void testBasicMatch() {
127127
assertMatch(delimiterFirstPattern, delimiterFirstInput, expectedKeys, expectedValues);
128128
}
129129

130-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39244")
131130
public void testBasicMatchUnicode() {
132131
String valueFirstInput = "";
133132
String keyFirstPattern = "";
@@ -138,6 +137,9 @@ public void testBasicMatchUnicode() {
138137
List<String> expectedValues = new ArrayList<>();
139138
for (int i = 0; i < randomIntBetween(1, 100); i++) {
140139
String key = randomAsciiAlphanumOfLengthBetween(1, 100);
140+
while (expectedKeys.contains(key)) { // keys should be unique in this test
141+
key = randomAsciiAlphanumOfLengthBetween(1, 100);
142+
}
141143
String value = randomRealisticUnicodeOfCodepointLengthBetween(1, 100);
142144
String delimiter = Integer.toString(randomInt()); //int to ensures values and delimiters don't overlap, else validation can fail
143145
keyFirstPattern += "%{" + key + "}" + delimiter;
@@ -375,13 +377,11 @@ private void assertMatch(String pattern, String input, List<String> expectedKeys
375377

376378
private void assertMatch(String pattern, String input, List<String> expectedKeys, List<String> expectedValues, String appendSeperator) {
377379
Map<String, String> results = new DissectParser(pattern, appendSeperator).parse(input);
378-
List<String> foundKeys = new ArrayList<>(results.keySet());
379-
List<String> foundValues = new ArrayList<>(results.values());
380-
Collections.sort(foundKeys);
381-
Collections.sort(foundValues);
382-
Collections.sort(expectedKeys);
383-
Collections.sort(expectedValues);
384-
assertThat(foundKeys, Matchers.equalTo(expectedKeys));
385-
assertThat(foundValues, Matchers.equalTo(expectedValues));
380+
assertThat(results.size(), Matchers.equalTo(expectedKeys.size()));
381+
assertThat(results.size(), Matchers.equalTo(expectedValues.size()));
382+
for (int i = 0; i < results.size(); i++) {
383+
final String key = expectedKeys.get(i);
384+
assertThat(results.get(key), Matchers.equalTo(expectedValues.get(i)));
385+
}
386386
}
387387
}

modules/mapper-extras/src/test/resources/rest-api-spec/test/dense-vector/20_special_cases.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ setup:
1111
body:
1212
settings:
1313
number_of_replicas: 0
14+
# we need to have 1 shard to get request failure in test "Dense vectors should error with sparse vector functions"
15+
number_of_shards: 1
1416
mappings:
1517
properties:
1618
my_dense_vector:
@@ -125,10 +127,6 @@ setup:
125127
---
126128
"Dense vectors should error with sparse vector functions":
127129

128-
- skip:
129-
version: "all"
130-
reason: "awaits fix in #39218"
131-
132130
- do:
133131
index:
134132
index: test-index

modules/mapper-extras/src/test/resources/rest-api-spec/test/sparse-vector/20_special_cases.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ setup:
1111
body:
1212
settings:
1313
number_of_replicas: 0
14+
# we need to have 1 shard to get request failure in test "Sparse vectors should error with dense vector functions"
15+
number_of_shards: 1
1416
mappings:
1517
properties:
1618
my_sparse_vector:
@@ -176,10 +178,6 @@ setup:
176178
---
177179
"Sparse vectors should error with dense vector functions":
178180

179-
- skip:
180-
version: "all"
181-
reason: "awaits fix in #39218"
182-
183181
- do:
184182
index:
185183
index: test-index

modules/transport-netty4/src/test/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public Settings onNodeStopped(String nodeName) throws IOException {
118118
public void testClearVotingTombstonesNotWaitingForRemoval() throws Exception {
119119
internalCluster().setBootstrapMasterNodeIndex(2);
120120
List<String> nodes = internalCluster().startNodes(3);
121+
ensureStableCluster(3);
121122
RestClient restClient = getRestClient();
122123
Response response = restClient.performRequest(new Request("POST", "/_cluster/voting_config_exclusions/" + nodes.get(2)));
123124
assertThat(response.getStatusLine().getStatusCode(), is(200));
@@ -131,6 +132,7 @@ public void testClearVotingTombstonesNotWaitingForRemoval() throws Exception {
131132
public void testClearVotingTombstonesWaitingForRemoval() throws Exception {
132133
internalCluster().setBootstrapMasterNodeIndex(2);
133134
List<String> nodes = internalCluster().startNodes(3);
135+
ensureStableCluster(3);
134136
RestClient restClient = getRestClient();
135137
String nodeToWithdraw = nodes.get(randomIntBetween(0, 2));
136138
Response response = restClient.performRequest(new Request("POST", "/_cluster/voting_config_exclusions/" + nodeToWithdraw));
@@ -145,6 +147,7 @@ public void testClearVotingTombstonesWaitingForRemoval() throws Exception {
145147
public void testFailsOnUnknownNode() throws Exception {
146148
internalCluster().setBootstrapMasterNodeIndex(2);
147149
internalCluster().startNodes(3);
150+
ensureStableCluster(3);
148151
RestClient restClient = getRestClient();
149152
try {
150153
restClient.performRequest(new Request("POST", "/_cluster/voting_config_exclusions/invalid"));

0 commit comments

Comments
 (0)