Change tests to only use Liquibase for schema 26/142726/1
authordanielhanrahan <daniel.hanrahan@est.tech>
Wed, 10 Dec 2025 18:25:24 +0000 (18:25 +0000)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Wed, 10 Dec 2025 18:25:24 +0000 (18:25 +0000)
Because ddl-auto was set to 'create-drop' in the test config,
Hibernate was overwriting Liquibase's schema. To correct this,
ddl-auto is set to none, and liquibase is set to drop-first.
DirtiesContext is also enabled for any tests using database
to ensure tests do not get stale data.

Issue-ID: POLICY-5333
Change-Id: Ie573c52556c5ba09d8c5f1a1e0d41c7a66c1a767
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/participant/ParticipantControllerTest.java
runtime-acm/src/test/resources/application-test.yaml

index 08d637d..488c4b1 100644 (file)
@@ -60,12 +60,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
 @ActiveProfiles({"test", "default"})
+@DirtiesContext
 class CommissioningControllerTest extends CommonRestController {
 
     private static final int NUMBER_COMPOSITIONS = 10;
index ed60977..7197326 100644 (file)
@@ -56,6 +56,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
@@ -67,6 +68,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @ActiveProfiles({ "test", "default" })
+@DirtiesContext
 class ParticipantControllerTest extends CommonRestController {
     private static final String PARTICIPANTS_ENDPOINT = "participants";
     private static final int NUMBER_RECORDS = 10;
index e3d4a48..e06a3c9 100644 (file)
@@ -7,5 +7,7 @@ spring:
       maximumPoolSize: 3
   jpa:
     hibernate:
-      ddl-auto: create-drop
+      ddl-auto: none
     open-in-view: false
+  liquibase:
+    drop-first: true