diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2021-01-04 14:21:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-01-04 14:21:44 +0000 |
commit | b41740d115b403e1790ec854c2aacf8b114ea6d0 (patch) | |
tree | 1996fc5c0f1137eb3d21a86949afb2fa7ce8af93 | |
parent | e3b0dc3e73843b3f9a15123911c131dae390690d (diff) | |
parent | 191b09ce5d3efcb96cc7bf8468ab62626ad62a34 (diff) |
Merge "Fix test container remain in docker after tests completion. IMPORTANT."
-rw-r--r-- | cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java b/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java index 759cc95319..a621b2ca4d 100644 --- a/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java +++ b/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java @@ -44,6 +44,7 @@ public class DatabaseTestContainer extends PostgreSQLContainer<DatabaseTestConta public static DatabaseTestContainer getInstance() { if (databaseTestContainer == null) { databaseTestContainer = new DatabaseTestContainer(); + Runtime.getRuntime().addShutdownHook(new Thread(databaseTestContainer::terminate)); } return databaseTestContainer; } @@ -58,7 +59,10 @@ public class DatabaseTestContainer extends PostgreSQLContainer<DatabaseTestConta @Override public void stop() { - //do nothing, JVM handles shut down + // do nothing on test completion, image removal will be performed via terminate() on JVM shutdown } + private void terminate() { + super.stop(); + } } |