Skip to content
Snippets Groups Projects
Unverified Commit 29d5f170 authored by Sergii Kabashniuk's avatar Sergii Kabashniuk Committed by GitHub
Browse files

Fixed MeteredExecutorServiceWrapperTest that is failing some Linux system (#15034)


* Fixed MeteredExecutorServiceWrapperTest that are failing some Linux system
Signed-off-by: default avatarSergii Kabashniuk <skabashniuk@redhat.com>
parent c7b2c639
No related branches found
No related tags found
No related merge requests found
...@@ -86,11 +86,7 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -86,11 +86,7 @@ public class MeteredExecutorServiceWrapperTest {
"userTagValue"); "userTagValue");
CountDownLatch runnableTaskStart = new CountDownLatch(1); CountDownLatch runnableTaskStart = new CountDownLatch(1);
// when // when
Future<?> future = Future<?> future = executor.submit(runnableTaskStart::countDown);
executor.submit(
() -> {
runnableTaskStart.countDown();
});
// then // then
runnableTaskStart.await(10, TimeUnit.SECONDS); runnableTaskStart.await(10, TimeUnit.SECONDS);
future.get(1, TimeUnit.MINUTES); future.get(1, TimeUnit.MINUTES);
...@@ -132,14 +128,17 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -132,14 +128,17 @@ public class MeteredExecutorServiceWrapperTest {
.gauge() .gauge()
.value(), .value(),
1.0); 1.0);
assertEquals( assertWithRetry(
registry () ->
.get("executor.completed") registry
.tag("name", MeteredExecutorServiceWrapperTest.class.getName()) .get("executor.completed")
.tags(userTags) .tag("name", MeteredExecutorServiceWrapperTest.class.getName())
.functionCounter() .tags(userTags)
.count(), .functionCounter()
1.0); .count(),
1.0,
10,
50);
assertEquals( assertEquals(
registry registry
.get("executor.queued") .get("executor.queued")
...@@ -163,7 +162,7 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -163,7 +162,7 @@ public class MeteredExecutorServiceWrapperTest {
.tags(userTags) .tags(userTags)
.gauge() .gauge()
.value(), .value(),
new Double(Integer.MAX_VALUE)); (double) Integer.MAX_VALUE);
assertEquals( assertEquals(
registry registry
.get("executor") .get("executor")
...@@ -194,13 +193,7 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -194,13 +193,7 @@ public class MeteredExecutorServiceWrapperTest {
CountDownLatch runnableTaskStart = new CountDownLatch(1); CountDownLatch runnableTaskStart = new CountDownLatch(1);
// when // when
((ScheduledExecutorService) executor) ((ScheduledExecutorService) executor)
.scheduleAtFixedRate( .scheduleAtFixedRate(runnableTaskStart::countDown, 0, 100, TimeUnit.SECONDS);
() -> {
runnableTaskStart.countDown();
},
0,
100,
TimeUnit.SECONDS);
// then // then
runnableTaskStart.await(10, TimeUnit.SECONDS); runnableTaskStart.await(10, TimeUnit.SECONDS);
...@@ -277,7 +270,7 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -277,7 +270,7 @@ public class MeteredExecutorServiceWrapperTest {
.tags(userTags) .tags(userTags)
.gauge() .gauge()
.value(), .value(),
new Double(Integer.MAX_VALUE)); (double) Integer.MAX_VALUE);
assertEquals( assertEquals(
registry registry
.get("executor") .get("executor")
...@@ -323,11 +316,7 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -323,11 +316,7 @@ public class MeteredExecutorServiceWrapperTest {
"userTagValue"); "userTagValue");
CountDownLatch runnableTaskStart = new CountDownLatch(1); CountDownLatch runnableTaskStart = new CountDownLatch(1);
// when // when
executor.schedule( executor.schedule(runnableTaskStart::countDown, new CronExpression(" * * * ? * * *"));
() -> {
runnableTaskStart.countDown();
},
new CronExpression(" * * * ? * * *"));
// then // then
runnableTaskStart.await(10, TimeUnit.SECONDS); runnableTaskStart.await(10, TimeUnit.SECONDS);
assertEquals( assertEquals(
...@@ -444,7 +433,7 @@ public class MeteredExecutorServiceWrapperTest { ...@@ -444,7 +433,7 @@ public class MeteredExecutorServiceWrapperTest {
1.0); 1.0);
} }
public <V> void assertWithRetry(Supplier<V> predicate, V expected, int times, int pause_millis) <V> void assertWithRetry(Supplier<V> predicate, V expected, int times, int pause_millis)
throws InterruptedException { throws InterruptedException {
for (int i = 0; i <= times; i++) { for (int i = 0; i <= times; i++) {
V actual = predicate.get(); V actual = predicate.get();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment