Skip to content

Commit 2b0bac3

Browse files
authored
Fix for race condition in interval watcher scheduler tests (#115501) (#115567)
1 parent b852e04 commit 2b0bac3

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

muted-tests.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,6 @@ tests:
351351
issue: https://github.com/elastic/elasticsearch/issues/102992
352352
- class: org.elasticsearch.bootstrap.SpawnerNoBootstrapTests
353353
issue: https://github.com/elastic/elasticsearch/issues/114555
354-
- class: org.elasticsearch.xpack.watcher.trigger.schedule.engine.TickerScheduleEngineTests
355-
method: testAddWithNoLastCheckedTimeButHasActivationTimeExecutesBeforeInitialInterval
356-
issue: https://github.com/elastic/elasticsearch/issues/115339
357-
- class: org.elasticsearch.xpack.watcher.trigger.schedule.engine.TickerScheduleEngineTests
358-
method: testAddWithLastCheckedTimeExecutesBeforeInitialInterval
359-
issue: https://github.com/elastic/elasticsearch/issues/115356
360-
- class: org.elasticsearch.xpack.watcher.trigger.schedule.engine.TickerScheduleEngineTests
361-
method: testWatchWithLastCheckedTimeExecutesBeforeInitialInterval
362-
issue: https://github.com/elastic/elasticsearch/issues/115354
363-
- class: org.elasticsearch.xpack.watcher.trigger.schedule.engine.TickerScheduleEngineTests
364-
method: testWatchWithNoLastCheckedTimeButHasActivationTimeExecutesBeforeInitialInterval
365-
issue: https://github.com/elastic/elasticsearch/issues/115368
366354
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
367355
method: test {p0=search.vectors/42_knn_search_int4_flat/Vector similarity with filter only}
368356
issue: https://github.com/elastic/elasticsearch/issues/115475

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,13 @@ public void testWatchWithLastCheckedTimeExecutesBeforeInitialInterval() throws E
312312

313313
engine.register(events -> {
314314
for (TriggerEvent ignored : events) {
315-
if (runCount.get() == 0) {
315+
if (runCount.getAndIncrement() == 0) {
316316
logger.info("job first fire");
317317
firstLatch.countDown();
318318
} else {
319319
logger.info("job second fire");
320320
secondLatch.countDown();
321321
}
322-
runCount.incrementAndGet();
323322
}
324323
});
325324

@@ -375,14 +374,13 @@ public void testWatchWithNoLastCheckedTimeButHasActivationTimeExecutesBeforeInit
375374

376375
engine.register(events -> {
377376
for (TriggerEvent ignored : events) {
378-
if (runCount.get() == 0) {
377+
if (runCount.getAndIncrement() == 0) {
379378
logger.info("job first fire");
380379
firstLatch.countDown();
381380
} else {
382381
logger.info("job second fire");
383382
secondLatch.countDown();
384383
}
385-
runCount.incrementAndGet();
386384
}
387385
});
388386

@@ -428,14 +426,13 @@ public void testAddWithLastCheckedTimeExecutesBeforeInitialInterval() throws Exc
428426

429427
engine.register(events -> {
430428
for (TriggerEvent ignored : events) {
431-
if (runCount.get() == 0) {
429+
if (runCount.getAndIncrement() == 0) {
432430
logger.info("job first fire");
433431
firstLatch.countDown();
434432
} else {
435433
logger.info("job second fire");
436434
secondLatch.countDown();
437435
}
438-
runCount.incrementAndGet();
439436
}
440437
});
441438

@@ -492,14 +489,13 @@ public void testAddWithNoLastCheckedTimeButHasActivationTimeExecutesBeforeInitia
492489

493490
engine.register(events -> {
494491
for (TriggerEvent ignored : events) {
495-
if (runCount.get() == 0) {
492+
if (runCount.getAndIncrement() == 0) {
496493
logger.info("job first fire");
497494
firstLatch.countDown();
498495
} else {
499496
logger.info("job second fire");
500497
secondLatch.countDown();
501498
}
502-
runCount.incrementAndGet();
503499
}
504500
});
505501

0 commit comments

Comments
 (0)