summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-09-10 16:21:55 +0300
committerIttay Stern <ittay.stern@att.com>2019-09-10 16:23:33 +0300
commit3d70e664f8b3268b6ada46411e5bfabfa303b4ef (patch)
tree8423791a0afd23a8bb96ed3140fc0c4c4c810898
parent3171bdbbf3882ed02d0c4e9807b360035493a197 (diff)
Add investigative mechanics around flaky test serviceWithVrf_resultAsExpected
Change-Id: Ia4bb9d9e15ce769b8fe4be624e93f03ca7b6af69 Issue-ID: VID-378 Signed-off-by: Ittay Stern <ittay.stern@att.com>
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java73
1 files changed, 56 insertions, 17 deletions
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
index 4ece31dfc..a563bd77d 100644
--- a/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/api/ServiceTreeApiTest.java
@@ -1,32 +1,43 @@
package org.onap.vid.api;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
+import static org.apache.commons.text.StringEscapeUtils.escapeJson;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_AIC;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.hvf6;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.olson3;
+import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.defaultPlacement;
+import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
-import org.onap.simulator.presetGenerator.presets.aai.*;
+import java.util.Map;
+import java.util.UUID;
+import org.onap.simulator.presetGenerator.presets.aai.Placement;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudRegionFromVnf;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServiceInstancesByInvariantId;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetVfModulesByVnf;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIModelsByInvariantIdGet;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet;
import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.testng.ITestResult;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.testng.util.RetryAnalyzerCount;
import vid.automation.test.services.SimulatorApi;
-import java.util.UUID;
-
-import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static org.apache.commons.text.StringEscapeUtils.escapeJson;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.*;
-import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet.defaultPlacement;
-import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
-
public class ServiceTreeApiTest extends BaseApiTest {
private static final String API_URL = "/aai_get_service_instance_topology/{subscriberId}/{serviceType}/{serviceInstanceId}";
@@ -384,8 +395,28 @@ public class ServiceTreeApiTest extends BaseApiTest {
assertJsonEquals(response, expected);
}
- @Test
- public void serviceWithVrf_resultAsExpected(){
+ public static class RetryServiceWithVrf extends RetryAnalyzerCount {
+ // For an unknown reason serviceWithVrf_resultAsExpected test is failing sometimes.
+ // This single retry might shed more light on the situation: will it work the 2nd
+ // time, or still fail 2 times in strike?
+
+ public RetryServiceWithVrf() {
+ setCount(2);
+ }
+
+ @Override
+ public boolean retryMethod(ITestResult result) {
+ if (result.isSuccess()) {
+ return false;
+ } else {
+ LOGGER.error(result.getName() + " failed; retrying (" + this.getClass().getCanonicalName() + ")");
+ return true;
+ }
+ }
+ }
+
+ @Test(retryAnalyzer = RetryServiceWithVrf.class)
+ public void serviceWithVrf_resultAsExpected() {
PresetAAIStandardQueryGet vpnBindingPreset =
PresetAAIStandardQueryGet.ofVpn("Active", ImmutableMultimap.of(), "mock-global-1", "mock-role-x", "VPN1260","USA,EMEA");
@@ -434,7 +465,15 @@ public class ServiceTreeApiTest extends BaseApiTest {
final String response = restTemplate.getForObject(buildUri(API_URL), String.class, "global-customer-id", "service-instance-type", "service-instance-id");
- assertJsonEquals(response, expected);
+ try {
+ assertJsonEquals(response, expected);
+ } catch (AssertionError error) {
+ // Logs what happens on simulator's end when error occures
+ final Map<String, Long> recordedSimulatorPaths = SimulatorApi.retrieveRecordedRequestsPathCounter();
+ System.err.println(recordedSimulatorPaths);
+ LOGGER.error(recordedSimulatorPaths);
+ throw error;
+ }
}
private String randUuid() {