Adjust performance test timings
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / performance / cps / WritePerfTest.groovy
index 419ec60..0c7107a 100644 (file)
@@ -31,24 +31,21 @@ class WritePerfTest extends CpsPerfTestBase {
         and: 'a list of device nodes to add'
             def jsonData = generateOpenRoadData(totalNodes)
         when: 'device nodes are added'
-            stopWatch.start()
+            resourceMeter.start()
             cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', jsonData, OffsetDateTime.now())
-            stopWatch.stop()
-            def durationInMillis = stopWatch.getTotalTimeMillis()
-        then: 'the operation takes less than #expectedDuration'
-            recordAndAssertPerformance("Writing ${totalNodes} devices", expectedDuration, durationInMillis)
+            resourceMeter.stop()
+            def durationInSeconds = resourceMeter.getTotalTimeInSeconds()
+        then: 'the operation takes less than #expectedDuration and memory used is within limit'
+            recordAndAssertResourceUsage("Writing ${totalNodes} devices", expectedDuration, durationInSeconds, memoryLimit, resourceMeter.getTotalMemoryUsageInMB())
         cleanup:
             cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', OffsetDateTime.now())
             cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor')
         where:
-            totalNodes || expectedDuration
-            50         ||   2_500
-            100        ||   4_000
-            200        ||   8_000
-            400        ||  16_000
-//          800        ||  32_000
-//          1600       ||  64_000
-//          3200       || 128_000
+            totalNodes || expectedDuration | memoryLimit
+            50         || 4                | 100
+            100        || 7                | 200
+            200        || 14               | 400
+            400        || 28               | 500
     }
 
     def 'Writing bookstore data has exponential time.'() {
@@ -59,25 +56,21 @@ class WritePerfTest extends CpsPerfTestBase {
         and: 'a list of books to add'
             def booksData = '{"books":[' + (1..totalBooks).collect {'{ "title": "' + it + '" }' }.join(',') + ']}'
         when: 'books are added'
-            stopWatch.start()
+            resourceMeter.start()
             cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', '/bookstore/categories[@code=1]', booksData, OffsetDateTime.now())
-            stopWatch.stop()
-            def durationInMillis = stopWatch.getTotalTimeMillis()
-        then: 'the operation takes less than #expectedDuration'
-            recordAndAssertPerformance("Writing ${totalBooks} books", expectedDuration, durationInMillis)
+            resourceMeter.stop()
+            def durationInSeconds = resourceMeter.getTotalTimeInSeconds()
+        then: 'the operation takes less than #expectedDuration and memory used is within limit'
+            recordAndAssertResourceUsage("Writing ${totalBooks} books", expectedDuration, durationInSeconds, memoryLimit, resourceMeter.getTotalMemoryUsageInMB())
         cleanup:
             cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', OffsetDateTime.now())
             cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor')
         where:
-            totalBooks || expectedDuration
-            400        ||     200
-            800        ||     500
-            1600       ||   1_000
-            3200       ||   2_500
-            6400       ||  10_000
-//          12800      ||  30_000
-//          25600      || 120_000
-//          51200      || 600_000
+            totalBooks || expectedDuration | memoryLimit
+            800        || 1                | 50
+            1600       || 2                | 100
+            3200       || 6                | 150
+            6400       || 18               | 200
     }
 
 }