aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2020-03-23 07:24:50 +0200
committerIttay Stern <ittay.stern@att.com>2020-03-23 05:27:20 +0000
commit9c411472a8aa8a218665d258f52c3d436ee9b58e (patch)
tree410ebaffb7e050d212060f88598f71f1c12170a6 /vid-automation/src/main
parentefefd95854efb51333dc36abe7bb33fca4d04e90 (diff)
Add some timed grace for assertion on log-lines
It happens that logging is delayed, and rows are not available on disk right after an inspected event. Issue-ID: VID-647 Change-Id: Ic47cb2beff0be699f018ff6b5f264a57479bd7d0 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-automation/src/main')
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java18
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/TestUtils.java20
2 files changed, 21 insertions, 17 deletions
diff --git a/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java b/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java
index ee3982c19..f4dd6780a 100644
--- a/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java
+++ b/vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java
@@ -17,13 +17,10 @@ import static vid.automation.test.utils.ExtendedHamcrestMatcher.hasItemsFromColl
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -199,20 +196,7 @@ public class AsyncInstantiationBase extends BaseMsoApiTest {
}
protected void assertAndRetryIfNeeded(Runnable asserter, long timeoutInSeconds) {
- final Instant expiry = Instant.now().plusSeconds(timeoutInSeconds);
- while (true) {
- try {
- asserter.run();
- break; // we're cool, assertion passed
- } catch (AssertionError fail) {
- Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
- if (Instant.now().isAfter(expiry)) {
- throw fail;
- } else {
- System.out.println("retrying after: " + fail);
- }
- }
- }
+ TestUtils.assertAndRetryIfNeeded(timeoutInSeconds, asserter);
}
protected ImmutableList<JobAuditStatus> vidAuditStatusesCompletedWithErrors(String jobId) {
diff --git a/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java b/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java
index cc292caa7..af3cc57b9 100644
--- a/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java
+++ b/vid-automation/src/main/java/org/onap/vid/api/TestUtils.java
@@ -11,10 +11,13 @@ import static vid.automation.test.utils.RegExMatcher.matchesRegEx;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import com.google.common.util.concurrent.Uninterruptibles;
import java.io.IOException;
import java.io.InputStream;
+import java.time.Instant;
import java.util.Map;
import java.util.Scanner;
+import java.util.concurrent.TimeUnit;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import org.apache.commons.text.RandomStringGenerator;
@@ -99,6 +102,23 @@ public class TestUtils {
return generator.generate(length);
}
+ public static void assertAndRetryIfNeeded(long timeoutInSeconds, Runnable asserter) {
+ final Instant expiry = Instant.now().plusSeconds(timeoutInSeconds);
+ while (true) {
+ try {
+ asserter.run();
+ break; // we're cool, assertion passed
+ } catch (AssertionError fail) {
+ Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
+ if (Instant.now().isAfter(expiry)) {
+ throw fail;
+ } else {
+ System.out.println("retrying after: " + fail);
+ }
+ }
+ }
+ }
+
@DataProvider
public static Object[][] trueAndFalse() {
return new Object[][]{{true}, {false}};