diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2024-07-03 15:41:40 +0100 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2024-07-03 16:19:01 +0100 |
commit | 5de4f4424f1dd0b422a3682ef905cfd7d71b29d9 (patch) | |
tree | 354e3fd6887995c4e384250fe6e98b6e0de435a9 /integration-test/src | |
parent | 37e328eeaa3e79416e70f348da79cff3ad2e547b (diff) |
Fix sonar issue in performance test ResourceMeter
Replace busy loop with await().until as suggested by sonar
Issue-ID: CPS-89
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Ic6c870c419a67708082ceb05ef3ccba884ae375e
Diffstat (limited to 'integration-test/src')
-rw-r--r-- | integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java b/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java index f8a2ecb4df..46bfcf69e6 100644 --- a/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java +++ b/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation + * Copyright (C) 2023-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ package org.onap.cps.integration; +import static org.awaitility.Awaitility.await; + import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; @@ -71,7 +73,7 @@ public class ResourceMeter { static void performGcAndWait() { final long gcCountBefore = getGcCount(); System.gc(); - while (getGcCount() == gcCountBefore) {} + await().until(() -> getGcCount() > gcCountBefore); } private static long getGcCount() { @@ -94,4 +96,3 @@ public class ResourceMeter { .forEach(MemoryPoolMXBean::resetPeakUsage); } } - |