|
45 | 45 | import java.util.Locale; |
46 | 46 | import java.util.Map; |
47 | 47 | import java.util.concurrent.TimeUnit; |
| 48 | +import java.util.concurrent.atomic.AtomicBoolean; |
48 | 49 | import java.util.stream.Collectors; |
49 | 50 |
|
50 | 51 | import static org.elasticsearch.core.TimeValue.timeValueSeconds; |
|
53 | 54 | import static org.hamcrest.Matchers.containsString; |
54 | 55 | import static org.hamcrest.Matchers.equalTo; |
55 | 56 | import static org.hamcrest.Matchers.everyItem; |
56 | | -import static org.hamcrest.Matchers.greaterThan; |
57 | 57 | import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
58 | 58 | import static org.hamcrest.Matchers.hasEntry; |
59 | 59 | import static org.hamcrest.Matchers.hasItems; |
@@ -202,11 +202,9 @@ public void testWatcher() throws Exception { |
202 | 202 | } |
203 | 203 | } |
204 | 204 |
|
205 | | - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/63088") |
206 | 205 | @SuppressWarnings("unchecked") |
207 | 206 | public void testWatcherWithApiKey() throws Exception { |
208 | 207 | final Request getWatchStatusRequest = new Request("GET", "/_watcher/watch/watch_with_api_key"); |
209 | | - getWatchStatusRequest.addParameter("filter_path", "status"); |
210 | 208 |
|
211 | 209 | if (isRunningAgainstOldCluster()) { |
212 | 210 | final Request createApiKeyRequest = new Request("PUT", "/_security/api_key"); |
@@ -247,11 +245,19 @@ public void testWatcherWithApiKey() throws Exception { |
247 | 245 | final Map<String, Object> status = (Map<String, Object>) getWatchStatusResponse.get("status"); |
248 | 246 | final int version = (int) status.get("version"); |
249 | 247 |
|
| 248 | + final AtomicBoolean versionIncreased = new AtomicBoolean(); |
| 249 | + final AtomicBoolean executed = new AtomicBoolean(); |
250 | 250 | assertBusy(() -> { |
251 | 251 | final Map<String, Object> newGetWatchStatusResponse = entityAsMap(client().performRequest(getWatchStatusRequest)); |
252 | 252 | final Map<String, Object> newStatus = (Map<String, Object>) newGetWatchStatusResponse.get("status"); |
253 | | - assertThat((int) newStatus.get("version"), greaterThan(version + 2)); |
254 | | - assertEquals("executed", newStatus.get("execution_state")); |
| 253 | + if (false == versionIncreased.get() && version < (int) newStatus.get("version")) { |
| 254 | + versionIncreased.set(true); |
| 255 | + } |
| 256 | + if (false == executed.get() && "executed".equals(newStatus.get("execution_state"))) { |
| 257 | + executed.set(true); |
| 258 | + } |
| 259 | + assertThat("version increased: [" + versionIncreased.get() + "], executed: [" + executed.get() + "]", |
| 260 | + versionIncreased.get() && executed.get(), is(true)); |
255 | 261 | }); |
256 | 262 | } finally { |
257 | 263 | stopWatcher(); |
|
0 commit comments