diff options
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute')
25 files changed, 1590 insertions, 590 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java index 0e09059b28..e4423dd7d0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java @@ -48,7 +48,6 @@ import org.openecomp.sdc.ci.tests.verificator.UserManagementVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -98,6 +97,7 @@ public class AdminUserManagment extends SetupCDTest { UserRoleEnum userRole = UserRoleEnum.DESIGNER; AdminWorkspaceUIUtilies.createNewUser(userId, userRole); ExtentTestActions.log(Status.INFO, "Trying to create the same user once again."); + GeneralUIUtils.ultimateWait(); // extra wait, necessary for system with large user list AdminWorkspaceUIUtilies.createNewUser(userId, userRole); ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.USER_ALREADY_EXIST); } @@ -106,9 +106,9 @@ public class AdminUserManagment extends SetupCDTest { @Test public void createInvalidMacIdTest(){ - if(true){ - throw new SkipException("Open bug 324032"); - } +// if(true){ +// throw new SkipException("Open bug 324032"); +// } String macId = generateValidMacId(); StringBuilder invalidMacId = new StringBuilder(macId); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java index 1af68d9364..38a71f4a20 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java @@ -41,7 +41,6 @@ import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.verificator.DeploymentViewVerificator; import org.openqa.selenium.WebElement; -import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -59,7 +58,7 @@ public class DeploymentViewTests extends SetupCDTest { @DataProvider(name = "CSAR_VF_Files", parallel = false) public Object[][] createDataX() { - return new Object[][] { { "vSeGWdoubleMembers.csar" }, { "vSeGW.csar" }, {"vSeGWsingleModule.csar"}}; + return new Object[][] {{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}}; } @@ -76,7 +75,7 @@ public class DeploymentViewTests extends SetupCDTest { List<WebElement> moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); DeploymentViewVerificator verificator = new DeploymentViewVerificator(filePath + baseFileName); verificator.verifyDeploymentPageModules(moduleRowsFromTable); - for(WebElement moduleRow :moduleRowsFromTable){ + for(WebElement moduleRow : moduleRowsFromTable){ String moduleRowText = moduleRow.getText(); verificator.verifyDeploymentPageSubElements(moduleRowText.split("\\.\\.")[1]); DeploymentPage.updateModuleName(moduleRowText, "updatedName"); @@ -89,8 +88,8 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception{ - String baseFileName = "baseUpdateMinusGroupFlowVF.csar"; - String updateFileName = "baseUpdateFlowVF.csar"; + String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + String updateFileName = "baseUpdateFlowVF_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); @@ -111,8 +110,8 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception{ - String baseFileName = "baseUpdateFlowVF.csar"; - String updateFileName = "baseUpdateMinusGroupFlowVF.csar"; + String baseFileName = "baseUpdateFlowVF_NEW.csar"; + String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 3)); @@ -145,9 +144,9 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception{ - String baseFileName = "baseUpdateMinusGroupFlowVF.csar"; - String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow.csar"; - String updateFileName2 = "baseUpdateFlowVF.csar"; + String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar"; + String updateFileName2 = "baseUpdateFlowVF_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); @@ -167,10 +166,6 @@ public class DeploymentViewTests extends SetupCDTest { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group with members", 3)); ResourceUIUtils.updateVfWithCsar(filePath, updateFileName2); - if(true){ - throw new SkipException("Open bug 305812"); - } - // validate that member was added to base_ldsa group DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2)); DeploymentViewVerificator.validateModuleNameUpadate(); @@ -178,7 +173,7 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup.csar"; + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3)); @@ -190,8 +185,8 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup.csar"; - String updateFileName = "baseUpdateFlowOneArtifactToGroup.csar"; + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3)); @@ -203,10 +198,6 @@ public class DeploymentViewTests extends SetupCDTest { // remove artifact from every group SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 3 artifacts in every group")); ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - if(true){ - throw new SkipException("Open bug 306329"); - } DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); DeploymentViewVerificator.validateModuleNameUpadate(); @@ -214,8 +205,8 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup.csar"; - String updateFileName = "baseUpdateFlowOneArtifactToGroup.csar"; + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 3 artifacts in every group ", 3)); @@ -227,10 +218,6 @@ public class DeploymentViewTests extends SetupCDTest { // add artifact to every group SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 4 artifacts in every group")); ResourceUIUtils.updateVfWithCsar(filePath, baseFileName); - - if(true){ - throw new SkipException("Open bug 306005"); - } DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName)); DeploymentViewVerificator.validateModuleNameUpadate(); @@ -238,8 +225,8 @@ public class DeploymentViewTests extends SetupCDTest { @Test public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup.csar"; - String updateFileName = "baseUpdateMixedArtifacts.csar"; + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + String updateFileName = "baseUpdateMixedArtifacts_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3)); @@ -252,18 +239,14 @@ public class DeploymentViewTests extends SetupCDTest { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, mixing between artifacts and groups", 3)); ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - if(true){ - throw new SkipException("Open bug 306005"); - } - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator()); DeploymentViewVerificator.validateModuleNameUpadate(); }; @Test public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception{ - String baseFileName = "baseUpdateMinusGroupFlowVF.csar"; - String updateFileName = "baseUpdateFlowVF.csar"; + String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + String updateFileName = "baseUpdateFlowVF_NEW.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java index a26919ae2a..cf510578ef 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java @@ -71,7 +71,6 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -93,7 +92,7 @@ public class ImportDCAE extends SetupCDTest { // update Resource ResourceReqDetails updatedResource = new ResourceReqDetails(); - updatedResource.setName("ciUpdatedNameImportDCAE"); + updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName()); updatedResource.setDescription("kuku"); updatedResource.setVendorName("updatedVendor"); updatedResource.setVendorRelease("updatedRelease"); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java index fca568794b..273a502895 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java @@ -53,10 +53,10 @@ import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; +import org.openecomp.sdc.ci.tests.verificator.PropertyVerificator; import org.openecomp.sdc.ci.tests.verificator.VFCverificator; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -234,6 +234,37 @@ public class ImportVFCAsset extends SetupCDTest { } + @Test + public void updateAfterCheckoutNewSimplePropertiesVFCTest() throws Exception{ + String fileName = "importVFC_VFC16.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT); + int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); + for (PropertyTypeEnum prop : propertyList){ + PropertiesUIUtils.addNewProperty(prop); + } + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + + for (PropertyTypeEnum prop : propertyList){ + PropertiesUIUtils.updateProperty(prop); + } + assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); + + for (PropertyTypeEnum prop : propertyList){ + PropertiesPage.clickOnProperty(prop.getName()); + PropertyVerificator.validateEditVFCPropertiesPopoverFields(prop); + PropertiesPage.getPropertyPopup().clickCancel(); + } + + } + @Test(dataProvider = "assetFiles") public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception{ @@ -285,12 +316,7 @@ public class ImportVFCAsset extends SetupCDTest { } @Test - public void activityLogVFCTest() throws Exception{ - - if(true){ - throw new SkipException("Open bug 291623"); - } - + public void activityLogVFCTest() throws Exception{ String fileName = "importVFC_VFC11.yml"; atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java index e6d1177425..7681af63c3 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java @@ -28,7 +28,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,6 +37,7 @@ import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.ArtifactsCorrelationManager; @@ -53,14 +53,14 @@ import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; import org.openqa.selenium.WebElement; import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -70,7 +70,7 @@ import com.clearspring.analytics.util.Pair; public class Onboard extends SetupCDTest { - protected static String filepath = FileHandling.getVnfRepositoryPath(); + protected static String filePath = FileHandling.getVnfRepositoryPath(); protected String makeDistributionValue; @Parameters({ "makeDistribution" }) @@ -80,19 +80,35 @@ public class Onboard extends SetupCDTest { } @Test + public void onboardVNFTestSanityOneFile() throws Exception, Throwable { +// List<String> fileNamesFromFolder = OnboardingUiUtils.getVnfNamesFileList(); +// String vnfFile = fileNamesFromFolder.get(0).toString(); + String vnfFile = "2017-302_vNSO.zip"; +// String vnfFile = "1-Fn-vprobe-be-11-2-5-1-vf-(MOBILITY)_v5.0.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); + } + + @Test public void onboardVNFTestSanity() throws Exception, Throwable { List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); String vnfFile = fileNamesFromFolder.get(0).toString(); - runOnboardToDistributionFlow(filepath, vnfFile); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); } - public void runOnboardToDistributionFlow(String filepath, String vnfFile) throws Exception, AWTException { - String vspName = onboardAndCertify(filepath, vnfFile); + public void runOnboardToDistributionFlow(ResourceReqDetails resourceReqDetails, ServiceReqDetails serviceMetadata, String filePath, String vnfFile) throws Exception, AWTException { + getExtendTest().log(Status.INFO, "Going to create resource with category: " + resourceReqDetails.getCategories().get(0).getName() + + " subCategory: " + resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName() + + " and service category: " + serviceMetadata.getCategory()); + String vspName = onboardAndCertify(resourceReqDetails, filePath, vnfFile); reloginWithNewRole(UserRoleEnum.DESIGNER); // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); +// ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ServiceUIUtils.createService(serviceMetadata, getUser()); ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); @@ -135,8 +151,8 @@ public class Onboard extends SetupCDTest { getExtendTest().log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile)); } - public String onboardAndCertify(String filepath, String vnfFile) throws Exception, IOException { - Pair<String,Map<String,String>> onboardAndValidate = OnboardingUtils.onboardAndValidate(filepath, vnfFile, getUser()); + public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception, IOException { + Pair<String,Map<String,String>> onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); String vspName = onboardAndValidate.left; DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen(); @@ -152,36 +168,41 @@ public class Onboard extends SetupCDTest { @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") - public void onboardVNFTest(String filepath, String vnfFile) throws Exception, Throwable { + public void onboardVNFTest(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); System.out.println("printttttttttttttt - >" + makeDistributionValue); - runOnboardToDistributionFlow(filepath, vnfFile); + ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource(); + ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService(); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); } @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") - public void onboardVNFShotFlow(String filepath, String vnfFile) throws Exception, Throwable { + public void onboardVNFShotFlow(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); System.out.println("printttttttttttttt - >" + makeDistributionValue); - onboardAndCertify(filepath, vnfFile); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + onboardAndCertify(resourceReqDetails, filePath, vnfFile); } @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") - public void onboardRandomVNFsTest(String filepath, String vnfFile) throws Exception, Throwable { + public void onboardRandomVNFsTest(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); System.out.println("printttttttttttttt - >" + makeDistributionValue); System.out.println("Vnf File name is: " + vnfFile); - runOnboardToDistributionFlow(filepath, vnfFile); + ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource(); + ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService(); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); } @Test public void onboardUpdateVNFTest() throws Exception, Throwable { -// Object[] fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); - List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); +// Object[] fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath); + List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath); // String vnfFile = fileNamesFromFolder[0].toString(); String vnfFile = fileNamesFromFolder.get(0); - - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(filepath, vnfFile, getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); String vspName = vsp.left; ResourceGeneralPage.clickSubmitForTestingButton(vspName); @@ -209,7 +230,7 @@ public class Onboard extends SetupCDTest { getExtendTest().log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile)); // update VendorSoftwareProduct - OnboardingUtils.updateVnfAndValidate(filepath, vsp, updatedVnfFile, getUser()); + OnboardingUiUtils.updateVnfAndValidate(filePath, vsp, updatedVnfFile, getUser()); ResourceGeneralPage.clickSubmitForTestingButton(vspName); @@ -257,9 +278,10 @@ public class Onboard extends SetupCDTest { @Test public void threeVMMSCsInServiceTest() throws Exception{ - + + String pathFile = FileHandling.getFilePath("VmmscArtifacts"); List<String> vmmscList = new ArrayList<String>(); - vmmscList = Arrays.asList(new File(filepath).list()).stream().filter(e -> e.contains("vmmsc") && e.endsWith(".zip")).collect(Collectors.toList()); + vmmscList = Arrays.asList(new File(pathFile).list()).stream().filter(e -> e.contains("vmmsc") && e.endsWith(".zip")).collect(Collectors.toList()); assertTrue("Did not find vMMSCs", vmmscList.size() > 0); Map<String, String> vspNames = new HashMap<String, String>(); @@ -267,16 +289,17 @@ public class Onboard extends SetupCDTest { getExtendTest().log(Status.INFO, String.format("Going to onboard the VNF %s......", vnfFile)); System.out.println(String.format("Going to onboard the VNF %s......", vnfFile)); - AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(getUser()); - Pair<String,Map<String,String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(vnfFile, filepath, getUser(), amdocsLicenseMembers); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, pathFile, getUser(), amdocsLicenseMembers); getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile)); HomePage.showVspRepository(); getExtendTest().log(Status.INFO,String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf(".")))); - OnboardingUtils.importVSP(createVendorSoftwareProduct); + OnboardingUiUtils.importVSP(createVendorSoftwareProduct); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); + DeploymentArtifactPage.verifyArtifactsExistInTable(pathFile, vnfFile); String vspName = createVendorSoftwareProduct.left; DeploymentArtifactPage.clickSubmitForTestingButton(vspName); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java index f32709e219..6cea8d6c6f 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java @@ -20,16 +20,12 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; import java.awt.AWTException; -import java.io.File; import java.sql.Timestamp; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.UUID; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; @@ -38,16 +34,16 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utilities.FileHandling; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtillViaApis; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -58,6 +54,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import fj.data.Either; + public class OnboardViaApis{ @@ -79,23 +76,11 @@ public class OnboardViaApis{ // resourceDetails = ElementFactory.getDefaultResource(); } - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") public void onboardVNFTestViaApis(String filepath, String vnfFile) throws Exception, Throwable { - Service service = null; - String fullFileName = FULL_PATH + vnfFile + ".csar"; - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Starting test with VNF: " + vnfFile); - service = runOnboardViaApisOnly(filepath, vnfFile); - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Finished test with VNF: " + vnfFile); - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Starting download service csar file: " + vnfFile); - File file = new File(fullFileName); - OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, file); - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Finished download service csar file: " + vnfFile); - System.out.println("end"); - + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Service service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); } @@ -105,148 +90,83 @@ public class OnboardViaApis{ List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); String vnfFile = fileNamesFromFolder.get(7); System.err.println(timestamp + " Starting test with VNF: " + vnfFile); - service = runOnboardViaApisOnly(filepath, vnfFile); - -// AtomicOperationUtils.getServiceObjectByNameAndVersion(sdncModifierDetails, serviceName, serviceVersion); -// RestResponse distributeService = AtomicOperationUtils.distributeService(service, true); -// Map<Long, ServiceDistributionStatus> convertServiceDistributionStatusToObject = ResponseParser.convertServiceDistributionStatusToObject(distributeService.getResponse()); -// convertServiceDistributionStatusToObject. + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); } - - - - public Service runOnboardViaApisOnly(String filepath, String vnfFile) throws Exception, AWTException { - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Starting onboard VNF: " + vnfFile); - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(filepath, vnfFile, sdncDesignerDetails1); - String vspName = createVendorSoftwareProduct.left; - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Finished onboard VNF: " + vnfFile); - ResourceReqDetails resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(vendorSoftwareProductObject, vspName); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, vspName); - - AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true); - resource = AtomicOperationUtils.getResourceObject(resource.getUniqueId()); - // create service - - Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); - Either<ComponentInstance,RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") + public void updateVSPFullScenario(String filepath, String vnfFile) throws Exception + { + //CREATE DATA REQUIRED FOR TEST + boolean skipReport = true; + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); +// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - return service; - } - - - - - - - - public static Pair<String, Map<String, String>> createVendorSoftwareProduct(String HeatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) - throws Exception { - Pair<String, Map<String, String>> pair = createVSP(HeatFileName, filepath, user, amdocsLicenseMembers); - - String vspid = pair.right.get("vspId"); - - prepareVspForUse(user, vspid); - - return pair; + // TEST START + + // Update exist VLM Version (From 1.0 to 2.0) + OnboardingUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails1, "1.0"); + // Set VLM version to 2.0 in VLM Meta data object + amdocsLicenseMembers.setLicenseVersionId("2.0"); + amdocsLicenseMembers.setLicenseVersionLabel("2.0"); + OnboardingUtils.validateVlmExist(amdocsLicenseMembers.getVendorId(), amdocsLicenseMembers.getLicenseVersionId(), sdncDesignerDetails1); + + // Update the VSP With the VLM new version and submit the VSP + vendorSoftwareProductObject = OnboardingUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1, "1.1", "2.0"); + OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(), sdncDesignerDetails1); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + System.out.println(distributeAndValidateService); } - - public static void prepareVspForUse(User user, String vspid) throws Exception { - RestResponse checkin = OnboardingUtils.checkinVendorSoftwareProduct(vspid, user); - assertEquals("did not succeed to checking new VSP", 200, checkin.getErrorCode().intValue()); - - RestResponse submit = OnboardingUtils.submitVendorSoftwareProduct(vspid, user); - assertEquals("did not succeed to submit new VSP", 200, submit.getErrorCode().intValue()); - - RestResponse createPackage = OnboardingUtils.createPackageOfVendorSoftwareProduct(vspid, user); - assertEquals("did not succeed to create package of new VSP ", 200, createPackage.getErrorCode().intValue()); + public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair<String, Map<String, String>> createVendorSoftwareProduct) { + VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); + Map<String, String> map = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setAttContact(map.get("attContact")); + vendorSoftwareProductObject.setCategory(map.get("category")); + vendorSoftwareProductObject.setComponentId(map.get("componentId")); + vendorSoftwareProductObject.setDescription(map.get("description")); + vendorSoftwareProductObject.setSubCategory(map.get("subCategory")); + vendorSoftwareProductObject.setVendorName(map.get("vendorName")); + vendorSoftwareProductObject.setVspId(map.get("vspId")); + vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); + String[] arrFileNameAndExtension = vnfFile.split("\\."); + vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage"); + vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]); + vendorSoftwareProductObject.setOnboardingOrigin(arrFileNameAndExtension[1]); + + return vendorSoftwareProductObject; } - public static AmdocsLicenseMembers createVendorLicense(User user) throws Exception { - - AmdocsLicenseMembers amdocsLicenseMembers; - String vendorLicenseName = "ciLicense" + UUID.randomUUID().toString().split("-")[0]; - RestResponse vendorLicenseResponse = OnboardingUtils.createVendorLicenseModels_1(vendorLicenseName, user); - assertEquals("did not succeed to create vendor license model", 200, vendorLicenseResponse.getErrorCode().intValue()); - String vendorId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), "value"); - - RestResponse vendorKeyGroupsResponse = OnboardingUtils.createVendorKeyGroups_2(vendorId, user); - assertEquals("did not succeed to create vendor key groups", 200, vendorKeyGroupsResponse.getErrorCode().intValue()); - String keyGroupId = ResponseParser.getValueFromJsonResponse(vendorKeyGroupsResponse.getResponse(), "value"); - - RestResponse vendorEntitlementPool = OnboardingUtils.createVendorEntitlementPool_3(vendorId, user); - assertEquals("did not succeed to create vendor entitlement pool", 200, vendorEntitlementPool.getErrorCode().intValue()); - String entitlementPoolId = ResponseParser.getValueFromJsonResponse(vendorEntitlementPool.getResponse(), "value"); - - RestResponse vendorLicenseFeatureGroups = OnboardingUtils.createVendorLicenseFeatureGroups_4(vendorId, keyGroupId, entitlementPoolId, user); - assertEquals("did not succeed to create vendor license feature groups", 200, vendorLicenseFeatureGroups.getErrorCode().intValue()); - String featureGroupId = ResponseParser.getValueFromJsonResponse(vendorLicenseFeatureGroups.getResponse(), "value"); - RestResponse vendorLicenseAgreement = OnboardingUtils.createVendorLicenseAgreement_5(vendorId, featureGroupId, user); - assertEquals("did not succeed to create vendor license agreement", 200, vendorLicenseAgreement.getErrorCode().intValue()); - String vendorLicenseAgreementId = ResponseParser.getValueFromJsonResponse(vendorLicenseAgreement.getResponse(), "value"); + public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception, AWTException { - RestResponse checkinVendorLicense = OnboardingUtils.checkinVendorLicense(vendorId, user); - assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue()); - - RestResponse submitVendorLicense = OnboardingUtils.submitVendorLicense(vendorId, user); - assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue()); - - amdocsLicenseMembers = new AmdocsLicenseMembers(vendorId, vendorLicenseName, vendorLicenseAgreementId, featureGroupId); - - return amdocsLicenseMembers; - } - - - public static Pair<String, Map<String, String>> createVSP(String HeatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception { - String vspName = OnboardingUtils.handleFilename(HeatFileName); - - Pair<RestResponse, Map<String, String>> createNewVspPair = OnboardingUtils.createNewVendorSoftwareProduct(vspName, amdocsLicenseMembers, user); - RestResponse createNewVendorSoftwareProduct = createNewVspPair.left; - assertEquals("did not succeed to create new VSP", 200,createNewVendorSoftwareProduct.getErrorCode().intValue()); - String vspid = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "vspId"); - String componentId = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "componentId"); - - Map<String, String> vspMeta = createNewVspPair.right; - Map<String, String> vspObject = new HashMap<String, String>(); - Iterator<String> iterator = vspMeta.keySet().iterator(); - while(iterator.hasNext()){ - Object key = iterator.next(); - Object value = vspMeta.get(key); - vspObject.put(key.toString(), value.toString()); - } - vspObject.put("vspId", vspid); - vspObject.put("componentId", componentId); - vspObject.put("vendorName", amdocsLicenseMembers.getVendorLicenseName()); - vspObject.put("attContact", user.getUserId()); - - RestResponse uploadHeatPackage = OnboardingUtils.uploadHeatPackage(filepath, HeatFileName, vspid, user); - assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); + Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1); + VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); - RestResponse validateUpload = OnboardingUtils.validateUpload(vspid, user); - assertEquals("did not succeed to validate upload process", 200, validateUpload.getErrorCode().intValue()); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - Pair<String, Map<String, String>> pair = new Pair<String, Map<String, String>>(vspName, vspObject); +// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - return pair; - } - - - - - - - - - -// ---------------------------------------------------------------------------------------------------------------------------------------- - - - - + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + return service; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlows.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlows.java new file mode 100644 index 0000000000..da43435cdf --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlows.java @@ -0,0 +1,400 @@ +package org.openecomp.sdc.ci.tests.execute.sanity; + +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; +import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; + +import fj.data.Either; + +public class OnboardingFlows extends SetupCDTest{ + + protected boolean skipReport = false; + protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + +// https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestPlan&id=6184 + + @Test + public void addVesFileToVsp() throws Exception{ + String vnfFile = "vMME_Ericsson_small_v2.zip"; + String vesArtifactFile = "VES.zip"; + String filePath = FileHandling.getFilePath("VFCArtifacts"); + String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile; + List<String> vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation); + List<String> tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation); + Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>(); + cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, cvfcArtifacts); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + List<ComponentInstance> componentInstances = resource.getComponentInstances(); + for(ComponentInstance componentInstance : componentInstances){ + if(componentInstance.getDeploymentArtifacts() !=null && !componentInstance.getDeploymentArtifacts().isEmpty()){ + Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts(); + for(Entry<String, ArtifactDefinition> entry : deploymentArtifacts.entrySet()){ + if(entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())){ + for(String vesArtifact : vesArtifacts){ + if(entry.getValue().getArtifactName().equals(vesArtifact)){ + tempVesArtifacts.remove(vesArtifact); + } + } + } + } + } + } + assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty()); + } + +// 741433: Update Old VSP +// 2. Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF +// 3. Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF +// @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") +// public void create2(String filePath, String vnfFile) throws Exception{ +// setLog(vnfFile); +// } + + +// 741509: E2E flow using old VLM + @Test + public void VlmReuse() throws Exception{ + List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); +// setLog(vnfFile); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + addComponentInstanceToComponentContainer.left().value(); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + +// update + vnfFile = newRandomFileNamesFromFolder.get(1); + getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile); + OnboardingUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails, "1.0"); + vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + addComponentInstanceToComponentContainer.left().value(); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + + + } + + +// 741607: E2E flow using old VSP + @Test + public void updateVfiVersionOnServiceLevel() throws Throwable{ + List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + +// update resource to v2.0 + String updateVnfFile = newRandomFileNamesFromFolder.get(1); + getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile); + OnboardingUiUtils.updateVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), updateVnfFile, filePath, sdncDesignerDetails, "2.0"); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource.getUniqueId()); + resourceReqDetails.setVersion(resource.getVersion()); + resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + } + + +// 741608: E2E flow using old Service +// @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") +// public void create5(String filePath, String vnfFile) throws Exception{ +// setLog(vnfFile); +// // 1. Create Service with old resource -> Certify this Service - > Distribute +// // 2. Service is distributed +// // 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute +// // 4. Service is distributed +// } + +// 741633: Update HEAT parameter value + @Test() + public void updateHeatParametersValue() throws Throwable{ + String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully"; + getExtendTest().log(Status.INFO, msg); + } + + @Test() + public void UpdateVSPRevertToEarlierVersion() throws Throwable + { + // Test Case: 745821 +// 1. Import VSP v1.0 + List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName()); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); +// 2. Create VF, certify - v1.0 is created + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName()); + Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName()); + resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); +// 3. Update VSP to v2.0 + getExtendTest().log(Status.INFO, "Update VSP to version 2.0"); + OnboardingUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, "2.0", sdncDesignerDetails1, filePath, vnfFile); + OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(),sdncDesignerDetails1); +// 4. Update the VF with v2.0 of the VSP + getExtendTest().log(Status.INFO, "Checkout VF v1.1"); + resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource_v1.getUniqueId()); + resourceReqDetails.setVersion("1.1"); + resourceReqDetails.setCsarVersion("2.0"); + getExtendTest().log(Status.INFO, "Update VF to v2.0"); + resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); + getExtendTest().log(Status.INFO, "Certify VF"); + Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); +// 5. Update VSP to v3.0 wih the zip from v1.0 + getExtendTest().log(Status.INFO, "Update VSP to version 3.0"); + OnboardingUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, "3.0", sdncDesignerDetails1); + OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(),sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Checkout VF v2.1"); + resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource_v1.getUniqueId()); + resourceReqDetails.setVersion("2.1"); + resourceReqDetails.setCsarVersion("3.0"); + getExtendTest().log(Status.INFO, "Update VF to v3.0"); + ResourceRestUtils.updateResource(resourceReqDetails,sdncDesignerDetails1,resource_v1.getUniqueId()); +// 6. Update VF to v3.0 + getExtendTest().log(Status.INFO, "Certify VF"); + Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); +// 7. Compare versions v1.0 and v3.0 - should be the same +// TODO: Shay add resource comparison. +// 8. Add each of the versions to service, certify - OK + ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName() ); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service"); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true); + getExtendTest().log(Status.INFO, "Certify Service"); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + System.out.println(""); + } + + @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "updateList") + public void distributeServiceAndUpgradeWithNewHeatFile(String vnfFile1, String vnfFile2) throws Throwable + { + setLog(String.format("Update VSP Test: Create VF from %s add it to service, distribute than upgrade the VF with file %s and update the service and distribute", vnfFile1, vnfFile2)); +// 1. Import VSP v1.0 + String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath(); + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1)); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct); +// 2. Create VF, certify - v1.0 is created + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); +// 3. Create Service add to it the certified VF and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); +// 5. Distribute the Service v1.0 + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); +// 6. Update VSP to v2.0 + getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2); + OnboardingUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, "2.0", sdncDesignerDetails1, filePath, vnfFile2); + getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: " ,vnfFile2)); + OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(),sdncDesignerDetails1); +// 7. Update the VF with v2.0 of the VSP and certify the VF + getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 " ,resourceReqDetails.getName())); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource.getUniqueId()); + resourceReqDetails.setVersion("1.1"); + resourceReqDetails.setCsarVersion("2.0"); + getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 " ,resourceReqDetails.getName(),vendorSoftwareProductObject.getName())); + resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0")); + Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); +// 8. Update the Service with the VFi version 2.0 + getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0")); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0")); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); +// 9. Distribute the service v2.0 + distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + } + + @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "VNF_List") + public void distributeServiceFromHeatFile(String filePath, String vnfFile) throws Throwable + { +// String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip"; +// String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip"; + setLog(String.format("Distribute Service Test: Create VF from %s add it to service than distribute", vnfFile)); +// 1. Import VSP v1.0 + //String filePath = FileHandling.getVnfRepositoryPath(); + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile)); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); +// 2. Create VF, certify - v1.0 is created + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); +// 3. Create Service add to it the certified VF and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); +// 5. Distribute the Service v1.0 + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + } + + @Test() + public void onboardE2EviaAPI() throws Throwable + { +// 1. Import VSP v1.0 + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile1 = "HeatCandidate_2017-09-20_13-37_70Name_2017-491-4vshaken-HTTP-CM-vf-v1.0-(VOIP)_10202017.zip"; + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1)); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct); +// 2. Create VF, certify - v1.0 is created + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); +// 3. Create Service add to it the certified VF and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); +// 5. Distribute the Service v1.0 + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } + + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java index 0bb315aefe..d24000806e 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java @@ -1,5 +1,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; +import static org.testng.Assert.assertTrue; + import java.util.List; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -10,22 +12,32 @@ import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.TypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.CircleSize; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage; import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; +import org.openecomp.sdc.ci.tests.pages.OpsOperationPage; import org.openecomp.sdc.ci.tests.pages.PropertiesPage; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; @@ -60,7 +72,7 @@ public class PNF extends SetupCDTest { // update Resource ResourceReqDetails updatedResource = new ResourceReqDetails(); - updatedResource.setName("ciUpdatedName"); + updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + pnfMetaData.getName()); updatedResource.setDescription("kuku"); updatedResource.setVendorName("updatedVendor"); updatedResource.setVendorRelease("updatedRelease"); @@ -68,7 +80,7 @@ public class PNF extends SetupCDTest { updatedResource.setCategories(pnfMetaData.getCategories()); updatedResource.setVersion("0.1"); updatedResource.setResourceType(ResourceTypeEnum.VF.getValue()); - List<String> newTags = pnfMetaData.getTags(); + List<String> newTags = pnfMetaData.getTags(); newTags.remove(pnfMetaData.getName()); newTags.add(updatedResource.getName()); updatedResource.setTags(newTags); @@ -105,7 +117,7 @@ public class PNF extends SetupCDTest { @Test public void addPropertiesToVfcInstanceInPNFTest() throws Exception { - String fileName = "CP.yml"; + String fileName = "CP02.yml"; ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); try{ @@ -130,6 +142,7 @@ public class PNF extends SetupCDTest { PropertiesPage.getPropertyPopup().clickSave(); findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); + SetupCDTest.getExtendTest().log(Status.INFO, "Validating properties"); AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); } } @@ -145,7 +158,7 @@ public class PNF extends SetupCDTest { ResourceReqDetails pnfMetaData = null; CanvasManager vfCanvasManager; CanvasElement cpElement = null; - String fileName = "CP.yml"; + String fileName = "CP03.yml"; try{ atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); @@ -228,7 +241,7 @@ public class PNF extends SetupCDTest { } @Test - public void deletePNFCheckedoutTest() throws Exception{ + public void deletePNFTest() throws Exception{ ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); GeneralPageElements.clickTrashButtonAndConfirm(); @@ -253,9 +266,9 @@ public class PNF extends SetupCDTest { VfVerificator.verifyVFMetadataInUI(pnfMetaData); } - + @Test - public void checkoutVfTest() throws Exception{ + public void checkoutPnfTest() throws Exception{ ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); ResourceGeneralPage.clickCheckinButton(pnfMetaData.getName()); @@ -287,7 +300,105 @@ public class PNF extends SetupCDTest { ResourceUIUtils.createPNF(pnfMetaData, getUser()); return pnfMetaData; } - + + @Test + public void verifyPNF_UI_Limitations() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Artifact Left Side Menu not exist"); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId("Deployment ArtifactLeftSideMenu")); + SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Left Side Menu not exist"); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId("DeploymentLeftSideMenu")); + } + + @Test + public void filteringCatalogByPNF() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + String pnfName = pnfMetaData.getName(); + ResourceGeneralPage.clickSubmitForTestingButton(pnfName); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(pnfName); + TesterOperationPage.certifyComponent(pnfName); + + pnfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + reloginWithNewRole(UserRoleEnum.DESIGNER); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF")); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName)); + GeneralUIUtils.clickOnElementByTestId(pnfName); + } + + @Test + public void addPNFtoServiceAndDistribute() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement("ContrailPort"); + vfCanvasManager.createElementOnCanvas("ContrailPort"); + + String pnfName = pnfMetaData.getName(); + ResourceGeneralPage.clickSubmitForTestingButton(pnfName); + + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(pnfName); + TesterOperationPage.certifyComponent(pnfName); + + pnfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + reloginWithNewRole(UserRoleEnum.DESIGNER); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(pnfName); + CanvasElement pnfElement = canvasManager.createElementOnCanvas(pnfName); + CompositionPage.searchForElement("Network"); + CanvasElement networkElement = canvasManager.createElementOnCanvas("Network"); + + canvasManager.linkElements(pnfElement, CircleSize.VF, networkElement, CircleSize.NORMATIVE); + String serviceName = serviceMetadata.getName(); + ServiceGeneralPage.clickSubmitForTestingButton(serviceName); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceName); + TesterOperationPage.certifyComponent(serviceName); + + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(serviceName); + GovernorOperationPage.approveSerivce(serviceName); + + reloginWithNewRole(UserRoleEnum.OPS); + GeneralUIUtils.findComponentAndClick(serviceName); + OpsOperationPage.distributeService(); + } + + @Test + public void checkInfomationArtifactUploadLimitation() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + List<WebElement> webElements = GeneralUIUtils.getWebElementsListBy(By.xpath("//button[@class='add-button ng-scope']")); + int numberOfElements = webElements.size(); + String buttonText = webElements.get(0).getText(); + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying only one button exist: Add Other Artifact"); + assertTrue(buttonText.equalsIgnoreCase(("Add Other Artifact"))); + assertTrue(1==numberOfElements, "There should be only one option for uploading artifact in PNF"); + } + + @Test + public void checkNonCPVLObjectsNotExistInComosition() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + String pnfName = pnfMetaData.getName(); + // Searching for VFC element and make sure it not exist in PNF composition (Only VL/CP are allowed). + CompositionPage.searchForElement("BlockStorage"); + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying Element found"); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId("BlockStorage")); + } + @Override protected UserRoleEnum getRole() { return UserRoleEnum.DESIGNER; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java new file mode 100644 index 0000000000..b4bd55c6ca --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java @@ -0,0 +1,124 @@ +package org.openecomp.sdc.ci.tests.execute.sanity; + +import java.util.Map; + +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.ConnectionWizardPopUpObject; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceContainer; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; +import org.openecomp.sdc.ci.tests.datatypes.enums.CircleSize; +import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; +import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; + +import fj.data.Either; + +public class PortMirroring extends SetupCDTest +{ + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER3; + } + + String portMirroringElementNameInPallete = "Port Mirroring Configuration"; + String portMirroringCapReqType = "org.openecomp.capabilities.PortMirroring"; + String portMirroringSourceCapability = "Port Mirroring Configuration 0: source: [1, UNBOUNDED]"; + String portMirroringCollectorCapability = "Port Mirroring Configuration 0: collector: [1, 1]"; + + @Test + public void createPortMirroringServiceProxy() throws Throwable { + //Using API onboard and certify 2 zip files Source: vmmme and Collector: Vprobe + String filePath = FileHandling.getPortMirroringRepositoryPath(); + ServiceContainer serviceContainerVmme_Source = createServiceFromHeatFile(filePath,"2016-227_vmme_vmme_30_1610_e2e.zip"); + ServiceContainer serviceContainerVprobe_Collector = createServiceFromHeatFile(filePath,"vProbe_2017-10-22_07-24.zip"); + +// String vmmeSourceName = "ciServiceb560327d162f"; +// String vprobeSourceName = "ciService3d9933d31791"; + + // create service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + String vmmeSourceName = serviceContainerVmme_Source.getService().getName(); + String vprobeSourceName = serviceContainerVprobe_Collector.getService().getName(); + + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + + CompositionPage.searchForElement(vmmeSourceName); + CanvasElement serviceElementVmmeSourceName = canvasManager.createElementOnCanvas(vmmeSourceName); + + CompositionPage.searchForElement(vprobeSourceName); + CanvasElement serviceElementVprobeCollector = canvasManager.createElementOnCanvas(vprobeSourceName); + + CompositionPage.searchForElement(portMirroringElementNameInPallete); + CanvasElement portMirroringConfigurationElement = canvasManager.createElementOnCanvas(portMirroringElementNameInPallete); + + ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("","", portMirroringCapReqType, portMirroringSourceCapability); + ConnectionWizardPopUpObject connectionWizardPopUpObjectVProbe = new ConnectionWizardPopUpObject("","", portMirroringCapReqType, portMirroringCollectorCapability); + + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, CircleSize.SERVICE,portMirroringConfigurationElement, CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVprobeCollector, CircleSize.SERVICE, portMirroringConfigurationElement, CircleSize.NORMATIVE, connectionWizardPopUpObjectVProbe); + + serviceMetadata.setVersion("0.1"); + ServiceVerificator.verifyLinkCreated(serviceMetadata, getUser(), 2); + + System.out.println("End"); + } + + public ServiceContainer createServiceFromHeatFile(String filePath, String vnfFile) throws Throwable + { + setLog(String.format("Distribute Service Test: Create VF from %s add it to service than distribute", vnfFile)); +// 1. Import VSP v1.0 + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER3); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile)); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); +// 2. Create VF, certify - v1.0 is created + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); +// 3. Create Service add to it the certified VF and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); + + return new ServiceContainer(service,resource,vendorSoftwareProductObject,amdocsLicenseMembers); + } + + +} + + diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java new file mode 100644 index 0000000000..4ccc7b024b --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.execute.sanity; + +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.pages.PropertiesAssignmentPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; + + +public class PropertiesAssignment extends SetupCDTest { + + private String filePath; + @BeforeClass + public void beforeClass(){ + filePath = FileHandling.getFilePath(""); + } + + @BeforeMethod + public void beforeTest(){ + System.out.println("File repository is : " + filePath); + getExtendTest().log(Status.INFO, "File repository is : " + filePath); + } + + + + @Test + public void declareAndDeleteInputVfTest() throws Exception { +// ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); +// ResourceUIUtils.createResource(vfMetaData, getUser()); + + String csarFile = "PCRF_OS_FIXED.csar"; + String componentName = "abstract_pcm"; + String propertyName = "min_instances"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnDeclareButton(); + AssertJUnit.assertTrue(PropertiesAssignmentPage.isPropertyChecked(propertyName)); + + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.findInput(componentName, propertyName); + PropertiesAssignmentPage.clickOnDeleteInputButton(); + PropertiesAssignmentPage.clickOnDeleteInputDialogConfirmationButton(); + PropertiesAssignmentPage.clickOnPropertiesTab(); + PropertiesAssignmentPage.findProperty(propertyName); + AssertJUnit.assertFalse(PropertiesAssignmentPage.isPropertyChecked(propertyName)); + + + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } + +} + diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java index 54656d8b9b..d6370c10dc 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java @@ -23,7 +23,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import static org.testng.AssertJUnit.assertTrue; import java.awt.AWTException; -import java.io.File; import java.util.Arrays; import java.util.List; @@ -31,7 +30,6 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; -import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; @@ -40,6 +38,7 @@ import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ServiceMetadataEnum; import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; @@ -69,7 +68,6 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.AssertJUnit; -import org.testng.SkipException; import org.testng.TestException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -117,7 +115,7 @@ public class Service extends SetupCDTest { // Update Service ServiceGeneralPage.deleteOldTags(serviceMetadata); - serviceMetadata.setName("ciUpdatedNameSanity"); + serviceMetadata.setName(ElementFactory.getServicePrefix() + "UpdatedName" + serviceMetadata.getName()); serviceMetadata.setDescription("updatedDescriptionSanity"); serviceMetadata.setProjectCode("654321"); serviceMetadata.setContactId("cs6543"); @@ -214,6 +212,23 @@ public class Service extends SetupCDTest { } @Test + public void createLinkService() throws Exception{ + String fileName2 = "vSeGW.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(resourceMetaData.getName()); + CanvasElement firstElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); + CanvasElement secondElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); + canvasManager.linkElements(firstElement, secondElement); + } + + @Test public void addDeploymentArtifactInCompositionScreenTest() throws Exception{ ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ServiceUIUtils.createService(serviceMetadata, getUser()); @@ -264,7 +279,7 @@ public class Service extends SetupCDTest { } @Test - public void addAPIArtifactInCompositionScreenTest() throws Exception{ + public void addAPIArtifactInCompositionScreenTest() throws Exception{ String fileName = HEAT_FILE_YAML_NAME, descriptionText = DESCRIPTION, url = "http://kuku.com"; @@ -272,7 +287,7 @@ public class Service extends SetupCDTest { ServiceUIUtils.createService(serviceMetadata, getUser()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - ArtifactInfo artifactInfo = new ArtifactInfo(filePath, fileName, descriptionText, ARTIFACT_LABEL,"OTHER"); + new ArtifactInfo(filePath, fileName, descriptionText, ARTIFACT_LABEL,"OTHER"); CompositionPage.showAPIArtifactTab(); for(DataTestIdEnum.APIArtifactsService artifact: DataTestIdEnum.APIArtifactsService.values()){ @@ -367,10 +382,6 @@ public class Service extends SetupCDTest { @Test public void addDeploymentArtifactToVFInstanceTest() throws Exception{ - if(true){ - throw new SkipException("Open bug 321669"); - } - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); @@ -385,12 +396,12 @@ public class Service extends SetupCDTest { @Test public void deleteDeploymentArtifactFromVFInstanceTest() throws Exception{ - + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); - CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); + createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); deleteAndVerifyArtifact(actualArtifactList); @@ -400,9 +411,9 @@ public class Service extends SetupCDTest { @Test public void deleteDeploymentArtifactFromVFInstanceNextVersionTest() throws Exception{ - if(true){ - throw new SkipException("Open bug 322930"); - } +// if(true){ +// throw new SkipException("Open bug 342260"); +// } ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); @@ -429,9 +440,9 @@ public class Service extends SetupCDTest { @Test public void updateDeploymentArtifactOnVFInstanceNextVersionTest() throws Exception{ - if(true){ - throw new SkipException("Open bug 322930"); - } +// if(true){ +// throw new SkipException("Open bug 322930"); +// } ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); @@ -569,7 +580,7 @@ public class Service extends SetupCDTest { @Test public void deploymentViewServiceTest() throws Exception{ - String fileName2 = "vSeGW.csar"; + String fileName2 = "vSeGWNew.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java index d70f5e8d5d..d42df64a5a 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java @@ -1,39 +1,21 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - package org.openecomp.sdc.ci.tests.execute.sanity; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Random; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; @@ -42,21 +24,22 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaInputsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinition; import org.openecomp.sdc.ci.tests.tosca.model.ToscaMetadataFieldsPresentationEnum; import org.openecomp.sdc.ci.tests.utilities.DownloadManager; import org.openecomp.sdc.ci.tests.utilities.FileHandling; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtillViaApis; import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils; import org.openecomp.sdc.ci.tests.verificator.ToscaValidation; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; -import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.openecomp.sdc.toscaparser.api.NodeTemplate; import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.testng.Assert; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.aventstack.extentreports.Status; @@ -66,27 +49,31 @@ import fj.data.Either; public class ToscaValidationTest extends SetupCDTest{ - - ToscaDefinition toscaMainAmdocsDefinition, toscaMainVfDefinition, toscaMainServiceDefinition; + + private static final String GENERIC_VF = "Generic_VF"; + private static final String GENERIC_PNF = "Generic_PNF"; + +// private ToscaDefinition toscaMainAmdocsDefinition, toscaMainVfDefinition, toscaMainServiceDefinition, toscaExpectedMainServiceDefinition; protected String vnfFile; protected String filepath; - protected File filesFolder; +// protected File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); protected SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); - protected ISdcCsarHelper fdntCsarHelper; - protected ResourceReqDetails resourceReqDetails; - protected Resource resource; - protected ServiceReqDetails serviceReqDetails; - protected Service service; - protected ComponentInstance componentInstanceDefinition; +// protected ISdcCsarHelper fdntCsarHelper; +// protected ResourceReqDetails resourceReqDetails; +// protected Resource resource; +// protected ServiceReqDetails serviceReqDetails; +// protected Service service; +// protected ComponentInstance componentInstanceDefinition; User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - File importToscaFilesFolder = new File("C:/Git_work/sdc/catalog-be/src/main/resources/import/tosca/"); +// File importToscaFilesFolder = new File("C:/Git_work/sdc/catalog-be/src/main/resources/import/tosca/"); - File dataTypesLocation = new File(importToscaFilesFolder.getPath() + "/data-types/dataTypes.yml"); +// File dataTypesLocation = new File(importToscaFilesFolder.getPath() + "/data-types/dataTypes.yml"); +// List<Boolean> status = new ArrayList<>(); - File genericVfFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_VF/Generic_VF.yml"); - File genericVfcFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_VFC/Generic_VFC.yml"); - File genericPnfFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_PNF/Generic_PNF.yml"); - File genericServiceFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_Service/Generic_Service.yml"); +// File genericVfFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_VF/Generic_VF.yml"); +// File genericVfcFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_VFC/Generic_VFC.yml"); +// File genericPnfFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_PNF/Generic_PNF.yml"); +// File genericServiceFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_Service/Generic_Service.yml"); // Map<String, DataTypeDefinition> parseDataTypesYaml = FileHandling.parseDataTypesYaml(dataTypesLocation.getAbsoluteFile().toString()); @@ -102,115 +89,246 @@ public class ToscaValidationTest extends SetupCDTest{ this.vnfFile = vnfFile; } + public ToscaValidationTest() { + } - @BeforeClass - - public void precondition() throws Exception{ + + +// @BeforeClass + @Test() + public void toscaFileValidator() throws Exception{ //--------------------------GENERAL-------------------------------- - setLog(vnfFile); - filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); -//--------------------------AMDOCS-------------------------------- - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(filepath, vnfFile, user); - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; - vendorSoftwareProductObject.setVspName(createVendorSoftwareProduct.left); - DownloadManager.downloadCsarByNameFromVSPRepository(vendorSoftwareProductObject.getVspName(), vendorSoftwareProductObject.getVspId(), false); - File amdocsCsarFileName = FileHandling.getLastModifiedFileNameFromDir(filesFolder.getAbsolutePath()); +/*// for debugging only + setLog("Test"); + File amdocsCsarFileName = (new File("C:\\Users\\al714h\\Downloads\\d218be69637647b0b693647d84a8c03f.csar")); toscaMainAmdocsDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName); - + toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:\\Users\\al714h\\Downloads\\resource-Civfonboarded2016073VmxBv301072E2eE60f5c15-csar.csar")); + */ + setLog(vnfFile); + List<Boolean> status = new ArrayList<>(); + ISdcCsarHelper fdntCsarHelper; + File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); +// filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); +//--------------------------AMDOCS-------------------------------- +// vnfFile = "HeatCandidate_2017-09-22_01-32_60Name_Vdbe-vsp-15.1x49-d50.3-v1.0-(VOIP).zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, user);//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + resourceReqDetails = createCustomizedVsp(resourceReqDetails, filepath, vnfFile); + + ToscaDefinition toscaMainAmdocsDefinition = downloadAndGetToscaMainYamlObjectUI(resourceReqDetails, filesFolder); +//------adding generic inputs to expected object + toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_VF); +// copy object + ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition); //TODO--------------------------AMDOCS DOWNLOAD VIA APIS-------------------------------- //--------------------------VF-------------------------------- // create VF base on VNF imported from previous step - have, resourceReqDetails object include part of resource metadata - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(vendorSoftwareProductObject, vendorSoftwareProductObject.getVspName()); - resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, vendorSoftwareProductObject.getVspName()); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - File VfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); - OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + VfCsarFileName)); - toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + VfCsarFileName)); + ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); + //--------------------------SERVICE-------------------------------- - serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(user); - service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); +// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, user); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); -// TODO declare all VFi inputs + add all generic + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + +//--------------------------getProperties set values and declare-------------------- + + Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER); + Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs(); + setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition); + PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName)); - toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName)); + ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName)); + + + + -//--------------------------verification against Pavel Parser-------------------------------- +//--------------------------initialization of Tosca Parser-------------------------------- + + fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder); + + +//---------------------------TESTS-------------------------------------------------- + status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); + status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); + status = validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status); + status = validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status); + status = validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status); + status = validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status); + status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status); + status = validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status); + status = validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status); - SetupCDTest.getExtendTest().log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object..."); - fdntCsarHelper = factory.getSdcCsarHelper(filesFolder.getPath() + ServiceCsarFileName); + if(status.contains(false)){ + SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile); + Assert.assertFalse(true); + } + } + + + + + + + + /**The method set values to toscaDefinition object service level only, to resource level should put instead of setDefault --> setValue + * inputs.get(componentInstanceInput.getName()).setValue(randomString); + * @param componentInstancesInputs + * @param toscaDefinition + */ + private void setValuesToPropertiesList(Map<String, List<ComponentInstanceInput>> componentInstancesInputs, ToscaDefinition toscaDefinition) { + for(Map.Entry<String, List<ComponentInstanceInput>> entry : componentInstancesInputs.entrySet()) { + List<ComponentInstanceInput> value = entry.getValue(); + String[] names = entry.getKey().split("\\."); + String expectedServiceInputPrefix = null; + Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs(); + if(names.length>0) { + expectedServiceInputPrefix = names[names.length - 1] + "_"; + } + for (ComponentInstanceInput componentInstanceInput :value) { + + String type = componentInstanceInput.getType(); + List<String> myList = new ArrayList<String>(); + myList.add("cbf8049e-69e8-48c3-a06f-255634391403"); + if (type.equals("string")) { + String randomString = getRandomString(); + componentInstanceInput.setValue(randomString); + inputs.get(componentInstanceInput.getName()).setDefault(randomString); + + } + else if (type.equals("integer") ) { + int randomInteger = getRandomInteger(); + componentInstanceInput.setValue(Integer.toString(randomInteger)); + inputs.get(componentInstanceInput.getName()).setDefault(randomInteger); + } + else if (type.equals("float") ){ + componentInstanceInput.setValue("5.5"); + inputs.get(componentInstanceInput.getName()).setDefault("5.5"); + + } + else if (type.equals("boolean") ){ + componentInstanceInput.setValue("true"); + inputs.get(componentInstanceInput.getName()).setDefault("true"); + } + else if (type.equals("list") ){ + String myListofStrings = myList.toString(); + componentInstanceInput.setValue(myListofStrings); + inputs.get(componentInstanceInput.getName()).setDefault(myListofStrings); + } + + String expectedServiceInputName = expectedServiceInputPrefix + componentInstanceInput.getName(); + ToscaInputsTopologyTemplateDefinition oldInput = inputs.get(componentInstanceInput.getName()); + inputs.put(expectedServiceInputName, oldInput); + inputs.remove(componentInstanceInput.getName()); + + } + + } } - + + protected String getRandomString() { + String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + StringBuilder salt = new StringBuilder(); + Random rnd = new Random(); + while (salt.length() < 18) { // length of the random string. + int index = (int) (rnd.nextFloat() * SALTCHARS.length()); + salt.append(SALTCHARS.charAt(index)); + } + String strValue = salt.toString(); + return strValue; + + } + + protected int getRandomInteger() { + Random r = new Random(); + int Low = 10; + int High = 100; + int integerValue = r.nextInt(High - Low) + Low; + return integerValue; + } + + //--------------------------Metadata verification-------------------------------- //--------------------------Resource-------------------------------- - @Test() - public void validateVfMetadata() throws Exception{ - setLog(vnfFile); - SetupCDTest.getExtendTest().log(Status.INFO, "validateVfMetadata " + vnfFile); + public List<Boolean> validateVfMetadata(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, ResourceReqDetails resourceReqDetails,Resource resource, String vnfFile, List<Boolean> status) throws Exception{ + reportStartTestPrint("validateVfMetadata", vnfFile); //add resource metadata to expected object toscaMainAmdocsDefinition = addAndGenerateResourceMetadataToExpectedObject(toscaMainAmdocsDefinition, resourceReqDetails, resource); Either<Boolean,Map<String,Object>> resourceToscaMetadataValidator = ToscaValidation.resourceToscaMetadataValidator(toscaMainAmdocsDefinition, toscaMainVfDefinition); - Assert.assertFalse(!resourceToscaMetadataValidator.left().value().equals(true), "Found error/s on Vf metadata verification"); - + if(resourceToscaMetadataValidator.isRight()) + status.add(false); + return status; } - @Test() - public void validateResourceNodeTemplateMetadata() throws Exception{ - setLog(vnfFile); - SetupCDTest.getExtendTest().log(Status.INFO, "validateResourceNodeTemplateMetadata " + vnfFile); + public List<Boolean> validateResourceNodeTemplateMetadata(ToscaDefinition toscaMainVfDefinition, Resource resource, String vnfFile, List<Boolean> status) throws Exception{ + reportStartTestPrint("validateResourceNodeTemplateMetadata", vnfFile); Map<String, Map<String, String>> generateReosurceNodeTemplateMetadataToExpectedObject = generateResourceNodeTemplateMetadataToExpectedObject(resource); Boolean resourceToscaMetadataValidator = ToscaValidation.resourceToscaNodeTemplateMetadataValidator(generateReosurceNodeTemplateMetadataToExpectedObject, toscaMainVfDefinition); - Assert.assertFalse(!resourceToscaMetadataValidator.equals(true), "Found error/s on Resource Node Template metadata verification"); + if(! resourceToscaMetadataValidator) + status.add(false); + return status; } //--------------------------Service-------------------------------- - @Test() - public void validateServiceMetadata() throws Exception{ - setLog(vnfFile); - SetupCDTest.getExtendTest().log(Status.INFO, "validateServiceMetadata " + vnfFile); + public List<Boolean> validateServiceMetadata(ToscaDefinition toscaMainServiceDefinition, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception{ + reportStartTestPrint("validateServiceMetadata", vnfFile); Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(generateServiceMetadataToExpectedObject, toscaMainServiceDefinition); - Assert.assertFalse(!serviceToscaMetadataValidator.left().value().equals(true), "Found error/s on Service metadata verification"); + if(serviceToscaMetadataValidator.isRight()) + status.add(false); + return status; } - @Test() - public void validateServiceNodeTemplateMetadata() throws Exception{ - setLog(vnfFile); - SetupCDTest.getExtendTest().log(Status.INFO, "validateServiceNodeTemplateMetadata " + vnfFile); + public List<Boolean> validateServiceNodeTemplateMetadata(ToscaDefinition toscaMainServiceDefinition, ComponentInstance componentInstanceDefinition, ResourceReqDetails resourceReqDetails, Resource resource, String vnfFile, List<Boolean> status) throws Exception{ + reportStartTestPrint("validateServiceNodeTemplateMetadata", vnfFile); Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); - Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.componentToscaNodeTemplateMetadataValidator(generateServiceNodeTemplateMetadataToExpectedObject, toscaMainServiceDefinition, componentInstanceDefinition.getName(), ComponentTypeEnum.SERVICE); - Assert.assertFalse(!serviceToscaMetadataValidator.left().value().equals(true), "Found error/s on Service Node Template metadata verification"); + Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.componentToscaNodeTemplateMetadataValidator(generateServiceNodeTemplateMetadataToExpectedObject, toscaMainServiceDefinition, componentInstanceDefinition.getName(), ComponentTypeEnum.SERVICE, componentInstanceDefinition.getName()); + if(serviceToscaMetadataValidator.isRight()) + status.add(false); + return status; } //--------------------------Service verification against Pavel Parser-------------------------------- - @Test() - public void validateServiceMetadataUsingParser() throws Exception{ - setLog(vnfFile); - SetupCDTest.getExtendTest().log(Status.INFO, "validateServiceMetadataUsingParser " + vnfFile); - Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); - Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); - Either<Boolean,Map<String, Object>> serviceToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceMetadataToExpectedObject, serviceMetadata); - Assert.assertFalse(!serviceToscaMetadataValidatorAgainstParser.left().value().equals(true), "Found error/s on Service metadata verification"); + public List<Boolean> validateServiceMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception{ + if(fdntCsarHelper == null){ + reportSkipTestPrint("validateServiceMetadataUsingParser", status); + }else{ + reportStartTestPrint("validateServiceMetadataUsingParser", vnfFile); + Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); + Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); + Either<Boolean,Map<String, Object>> serviceToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceMetadataToExpectedObject, serviceMetadata); + if(serviceToscaMetadataValidatorAgainstParser.isRight()) + status.add(false); + } + return status; } - @Test() - public void validateServiceNodeTemplateMetadataUsingParser() throws Exception{ - setLog(vnfFile); - SetupCDTest.getExtendTest().log(Status.INFO, "validateServiceMetadataUsingParser " + vnfFile); - Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); - List<NodeTemplate> serviceNodeTemplates = fdntCsarHelper.getServiceNodeTemplates(); - Metadata serviceNodeTemplateMetadata = serviceNodeTemplates.get(0).getMetaData(); - Either<Boolean,Map<String, Object>> serviceNodeTemplateToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceNodeTemplateMetadataToExpectedObject, serviceNodeTemplateMetadata); - Assert.assertFalse(!serviceNodeTemplateToscaMetadataValidatorAgainstParser.left().value().equals(true), "Found error/s on Service metadata verification"); + public List<Boolean> validateServiceNodeTemplateMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ResourceReqDetails resourceReqDetails,Resource resource, ComponentInstance componentInstanceDefinition, String vnfFile, List<Boolean> status) throws Exception{ + if(fdntCsarHelper == null){ + reportSkipTestPrint("validateServiceNodeTemplateMetadataUsingParser", status); + }else{ + reportStartTestPrint("validateServiceNodeTemplateMetadataUsingParser", vnfFile); + Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); + List<NodeTemplate> serviceNodeTemplates = fdntCsarHelper.getServiceNodeTemplates(); + Metadata serviceNodeTemplateMetadata = serviceNodeTemplates.get(0).getMetaData(); + Either<Boolean,Map<String, Object>> serviceNodeTemplateToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceNodeTemplateMetadataToExpectedObject, serviceNodeTemplateMetadata); + if(serviceNodeTemplateToscaMetadataValidatorAgainstParser.isRight()) + status.add(false); + } + return status; } @@ -218,13 +336,51 @@ public class ToscaValidationTest extends SetupCDTest{ //--------------------------Input verification-------------------------------- //--------------------------Resource-------------------------------- - + public List<Boolean> validateResourceInputs(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, String vnfFile, List<Boolean> status) throws Exception{ + reportStartTestPrint("validateResourceInputs", vnfFile); + Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaMainAmdocsDefinition.getTopology_template().getInputs(); + Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainVfDefinition.getTopology_template().getInputs(); + Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); + if(toscaInputsValidator.isRight()) + status.add(false); + return status; + } //--------------------------Service-------------------------------- + public List<Boolean> validateServiceInputs(ToscaDefinition toscaExpectedMainServiceDefinition, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception{ + reportStartTestPrint("validateServiceInputs", vnfFile); + Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); + Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainServiceDefinition.getTopology_template().getInputs(); + Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); + if(toscaInputsValidator.isRight()) + status.add(false); + return status; + } //--------------------------Service verification against Pavel Parser-------------------------------- + public List<Boolean> validateServiceInputsUsingParser(ISdcCsarHelper fdntCsarHelper, ToscaDefinition toscaExpectedMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception{ + if(fdntCsarHelper == null){ + reportSkipTestPrint("validateServiceInputsUsingParser", status); + }else{ + reportStartTestPrint("validateServiceInputsUsingParser", vnfFile); + Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); + Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidatorAgainstParser(expectedInputsMap, fdntCsarHelper); + if(toscaInputsValidator.isRight()) + status.add(false); + } + return status; + } + //--------------------------XXX verification-------------------------------- + + //--------------------------Resource-------------------------------- + + + //--------------------------Service-------------------------------- + + + //--------------------------Service verification against Pavel Parser-------------------------------- @@ -239,6 +395,38 @@ public class ToscaValidationTest extends SetupCDTest{ } + public static ToscaDefinition addGenericInputsToToscaObject(ToscaDefinition toscaDefinition, String genericName) throws Exception { + Resource genericResource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, genericName, "1.0"); + ToscaTopologyTemplateDefinition topologyTemplate = toscaDefinition.getTopology_template(); + Map<String, ToscaInputsTopologyTemplateDefinition> newInput = new HashMap<String, ToscaInputsTopologyTemplateDefinition>(); + for (PropertyDefinition property : genericResource.getProperties()) { + ToscaInputsTopologyTemplateDefinition input = new ToscaInputsTopologyTemplateDefinition(); +// input.setConstraints(property.getConstraints()); + input.setDefault(property.getDefaultValue()); + input.setDescription(property.getDescription()); +// input.setEntry_schema(property.getSchema()); + input.setName(property.getName()); +// input.setRequired(property.get); + input.setStatus(property.getStatus()); + input.setType(property.getType()); + input.setValue(property.getValue()); + newInput.put(property.getName(),input); + } + + topologyTemplate.addInputs(newInput); + toscaDefinition.setTopology_template(topologyTemplate); + return toscaDefinition; + } + + public static ToscaDefinition setNameToToscaInput(ToscaDefinition toscaDefinition) { + Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs(); + for (String name : inputs.keySet()) { + inputs.get(name).setName(name); + } + toscaDefinition.getTopology_template().setInputs(inputs); + return toscaDefinition; + } + public static ToscaDefinition addAndGenerateResourceMetadataToExpectedObject(ToscaDefinition toscaDefinition, ResourceReqDetails resourceReqDetails, Component component) { @@ -255,7 +443,7 @@ public class ToscaValidationTest extends SetupCDTest{ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resourceReqDetails.getCategories().get(0).getName()); metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resourceReqDetails.getDescription()); metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, "VF"); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resourceReqDetails.getResourceType()); metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID()); metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName()); @@ -329,6 +517,199 @@ public class ToscaValidationTest extends SetupCDTest{ return metadata; } - + public static void reportStartTestPrint (String testName, String vnfFile){ +// reportMessageInColor("info", "blue", "Running test \" + testName + \" with zip file - \" + vnfFile"); + SetupCDTest.getExtendTest().log(Status.INFO, "<html><font color=\"blue\"> Running test " + testName + " with zip file - " + vnfFile + "</font></html>"); + } + public static void reportSkipTestPrint (String testName, List<Boolean> status){ +// reportMessageInColor("error", "orange", "Skip test \" + testName + \" due to previous tosca parser error"); + SetupCDTest.getExtendTest().log(Status.ERROR, "<html><font color=\"orange\"> Skip test " + testName + " due to previous tosca parser error" + "</font></html>"); + status.add(false); + } + public static void reportMessageInColor(String status, String color, String message){ + String printLine = getReportMessageInColor(color, message); + SetupCDTest.getExtendTest().log(Status.valueOf(status), printLine); +// SetupCDTest.getExtendTest().log(Status.valueOf(status), getReportMessageInColor(color, message)); + } + /** + * @param color = red, green, orange, blue ... + * @param message - message string + * @return string in desired color + */ + public static String getReportMessageInColor(String color, String message){ + String returnValue = ("<html><font color=\\\"+color+\"\">" + message + "</font></html>").toString(); + return returnValue; + } + +/* @Test() + public void printTest(){ + System.out.println("print"); + reportMessageInColor("ERROR", "green", "green"); + reportMessageInColor("INFO", "orange", "orange"); + reportMessageInColor("INFO", "red", "red"); + }*/ + +/* @Test + public void allottedResourceModelTest() throws Exception{ + List<Boolean> status = new ArrayList<>(); + + List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder); + String vnfFile = newRandomFileNamesFromFolder.get(0); + setLog(vnfFile); + String filePath = FileHandling.getVnfRepositoryPath(); + File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); + + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(ResourceCategoryEnum.ALLOTTED_RESOURCE_SERVICE_ADMIN); + resourceReqDetails = createCustomizedVsp(resourceReqDetails, filePath, vnfFile); + + ToscaDefinition toscaMainAmdocsDefinition = downloadAndGetToscaMainYamlObjectUI(resourceReqDetails, filesFolder); + toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_VF); + + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); + + status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); + status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); + status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status); + + if(status.contains(false)){ + SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: allottedResourceModelTest tosca validation test failed with zip file " + vnfFile); + Assert.assertFalse(true); + } + } + + + + @Test() + public void NetworkModel() throws Exception{ +//--------------------------GENERAL-------------------------------- + String vnfFile = "networkModel"; + setLog(vnfFile); + List<Boolean> status = new ArrayList<>(); + ISdcCsarHelper fdntCsarHelper; + ToscaDefinition toscaMainAmdocsDefinition = new ToscaDefinition(); + File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); +// filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); + + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, user); + toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_PNF); + ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition); +//--------------------------VF-------------------------------- + Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceReqDetails,UserRoleEnum.DESIGNER,true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); + +//--------------------------SERVICE-------------------------------- + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + +//--------------------------getProperties set values and declare-------------------- + + Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER); + Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs(); + setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition); + PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user); + + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); + OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName)); + ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName)); + +//--------------------------initialization of Tosca Parser-------------------------------- + + fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder); + + +//---------------------------TESTS-------------------------------------------------- + status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); + status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); + status = validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status); + status = validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status); + status = validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status); + status = validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status); + status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status); + status = validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status); + status = validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status); + + if(status.contains(false)){ + SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile); + Assert.assertFalse(true); + } + }*/ + + // help method to toscaValidation tests + private ISdcCsarHelper initSdcCsarHelper(File serviceCsarFileName, File filesFolder) { + + ISdcCsarHelper fdntCsarHelper; + try{ + SetupCDTest.getExtendTest().log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object..."); + fdntCsarHelper = factory.getSdcCsarHelper(filesFolder.getPath() + serviceCsarFileName); + }catch(Exception e){ + SetupCDTest.getExtendTest().log(Status.ERROR, "Tosca parser FAILED to convert service csar file to ISdcCsarHelper object..."); + SetupCDTest.getExtendTest().log(Status.FAIL, e); + fdntCsarHelper = null; + } + return fdntCsarHelper; + } + + + /** + * @param resourceReqDetails to create Vsp + * @return updated resourceReqDetails after Vsp was created + */ + private ResourceReqDetails createCustomizedVsp(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception { + Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user); + VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + return resourceReqDetails; + } + + /** + * @param resourceReqDetails to download csar file via UI + * @return Tosca definition object from main yaml file + */ + private ToscaDefinition downloadAndGetToscaMainYamlObjectUI(ResourceReqDetails resourceReqDetails, File filesFolder) throws Exception { + DownloadManager.downloadCsarByNameFromVSPRepository(resourceReqDetails.getName(), false); + File amdocsCsarFileName = FileHandling.getLastModifiedFileNameFromDir(filesFolder.getAbsolutePath()); + return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName); + } + + /** + * @param toscaMainAmdocsDefinition object to add generic properties + * @param genericName resource name + * @return updated toscaMainAmdocsDefinition object + */ + private ToscaDefinition addGenericPropertiesToToscaDefinitionObject(ToscaDefinition toscaMainAmdocsDefinition, String genericName) throws Exception { + toscaMainAmdocsDefinition = setNameToToscaInput(toscaMainAmdocsDefinition); + toscaMainAmdocsDefinition = addGenericInputsToToscaObject(toscaMainAmdocsDefinition, genericName); + return toscaMainAmdocsDefinition; + } + + /** + * @param resource to download csar file via API + * @return Tosca definition object from main yaml file + */ + private ToscaDefinition downloadAndGetToscaMainYamlObjectApi(Resource resource, File filesFolder) throws Exception { + File VfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); + OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + VfCsarFileName)); + return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + VfCsarFileName)); + } + + /*public static void main(String[] args) { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + List<CategoryDefinition> categories = resourceReqDetails.getCategories(); + System.out.println(categories); + }*/ + } + + diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java index c96c66982c..b79393a0c9 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java @@ -46,12 +46,12 @@ import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; import org.openecomp.sdc.ci.tests.utilities.DownloadManager; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import org.openecomp.sdc.ci.tests.verificator.VFCArtifactVerificator; -import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -73,10 +73,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void ImportMultiVFCTest_TC1407998() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - String csarFile = "Import_Multi_VFC.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); @@ -96,10 +92,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - String csarFile = "LDSA-ORIG.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); resourceMetaData.setVersion("0.1"); @@ -125,10 +117,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - String csarFile = "LDSA-ORIG.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); resourceMetaData.setVersion("0.1"); @@ -143,10 +131,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); resourceMetaData.setVersion("0.1"); @@ -172,10 +156,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - String csarFile = "LDSA-SINGLE.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); resourceMetaData.setVersion("0.1"); @@ -210,6 +190,7 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception{ + String csarFile = "LDSA-ORIG.csar"; ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); resourceMetaData.setVersion("0.1"); @@ -232,30 +213,26 @@ public class VFCArtifacts extends SetupCDTest { @Test public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); String vnfFile = "vProbes_FE.zip"; String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip"; - AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(getUser()); - Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser(), amdocsLicenseMembers); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); String vspName = createVSP.left; resourceMetaData.setName(vspName); Map<String, String> resourceMeta = createVSP.right; String vspid = resourceMeta.get("vspId"); OnboardingUtils.addVFCArtifacts(filePath, snmpFile, null, vspid, getUser()); - OnboardingUtils.prepareVspForUse(getUser(), vspid); + OnboardingUtils.prepareVspForUse(getUser(), vspid, "0.1"); String downloadDirectory = getWindowTest().getDownloadDirectory(); String csarFile = vspid + ".csar"; DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); - OnboardingUtils.importVSP(createVSP); + OnboardingUiUtils.importVSP(createVSP); resourceMetaData.setVersion("0.1"); verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null); @@ -268,10 +245,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - //check of version is 1 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); @@ -279,21 +252,21 @@ public class VFCArtifacts extends SetupCDTest { String snmpPollFile = "vprobes-vLB.zip"; String updatedSnmpPollFile = "vprobes-vLBAgent.zip"; - AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(getUser()); - Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser(), amdocsLicenseMembers); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); String vspName = createVSP.left; resourceMetaData.setName(vspName); Map<String, String> resourceMeta = createVSP.right; String vspid = resourceMeta.get("vspId"); String montoringComponentId = OnboardingUtils.addVFCArtifacts(filePath, snmpPollFile, null, vspid, getUser()); - OnboardingUtils.prepareVspForUse(getUser(), vspid); + OnboardingUiUtils.prepareVspForUse(getUser(), vspid, "0.1"); String downloadDirectory = getWindowTest().getDownloadDirectory(); String csarFile = vspid + ".csar"; DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); - OnboardingUtils.importVSP(createVSP); + OnboardingUiUtils.importVSP(createVSP); ResourceGeneralPage.clickSubmitForTestingButton(vspName); @@ -302,10 +275,10 @@ public class VFCArtifacts extends SetupCDTest { TesterOperationPage.certifyComponent(vspName); reloginWithNewRole(UserRoleEnum.DESIGNER); - OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpPollFile, null, montoringComponentId, getUser()); + OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpPollFile, null, montoringComponentId, getUser(), "0.1"); DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); - OnboardingUtils.updateVSP(createVSP); + OnboardingUiUtils.updateVSP(createVSP); resourceMetaData.setVersion("1.1"); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); @@ -318,10 +291,6 @@ public class VFCArtifacts extends SetupCDTest { @Test public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception{ - if(true){ - throw new SkipException("Open bug 294400"); - } - //check of version is 2 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); @@ -329,21 +298,21 @@ public class VFCArtifacts extends SetupCDTest { String snmpFile = "vprobes-vLB.zip"; String updatedSnmpFile = "vprobes-vLB-Modified.zip"; - AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(getUser()); - Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser(), amdocsLicenseMembers); + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser()); + Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); String vspName = createVSP.left; resourceMetaData.setName(vspName); Map<String, String> resourceMeta = createVSP.right; String vspid = resourceMeta.get("vspId"); String monitoringId = OnboardingUtils.addVFCArtifacts(filePath, snmpFile, null, vspid, getUser()); - OnboardingUtils.prepareVspForUse(getUser(), vspid); + OnboardingUiUtils.prepareVspForUse(getUser(), vspid, "0.1"); String downloadDirectory = getWindowTest().getDownloadDirectory(); String csarFile = vspid + ".csar"; DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); - OnboardingUtils.importVSP(createVSP); + OnboardingUiUtils.importVSP(createVSP); Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile); List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); @@ -359,10 +328,10 @@ public class VFCArtifacts extends SetupCDTest { TesterOperationPage.certifyComponent(vspName); reloginWithNewRole(UserRoleEnum.DESIGNER); - OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpFile, null, monitoringId, getUser()); + OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpFile, null, monitoringId, getUser(), "0.1"); DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); - OnboardingUtils.updateVSP(createVSP); + OnboardingUiUtils.updateVSP(createVSP); resourceMetaData.setVersion("1.1"); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); @@ -378,12 +347,6 @@ public class VFCArtifacts extends SetupCDTest { } - - - - - - @Override protected UserRoleEnum getRole() { return UserRoleEnum.DESIGNER; @@ -391,6 +354,7 @@ public class VFCArtifacts extends SetupCDTest { private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcArtifacts(String filepath, String csarFile, ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception { + ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts"); Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = null; ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file"); @@ -408,7 +372,7 @@ public class VFCArtifacts extends SetupCDTest { Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap; Map<String,LinkedList<HeatMetaFirstLevelDefinition>> vfcDeploymentArtifacts = (Map<String,LinkedList<HeatMetaFirstLevelDefinition>>)artifactsFromCsar.get(key); LinkedList<HeatMetaFirstLevelDefinition> deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT); - LinkedList<HeatMetaFirstLevelDefinition> informationalList = (LinkedList<HeatMetaFirstLevelDefinition>) artifactsFromCsar.get(INFORMATIONAL); + LinkedList<HeatMetaFirstLevelDefinition> informationalList = (LinkedList<HeatMetaFirstLevelDefinition>) vfcDeploymentArtifacts.get(INFORMATIONAL); expectedArtifactMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>(); if(deploymentList == null){ @@ -422,7 +386,6 @@ public class VFCArtifacts extends SetupCDTest { expectedArtifactMap.put(ARTIFACTS, informationalList); } - VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse); return expectedArtifactMap; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java index 730cc1ce56..fe2187f338 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java @@ -63,10 +63,11 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; +import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; @@ -78,7 +79,6 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.AssertJUnit; -import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -111,7 +111,7 @@ public class Vf extends SetupCDTest { // update Resource ResourceReqDetails updatedResource = new ResourceReqDetails(); - updatedResource.setName("ciUpdatedName"); + updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName()); updatedResource.setDescription("kuku"); updatedResource.setVendorName("updatedVendor"); updatedResource.setVendorRelease("updatedRelease"); @@ -646,8 +646,9 @@ public class Vf extends SetupCDTest { @Test public void exportToscaWithModulePropertiesVFTest() throws AWTException, Exception { - String vnfFile = "2016-042_vmsp_pxmc_30_1607_e2e.zip"; - Pair<String, Map<String, String>> vsp=OnboardingUtils.onboardAndValidate(FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); String vspName = vsp.left; ResourceGeneralPage.clickSubmitForTestingButton(vsp.left); Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); @@ -656,14 +657,17 @@ public class Vf extends SetupCDTest { @Test public void exportToscaWithModulePropertiesTemplateCheckVFTest() throws AWTException, Exception { - String vnfFile = "2016-042_vmsp_pxmc_30_1607_e2e.zip"; - OnboardingUtils.onboardAndValidate(FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue()); File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - ToscaDefinition toscaDefinition = VfModuleVerificator.getToscaTemplate(latestFilefromDir.getAbsolutePath()); + ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); VfModuleVerificator.validateSpecificModulePropertiesFromFile(toscaDefinition); } + + @Override protected UserRoleEnum getRole() { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java index 2faeedc15b..8055a86d58 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java @@ -39,6 +39,7 @@ import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.CompositionScreenEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; import org.openecomp.sdc.ci.tests.datatypes.HeatWithParametersDefinition; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; @@ -50,9 +51,10 @@ import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.HomeUtils; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openqa.selenium.WebElement; import org.testng.SkipException; import org.testng.annotations.BeforeMethod; @@ -63,19 +65,29 @@ import com.aventstack.extentreports.Status; import com.clearspring.analytics.util.Pair; public class VfArtifacts extends SetupCDTest{ - + + public static final String VSAEGW_FDNT_30_1607_E2E_ZIP = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; + public static final String VFW_FCGI_30_1607_E2E_ZIP = "2016-044_vfw_fcgi_30_1607_e2e.zip"; + public static final String FDNT_UPDATE_HEAT_PARAMS_ZIP = "FDNT_UpdateHeatParams.zip"; + public static final String FDNT_WITHOUT_ENV_FILES_ZIP = "FDNT_WithoutEnvFiles.zip"; + public static final String VLANDSLIDE_LDSA_30_1607_E2E_ZIP = "2016-014_vlandslide_ldsa_30_1607_e2e.zip"; + public static final String VJSA_VJSA_30_1610_E2E_ZIP = "2016-209_vjsa_vjsa_30_1610_e2e.zip"; + public static final String VLB_LMSP_30_1607_E2E_ZIP = "2016-045_vlb_lmsp_30_1607_e2e.zip"; + public static final String MOBT_MOBT_30_1607_E2E_ZIP = "2016-109_mobt_mobt_30_1607_e2e.zip"; + public static final String MOBT_MOBT_30_1607_E2E_DIFFERENT_PARAMS_ZIP = "2016-109_mobt_mobt_30_1607_e2e_DifferentParams.zip"; + public static final String VMSP_PXMC_30_1607_E2E_ZIP = "2016-042_vmsp_pxmc_30_1607_e2e.zip"; + public static final String VFW_FNAT_30_1607_E2E_ZIP = "2016-044_vfw_fnat_30_1607_e2e.zip"; + public static final String VLANDSLIDE_LDST_30_1607_E2E_ZIP = "2016-014_vlandslide_ldst_30_1607_e2e.zip"; + public static final String VIXIA_IXLA_30_1607_E2E_ZIP = "2016-017_vixia_ixla_30_1607_e2e.zip"; private String filePath; private String vnfsRepositoryPath; - private String updatedVnfsRepositoryPath; private String createdEnvFilePath; private static final String PARAMETERS = "parameters"; @BeforeMethod public void beforeTest() throws FileNotFoundException{ filePath = getWindowTest().getDownloadDirectory(); - vnfsRepositoryPath = FileHandling.getVnfRepositoryPath(); -// vnfsRepositoryPath = FileHandling.getFilePath("Old_VNFs"); - updatedVnfsRepositoryPath = vnfsRepositoryPath + "UpdatedVNFs"; + vnfsRepositoryPath = FileHandling.getFilePath("VfArtifacts"); Config config = Utils.getConfig(); createdEnvFilePath = config.getWindowsDownloadDirectory(); } @@ -91,11 +103,11 @@ public class VfArtifacts extends SetupCDTest{ public Object[][] provideData() { return new Object[][] { - { "2016-043_vsaegw_fdnt_30_1607_e2e.zip", "FDNT_UpdateHeatParams.zip", "2", "2" }, // expected heat version 2 and heatEnv 2 - { "2016-043_vsaegw_fdnt_30_1607_e2e.zip", "FDNT_WithoutEnvFiles.zip", "1", "2" }, // expected heat version 1 and heatEnv 2 - { "2016-014_vlandslide_ldsa_30_1607_e2e.zip", "2016-209_vjsa_vjsa_30_1610_e2e.zip", "1", "1" }, // expected heat version 1 and heatEnv 1 - { "2016-045_vlb_lmsp_30_1607_e2e.zip", "2016-045_vlb_lmsp_30_1607_e2e.zip", "1", "2" }, // expected heat version 1 and heatEnv 2(DE270634) - { "2016-109_mobt_mobt_30_1607_e2e.zip", "2016-109_mobt_mobt_30_1607_e2e_DifferentParams.zip", "2", "2" } // expected heat version 2 and heatEnv 2 + { VSAEGW_FDNT_30_1607_E2E_ZIP, FDNT_UPDATE_HEAT_PARAMS_ZIP, "2", "2" }, // expected heat version 2 and heatEnv 2 + { VSAEGW_FDNT_30_1607_E2E_ZIP, FDNT_WITHOUT_ENV_FILES_ZIP, "1", "2" }, // expected heat version 1 and heatEnv 2 + {VLANDSLIDE_LDSA_30_1607_E2E_ZIP, VJSA_VJSA_30_1610_E2E_ZIP, "1", "1" }, // expected heat version 1 and heatEnv 1 + {VLB_LMSP_30_1607_E2E_ZIP, VLB_LMSP_30_1607_E2E_ZIP, "1", "2" }, // expected heat version 1 and heatEnv 2(DE270634) + {MOBT_MOBT_30_1607_E2E_ZIP, MOBT_MOBT_30_1607_E2E_DIFFERENT_PARAMS_ZIP, "2", "2" } // expected heat version 2 and heatEnv 2 }; } @@ -103,9 +115,10 @@ public class VfArtifacts extends SetupCDTest{ @Test public void uploadUpdatedHeatEnv() throws Exception{ - String vnfFile = "2016-042_vmsp_pxmc_30_1607_e2e.zip"; + String vnfFile = VMSP_PXMC_30_1607_E2E_ZIP; File updateEnvFile = null; - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = vsp.left; Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); @@ -127,9 +140,10 @@ public class VfArtifacts extends SetupCDTest{ @Test public void uploadUpdatedAllHeatEnv() throws Exception{ - String vnfFile = "2016-044_vfw_fnat_30_1607_e2e.zip"; + String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; File updateEnvFile = null; - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = vsp.left; Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); @@ -150,9 +164,10 @@ public class VfArtifacts extends SetupCDTest{ @Test public void uploadUpdatedAllHeatEnvComposition() throws Exception{ - String vnfFile = "2016-014_vlandslide_ldst_30_1607_e2e.zip"; + String vnfFile = VLANDSLIDE_LDST_30_1607_E2E_ZIP; File updateEnvFile = null; - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = vsp.left; Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); @@ -177,13 +192,14 @@ public class VfArtifacts extends SetupCDTest{ @Test // Download ENV file from VF level Update VSP. public void downloadEnvFromVFLevelUpdateVSP() throws Throwable { - String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; - String updatedVnfFile="2016-014_vlandslide_ldsa_30_1607_e2e.zip"; + String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; + String updatedVnfFile= VLANDSLIDE_LDSA_30_1607_E2E_ZIP; String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - Pair<String, Map<String, String>> CreatedVsp=OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> CreatedVsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = CreatedVsp.left; GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUtils.updateVnfAndValidate(vnfsRepositoryPath, CreatedVsp, updatedVnfFile, getUser()); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, CreatedVsp, updatedVnfFile, getUser()); //get updated vsp env files Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, downloadDirPath); GeneralUIUtils.findComponentAndClick(vspName); @@ -203,11 +219,10 @@ public class VfArtifacts extends SetupCDTest{ @Test // Download ENV file from VF level Work-Space. public void downloadEnvFromVFLevelWorkSpace() throws AWTException, Exception { - String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; + String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - - Pair<String, Map<String, String>> vsp=OnboardingUtils.onboardAndValidate(FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.left,downloadDirPath); GeneralUIUtils.findComponentAndClick(vsp.left); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); @@ -229,9 +244,9 @@ public class VfArtifacts extends SetupCDTest{ public void downloadEnvVFLevelComposition() throws AWTException, Exception { String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; - - Pair<String, Map<String, String>> vsp=OnboardingUtils.onboardAndValidate(FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.left,downloadDirPath); GeneralUIUtils.findComponentAndClick(vsp.left); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); @@ -253,10 +268,10 @@ public class VfArtifacts extends SetupCDTest{ // Download ENV file from VF level Update parameters in UI. public void downloadEnvVFLevelUpdateParameters() throws AWTException, Exception { - String vnfFile = "2016-044_vfw_fcgi_30_1607_e2e.zip"; + String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - Pair<String, Map<String, String>> CreatedVsp=OnboardingUtils.onboardAndValidate(FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> CreatedVsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, CreatedVsp.left, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); List<HeatWithParametersDefinition> envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); @@ -298,8 +313,9 @@ public class VfArtifacts extends SetupCDTest{ @Test public void checkDefaultCreatedEnvArtifacts() throws Exception{ - String vnfFile = "2016-017_vixia_ixla_30_1607_e2e.zip"; - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + String vnfFile = VIXIA_IXLA_30_1607_E2E_ZIP; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = vsp.left; Map<String, File> generatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); HomeUtils.findComponentAndClick(vspName); @@ -319,12 +335,12 @@ public class VfArtifacts extends SetupCDTest{ @Test(dataProvider = "heatEnvAndVersion") public void checkDefaultCreatedEnvArtifactsAfterVspUpdate(String vnfFile, String updatedVnfFile, String expectedHeatVersion, String expectedHeatEnvVersion) throws Throwable{ String stringForLog = String.format("%s:%s:%s:%s", vnfFile, updatedVnfFile, expectedHeatVersion, expectedHeatEnvVersion); - setLog(stringForLog); - - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + setLog(stringForLog); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = vsp.left; GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUtils.updateVnfAndValidate(updatedVnfsRepositoryPath, vsp, updatedVnfFile, getUser()); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); Map<String, File> generatedUpdatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); HomeUtils.findComponentAndClick(vspName); GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); @@ -332,26 +348,27 @@ public class VfArtifacts extends SetupCDTest{ // TODO test will pass on case all objects on deployment view are visible GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue()+envFileEntry.getKey()); ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); - if(true){ - throw new SkipException("Test skipped, new artifact version design should be developed"); - } - ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatEnvVersion, ArtifactTypeEnum.HEAT_ENV); - ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatVersion, ArtifactTypeEnum.HEAT); +// ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatEnvVersion, ArtifactTypeEnum.HEAT_ENV); +// ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatVersion, ArtifactTypeEnum.HEAT); + } + if(true){ + throw new SkipException("Test skipped, new artifact version design should be developed"); } } // expected heat version 1 and heatEnv 3 @Test public void checkDefaultCreatedEnvArtifactsVspUpdatedWithSameVspTwice() throws Throwable{ - String vnfFile = "2016-044_vfw_fcgi_30_1607_e2e.zip"; - String updatedVnfFile = "2016-044_vfw_fcgi_30_1607_e2e.zip"; - Pair<String,Map<String,String>> vsp = OnboardingUtils.onboardAndValidate(vnfsRepositoryPath, vnfFile, getUser()); + String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; + String updatedVnfFile = VFW_FCGI_30_1607_E2E_ZIP; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String,Map<String,String>> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); String vspName = vsp.left; GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); Map<String, File> generatedUpdatedSecondTimeEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); HomeUtils.findComponentAndClick(vspName); GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java index 24badb3ec2..ef8a337394 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java @@ -43,7 +43,6 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openqa.selenium.WebElement; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.Test; @@ -94,11 +93,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1434247 - Import VF Artifacts - Informational Artifacts - One Artifact, One Type @Test public void importVfArtifactsInformationalArtifactsOneArtifactOneType() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String fileName = "TC1434247.csar"; String folder ="US825779"; @@ -116,11 +110,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1434248 - Import VF Artifacts - Informational Artifacts - Multiple Artifacts, Multiple Types @Test public void importVfArtifactsInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String fileName = "TC1434248.csar"; String folder ="US825779"; @@ -140,11 +129,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1434249 - Import VF Artifacts - Deployment and Informational Artifacts - Multiple Artifacts, Multiple Types @Test public void importVfArtifactsDeploymentAndInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String fileName = "TC1434249.csar"; String folder ="US825779"; @@ -171,11 +155,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1438310 - Import VF Artifacts - Deployment Artifacts - Artifact Type Invalid @Test public void importVFArtifactsDeploymentArtifactsArtifactTypeInvalid() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String fileName = "DeploymentArtifactWithInvalidType.csar"; String folder ="US825779"; @@ -191,11 +170,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1438311 - Import VF Artifacts - Informational Artifacts - Artifact Type Invalid @Test public void importVfArtifactsInformationalArtifactsArtifactTypeInvalid() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String fileName = "InformationArtifactWithInvalidType.csar"; String folder ="US825779"; @@ -335,11 +309,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1443887 - Update With One New Informational Artifact @Test public void updateWithOneNewInformationalArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String fileName = "ImportTC1443887.csar"; String folder ="US825779"; @@ -363,11 +332,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1443888 - Update With One Removed Informational Artifact @Test public void updateWithOneRemovedInformationalArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String folder ="US825779"; String fileName = "ImportTC1443888.csar"; @@ -397,11 +361,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1443890 - Update With One New Artifact Version Informational Artifact @Test public void updateWithOneNewArtifactVersionInformationalArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String folder ="US825779"; String fileName = "ImportTC1443890.csar"; @@ -426,12 +385,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update // TC1443893 - Update CSAR With Same Artifacts As Imported @Test - public void updateCSARWithSameArtifactsAsImported() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - + public void updateCSARWithSameArtifactsAsImported() throws Exception { String folder ="US825779"; String fileName = "ImportUpdateTC1443893.csar"; @@ -462,11 +416,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1443954 - Update With Multiple Changes In Deployment And Informational Artifacts @Test public void updateWithMultipleChangesInDeploymentAndInformationalArtifacts() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String folder ="US825779"; String fileName = "ImportTC1443954.csar"; @@ -560,11 +509,6 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1444207 - Update With Existed Informational Artifact By Artifact With Different Type @Test public void updateWithExistedInformationalArtifactByArtifactWithDifferentType() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - String folder ="US825779"; String fileName = "ImportTC1444207.csar"; @@ -667,11 +611,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // TC1444530 - Update Deployment Artifact With Invalid Type @Test public void updateDeploymentArtifactWithInvalidType() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - + String folder ="US825779"; String fileName = "ImportTC1444530.csar"; @@ -694,12 +634,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update // TC1444531 - Update Informational Artifact With Invalid Type @Test - public void updateInformationalArtifactWithInvalidType() throws Exception { - - if(true){ - throw new SkipException("Open bug 299719"); - } - + public void updateInformationalArtifactWithInvalidType() throws Exception { String folder ="US825779"; String fileName = "ImportTC1444531.csar"; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java index 1d7c4ae554..a20e3db2de 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java @@ -24,7 +24,6 @@ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -35,8 +34,6 @@ import java.util.Date; import java.util.List; import java.util.stream.Collectors; -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPReply; @@ -205,7 +202,6 @@ public class AttFtpClient { try { deleted = apacheFtpClient.deleteFile(file.getName()); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java index fd53249ac2..6c76e327f0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java @@ -37,8 +37,6 @@ import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxProfile; -import org.testng.ITestContext; -import org.testng.ITestResult; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; @@ -59,7 +57,10 @@ public class DriverFactory { @BeforeSuite(alwaysRun = true) public static void instantiateDriverObject() { - + + // Selenium 3.4.0 change, location of gecko driver, set system property +// System.setProperty("webdriver.gecko.driver","C:\\Gekko18\\geckodriver-v0.18.0-win64\\geckodriver.exe"); //change for 3.4.0, gecko driver location + // End of Selenium 3.4.0 change File basePath = new File(FileHandling.getBasePath()); File[] listFiles = basePath.listFiles(new FilenameFilter() { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java index 0523647c16..6718150115 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.util.UUID; +import org.openecomp.sdc.ci.tests.api.SomeInterface; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import com.aventstack.extentreports.ExtentTest; @@ -35,13 +36,15 @@ import com.aventstack.extentreports.markuputils.MarkupHelper; public class ExtentTestActions { + public static SomeInterface testManager = new ExtentTestManager(); + public static void log(Status logStatus, Markup mark){ - ExtentTest test = ExtentTestManager.getTest(); + ExtentTest test = testManager.getTest(); test.log(logStatus, mark); } public static void log(Status logStatus, String message){ - ExtentTest test = ExtentTestManager.getTest(); + ExtentTest test = testManager.getTest(); test.log(logStatus, message); } @@ -50,7 +53,7 @@ public class ExtentTestActions { } public static void log(Status logStatus, Throwable throwabel){ - ExtentTest test = ExtentTestManager.getTest(); + ExtentTest test = testManager.getTest(); test.log(logStatus, throwabel); } @@ -90,7 +93,7 @@ public class ExtentTestActions { e.printStackTrace(); } - ExtentTest test = ExtentTestManager.getTest(); + ExtentTest test = testManager.getTest(); test.log(logStatus, message, MediaEntityBuilder.createScreenCaptureFromPath(imageFilePath).build()); return imageFilePath; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java index b5ed1ea498..6d9b367460 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java @@ -22,15 +22,22 @@ package org.openecomp.sdc.ci.tests.execute.setup; import java.util.HashMap; +import org.openecomp.sdc.ci.tests.api.SomeInterface; + import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentTest; -public class ExtentTestManager { +public class ExtentTestManager implements SomeInterface{ private static HashMap<Long, ExtentTest> extentTestMap = new HashMap<Long, ExtentTest>(); private static ExtentReports extent = ExtentManager.getReporter(); - - public static synchronized ExtentTest getTest() { + + public ExtentTestManager(){ + + } + + @Override + public synchronized ExtentTest getTest() { return extentTestMap.get(Thread.currentThread().getId()); } @@ -54,7 +61,7 @@ public class ExtentTestManager { String[] parts = clazz.getName().split("\\."); String lastOne1 = parts[parts.length-1]; String lastOne2 = parts[parts.length-2]; - getTest().assignCategory(lastOne2 + "-" + lastOne1); + extentTestMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1); } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java index bab4508716..f996514dc0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java @@ -27,11 +27,9 @@ import java.net.SocketAddress; import java.net.URI; import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; import org.slf4j.LoggerFactory; -import com.aventstack.extentreports.ExtentTest; import com.github.markusbernhardt.proxy.ProxySearch; import com.github.markusbernhardt.proxy.ProxySearch.Strategy; import com.github.markusbernhardt.proxy.util.PlatformUtil; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java index 0a01da06c3..d208537702 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java @@ -20,10 +20,8 @@ package org.openecomp.sdc.ci.tests.execute.setup; -import org.testng.Assert; import org.testng.IRetryAnalyzer; import org.testng.ITestResult; -import org.testng.annotations.Test; public class Retry implements IRetryAnalyzer { private int retryCount = 0; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java index 21aa5720a0..3bb4c7598c 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java @@ -26,15 +26,10 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; import java.util.UUID; -import java.util.logging.FileHandler; -import java.util.logging.Handler; -import java.util.logging.LogManager; -import java.util.logging.Logger; import org.json.simple.JSONObject; -import org.littleshoot.proxy.impl.ClientToProxyConnection; -import org.littleshoot.proxy.impl.ProxyToServerConnection; import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.api.SomeInterface; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -60,16 +55,15 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; import org.testng.annotations.Test; -import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.Status; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; -import groovyjarjarantlr.Utils; -import net.lightbody.bmp.BrowserMobProxyServer; import net.lightbody.bmp.core.har.Har; public abstract class SetupCDTest extends DriverFactory { @@ -107,7 +101,8 @@ public abstract class SetupCDTest extends DriverFactory { /**************** METHODS ****************/ public static ExtentTest getExtendTest() { - return ExtentTestManager.getTest(); + SomeInterface testManager = new ExtentTestManager(); + return testManager.getTest(); } public static WindowTest getWindowTest(){ return WindowTestManager.getWindowMap(); @@ -230,7 +225,7 @@ public abstract class SetupCDTest extends DriverFactory { } public void addResultToCSV(ITestResult result, ITestContext context) { String suiteName = ExtentManager.getSuiteName(context); - ExtentTest test = ExtentTestManager.getTest(); + ExtentTest test = getExtendTest(); com.aventstack.extentreports.model.Test model = test.getModel(); String name = model.getName(); String status = model.getStatus().toString(); @@ -268,15 +263,19 @@ public abstract class SetupCDTest extends DriverFactory { } - - @AfterSuite(alwaysRun = true) - - public void afterSuite2() throws Exception { + @Parameters({ "eraseAfterTests" }) + @AfterSuite(alwaysRun = true) + public void afterSuite2(@Optional("true") String eraseAfterTestsReadValue) throws Exception { // public void afterSuite() throws Exception { csvReport.closeFile(); generateReport4Jenkins(myContext); - RestCDUtils.deleteOnDemand(); + + if (Boolean.parseBoolean(eraseAfterTestsReadValue)){ + RestCDUtils.deleteOnDemand(); + } else { + System.out.println("Resources will not be deleted according to suite configuration ..."); + } if (getConfig().getUseBrowserMobProxy()){ MobProxy.getPoxyServer().stop(); @@ -506,7 +505,7 @@ public abstract class SetupCDTest extends DriverFactory { navigateAndLogin(role); } - public static void setLocalUrl(UserRoleEnum role) { + /*public static void setLocalUrl(UserRoleEnum role) { switch (role) { case ADMIN: { url = "http://localhost:8181/sdc1/proxy-admin1#/dashboard"; @@ -548,7 +547,7 @@ public abstract class SetupCDTest extends DriverFactory { break; } } - } + }*/ public void addTrafficFileToReport(ITestResult result) { try { @@ -600,8 +599,8 @@ public abstract class SetupCDTest extends DriverFactory { System.out.println("attsdc.yaml file path is : " + attsdcFilePath); String filepath = FileHandling.getBasePath() + File.separator + "Files" + File.separator; - System.setProperty("filepath", filepath); - System.out.println("filepath is : " + System.getProperty("filepath")); + System.setProperty("filePath", filepath); + System.out.println("filePath is : " + System.getProperty("filePath")); Object[] testSuitsList = FileHandling.filterFileNamesFromFolder(FileHandling.getBasePath() + File.separator + "testSuites", ".xml"); if (testSuitsList != null) { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java index 5a95df39f8..1dc099e9ea 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java @@ -21,17 +21,16 @@ package org.openecomp.sdc.ci.tests.execute.setup; import java.io.File; -import java.io.FileNotFoundException; import java.net.MalformedURLException; import java.net.URL; import java.util.UUID; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.utilities.FileHandling; -import org.openecomp.sdc.ci.tests.utils.Utils; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; +//import org.openqa.selenium.firefox.FirefoxOptions; // Selenium 3.4.0 change import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; @@ -74,6 +73,13 @@ public class WebDriverThread { if (mobProxyStatus){ setWebDriverWithMobProxy(); } else { + + // Selenium 3.4.0 change, add firefox options : set, add firefox 5.X location and enable +// FirefoxOptions options = new FirefoxOptions(); +// options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox5\\firefox.exe"); //Location where Firefox is installed +// options.addPreference("dom.file.createInChild", true); // Enable file upload with sendKeys + // End of Selenium 3.4.0 change + System.out.println("Opening LOCAL browser"); DesiredCapabilities cap = new DesiredCapabilities(); @@ -81,6 +87,8 @@ public class WebDriverThread { cap.setBrowserName("firefox"); cap.setCapability(FirefoxDriver.PROFILE, initFirefoxProfile()); +// cap.setCapability("moz:firefoxOptions", options); //Add options to Capabilities, Selenium 3.4.0 change + firefoxProfile.setPreference("network.proxy.type", 2); firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://emea-auto.proxy.att.com:8001/"); firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost"); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java index 5e5ddc4fbd..b160b57132 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java @@ -22,8 +22,6 @@ package org.openecomp.sdc.ci.tests.execute.setup; import java.util.HashMap; -import com.aventstack.extentreports.ExtentTest; - public class WindowTestManager { private static HashMap<Long, WindowTest> windowMap = new HashMap<Long, WindowTest>(); |