Skip to content

Commit 96aaca8

Browse files
committed
[Test] Wait for no relocating shards in indices.stats/13_fields tests
MixedClusterClientYamlTestSuiteIT sometimes fails when executing the indices.stats/13_fields/* REST tests. It does not reproduce locally but the execution logs show that it failed when a shard is relocating during the set up execution. This commit change the set up so that it now waits for all shards to be active before executing the tests. closes #26732, #27146
1 parent acdc164 commit 96aaca8

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/13_fields.yml

+36-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ setup:
44
- do:
55
indices.create:
66
index: test1
7+
wait_for_active_shards: all
78
body:
89
mappings:
910
bar:
@@ -20,6 +21,12 @@ setup:
2021
fields:
2122
completion:
2223
type: completion
24+
25+
- do:
26+
cluster.health:
27+
wait_for_active_shards: all
28+
wait_for_no_relocating_shards: true
29+
2330
- do:
2431
index:
2532
index: test1
@@ -29,10 +36,10 @@ setup:
2936

3037
- do:
3138
index:
32-
index: test2
33-
type: baz
34-
id: 1
35-
body: { "bar": "bar", "baz": "baz" }
39+
index: test1
40+
type: bar
41+
id: 2
42+
body: { "bar": "foo", "baz": "foo" }
3643

3744
- do:
3845
indices.refresh: {}
@@ -57,18 +64,17 @@ setup:
5764
completion:
5865
field: baz.completion
5966

60-
- do:
61-
indices.refresh: {}
62-
6367
- do:
6468
search:
65-
sort: bar,baz
69+
body:
70+
sort: [ "bar", "baz" ]
6671

6772
---
6873
"Fields - blank":
6974
- do:
7075
indices.stats: {}
7176

77+
- match: { _shards.failed: 0}
7278
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
7379
- is_false: _all.total.fielddata.fields
7480
- gt: { _all.total.completion.size_in_bytes: 0 }
@@ -79,6 +85,7 @@ setup:
7985
- do:
8086
indices.stats: { fields: bar }
8187

88+
- match: { _shards.failed: 0}
8289
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
8390
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
8491
- is_false: _all.total.fielddata.fields.baz
@@ -90,6 +97,7 @@ setup:
9097
- do:
9198
indices.stats: { fields: "bar,baz.completion" }
9299

100+
- match: { _shards.failed: 0}
93101
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
94102
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
95103
- is_false: _all.total.fielddata.fields.baz
@@ -102,6 +110,7 @@ setup:
102110
- do:
103111
indices.stats: { fields: "*" }
104112

113+
- match: { _shards.failed: 0}
105114
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
106115
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
107116
- gt: { _all.total.fielddata.fields.baz.memory_size_in_bytes: 0 }
@@ -114,6 +123,7 @@ setup:
114123
- do:
115124
indices.stats: { fields: "bar*" }
116125

126+
- match: { _shards.failed: 0}
117127
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
118128
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
119129
- is_false: _all.total.fielddata.fields.baz
@@ -126,6 +136,7 @@ setup:
126136
- do:
127137
indices.stats: { fields: "bar*", metric: _all }
128138

139+
- match: { _shards.failed: 0}
129140
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
130141
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
131142
- is_false: _all.total.fielddata.fields.baz
@@ -138,6 +149,7 @@ setup:
138149
- do:
139150
indices.stats: { fields: "bar*", metric: fielddata }
140151

152+
- match: { _shards.failed: 0}
141153
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
142154
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
143155
- is_false: _all.total.fielddata.fields.baz
@@ -148,6 +160,7 @@ setup:
148160
- do:
149161
indices.stats: { fields: "bar*", metric: completion }
150162

163+
- match: { _shards.failed: 0}
151164
- is_false: _all.total.fielddata
152165
- gt: { _all.total.completion.size_in_bytes: 0 }
153166
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
@@ -158,6 +171,7 @@ setup:
158171
- do:
159172
indices.stats: { fields: "bar*" , metric: [ completion, fielddata, search ]}
160173

174+
- match: { _shards.failed: 0}
161175
- gt: { _all.total.fielddata.memory_size_in_bytes: 0 }
162176
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
163177
- is_false: _all.total.fielddata.fields.baz
@@ -170,6 +184,7 @@ setup:
170184
- do:
171185
indices.stats: { fielddata_fields: bar }
172186

187+
- match: { _shards.failed: 0}
173188
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
174189
- is_false: _all.total.fielddata.fields.baz
175190
- is_false: _all.total.completion.fields
@@ -179,6 +194,7 @@ setup:
179194
- do:
180195
indices.stats: { fielddata_fields: "bar,baz,baz.completion" }
181196

197+
- match: { _shards.failed: 0}
182198
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
183199
- gt: { _all.total.fielddata.fields.baz.memory_size_in_bytes: 0 }
184200
- is_false: _all.total.completion.fields
@@ -188,6 +204,7 @@ setup:
188204
- do:
189205
indices.stats: { fielddata_fields: "*" }
190206

207+
- match: { _shards.failed: 0}
191208
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
192209
- gt: { _all.total.fielddata.fields.baz.memory_size_in_bytes: 0 }
193210
- is_false: _all.total.completion.fields
@@ -197,6 +214,7 @@ setup:
197214
- do:
198215
indices.stats: { fielddata_fields: "*r" }
199216

217+
- match: { _shards.failed: 0}
200218
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
201219
- is_false: _all.total.fielddata.fields.baz
202220
- is_false: _all.total.completion.fields
@@ -207,6 +225,7 @@ setup:
207225
- do:
208226
indices.stats: { fielddata_fields: "*r", metric: _all }
209227

228+
- match: { _shards.failed: 0}
210229
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
211230
- is_false: _all.total.fielddata.fields.baz
212231
- is_false: _all.total.completion.fields
@@ -216,6 +235,7 @@ setup:
216235
- do:
217236
indices.stats: { fielddata_fields: "*r", metric: fielddata }
218237

238+
- match: { _shards.failed: 0}
219239
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
220240
- is_false: _all.total.fielddata.fields.baz
221241
- is_false: _all.total.completion.fields
@@ -226,6 +246,7 @@ setup:
226246
- do:
227247
indices.stats: { fielddata_fields: "*r", metric: [ fielddata, search] }
228248

249+
- match: { _shards.failed: 0}
229250
- gt: { _all.total.fielddata.fields.bar.memory_size_in_bytes: 0 }
230251
- is_false: _all.total.fielddata.fields.baz
231252
- is_false: _all.total.completion.fields
@@ -236,6 +257,7 @@ setup:
236257
- do:
237258
indices.stats: { completion_fields: bar.completion }
238259

260+
- match: { _shards.failed: 0}
239261
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
240262
- is_false: _all.total.completion.fields.baz\.completion
241263
- is_false: _all.total.fielddata.fields
@@ -245,6 +267,7 @@ setup:
245267
- do:
246268
indices.stats: { completion_fields: "bar.completion,baz,baz.completion" }
247269

270+
- match: { _shards.failed: 0}
248271
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
249272
- gt: { _all.total.completion.fields.baz\.completion.size_in_bytes: 0 }
250273
- is_false: _all.total.fielddata.fields
@@ -254,6 +277,7 @@ setup:
254277
- do:
255278
indices.stats: { completion_fields: "*" }
256279

280+
- match: { _shards.failed: 0}
257281
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
258282
- gt: { _all.total.completion.fields.baz\.completion.size_in_bytes: 0 }
259283
- is_false: _all.total.fielddata.fields
@@ -263,6 +287,7 @@ setup:
263287
- do:
264288
indices.stats: { completion_fields: "*r*" }
265289

290+
- match: { _shards.failed: 0}
266291
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
267292
- is_false: _all.total.completion.fields.baz\.completion
268293
- is_false: _all.total.fielddata.fields
@@ -272,6 +297,7 @@ setup:
272297
- do:
273298
indices.stats: { completion_fields: "*r*", metric: _all }
274299

300+
- match: { _shards.failed: 0}
275301
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
276302
- is_false: _all.total.completion.fields.baz\.completion
277303
- is_false: _all.total.fielddata.fields
@@ -281,6 +307,7 @@ setup:
281307
- do:
282308
indices.stats: { completion_fields: "*r*", metric: completion }
283309

310+
- match: { _shards.failed: 0}
284311
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
285312
- is_false: _all.total.completion.fields.baz\.completion
286313
- is_false: _all.total.fielddata.fields
@@ -290,6 +317,7 @@ setup:
290317
- do:
291318
indices.stats: { completion_fields: "*r*", metric: [ completion, search ] }
292319

320+
- match: { _shards.failed: 0}
293321
- gt: { _all.total.completion.fields.bar\.completion.size_in_bytes: 0 }
294322
- is_false: _all.total.completion.fields.baz\.completion
295323
- is_false: _all.total.fielddata.fields

server/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo
4848
case "none":
4949
return s;
5050
default:
51-
throw new IllegalArgumentException("failed to parse [" + s + "] must be one of [node,node]");
51+
throw new IllegalArgumentException("failed to parse [" + s + "] must be one of [node,none]");
5252
}
5353
}, Property.IndexScope);
5454

server/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
public class ShardFieldData implements IndexFieldDataCache.Listener {
3434

35-
final CounterMetric evictionsMetric = new CounterMetric();
36-
final CounterMetric totalMetric = new CounterMetric();
37-
final ConcurrentMap<String, CounterMetric> perFieldTotals = ConcurrentCollections.newConcurrentMap();
35+
private final CounterMetric evictionsMetric = new CounterMetric();
36+
private final CounterMetric totalMetric = new CounterMetric();
37+
private final ConcurrentMap<String, CounterMetric> perFieldTotals = ConcurrentCollections.newConcurrentMap();
3838

3939
public FieldDataStats stats(String... fields) {
4040
ObjectLongHashMap<String> fieldTotals = null;

0 commit comments

Comments
 (0)