49
49
import java .util .Locale ;
50
50
import java .util .Map ;
51
51
import java .util .concurrent .TimeUnit ;
52
+ import java .util .concurrent .atomic .AtomicBoolean ;
52
53
import java .util .stream .Collectors ;
53
54
54
55
import static org .elasticsearch .core .TimeValue .timeValueSeconds ;
59
60
import static org .hamcrest .Matchers .containsString ;
60
61
import static org .hamcrest .Matchers .equalTo ;
61
62
import static org .hamcrest .Matchers .everyItem ;
62
- import static org .hamcrest .Matchers .greaterThan ;
63
63
import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
64
64
import static org .hamcrest .Matchers .hasEntry ;
65
65
import static org .hamcrest .Matchers .hasItems ;
@@ -231,7 +231,6 @@ public void testWatcher() throws Exception {
231
231
}
232
232
}
233
233
234
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/63088" )
235
234
@ SuppressWarnings ("unchecked" )
236
235
public void testWatcherWithApiKey () throws Exception {
237
236
assumeTrue ("API key is available since 6.7.0" , getOldClusterVersion ().onOrAfter (Version .V_6_7_0 ));
@@ -252,7 +251,6 @@ public void testWatcherWithApiKey() throws Exception {
252
251
253
252
assertBusy (() -> {
254
253
final Request getRequest = new Request ("GET" , getWatcherEndpoint () + "/watch/watch_with_api_key" );
255
- getRequest .addParameter ("filter_path" , "status" );
256
254
final Map <String , Object > getWatchStatusResponse = entityAsMap (client ().performRequest (getRequest ));
257
255
final Map <String , Object > status = (Map <String , Object >) getWatchStatusResponse .get ("status" );
258
256
assertEquals ("executed" , status .get ("execution_state" ));
@@ -273,7 +271,6 @@ public void testWatcherWithApiKey() throws Exception {
273
271
274
272
try {
275
273
final Request getWatchStatusRequest = new Request ("GET" , "_watcher/watch/watch_with_api_key" );
276
- getWatchStatusRequest .addParameter ("filter_path" , "status" );
277
274
if (getOldClusterVersion ().before (Version .V_7_0_0 )) {
278
275
getWatchStatusRequest .setOptions (
279
276
expectWarnings (
@@ -285,11 +282,19 @@ public void testWatcherWithApiKey() throws Exception {
285
282
final Map <String , Object > status = (Map <String , Object >) getWatchStatusResponse .get ("status" );
286
283
final int version = (int ) status .get ("version" );
287
284
285
+ final AtomicBoolean versionIncreased = new AtomicBoolean ();
286
+ final AtomicBoolean executed = new AtomicBoolean ();
288
287
assertBusy (() -> {
289
288
final Map <String , Object > newGetWatchStatusResponse = entityAsMap (client ().performRequest (getWatchStatusRequest ));
290
289
final Map <String , Object > newStatus = (Map <String , Object >) newGetWatchStatusResponse .get ("status" );
291
- assertThat ((int ) newStatus .get ("version" ), greaterThan (version + 2 ));
292
- assertEquals ("executed" , newStatus .get ("execution_state" ));
290
+ if (false == versionIncreased .get () && version < (int ) newStatus .get ("version" )) {
291
+ versionIncreased .set (true );
292
+ }
293
+ if (false == executed .get () && "executed" .equals (newStatus .get ("execution_state" ))) {
294
+ executed .set (true );
295
+ }
296
+ assertThat ("version increased: [" + versionIncreased .get () + "], executed: [" + executed .get () + "]" ,
297
+ versionIncreased .get () && executed .get (), is (true ));
293
298
});
294
299
} finally {
295
300
stopWatcher ();
0 commit comments