Fix intermittent test failure of Delta between anchors 77/138777/1
authordanielhanrahan <daniel.hanrahan@est.tech>
Fri, 16 Aug 2024 13:15:23 +0000 (14:15 +0100)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Fri, 16 Aug 2024 13:15:23 +0000 (14:15 +0100)
Test fails sometimes due to non-deterministic order of results.
The issue is fixed by sorting the delta reports.

Issue-ID: CPS-2369
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I60fd459a482a7e3dc209ee3056794817d37f5149

integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy

index b274324..d8395d0 100644 (file)
@@ -459,17 +459,19 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase {
     def 'Get delta between 2 anchors'() {
         when: 'attempt to get delta report between anchors'
             def result = objectUnderTest.getDeltaByDataspaceAndAnchors(FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_ANCHOR_3, BOOKSTORE_ANCHOR_5, '/', OMIT_DESCENDANTS)
+        and: 'report is ordered based on xpath'
+            result = result.toList().sort { it.xpath }
         then: 'delta report contains expected number of changes'
             result.size() == 3
         and: 'delta report contains UPDATE action with expected xpath'
             assert result[0].getAction() == 'update'
             assert result[0].getXpath() == '/bookstore'
-        and: 'delta report contains REMOVE action with expected xpath'
-            assert result[1].getAction() == 'remove'
-            assert result[1].getXpath() == "/bookstore-address[@bookstore-name='Easons-1']"
         and: 'delta report contains ADD action with expected xpath'
-            assert result[2].getAction() == 'add'
-            assert result[2].getXpath() == "/bookstore-address[@bookstore-name='Crossword Bookstores']"
+            assert result[1].getAction() == 'add'
+            assert result[1].getXpath() == "/bookstore-address[@bookstore-name='Crossword Bookstores']"
+        and: 'delta report contains REMOVE action with expected xpath'
+            assert result[2].getAction() == 'remove'
+            assert result[2].getXpath() == "/bookstore-address[@bookstore-name='Easons-1']"
     }
 
     def 'Get delta between 2 anchors returns empty response when #scenario'() {