Skip to content

Commit

Permalink
Removed tests that race with task execution
Browse files Browse the repository at this point in the history
  • Loading branch information
chemicL committed Jul 13, 2022
1 parent ef4a5d1 commit 22e8b1d
Showing 1 changed file with 0 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -689,62 +689,6 @@ public void immediateTaskIsExecuted() throws Exception {
assertThat((end - start) >= 1000).as("Timeout too long").isTrue();
}

@Test
public void immediateTaskIsSkippedIfDisposeRightAfter() throws Exception {
Scheduler serviceRB = Schedulers.newSingle("rbWork");
Scheduler.Worker r = serviceRB.createWorker();

long start = System.currentTimeMillis();
AtomicInteger latch = new AtomicInteger(1);
Consumer<String> c = ev -> {
latch.decrementAndGet();
try {
System.out.println("ev: "+ev);
Thread.sleep(1000);
}
catch(InterruptedException ie){
throw Exceptions.propagate(ie);
}
};
r.schedule(() -> c.accept("Hello World!"));
serviceRB.dispose();

Thread.sleep(1200);
long end = System.currentTimeMillis();


assertThat(latch.intValue() == 1).as("Task not skipped").isTrue();
assertThat((end - start) >= 1000).as("Timeout too long").isTrue();
}

@Test
public void immediateTaskIsNotSkippedIfDisposedGracefullyRightAfter() throws Exception {
Scheduler serviceRB = Schedulers.newSingle("rbWork");
Scheduler.Worker r = serviceRB.createWorker();

long start = System.currentTimeMillis();
AtomicInteger latch = new AtomicInteger(1);
Consumer<String> c = ev -> {
latch.decrementAndGet();
try {
System.out.println("ev: "+ev);
Thread.sleep(1000);
}
catch(InterruptedException ie){
throw Exceptions.propagate(ie);
}
};
r.schedule(() -> c.accept("Hello World!"));
serviceRB.disposeGracefully(Duration.ofMillis(1200)).subscribe();

Thread.sleep(1200);
long end = System.currentTimeMillis();


assertThat(latch.intValue() == 0).as("Task skipped").isTrue();
assertThat((end - start) >= 1000).as("Timeout too long").isTrue();
}

@Test
public void singleSchedulerPipelining() throws Exception {
Scheduler serviceRB = Schedulers.newSingle("rb", true);
Expand Down

0 comments on commit 22e8b1d

Please sign in to comment.