aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/org/onap/vid/api
diff options
context:
space:
mode:
Diffstat (limited to 'vid-automation/src/main/java/org/onap/vid/api')
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/AsyncInstantiationBase.java72
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java5
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java2
3 files changed, 49 insertions, 30 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 2a6b012fe..66bde727e 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
@@ -1,34 +1,8 @@
package org.onap.vid.api;
-import static java.lang.Boolean.FALSE;
-import static java.lang.Boolean.TRUE;
-import static java.util.Collections.emptyList;
-import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toMap;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.hasSize;
-import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static vid.automation.test.utils.ExtendedHamcrestMatcher.hasItemsFromCollection;
-
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;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@@ -64,6 +38,33 @@ import vid.automation.test.model.ServiceAction;
import vid.automation.test.services.AsyncJobsService;
import vid.automation.test.services.SimulatorApi;
+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;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+import static java.util.Collections.emptyList;
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toMap;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.hasSize;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import static vid.automation.test.utils.ExtendedHamcrestMatcher.hasItemsFromCollection;
+
public class AsyncInstantiationBase extends BaseMsoApiTest {
public static final String CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF = "asyncInstantiation/vidRequestCreateALaCarteWithVnf.json";
@@ -408,10 +409,12 @@ public class AsyncInstantiationBase extends BaseMsoApiTest {
}
protected void assertExpectedStatusAndServiceInfo(JobStatus finalState, String jobId, ServiceInfo expectedServiceInfo) {
- assertExpectedStatusAndServiceInfo(finalState, jobId, false, expectedServiceInfo);
+ assertExpectedStatusAndServiceInfo(finalState, jobId, PATIENCE_LEVEL.FAIL_FAST, expectedServiceInfo);
}
- protected void assertExpectedStatusAndServiceInfo(JobStatus finalState, String jobId, boolean longWait, ServiceInfo expectedServiceInfo) {
+ enum PATIENCE_LEVEL { FAIL_FAST, FAIL_SLOW, FAIL_VERY_SLOW }
+
+ protected void assertExpectedStatusAndServiceInfo(JobStatus finalState, String jobId, PATIENCE_LEVEL patienceLevel, ServiceInfo expectedServiceInfo) {
JobInfoChecker<Integer> jobInfoChecker = new JobInfoChecker<>(
restTemplate, ImmutableSet.of(JobStatus.PENDING, JobStatus.IN_PROGRESS, finalState), jobId, expectedServiceInfo);
boolean result = jobInfoChecker.test(null);
@@ -421,10 +424,21 @@ public class AsyncInstantiationBase extends BaseMsoApiTest {
if (ImmutableList.of(JobStatus.COMPLETED, JobStatus.PAUSE).contains(finalState) && expectedServiceInfo.serviceInstanceId==null) {
expectedServiceInfo.serviceInstanceId = BaseMSOPreset.DEFAULT_INSTANCE_ID;
}
- result = Wait.waitFor(jobInfoChecker, null, 30, longWait ? 2 : 1);
+ result = Wait.waitFor(jobInfoChecker, null, 30, waitIntervalBy(patienceLevel));
assertTrue("service info of jobId: " + jobId + " was in status: " + jobInfoChecker.lastStatus, result);
}
+ private int waitIntervalBy(PATIENCE_LEVEL patienceLevel) {
+ switch (patienceLevel) {
+ case FAIL_SLOW:
+ return 2;
+ case FAIL_VERY_SLOW:
+ return 3;
+ default:
+ return 1;
+ }
+ }
+
protected List<String> createBulkOfMacroInstances(ImmutableList<BasePreset> presets, boolean isPause, int bulkSize, Map<Keys, String> names) {
SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
return createBulkOfInstances(isPause, bulkSize, names, CREATE_BULK_OF_MACRO_REQUEST);
diff --git a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
index 5b7b1b214..7ce29446c 100644
--- a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
+++ b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
@@ -8,6 +8,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
+//import com.automation.common.report_portal_integration.listeners.ReportPortalListener;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -33,10 +34,12 @@ import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
import vid.automation.test.infra.FeaturesTogglingConfiguration;
import vid.automation.test.services.UsersService;
import vid.automation.test.utils.CookieAndJsonHttpHeadersInterceptor;
+//@Listeners(ReportPortalListener.class)
public class BaseApiTest {
protected static final Logger LOGGER = LogManager.getLogger(BaseApiTest.class);
@@ -63,7 +66,7 @@ public class BaseApiTest {
}
private URI getUri() {
- String host = System.getProperty("VID_HOST", "10.0.0.10");
+ String host = System.getProperty("VID_HOST", "127.0.0.1");
int port = Integer.valueOf(System.getProperty("VID_PORT", "8080"));
return new JerseyUriBuilder().host(host).port(port).scheme("http").path("vid").build();
}
diff --git a/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java b/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java
index 175638008..caece3217 100644
--- a/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java
+++ b/vid-automation/src/main/java/org/onap/vid/api/BaseMsoApiTest.java
@@ -1,5 +1,6 @@
package org.onap.vid.api;
+//import com.automation.common.report_portal_integration.annotations.Step;
import com.google.common.collect.ImmutableMap;
import org.json.JSONException;
import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
@@ -82,6 +83,7 @@ public class BaseMsoApiTest extends BaseApiTest {
}
}
+ //@Step(description = "method: ${method}, uri: ${uri}, body: ${body}")
protected MsoResponseWrapper2 callMsoForResponseWrapper(HttpMethod method, String uri, String body) {
MsoResponseWrapper2 responseWrapper;
switch (method) {