Merge "Part 1: Refactor CPS Delta code to utility class"
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / performance / cps / ModuleQueryPerfTest.groovy
index 6efebd4..44bf812 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
 package org.onap.cps.integration.performance.cps
 
 import org.onap.cps.integration.performance.base.CpsPerfTestBase
-import org.onap.cps.spi.model.ModuleReference
+import org.onap.cps.api.model.ModuleReference
 
 class ModuleQueryPerfTest extends CpsPerfTestBase {
 
@@ -70,10 +70,7 @@ class ModuleQueryPerfTest extends CpsPerfTestBase {
             }
             resourceMeter.stop()
         then: 'operation takes less than expected duration'
-            recordAndAssertResourceUsage('Module query test setup',
-                    45, resourceMeter.totalTimeInSeconds,
-                    500, resourceMeter.totalMemoryUsageInMB
-            )
+            recordAndAssertResourceUsage('CPS:Module query test setup', 150, resourceMeter.totalTimeInSeconds, resourceMeter.totalMemoryUsageInMB)
     }
 
     def 'Querying anchors by module name is NOT dependant on the file size of the module.'() {
@@ -84,13 +81,11 @@ class ModuleQueryPerfTest extends CpsPerfTestBase {
         then: 'expected number of anchors is returned'
             assert result.size() == TOTAL_TEST_ANCHORS
         and: 'operation completes with expected resource usage'
-            recordAndAssertResourceUsage("Query for anchors with ${scenario}",
-                    expectedTimeInSeconds, resourceMeter.totalTimeInSeconds,
-                    150, resourceMeter.totalMemoryUsageInMB)
+            recordAndAssertResourceUsage("CPS:Query for anchors with ${scenario}", 0.1, resourceMeter.totalTimeInSeconds, resourceMeter.totalMemoryUsageInMB, REFERENCE_GRAPH)
         where: 'the following parameters are used'
-            scenario         | yangModuleName || expectedTimeInSeconds
-            '1 KB module'    | 'module0'      || 3
-            '1000 KB module' | 'module1'      || 3
+            scenario         | yangModuleName
+            '1 KB module'    | 'module0'
+            '1000 KB module' | 'module1'
     }
 
     def 'Module query - Clean up test data.'() {
@@ -100,6 +95,7 @@ class ModuleQueryPerfTest extends CpsPerfTestBase {
                 cpsModuleService.deleteSchemaSetsWithCascade(CPS_PERFORMANCE_TEST_DATASPACE, (i..i+100).collect {SCHEMA_SET_PREFIX + it})
             }
             cpsModuleService.deleteSchemaSetsWithCascade(CPS_PERFORMANCE_TEST_DATASPACE, [SCHEMA_SET_PREFIX + '0'])
+            cpsModuleService.deleteAllUnusedYangModuleData(CPS_PERFORMANCE_TEST_DATASPACE)
     }
 
     // This makes a Yang module of approximately target length in bytes by padding the description field with many '*'