Skip to content

Commit 245d224

Browse files
committed
Add timeout to shutdown
Add timeout to all shutdown calls in test classes. JIRA: LIGHTY-299 Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech> (cherry picked from commit b65dd3d)
1 parent 99d9775 commit 245d224

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lighty-core/lighty-controller-guice-di/src/test/java/io/lighty/core/controller/guice/tests/GuiceDITest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.lighty.core.controller.impl.config.ControllerConfiguration;
1919
import io.lighty.core.controller.impl.util.ControllerConfigUtils;
2020
import java.util.concurrent.ExecutionException;
21+
import java.util.concurrent.TimeUnit;
2122
import org.slf4j.Logger;
2223
import org.slf4j.LoggerFactory;
2324
import org.testng.annotations.AfterClass;
@@ -50,7 +51,7 @@ public void init() throws ExecutionException, InterruptedException, Configuratio
5051
public void shutdown() {
5152
try {
5253
if (lightyController != null) {
53-
lightyController.shutdown().get();
54+
lightyController.shutdown(60, TimeUnit.SECONDS);
5455
}
5556
} catch (Exception e) {
5657
LOG.error("Shutdown of LightyController failed", e);

lighty-core/lighty-controller-spring-di/src/test/java/io/lighty/core/controller/spring/LightyCoreSpringConfigurationTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.lighty.core.controller.impl.util.ControllerConfigUtils;
1919
import java.util.Collections;
2020
import java.util.concurrent.ExecutionException;
21+
import java.util.concurrent.TimeUnit;
2122
import org.junit.jupiter.api.Test;
2223
import org.opendaylight.controller.cluster.ActorSystemProvider;
2324
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
@@ -198,7 +199,7 @@ public LightyController initLightyController() throws LightyLaunchException, Int
198199
public void shutdownLightyController(LightyController lightyController) throws LightyLaunchException {
199200
try {
200201
LOG.info("Shutting down LightyController ...");
201-
lightyController.shutdown().get();
202+
lightyController.shutdown(60, TimeUnit.SECONDS);
202203
} catch (Exception e) {
203204
throw new LightyLaunchException("Could not shutdown LightyController", e);
204205
}

lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/test/java/io/lighty/aaa/ShiroInitializationTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import io.lighty.server.LightyServerBuilder;
1919
import java.net.InetSocketAddress;
2020
import java.util.Optional;
21-
import java.util.concurrent.ExecutionException;
21+
import java.util.concurrent.TimeUnit;
2222
import org.mockito.Mock;
2323
import org.mockito.MockitoAnnotations;
2424
import org.opendaylight.aaa.api.CredentialAuth;
@@ -81,11 +81,11 @@ public void init() {
8181
}
8282

8383
@AfterMethod
84-
public void tearDown() throws ExecutionException, InterruptedException {
84+
public void tearDown() {
8585
if (aaaLighty != null) {
8686
// Stop the object and ensure that stopping was successful
8787
assertTrue(aaaLighty.stopProcedure());
88-
assertTrue(aaaLighty.shutdown().get());
88+
assertTrue(aaaLighty.shutdown(60, TimeUnit.SECONDS));
8989
}
9090
}
9191

0 commit comments

Comments
 (0)