Skip to content

Commit

Permalink
Add timeout to shutdown
Browse files Browse the repository at this point in the history
Add timeout to all shutdown calls in test classes.

JIRA: LIGHTY-299
Signed-off-by: Ivan Hrasko <[email protected]>
  • Loading branch information
ihrasko committed Oct 31, 2024
1 parent a80868f commit 12196cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.lighty.core.controller.impl.config.ControllerConfiguration;
import io.lighty.core.controller.impl.util.ControllerConfigUtils;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -50,7 +51,7 @@ public void init() throws ExecutionException, InterruptedException, Configuratio
public void shutdown() {
try {
if (lightyController != null) {
lightyController.shutdown().get();
lightyController.shutdown(60, TimeUnit.SECONDS);
}
} catch (Exception e) {
LOG.error("Shutdown of LightyController failed", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.lighty.core.controller.impl.util.ControllerConfigUtils;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
Expand Down Expand Up @@ -198,7 +199,7 @@ public LightyController initLightyController() throws LightyLaunchException, Int
public void shutdownLightyController(LightyController lightyController) throws LightyLaunchException {
try {
LOG.info("Shutting down LightyController ...");
lightyController.shutdown().get();
lightyController.shutdown(60, TimeUnit.SECONDS);
} catch (Exception e) {
throw new LightyLaunchException("Could not shutdown LightyController", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.lighty.server.LightyServerBuilder;
import java.net.InetSocketAddress;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.aaa.api.CredentialAuth;
Expand Down Expand Up @@ -81,11 +81,11 @@ public void init() {
}

@AfterMethod
public void tearDown() throws ExecutionException, InterruptedException {
public void tearDown() {
if (aaaLighty != null) {
// Stop the object and ensure that stopping was successful
assertTrue(aaaLighty.stopProcedure());
assertTrue(aaaLighty.shutdown().get());
assertTrue(aaaLighty.shutdown(60, TimeUnit.SECONDS));
}
}

Expand Down

0 comments on commit 12196cf

Please sign in to comment.