Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
* Verifies that a handler in a {@link BlockingEventLoop} is interrupted when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
import java.time.Duration;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;

class DiskSpaceMonitorTest extends ThreadsTestCommon {

@BeforeEach
void beforeEach(){
void beforeEach() {
clearState();
}

@AfterEach
void afterEach(){
void afterEach() {
clearState();
DiskSpaceMonitor.INSTANCE.setThresholdPercentage(5);
}
Expand Down Expand Up @@ -78,5 +78,4 @@ void ensureThatDiskSpaceMonitorRunsForMoreThanOneIteration() throws InterruptedE
timeProvider.advanceMillis(Duration.ofHours(24).toMillis());
Thread.sleep(1000);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

import java.util.concurrent.TimeoutException;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

class EventGroupBadAffinityTest extends ThreadsTestCommon {

/**
* Ensures that an invalid CPU affinity string fails fast so that
* misconfigured deployments do not run with unexpected processor binding.
*/
@Timeout(5_000)
@Test
@Timeout(5000)
void testInvalidAffinity() {
expectException("Cannot parse 'xxx'");
ignoreException("Timed out waiting for start!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,4 @@ void testThrowingEventLoopAddedAfterStartBlocking() {
void testThrowingEventLoopAddedAfterStartConcurrent() {
addThrowingEventLoopAfterEventLoopStarted(new ThrowingHandler(HandlerPriority.CONCURRENT, true, false));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import org.junit.jupiter.api.Timeout;

import java.util.ArrayList;
Expand All @@ -20,7 +21,7 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.*;

/**
* Spawns many event groups across several processes to check that a large
Expand All @@ -31,8 +32,8 @@ class EventGroupStressTest extends ThreadsTestCommon {
private static final int NUM_PROCESSES = 10;
private static final int NUM_GROUPS_PER_PROCESS = 20;

@Disabled("https://github.com/OpenHFT/Chronicle-Threads/issues/186")
@Test
@Disabled("https://github.com/OpenHFT/Chronicle-Threads/issues/186")
@Timeout(30)
void canOverloadTheCPUWithEventGroupsSafely() {
assumeFalse(OS.isWindows());
Expand Down
45 changes: 22 additions & 23 deletions src/test/java/net/openhft/chronicle/threads/EventGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.openhft.chronicle.core.io.*;
import net.openhft.chronicle.core.threads.*;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
Expand Down Expand Up @@ -63,8 +62,8 @@ public void preAfter() throws InterruptedException {
handlers.forEach(TestHandler::checkCloseOrder);
}

@Timeout(5)
@Test
@Timeout(5)
void testEventLoopName() {
try (final EventLoop eventGroup = EventGroup.builder()
.withName("my-eg/")
Expand All @@ -73,8 +72,8 @@ void testEventLoopName() {
}
}

@Timeout(5)
@Test
@Timeout(5)
void testSimpleEventGroupTest() throws InterruptedException {

final AtomicInteger value = new AtomicInteger();
Expand Down Expand Up @@ -114,14 +113,14 @@ void testSimpleEventGroupTest() throws InterruptedException {
}
}

@Timeout(5)
@Test
@Timeout(5)
void testSimpleEventGroupPrivateGroup() {
doTestSimpleEventGroup(true);
}

@Timeout(5)
@Test
@Timeout(5)
void testSimpleEventGroupNonPrivateGroup() {
doTestSimpleEventGroup(false);
}
Expand All @@ -143,8 +142,8 @@ private void doTestSimpleEventGroup(boolean privateGroup) {
}
}

@Timeout(5)
@Test
@Timeout(5)
void testClosePausedBlockingEventLoop() {
final EventLoop eventGroup = EventGroup.builder().build();
eventGroup.start();
Expand All @@ -154,8 +153,8 @@ void testClosePausedBlockingEventLoop() {
assertTrue(eventGroup.isStopped());
}

@Timeout(5)
@Test
@Timeout(5)
void testCloseAwaitTermination() {
final EventLoop eventGroup = EventGroup.builder().build();
eventGroup.start();
Expand All @@ -164,8 +163,8 @@ void testCloseAwaitTermination() {
assertTrue(eventGroup.isStopped());
}

@Timeout(5)
@Test
@Timeout(5)
void testCloseStopAwaitTermination() {
final EventLoop eventGroup = EventGroup.builder().build();
eventGroup.start();
Expand All @@ -175,8 +174,8 @@ void testCloseStopAwaitTermination() {
assertTrue(eventGroup.isStopped());
}

@Timeout(5)
@Test
@Timeout(5)
void testCloseStopIdempotent() {
final EventLoop eventGroup = EventGroup.builder().build();
eventGroup.start();
Expand All @@ -187,17 +186,17 @@ void testCloseStopIdempotent() {
assertTrue(eventGroup.isStopped());
}

@Timeout(5)
@Test
@Timeout(5)
void testCloseAwaitTerminationWithoutStarting() {
final EventLoop eventGroup = EventGroup.builder().build();
eventGroup.close();
assertTrue(eventGroup.isClosed());
assertTrue(eventGroup.isStopped());
}

@Timeout(5)
@Test
@Timeout(5)
void checkNoThreadsCreatedIfEventGroupNotStarted() {
final ThreadDump threadDump = new ThreadDump();
try (final EventLoop eventGroup = EventGroup.builder().build()) {
Expand All @@ -207,8 +206,8 @@ void checkNoThreadsCreatedIfEventGroupNotStarted() {
}
}

@Timeout(5)
@Test
@Timeout(5)
void checkAllEventHandlerTypesStartAndStop() throws InterruptedException {
try (final EventLoop eventGroup = EventGroup.builder().build()) {
for (HandlerPriority hp : HandlerPriority.values())
Expand All @@ -219,8 +218,8 @@ void checkAllEventHandlerTypesStartAndStop() throws InterruptedException {
}
}

@Timeout(5)
@Test
@Timeout(5)
void checkNoThreadsAfterStopCalled() throws InterruptedException {
final ThreadDump threadDump = new ThreadDump();
try (final EventLoop eventGroup = EventGroup.builder().build()) {
Expand All @@ -235,8 +234,8 @@ void checkNoThreadsAfterStopCalled() throws InterruptedException {
}
}

@Timeout(5)
@Test
@Timeout(5)
void checkHandlersNotClosedAfterStop() throws InterruptedException {
try (final EventLoop eventGroup = EventGroup.builder().build()) {
for (HandlerPriority hp : HandlerPriority.values())
Expand All @@ -250,8 +249,8 @@ void checkHandlersNotClosedAfterStop() throws InterruptedException {
handlers.forEach(testHandler -> assertTrue(testHandler.isClosed()));
}

@Timeout(5)
@Test
@Timeout(5)
void checkHandlersClosedImmediatelyOnInvalidHandlerException() throws InterruptedException {
try (final EventLoop eventGroup = EventGroup.builder().build()) {
for (HandlerPriority hp : HandlerPriority.values())
Expand All @@ -264,8 +263,8 @@ void checkHandlersClosedImmediatelyOnInvalidHandlerException() throws Interrupte
}
}

@Timeout(5)
@Test
@Timeout(5)
void checkAllEventHandlerTypesStartAndStopAddAgain() throws InterruptedException {
expectException("Only one high handler supported was TestHandler");
try (final EventLoop eventGroup = EventGroup.builder().build()) {
Expand All @@ -286,14 +285,14 @@ void checkAllEventHandlerTypesStartAndStopAddAgain() throws InterruptedException
}
}

@Timeout(5)
@Test
@Timeout(5)
void checkExecutedInOrderOfPriorityInline() throws InterruptedException {
checkExecutedOrderOfPriority(HandlerPriority.MEDIUM, HandlerPriority.HIGH, HandlerPriority.MEDIUM);
}

@Timeout(5)
@Test
@Timeout(5)
void checkExecutedInOrderOfPriorityLoop() throws InterruptedException {
checkExecutedOrderOfPriority(HandlerPriority.MEDIUM, HandlerPriority.MEDIUM, HandlerPriority.HIGH, HandlerPriority.MEDIUM, HandlerPriority.MEDIUM, HandlerPriority.MEDIUM);
}
Expand All @@ -319,8 +318,8 @@ private void checkExecutedOrderOfPriority(HandlerPriority... priorities) throws
assertTrue(this.handlers.get(0).actionCalled.get() > this.handlers.get(1).actionCalled.get());
}

@Timeout(5)
@Test
@Timeout(5)
void checkAllEventHandlerTypesStartInvalidEventHandlerException() throws InterruptedException {
checkException(ExceptionType.INVALID_EVENT_HANDLER);
}
Expand All @@ -341,8 +340,8 @@ private void checkException(ExceptionType exceptionType) throws InterruptedExcep

// TODO: checkAllEventHandlerTypesContinueRuntimeException()

@Timeout(5)
@Test
@Timeout(5)
void testCloseAddHandler() {
try (final EventLoop eventGroup = EventGroup.builder().build()) {
closeQuietly(eventGroup); // Direct call to close causes an unsuppressable warning in Java 21+
Expand All @@ -359,8 +358,8 @@ void testCloseAddHandler() {
}
}

@Timeout(5)
@Test
@Timeout(5)
void testEventGroupNoCoreEventLoop() {
final AtomicReference<EventLoop> ref = new AtomicReference<>();
try (EventLoop eg = EventGroup.builder()
Expand Down Expand Up @@ -521,9 +520,9 @@ public void loopFinished() {
if (System.currentTimeMillis() > timeoutTime) {
final List<HandlerPriority> handlerPrioritiesThatDidntFinish = eventHandlerFinishedForPriority.keySet().stream().filter(k -> !eventHandlerFinishedForPriority.get(k).get()).collect(Collectors.toList());
if (handlerPrioritiesThatDidntFinish.isEmpty()) {
Assertions.fail("Event group didn't throw an exception when attempting to close!");
fail("Event group didn't throw an exception when attempting to close!");
} else {
Assertions.fail("Handlers for " + handlerPrioritiesThatDidntFinish + " didn't finish");
fail("Handlers for " + handlerPrioritiesThatDidntFinish + " didn't finish");
}
}
Jvm.pause(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.openhft.chronicle.core.threads.EventHandler;
import net.openhft.chronicle.core.threads.EventLoop;
import net.openhft.chronicle.core.threads.InvalidEventHandlerException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -22,8 +21,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
* Exercises the helper routines in {@link EventLoops} and the life-cycle
Expand Down Expand Up @@ -51,8 +49,8 @@ void stopAllCanHandleNulls() {
}
}

@Timeout(5_000)
@Test
@Timeout(5000)
void stopAllWillBlockUntilTheLastEventLoopStops() {
try (final MediumEventLoop mediumEventLoop = new MediumEventLoop(null, "test", Pauser.balanced(), false, "none");
final BlockingEventLoop blockingEventLoop = new BlockingEventLoop("blocker")) {
Expand Down Expand Up @@ -129,7 +127,7 @@ public void loopFinished() {
long timeoutTime = System.currentTimeMillis() + 500;
while (!exceptionThrownInHandler.get()) {
if (System.currentTimeMillis() > timeoutTime) {
Assertions.fail("Event loop " + el.name() + " didn't " + (eventHandlerFinished.get() ? "throw an exception when attempting to close" : "run in this time"));
fail("Event loop " + el.name() + " didn't " + (eventHandlerFinished.get() ? "throw an exception when attempting to close" : "run in this time"));
}
Jvm.pause(10);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

/**
* Confirms the stable {@code toString} output for each built-in pauser.
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/net/openhft/chronicle/threads/PauserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
* Tests the behaviour of the various {@link Pauser} implementations.
Expand Down
Loading