diff options
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java')
-rw-r--r-- | vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java | 182 |
1 files changed, 116 insertions, 66 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java b/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java index 899eed9a1..a3480f8c2 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/InstantiationStatusTest.java @@ -1,42 +1,60 @@ package vid.automation.test.test; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME; +import static org.testng.Assert.assertEquals; +import static org.testng.AssertJUnit.assertTrue; +import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON; +import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; + import com.google.common.collect.ImmutableMap; +import java.util.Collections; import org.junit.Assert; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openqa.selenium.JavascriptExecutor; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames; +import org.onap.vid.api.AsyncInstantiationBase; +import org.onap.vid.api.CreateServiceWithFailedVnf; +import org.onap.vid.api.TestUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; import vid.automation.test.infra.FeatureTogglingTest; +import vid.automation.test.infra.Features; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; +import vid.automation.test.sections.DrawingBoardPage; import vid.automation.test.sections.InstantiationStatusPage; import vid.automation.test.sections.SideMenu; +import vid.automation.test.sections.VidBasePage; import vid.automation.test.services.AsyncJobsService; -import java.util.UUID; - -import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION; -import static vid.automation.test.sections.InstantiationStatusPage.assertInstantiationStatusRow; -import static vid.automation.test.sections.InstantiationStatusPage.getNumberOfTableRows; - @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION) public class InstantiationStatusTest extends VidBaseTestCase { + private final String serviceModelVersion = "5.1"; + private final String regionId = "a93f8383-707e-43fa-8191-a6e69a1aab17"; + final static String owningEntityName = "Lucine Sarika"; + final static String subscriberName = "SILVIA ROBBINS"; + private static final String COMPLETED = "COMPLETED"; + private static final String CREATE_BULK_OF_ALACARTE_REQUEST = "asyncInstantiation/vidRequestCreateALaCarte.json"; + private final VidBasePage vidBasePage = new VidBasePage(); - private final String serviceModelVersion = "1.0"; - private final String subscriberId = "ac040e8a-b43a-441b-ab87-603f5b70be55"; - private final String regionId = "my-expected-region-id"; - private final String projectName = "a-project-name"; - final static String owningEntityName = "expected-owningEntityName"; - final static String subscriberName = "expected-subscriberName"; - - - private String currentUUI; + private AsyncInstantiationBase asyncInstantiationBase; @BeforeClass protected void dropAllAsyncJobs() { AsyncJobsService asyncJobsService = new AsyncJobsService(); asyncJobsService.dropAllAsyncJobs(); + asyncInstantiationBase = new AsyncInstantiationBase(); + asyncInstantiationBase.init(); + UserCredentials userCredentials = getUserCredentials(); + //login for API test (needed besides selenium test via browser) + asyncInstantiationBase.login(userCredentials); } @AfterClass @@ -45,58 +63,21 @@ public class InstantiationStatusTest extends VidBaseTestCase { asyncJobsService.muteAllAsyncJobs(); } - @BeforeMethod - protected void createJobsData() { - addOneJob(); - SideMenu.navigateToMacroInstantiationStatus(); - } - private String addOneJob() { - currentUUI = UUID.randomUUID().toString(); - final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver(); - Object result = javascriptExecutor.executeScript( - "return (function postJob(){var xhttp = new XMLHttpRequest(); " + - " " + - " xhttp.onreadystatechange = function() { " + - " return this.responseText; " + - " }; " + - " " + - " xhttp.open(\"POST\", '/vid/asyncInstantiation/bulk', false); " + - " xhttp.setRequestHeader(\"Content-type\", \"application/json\"); " + - " xhttp.send(`{ " + - " \"modelInfo\": { " + - " \"modelType\": \"service\", " + - " \"modelInvariantId\": \"300adb1e-9b0c-4d52-bfb5-fa5393c4eabb\", " + - " \"modelVersionId\": \"5c9e863f-2716-467b-8799-4a67f378dcaa\", " + - " \"modelName\": \"AIM_TRANSPORT_00004\", " + - " \"modelVersion\": \"" + serviceModelVersion + "\" " + - " }, " + - " \"owningEntityId\" : \"someID\", " + - " \"owningEntityName\": \"" + owningEntityName + "\", " + - " \"projectName\" : \"" + projectName + currentUUI + "\", " + - " \"globalSubscriberId\": \"" + subscriberId + "\", " + - " \"subscriberName\": \"" + subscriberName + "\", " + - " \"productFamilyId\" : \"myProductFamilyId\", " + - " \"instanceName\" : \"MichaelJordan\", " + - " \"subscriptionServiceType\" : \"mySubType\", " + - " \"lcpCloudRegionId\" : \"" + regionId + "\", " + - " \"tenantId\" : \"greatTenant\", " + - " \"bulkSize\": 1, " + - " \"isUserProvidedNaming\": \"true\", " + - " \"vnfs\": {} " + - "} `); " + - " " + - "return JSON.parse(xhttp.responseText).entity;})()" - ); - - return result.toString(); + String serviceName = TestUtils.generateRandomAlphaNumeric(8); + final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = + ImmutableMap.of(SERVICE_NAME, serviceName); + asyncInstantiationBase.createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_REQUEST).get(0); + return serviceName; } @Test public void testServiceInfoIsPresentedInTable() { + String serviceName = addOneJob(); + SideMenu.navigateToMacroInstantiationStatus(); InstantiationStatusPage.clickRefreshButton(); - assertInstantiationStatusRow(projectName + currentUUI, ImmutableMap.of( + InstantiationStatusPage.assertInstantiationStatusRow(serviceName, ImmutableMap.of( "subscriberName", subscriberName, "regionId", regionId, "serviceModelVersion", serviceModelVersion, @@ -104,15 +85,84 @@ public class InstantiationStatusTest extends VidBaseTestCase { )); } - @Test public void testServiceInfoDataUpdatingAfterClickRefresh() { - long numberOfRows = getNumberOfTableRows(60); + addOneJob(); + SideMenu.navigateToMacroInstantiationStatus(); + InstantiationStatusPage.clickRefreshButton(); + long numberOfRows = InstantiationStatusPage.getNumberOfTableRows(60); addOneJob(); InstantiationStatusPage.clickRefreshButton(); - int numberOfRowsAfterRefresh = getNumberOfTableRows(60); + int numberOfRowsAfterRefresh = InstantiationStatusPage.getNumberOfTableRows(60); Assert.assertEquals(numberOfRows + 1 , numberOfRowsAfterRefresh); } + + @Test + @FeatureTogglingTest(Features.FLAG_1902_RETRY_JOB) + public void testRedeployFromDrawingBoardOfServiceWithFailedVnf() { + SideMenu.navigateToMacroInstantiationStatus(); + + CreateServiceWithFailedVnf createServiceWithFailedVnf = createServiceWithFailedVnfAssertStausAndSimulatorRegistration(); + String originalServiceName = createServiceWithFailedVnf.getNames().get(SERVICE_NAME); + + InstantiationStatusPage.clickRefreshButton(); + + //Open job + InstantiationStatusPage.openDrawingBoardForRetry(originalServiceName); + DrawingBoardPage.goToIframe(); + + Wait.waitByTestId("error-msg-wrapper", 10); + boolean isErrorShown = Wait.waitByClassAndText("sub-title", "Attention: You are currently viewing instances from the MSO. 1 of the instances failed, please try again.", 10); + assertTrue(isErrorShown); + + //validate audit info for failed vnf + String originalVnfName = createServiceWithFailedVnf.getNames().get(VNF_NAME); + hoverAndClickMenuByName(originalVnfName, "fe042c22-ba82-43c6-b2f6-8f1fc4164091-vSAMP12 1", Constants.DrawingBoard.CONTEXT_MENU_SHOW_AUDIT); + checkFailedAuditInfoOnRetry(originalVnfName, createServiceWithFailedVnf.getFirstIds().vnfReqId, "Vnf failed."); + + Click.byTestId(DEPLOY_BUTTON); + VidBasePage.goOutFromIframe(); + GeneralUIUtils.ultimateWait(); + vidBasePage.goToIframe(); + GeneralUIUtils.ultimateWait(); + + checkRetryRequestToBeComplete(createServiceWithFailedVnf, originalServiceName); + } + + private void checkFailedAuditInfoOnRetry(String instanceName, String requestId, String message) { + WebElement webElement = Get.byTestId("model-item-value-instance_name"); + assertEquals(webElement.getText(), instanceName, "Instance Name must be equal"); + + WebElement msoTableElement = Get.byId("service-instantiation-audit-info-mso"); + assertEquals(3, msoTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "Audit info MSO table must contain 3 columns"); + assertEquals(requestId, msoTableElement.findElement(By.id("msoRequestId")).getText(), "Audit info Request Id is not equal"); + assertEquals("Failed", msoTableElement.findElement(By.id("msoJobStatus")).getText(), "Audit info Job Status is not equal"); + assertEquals(message, msoTableElement.findElement(By.id("msoAdditionalInfo")).getText(), "Audit info AdditionalInfo is not equal"); + + vidBasePage.screenshotDeployDialog("retry-audit-info-" + instanceName); + Click.byId(Constants.AuditInfoModal.CANCEL_BUTTON); + GeneralUIUtils.ultimateWait(); + } + + private CreateServiceWithFailedVnf createServiceWithFailedVnfAssertStausAndSimulatorRegistration() { + + //CreateServiceWithFailedVnf is common for API test and UI test, + //so if you change it, make sure both test are compatible with your changes + CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(asyncInstantiationBase); + createServiceWithFailedVnf.createServicesWithVnfCompletedWithError(); + createServiceWithFailedVnf.firstTimeAssertion(); + createServiceWithFailedVnf.secondRegistration(); + return createServiceWithFailedVnf; + } + + private void checkRetryRequestToBeComplete(CreateServiceWithFailedVnf createServiceWithFailedVnf, String originalServiceName) { + DrawingBoardPage.ServiceStatusChecker serviceStatusChecker = new DrawingBoardPage.ServiceStatusChecker(originalServiceName, Collections.singleton(COMPLETED)); + //there shall be 2 rows with same service name, one with completed with error and one completed + //so the following line might be buggy, and we need to improve it one day ... + boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 30, 2); + assertTrue("service " + originalServiceName + " wasn't completed after in time", statusIsShown); + createServiceWithFailedVnf.simulatorCallsAssertion(); + } } |