2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.sanity;
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders;
25 import org.openecomp.sdc.ci.tests.datatypes.*;
26 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
27 import org.openecomp.sdc.ci.tests.execute.setup.ArtifactsCorrelationManager;
28 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
29 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
30 import org.openecomp.sdc.ci.tests.pages.*;
31 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
32 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
33 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
34 import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils;
35 import org.openecomp.sdc.ci.tests.utils.Utils;
36 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
37 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils;
38 import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils;
39 import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils;
40 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
41 import org.openqa.selenium.WebElement;
42 import org.testng.AssertJUnit;
43 import org.testng.annotations.BeforeMethod;
44 import org.testng.annotations.Optional;
45 import org.testng.annotations.Parameters;
46 import org.testng.annotations.Test;
49 import java.util.Arrays;
50 import java.util.HashMap;
51 import java.util.List;
53 import java.util.stream.Collectors;
55 import static org.testng.AssertJUnit.assertNotNull;
56 import static org.testng.AssertJUnit.assertTrue;
58 public class OnboardingFlowsUI extends SetupCDTest {
60 protected static String filePath = FileHandling.getVnfRepositoryPath();
61 protected String makeDistributionValue;
63 @Parameters({"makeDistribution"})
65 public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
66 makeDistributionValue = makeDistributionReadValue;
70 public void onboardVNFTestSanityOneFile() throws Throwable {
71 String vnfFile = "1-VF-vUSP-vCCF-DB_v11.1.zip";
72 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
73 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
74 runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
78 public void performanceTest() throws Throwable {
79 System.out.println("Start test");
80 Long actualTestRunTime = Utils.getActionDuration(() -> {
82 onboardVNFTestSanityOneFile();
83 } catch (Throwable throwable) {
84 throwable.printStackTrace();
87 Long regularTestRunTime = 400L;
89 assertTrue("Expected test run time should be less from " + regularTestRunTime * factor + ", actual time is " + actualTestRunTime, regularTestRunTime * factor > actualTestRunTime);
93 public void onboardVNFTestSanity() throws Throwable {
94 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList();
95 String vnfFile = fileNamesFromFolder.get(0).toString();
96 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
97 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
98 runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
102 public void runOnboardToDistributionFlow(ResourceReqDetails resourceReqDetails, ServiceReqDetails serviceMetadata, String filePath, String vnfFile) throws Exception {
103 getExtendTest().log(Status.INFO, "Going to create resource with category: " + resourceReqDetails.getCategories().get(0).getName()
104 + " subCategory: " + resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()
105 + " and service category: " + serviceMetadata.getCategory());
106 String vspName = onboardAndCertify(resourceReqDetails, filePath, vnfFile);
108 //TODO Andrey check return window after certification
109 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
111 // ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
112 ServiceUIUtils.createService(serviceMetadata, getUser());
114 ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
115 CompositionPage.searchForElement(vspName);
116 CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
117 CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName);
118 ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName);
120 assertNotNull(vfElement);
121 ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
122 ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: ");
124 ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
126 reloginWithNewRole(UserRoleEnum.TESTER);
127 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
128 TesterOperationPage.certifyComponent(serviceMetadata.getName());
130 reloginWithNewRole(UserRoleEnum.GOVERNOR);
131 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
132 GovernorOperationPage.approveSerivce(serviceMetadata.getName());
134 if (makeDistributionValue.equals("true")) {
137 reloginWithNewRole(UserRoleEnum.OPS);
138 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
139 OpsOperationPage.distributeService();
140 OpsOperationPage.displayMonitor();
142 List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
143 AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
145 OpsOperationPage.waitUntilArtifactsDistributed(0);
147 // validateInputArtsVSouput(serviceMetadata.getName());
151 getExtendTest().log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile));
154 public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception {
155 VendorSoftwareProductObject onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
156 String vspName = onboardAndValidate.getName();
158 DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
159 ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : ");
161 DeploymentArtifactPage.clickCertifyButton(vspName);
166 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
167 public void onboardVNFTest(String filePath, String vnfFile) throws Throwable {
169 System.out.println("printttttttttttttt - >" + makeDistributionValue);
170 ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource();
171 ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService();
172 runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
175 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
176 public void onboardVNFShotFlow(String filePath, String vnfFile) throws Throwable {
178 System.out.println("printttttttttttttt - >" + makeDistributionValue);
179 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
180 onboardAndCertify(resourceReqDetails, filePath, vnfFile);
183 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
184 public void onboardRandomVNFsTest(String filePath, String vnfFile) throws Throwable {
186 System.out.println("printttttttttttttt - >" + makeDistributionValue);
187 System.out.println("Vnf File name is: " + vnfFile);
188 ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource();
189 ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService();
190 runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
195 public void onboardUpdateVNFTest() throws Throwable {
196 List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath);
197 String vnfFile = fileNamesFromFolder.get(0);
198 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
199 VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
200 String vspName = vsp.getName();
201 ResourceGeneralPage.clickCertifyButton(vspName);
204 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
205 ServiceUIUtils.createService(serviceMetadata, getUser());
207 ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
208 CompositionPage.searchForElement(vspName);
209 CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
210 CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName);
211 assertNotNull(vfElement);
212 ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
214 HomePage.navigateToHomePage();
217 String updatedVnfFile = fileNamesFromFolder.get(1);
219 getExtendTest().log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile));
220 // update VendorSoftwareProduct
221 OnboardingUiUtils.updateVnfAndValidate(filePath, vsp, updatedVnfFile, getUser());
222 ResourceGeneralPage.clickCertifyButton(vspName);
224 // replace exiting VFI in service with new updated
226 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
227 ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
228 serviceCanvasManager = CanvasManager.getCanvasManager();
229 CompositionPage.changeComponentVersion(serviceCanvasManager, vfElement, "2.0");
230 ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
232 ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
234 reloginWithNewRole(UserRoleEnum.TESTER);
235 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
236 TesterOperationPage.certifyComponent(serviceMetadata.getName());
238 reloginWithNewRole(UserRoleEnum.GOVERNOR);
239 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
240 GovernorOperationPage.approveSerivce(serviceMetadata.getName());
243 reloginWithNewRole(UserRoleEnum.OPS);
244 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
245 OpsOperationPage.distributeService();
246 OpsOperationPage.displayMonitor();
248 List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
249 AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
251 OpsOperationPage.waitUntilArtifactsDistributed(0);
252 getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile));
257 public void threeVMMSCsInServiceTest() throws Exception {
259 String pathFile = FileHandling.getFilePath("VmmscArtifacts");
260 List<String> vmmscList = Arrays.asList(new File(pathFile).list()).stream().filter(e -> e.contains("vmmsc") && e.endsWith(".zip")).collect(Collectors.toList());
261 assertTrue("Did not find vMMSCs", vmmscList.size() > 0);
263 Map<String, String> vspNames = new HashMap<>();
264 for (String vnfFile : vmmscList) {
265 getExtendTest().log(Status.INFO, String.format("Going to onboard the VNF %s......", vnfFile));
266 System.out.println(String.format("Going to onboard the VNF %s......", vnfFile));
268 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
269 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
270 VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, pathFile, getUser(), amdocsLicenseMembers);
272 getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile));
273 HomePage.showVspRepository();
274 getExtendTest().log(Status.INFO, String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf("."))));
275 OnboardingUiUtils.importVSP(createVendorSoftwareProduct);
277 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
278 DeploymentArtifactPage.verifyArtifactsExistInTable(pathFile, vnfFile);
280 String vspName = createVendorSoftwareProduct.getName();
281 DeploymentArtifactPage.clickCertifyButton(vspName);
282 vspNames.put(vnfFile, vspName);
285 /* reloginWithNewRole(UserRoleEnum.TESTER);
286 for (String vsp : vspNames.values()){
287 GeneralUIUtils.findComponentAndClick(vsp);
288 TesterOperationPage.certifyComponent(vsp);
291 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
293 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
294 ServiceUIUtils.createService(serviceMetadata, getUser());
295 ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
296 CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
298 for (String vsp : vspNames.values()) {
299 CompositionPage.searchForElement(vsp);
300 CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vsp);
301 assertNotNull(vfElement);
303 ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", vspNames.values().size(), getUser());
304 File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Info_" + getExtendTest().getModel().getName());
305 final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath();
306 SetupCDTest.getExtendTest().log(Status.INFO, "Three kinds of vMMSC are in canvas now." + getExtendTest().addScreenCaptureFromPath(absolutePath));
308 ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
310 reloginWithNewRole(UserRoleEnum.TESTER);
311 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
312 TesterOperationPage.certifyComponent(serviceMetadata.getName());
314 reloginWithNewRole(UserRoleEnum.GOVERNOR);
315 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
316 GovernorOperationPage.approveSerivce(serviceMetadata.getName());
318 reloginWithNewRole(UserRoleEnum.OPS);
319 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
320 OpsOperationPage.distributeService();
321 OpsOperationPage.displayMonitor();
323 List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
324 AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
326 OpsOperationPage.waitUntilArtifactsDistributed(0);
332 protected UserRoleEnum getRole() {
333 return UserRoleEnum.DESIGNER;