diff options
7 files changed, 255 insertions, 52 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 8855b51f0..66cdee374 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 @@ -305,15 +305,19 @@ public class AsyncInstantiationBase extends BaseMsoApiTest { final List<String> jobIds = createBulkOfMacroInstances(presets, false, bulkSize, names); Assert.assertEquals(jobIds.size(),bulkSize); + waitForJobsToSuccessfullyCompleted(bulkSize, jobIds); + return jobIds; + } + + public void waitForJobsToSuccessfullyCompleted(int bulkSize, List<String> jobIds) { assertTrue(String.format("Not all services with ids: %s are in state completed after 30 sec", jobIds.stream().collect(joining(","))), Wait.waitFor(y-> serviceListCall().getBody().stream() .filter(si -> jobIds.contains(si.jobId)) - .filter(si -> si.jobStatus==JobStatus.COMPLETED) + .filter(si -> si.jobStatus== JobStatus.COMPLETED) .count() == bulkSize, null, 30, 1 )); - return jobIds; } protected List<JobAuditStatus> getJobMsoAuditStatusForAlaCarte(String jobUUID, String requestId, String serviceInstanceId){ diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java index df3b41d06..2a122119d 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java @@ -1,20 +1,17 @@ package vid.automation.test.test; +import java.util.ArrayList; import org.junit.Assert; import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; import vid.automation.test.infra.Click; import vid.automation.test.infra.Exists; -import vid.automation.test.infra.Get; import vid.automation.test.infra.SelectOption; import vid.automation.test.model.Service; import vid.automation.test.model.ServiceModel; import vid.automation.test.sections.ViewEditPage; -import java.util.ArrayList; -import java.util.List; - public class CreateInstanceDialogBaseTest extends VidBaseTestCase { protected ViewEditPage viewEditPage= new ViewEditPage(); @@ -147,24 +144,4 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { Assert.assertTrue(field + " " + Constants.REQUIRED, byclassAndText); } - protected void cancelPopup() { - viewEditPage.clickCancelButtonByTestID(); - GeneralUIUtils.ultimateWait(); - } - - - - public static void AssertUnselectedOptionInMultiselectById(String multiSelectId, String unselectedOption){ - Click.byId(multiSelectId); - WebElement element = Get.byClassAndText(Constants.MULTI_SELECT_UNSELECTED_CLASS, unselectedOption); - Assert.assertTrue("The option "+ unselectedOption +" is already selected",element != null); - Click.byId(multiSelectId); - } - - public void validateDynamicFields(List<String> dynamicFields) { - for (String field : dynamicFields) { - WebElement fieldElement = GeneralUIUtils.findByText(field); - Assert.assertNotNull("couldn't find dynamic field: " + field, fieldElement); - } - } } diff --git a/vid-automation/src/main/java/vid/automation/test/test/ModernUITestBase.java b/vid-automation/src/main/java/vid/automation/test/test/ModernUITestBase.java new file mode 100644 index 000000000..dd6a0f6b8 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/ModernUITestBase.java @@ -0,0 +1,34 @@ +package vid.automation.test.test; + +import static vid.automation.test.infra.ModelInfo.pasqualeVmxVpeBvService488Annotations; + +import com.google.common.collect.ImmutableList; +import java.util.UUID; +import org.jetbrains.annotations.NotNull; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.sections.ViewEditPage; + +public class ModernUITestBase extends VidBaseTestCase { + + protected ViewEditPage viewEditPage = new ViewEditPage(); + + protected void prepareServicePreset(ModelInfo modelInfo, boolean deploy) { + String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89"; + + if (deploy) { + registerExpectationForServiceDeployment( + ImmutableList.of( + modelInfo, + pasqualeVmxVpeBvService488Annotations + ), + subscriberId, null); + } else { + registerExpectationForServiceBrowseAndDesign(ImmutableList.of(modelInfo), subscriberId); + } + } + + @NotNull + protected String uuid() { + return UUID.randomUUID().toString(); + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java index 68a3cdefe..eb3406f5f 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java @@ -11,6 +11,7 @@ import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOw import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE; import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID; import static org.testng.Assert.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; import static vid.automation.test.infra.Features.FLAG_1902_VNF_GROUPING; import static vid.automation.test.infra.Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI; @@ -28,7 +29,6 @@ import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcomp import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse; import static vid.automation.test.infra.ModelInfo.macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse; import static vid.automation.test.infra.ModelInfo.macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails; -import static vid.automation.test.infra.ModelInfo.pasqualeVmxVpeBvService488Annotations; import static vid.automation.test.infra.ModelInfo.transportWithPnfsService; import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset; @@ -48,13 +48,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.UUID; import java.util.stream.Collectors; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.hamcrest.Matchers; -import org.jetbrains.annotations.NotNull; import org.onap.sdc.ci.tests.datatypes.UserCredentials; import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetL3NetworksByCloudRegionSpecificState; @@ -106,7 +104,7 @@ import vid.automation.test.test.NewServiceInstanceTest.ServiceData.IS_GENERATED_ import vid.automation.test.utils.ReadFile; @FeatureTogglingTest(FLAG_ENABLE_WEBPACK_MODERN_UI) -public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { +public class NewServiceInstanceTest extends ModernUITestBase { public static final String COMPLETED = "COMPLETED"; private static final String IN_PROGRESS = "IN_PROGRESS"; @@ -1384,12 +1382,13 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { } } - @NotNull - private String uuid() { - return UUID.randomUUID().toString(); + public void validateDynamicFields(List<String> dynamicFields) { + for (String field : dynamicFields) { + WebElement fieldElement = GeneralUIUtils.findByText(field); + assertNotNull("couldn't find dynamic field: " + field, fieldElement); + } } - private void assertNotificationAreaVisibilityBehaviourAndSetBulkSize(int size) { WebElement webElement = Get.byId("notification-area"); Assert.assertNull(webElement, "notification area should be invisible if only 1 qty."); @@ -1400,22 +1399,6 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { Assert.assertNotNull(webElement, "notification area should be visible if more then 1 qty."); } - //@Step("prepare service preset") - private void prepareServicePreset(ModelInfo modelInfo, boolean deploy) { - String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89"; - - if (deploy) { - registerExpectationForServiceDeployment( - ImmutableList.of( - modelInfo, - pasqualeVmxVpeBvService488Annotations - ), - subscriberId, null); - } else { - registerExpectationForServiceBrowseAndDesign(ImmutableList.of(modelInfo), subscriberId); - } - } - static class ServiceData { ServiceData(String modelUuid, List<String> dynamicFields, IS_GENERATED_NAMING isServiceGeneratedNaming, diff --git a/vid-automation/src/main/java/vid/automation/test/test/TemplateInstantiationTest.java b/vid-automation/src/main/java/vid/automation/test/test/TemplateInstantiationTest.java new file mode 100644 index 000000000..a540bf0be --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/TemplateInstantiationTest.java @@ -0,0 +1,140 @@ +package vid.automation.test.test; + +import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE; +import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME; +import static org.onap.vid.api.TestUtils.generateRandomAlphaNumeric; +import static vid.automation.test.Constants.BrowseASDC.NewServicePopup.SET_BUTTON; +import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_BUTTON_HEADER; +import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_HEADER_EDIT_ITEM; +import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import java.util.List; +import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceAlacarte; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys; +import org.onap.vid.api.AsyncInstantiationBase; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Input; +import vid.automation.test.infra.ModelInfo; +import vid.automation.test.sections.DrawingBoardPage; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.sections.VidBasePage; +import vid.automation.test.services.AsyncJobsService; + +public class TemplateInstantiationTest extends ModernUITestBase { + + private AsyncInstantiationBase asyncInstantiationBase; + + @BeforeClass + protected void setUp() { + 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 + protected void tearDown() { + AsyncJobsService asyncJobsService = new AsyncJobsService(); + asyncJobsService.muteAllAsyncJobs(); + } + + /* + In this test we create an simple aLaCarte service via api, + Then browse SDC -> search for same model uuid -> deploy -> + template popup is opened -> select the service -> click load template -> + drawing board is opened -> edit service instance name -> deploy -> + instantiation status is opened -> wait for service to completed. + */ + @Test + public void instantiateALaCarteServiceFromTemplateTest() { + + final ModelInfo modelInfo = ModelInfo.aLaCarteServiceCreationNewUI; + String templateInstanceName = "template"+generateRandomAlphaNumeric(10); + String requestorID = getUserCredentials().getUserId(); + String serviceRequestId = uuid(); + String serviceInstanceId = uuid(); + + //prepare presets for first instantiation (template), and rest of scenario till deploy + prepareServicePreset(modelInfo, true); + registerExpectationFromPresets( + ImmutableList.of( + new PresetMSOCreateServiceInstanceAlacarte( + ImmutableMap.of(Keys.SERVICE_NAME, templateInstanceName), + serviceRequestId, serviceInstanceId, + requestorID, modelInfo), + PRESET_SOME_LEGACY_REGION_TO_ATT_AIC, + new PresetMSOOrchestrationRequestGet(COMPLETE, serviceRequestId) + ), + APPEND + ); + + //create service instance via API + final List<String> jobsIds = asyncInstantiationBase.createBulkOfInstances(false, 1, + ImmutableMap.of(SERVICE_NAME, templateInstanceName), "asyncInstantiation/vidRequestCreateALaCarteForTemplate.json"); + asyncInstantiationBase.waitForJobsToSuccessfullyCompleted(1, jobsIds); + + String newInstanceName = "template"+generateRandomAlphaNumeric(10); + String serviceRequestId2 = uuid(); + String serviceInstanceId2 = uuid(); + + //load template and and edit service instance name + browseSdcAndClickDeploy(modelInfo); + selectTemplateByNameAndLoadTemplate(templateInstanceName); + VidBasePage.goToIframe(); + editServiceInstanceName(newInstanceName); + + //prepare presets for second service instance deploy + registerExpectationFromPresets( + ImmutableList.of( + new PresetMSOCreateServiceInstanceAlacarte( + ImmutableMap.of(Keys.SERVICE_NAME, newInstanceName), + serviceRequestId2, serviceInstanceId2, + requestorID, modelInfo), + PRESET_SOME_LEGACY_REGION_TO_ATT_AIC, + new PresetMSOOrchestrationRequestGet(COMPLETE, serviceRequestId2) + ), + CLEAR_THEN_SET + ); + + //deploy the service and wait for completion + Click.byTestId(DEPLOY_BUTTON); + VidBasePage.goToIframe(); + new DrawingBoardPage().verifyServiceCompletedOnTime(newInstanceName, "service deployed from template"); + } + + private void browseSdcAndClickDeploy(ModelInfo modelInfo) { + SideMenu.navigateToBrowseASDCPage(); + GeneralUIUtils.ultimateWait(); + loadTemplatesPopupOnBrowseASDCPage(modelInfo.modelVersionId); + } + + private void selectTemplateByNameAndLoadTemplate(String templateInstanceName) { + Click.byText(templateInstanceName); + Click.byTestId("LoadTemplateButton"); + } + + private void editServiceInstanceName(String newInstanceName) { + GeneralUIUtils.getClickableButtonBy(Get.getXpathForDataTestId(CONTEXT_MENU_BUTTON_HEADER), 60).click(); + Click.byTestId(CONTEXT_MENU_HEADER_EDIT_ITEM); + GeneralUIUtils.ultimateWait(); + Input.replaceText(newInstanceName, "instanceName"); + Click.byTestId(SET_BUTTON); + } + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java index c2733f0fb..fd3dd47a6 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java +++ b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java @@ -523,13 +523,21 @@ public class VidBaseTestCase extends SetupCDTest{ loadServicePopupOnBrowseASDCPage(modelVersionId); } - protected void loadServicePopupOnBrowseASDCPage(String modelVersionId ) { + protected void loadServicePopupOnBrowseASDCPage(String modelVersionId) { + loadServicePopupOnBrowseASDCPage(modelVersionId, "Model version"); + } + + protected void loadTemplatesPopupOnBrowseASDCPage (String modelVersionId) { + loadServicePopupOnBrowseASDCPage(modelVersionId, "Templates"); + } + + protected void loadServicePopupOnBrowseASDCPage(String modelVersionId, String expectedText) { DeployModernUIMacroDialog deployMacroDialog = new DeployModernUIMacroDialog(); VidBasePage.goOutFromIframe(); deployMacroDialog.clickDeployServiceButtonByServiceUUID(modelVersionId); deployMacroDialog.goToIframe(); GeneralUIUtils.ultimateWait(); - Wait.byText("Model version"); + Wait.byText(expectedText); } public void assertSetButtonDisabled(String buttonTestId) { diff --git a/vid-automation/src/main/resources/asyncInstantiation/vidRequestCreateALaCarteForTemplate.json b/vid-automation/src/main/resources/asyncInstantiation/vidRequestCreateALaCarteForTemplate.json new file mode 100644 index 000000000..5b831b937 --- /dev/null +++ b/vid-automation/src/main/resources/asyncInstantiation/vidRequestCreateALaCarteForTemplate.json @@ -0,0 +1,57 @@ +{ + "action": "Create", + "isDirty": true, + "vnfs": {}, + "vrfs": {}, + "instanceParams": [{} + ], + "validationCounter": 0, + "existingNames": { + "alacartewithvnfzvcjg": "" + }, + "existingVNFCounterMap": { + "e9ed1da0-c078-426a-8e84-6f4e85eace59": 0 + }, + "existingVRFCounterMap": {}, + "existingVnfGroupCounterMap": {}, + "existingNetworksCounterMap": {}, + "networks": {}, + "vnfGroups": {}, + "bulkSize": 1, + "instanceName": "SERVICE_NAME", + "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", + "subscriptionServiceType": "TYLER SILVIA", + "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", + "projectName": "WATKINS", + "rollbackOnFailure": true, + "aicZoneName": null, + "owningEntityName": "WayneHolland", + "testApi": "VNF_API", + "tenantName": null, + "modelInfo": { + "modelInvariantId": "d1068db8-b933-4919-8972-8bc1aed366c8", + "modelVersionId": "f3862254-8df2-4a0a-8137-0a9fe985860c", + "modelName": "vOCG_1804_SVC", + "modelVersion": "1.0", + "uuid": "f3862254-8df2-4a0a-8137-0a9fe985860c", + "modelUniqueId": "f3862254-8df2-4a0a-8137-0a9fe985860c" + }, + "isALaCarte": true, + "name": "vOCG_1804_SVC", + "version": "1.0", + "description": "updated HEAT", + "category": "Emanuel", + "uuid": "f3862254-8df2-4a0a-8137-0a9fe985860c", + "invariantUuid": "d1068db8-b933-4919-8972-8bc1aed366c8", + "serviceType": "", + "serviceRole": "", + "vidNotions": { + "instantiationUI": "anyAlacarteWhichNotExcluded", + "modelCategory": "other", + "viewEditUI": "legacy", + "instantiationType": "ALaCarte" + }, + "isEcompGeneratedNaming": true, + "isMultiStepDesign": false, + "subscriberName": "SILVIA ROBBINS" +}
\ No newline at end of file |