aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ri/src/test/java
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2020-12-28 10:14:41 +0200
committerRuslan Kashapov <ruslan.kashapov@pantheon.tech>2020-12-28 10:16:27 +0200
commit191b09ce5d3efcb96cc7bf8468ab62626ad62a34 (patch)
treec04c4eda60fe619db1435bb1841ca45d90535659 /cps-ri/src/test/java
parent1d9845679de45007db30eee42c105edcffd972fb (diff)
Fix test container remain in docker after tests completion. IMPORTANT.
Issue-ID: CPS-124 Change-Id: I6e423792c1a63d0f828577ca01d32366d2e693bb Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-ri/src/test/java')
-rw-r--r--cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java6
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();
+ }
}