diff options
author | sourabh_sourabh <sourabh.sourabh@est.tech> | 2023-01-23 12:51:15 +0000 |
---|---|---|
committer | sourabh_sourabh <sourabh.sourabh@est.tech> | 2023-01-23 16:33:54 +0000 |
commit | 7421c69ac9765cc390c8d50911e354a6c241e243 (patch) | |
tree | 32a3a512576721d6c775465c90fd936953f0d26e /cps-ri/src/test/groovy/org/onap | |
parent | c6bebbcfc4dbef5e91245b5f69714b238c0515af (diff) |
Use native query to delete data nodes
- Used hashcode to remove child fragment based on it's xpath
- Used native query to delete fragment by altering fragment_parent_id_fkey CONSTRAINT.
Issue-ID: CPS-1439
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Change-Id: If19c449818e18f8fd666503b7346704eeb4a95d0
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ri/src/test/groovy/org/onap')
2 files changed, 14 insertions, 11 deletions
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy index 87e59c60dc..5dab87eec4 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy @@ -32,6 +32,7 @@ import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.model.DataNodeBuilder import org.onap.cps.spi.repository.AnchorRepository import org.onap.cps.spi.repository.DataspaceRepository +import org.onap.cps.spi.repository.FragmentNativeRepository import org.onap.cps.spi.repository.FragmentRepository import org.onap.cps.spi.utils.SessionManager import org.onap.cps.utils.JsonObjectMapper @@ -45,8 +46,10 @@ class CpsDataPersistenceServiceSpec extends Specification { def mockFragmentRepository = Mock(FragmentRepository) def jsonObjectMapper = new JsonObjectMapper(new ObjectMapper()) def mockSessionManager = Mock(SessionManager) + def stubFragmentNativeRepository = Stub(FragmentNativeRepository) - def objectUnderTest = Spy(new CpsDataPersistenceServiceImpl(mockDataspaceRepository, mockAnchorRepository, mockFragmentRepository, jsonObjectMapper, mockSessionManager)) + def objectUnderTest = Spy(new CpsDataPersistenceServiceImpl(mockDataspaceRepository, mockAnchorRepository, + mockFragmentRepository, jsonObjectMapper, mockSessionManager, stubFragmentNativeRepository)) def 'Storing data nodes individually when batch operation fails'(){ given: 'two data nodes and supporting repository mock behavior' diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy index 5aae285d7b..4dd4823c95 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsDataPersistenceServiceDeletePerfTest.groovy @@ -61,8 +61,8 @@ class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase } stopWatch.stop() def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 6000 milliseconds' - assert deleteDurationInMillis < 6000 + then: 'delete duration is under 300 milliseconds' + assert deleteDurationInMillis < 300 } def 'Delete 50 grandchildren (that have no descendants)'() { @@ -74,8 +74,8 @@ class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase } stopWatch.stop() def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 500 milliseconds' - assert deleteDurationInMillis < 500 + then: 'delete duration is under 350 milliseconds' + assert deleteDurationInMillis < 350 } def 'Delete 1 large data node with many descendants'() { @@ -84,8 +84,8 @@ class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase objectUnderTest.deleteDataNode(PERF_DATASPACE, PERF_ANCHOR, PERF_TEST_PARENT) stopWatch.stop() def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 2500 milliseconds' - assert deleteDurationInMillis < 2500 + then: 'delete duration is under 250 milliseconds' + assert deleteDurationInMillis < 250 } @Sql([CLEAR_DATA, PERF_TEST_DATA]) @@ -108,8 +108,8 @@ class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase } stopWatch.stop() def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 4000 milliseconds' - assert deleteDurationInMillis < 4000 + then: 'delete duration is under 1000 milliseconds' + assert deleteDurationInMillis < 1000 } def 'Delete 10 list elements with keys'() { @@ -122,8 +122,8 @@ class CpsDataPersistenceServiceDeletePerfTest extends CpsPersistencePerfSpecBase } stopWatch.stop() def deleteDurationInMillis = stopWatch.getTotalTimeMillis() - then: 'delete duration is under 6000 milliseconds' - assert deleteDurationInMillis < 6000 + then: 'delete duration is under 1200 milliseconds' + assert deleteDurationInMillis < 1200 } @Sql([CLEAR_DATA, PERF_TEST_DATA]) |