From 75aacbbe1acf78fa53378f07f0a8c7769449a17e Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Mon, 17 Jul 2017 21:12:03 +0300 Subject: [SDC] rebase 1710 code Change-Id: I532ed68979fee7840ea8a5395e7e965b155fb9f9 Signed-off-by: Michael Lando --- .../tests/US/MIBsArtifactsOnResourceInstance.java | 4 --- .../sdc/ci/tests/datatypes/DataTestIdEnum.java | 22 ++++++------ .../sdc/ci/tests/execute/sanity/Onboard.java | 41 ++++++++++++++++++++++ .../ci/tests/execute/sanity/OnboardViaApis.java | 32 +++++++++++++++++ .../sdc/ci/tests/execute/sanity/Service.java | 12 ------- .../openecomp/sdc/ci/tests/execute/sanity/Vf.java | 4 --- .../sdc/ci/tests/utilities/OnboardingUtils.java | 29 ++++++++++----- 7 files changed, 105 insertions(+), 39 deletions(-) (limited to 'ui-ci/src/main/java') diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java index 949a20b4a9..4e4192fe7e 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java @@ -78,10 +78,6 @@ public class MIBsArtifactsOnResourceInstance extends SetupCDTest { setLog("mibsArtifactCRUDUi"); String filePath = FileHandling.getFilePath(folder); - if(true){ - throw new SkipException("Open bug 197101"); - } - // import Resource ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser()); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java index ef510b8a12..5bbc8ad9e0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java @@ -433,19 +433,19 @@ public final class DataTestIdEnum { } public enum StepsEnum { - GENERAL("Generalstep"), + GENERAL("General"), ICON("Iconstep"), - DEPLOYMENT_ARTIFACT("Deployment Artifactstep"), - INFORMATION_ARTIFACT("Information Artifactstep"), - PROPERTIES("Propertiesstep"), - COMPOSITION("Compositionstep"), - ACTIVITY_LOG("Activity Logstep"), - DEPLOYMENT_VIEW("Deploymentstep"), - TOSCA_ARTIFACTS("TOSCA Artifactsstep"), + DEPLOYMENT_ARTIFACT("Deployment Artifact"), + INFORMATION_ARTIFACT("Information Artifact"), + PROPERTIES("Properties"), + COMPOSITION("Composition"), + ACTIVITY_LOG("Activity Log"), + DEPLOYMENT_VIEW("Deployment"), + TOSCA_ARTIFACTS("TOSCA Artifacts"), MONITOR("Monitor step"), - MANAGEMENT_WORKFLOW("Management Workflowstep"), - INPUTS("Inputsstep"), - HIERARCHY("Hierarchystep"); + MANAGEMENT_WORKFLOW("Management Workflow"), + INPUTS("Inputs"), + HIERARCHY("Hierarchy"); private String value; 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 fddb97ace3..76723bba11 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 @@ -27,9 +27,11 @@ import java.awt.AWTException; import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.stream.Collectors; import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; @@ -94,6 +96,36 @@ public class Onboard extends SetupCDTest { return provideData(fileNamesFromFolder, filepath); } + + @DataProvider(name = "randomVNF_List", parallel = false) + private static final Object[][] randomVnfList() throws Exception { + int randomElementNumber = 3; //how many VNFs to onboard randomly + String filepath = getFilePath(); + Object[] fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); + Object[] newRandomFileNamesFromFolder = getRandomElements(randomElementNumber, fileNamesFromFolder); + System.out.println(String.format("There are %s zip file(s) to test", newRandomFileNamesFromFolder.length)); + return provideData(newRandomFileNamesFromFolder, filepath); + } + + + private static Object[] getRandomElements(int randomElementNumber, Object[] fileNamesFromFolder) { + if(fileNamesFromFolder.length == 0 || fileNamesFromFolder.length < randomElementNumber){ + return null; + }else{ + List indexList = new ArrayList<>(); + Object[] newRandomFileNamesFromFolder = new Object[randomElementNumber]; + for(int i = 0; i < fileNamesFromFolder.length; i++){ + indexList.add(i); + } + Collections.shuffle(indexList); + Integer[] randomArray = indexList.subList(0, randomElementNumber).toArray(new Integer[randomElementNumber]); + for(int i = 0; i < randomArray.length; i++){ + newRandomFileNamesFromFolder[i] = fileNamesFromFolder[randomArray[i]]; + } + return newRandomFileNamesFromFolder; + } + } + public static String getFilePath() { String filepath = System.getProperty("filepath"); if (filepath == null && System.getProperty("os.name").contains("Windows")) { @@ -116,6 +148,7 @@ public class Onboard extends SetupCDTest { runOnboardToDistributionFlow(filepath, vnfFile); } + public void runOnboardToDistributionFlow(String filepath, String vnfFile) throws Exception, AWTException { Pair> onboardAndValidate = OnboardingUtils.onboardAndValidate(filepath, vnfFile, getUser()); String vspName = onboardAndValidate.left; @@ -193,6 +226,14 @@ public class Onboard extends SetupCDTest { runOnboardToDistributionFlow(filepath, vnfFile); } + @Test(dataProvider = "randomVNF_List") + 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); + } + @Test public void onboardUpdateVNFTest() throws Exception, Throwable { 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 cb647aec6d..0dc6740c30 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 @@ -25,6 +25,7 @@ import static org.testng.AssertJUnit.assertEquals; import java.awt.AWTException; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.sql.Timestamp; import java.util.ArrayList; @@ -40,6 +41,7 @@ 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.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus; 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; @@ -49,6 +51,8 @@ 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; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.openecomp.sdc.toscaparser.api.common.JToscaException; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -125,6 +129,34 @@ public class OnboardViaApis{ } + + @Test + public void onboardingAndParser() throws Exception { + Service service = null; + String filepath = getFilePath(); + Object[] fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); + String vnfFile = fileNamesFromFolder[7].toString(); + 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 convertServiceDistributionStatusToObject = ResponseParser.convertServiceDistributionStatusToObject(distributeService.getResponse()); +// convertServiceDistributionStatusToObject. + } + + public static String getFilePath() { + String filepath = System.getProperty("filepath"); + if (filepath == null && System.getProperty("os.name").contains("Windows")) { + filepath = FileHandling.getResourcesFilesPath() +"VNFs"; + } + + else if(filepath.isEmpty() && !System.getProperty("os.name").contains("Windows")){ + filepath = FileHandling.getBasePath() + File.separator + "Files" + File.separator +"VNFs"; + } + return filepath; + } + public static void downloadToscaCsarToDirectory(Service service, File file) { try { Either serviceToscaArtifactPayload = AtomicOperationUtils.getServiceToscaArtifactPayload(service, "assettoscacsar"); 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 d5920a22ca..3a42d22d0e 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 @@ -387,10 +387,6 @@ public class Service extends SetupCDTest { @Test public void deleteDeploymentArtifactFromVFInstanceTest() throws Exception{ - if(true){ - throw new SkipException("Open bug 300513"); - } - 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()); @@ -405,10 +401,6 @@ public class Service extends SetupCDTest { @Test public void deleteDeploymentArtifactFromVFInstanceNextVersionTest() throws Exception{ - if(true){ - throw new SkipException("Open bug 300513"); - } - 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()); @@ -434,10 +426,6 @@ public class Service extends SetupCDTest { @Test public void updateDeploymentArtifactOnVFInstanceNextVersionTest() throws Exception{ - if(true){ - throw new SkipException("Open bug 300513"); - } - 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()); 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 a94a63500d..ef7a534ee9 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 @@ -231,10 +231,6 @@ public class Vf extends SetupCDTest { @Test public void addPropertiesToVfcInstanceInVfTest() throws Exception { - if(true){ - throw new SkipException("Open bug 292047"); - } - String fileName = "vFW_VFC.yml"; ResourceReqDetails 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/utilities/OnboardingUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java index 621cc26a12..ae05e77aff 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java @@ -506,6 +506,7 @@ public class OnboardingUtils { jObject.put("description", "new VSP description"); jObject.put("category", "resourceNewCategory.generic"); jObject.put("subCategory", "resourceNewCategory.generic.database"); + jObject.put("onboardingMethod", "HEAT"); jObject.put("licensingVersion", jlicensingVersionObj); jObject.put("vendorName", vendorName); jObject.put("vendorId", vendorId); @@ -669,7 +670,7 @@ public class OnboardingUtils { boolean vspFound = HomePage.searchForVSP(vspName); if (vspFound){ - + List elemenetsFromTable = HomePage.getElemenetsFromTable(); // WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30); // WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1))); @@ -767,24 +768,36 @@ public class OnboardingUtils { LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); ArtifactsCorrelationManager.addVNFartifactDetails(vspName, deploymentArtifacts); - validateDeploymentArtifactsVersion(deploymentArtifacts); + List heatEnvFilesFromCSAR = deploymentArtifacts.stream().filter(e -> e.getType().equals("HEAT_ENV")). + map(e -> e.getFileName()). + collect(Collectors.toList()); + + validateDeploymentArtifactsVersion(deploymentArtifacts, heatEnvFilesFromCSAR); + DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); return createVendorSoftwareProduct; } - public static void validateDeploymentArtifactsVersion(LinkedList deploymentArtifacts) { - String artifactVersion = "1"; + public static void validateDeploymentArtifactsVersion(LinkedList deploymentArtifacts, + List heatEnvFilesFromCSAR) { + String artifactVersion; String artifactName; - + for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) { + artifactVersion = "1"; + if(deploymentArtifact.getType().equals("HEAT_ENV")) { continue; } else if(deploymentArtifact.getFileName().contains(".")) { - artifactName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf(".")); + artifactName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf(".")); } else { - artifactName = deploymentArtifact.getFileName().trim(); + artifactName = deploymentArtifact.getFileName().trim(); + } + + if (heatEnvFilesFromCSAR.contains(artifactName + ".env")){ + artifactVersion = "2"; } - ArtifactUIUtils.validateArtifactNameVersionType(artifactName, artifactVersion, deploymentArtifact.getType()); + ArtifactUIUtils.validateArtifactNameVersionType(artifactName, artifactVersion, deploymentArtifact.getType()); } } -- cgit 1.2.3-korg