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 static org.testng.Assert.assertTrue;
26 import java.util.HashMap;
27 import java.util.LinkedList;
28 import java.util.List;
30 import java.util.stream.Collectors;
32 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
34 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
35 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
38 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
39 import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar;
40 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
41 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
42 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
43 import org.openecomp.sdc.ci.tests.pages.HomePage;
44 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
45 import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
46 import org.openecomp.sdc.ci.tests.utilities.DownloadManager;
47 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
48 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
49 import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils;
50 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
51 import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
52 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
53 import org.openecomp.sdc.ci.tests.verificator.VFCArtifactVerificator;
54 import org.testng.SkipException;
55 import org.testng.annotations.BeforeClass;
56 import org.testng.annotations.Test;
58 import com.aventstack.extentreports.Status;
59 import com.clearspring.analytics.util.Pair;
61 public class VFCArtifacts extends SetupCDTest {
63 private static final String DEPLOYMENT = "Deployment";
64 private static final String INFORMATIONAL = "Informational";
65 private static final String ARTIFACTS = "artifacts";
66 private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts";
67 private String filePath;
68 private Object object;
70 public void beforeClass(){
71 filePath = System.getProperty("filepath");
72 if (filePath == null && System.getProperty("os.name").contains("Windows")) {
73 filePath = FileHandling.getResourcesFilesPath() + "VFCArtifacts"+ File.separator;
75 else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
76 filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "VFCArtifacts"+ File.separator;
81 public void ImportMultiVFCTest_TC1407998() throws Exception{
84 throw new SkipException("Open bug 294400");
87 String csarFile = "Import_Multi_VFC.csar";
89 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
90 resourceMetaData.setVersion("0.1");
91 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
93 RestResponse getResponse = RestCDUtils.getResource(resourceMetaData, getUser());
94 assertTrue(getResponse.getErrorCode().intValue() == 200);
96 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = verifyVfcArtifacts(filePath, csarFile, resourceMetaData, getResponse);
98 VFCArtifactVerificator.verifyVFCArtifactsNotInVFArtifactList(resourceMetaData, getUser(), getResponse, expectedArtifactMap);
104 public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception{
107 throw new SkipException("Open bug 294400");
110 String csarFile = "LDSA-ORIG.csar";
111 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
112 resourceMetaData.setVersion("0.1");
113 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
115 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
116 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
117 for (String key : vfcKeys){
118 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
121 String updatedCsarFile = "LDSA-MODIFY.csar";
122 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
124 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
125 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
126 for (String key : updatedVfcKeys){
127 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
128 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
133 public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception{
136 throw new SkipException("Open bug 294400");
139 String csarFile = "LDSA-ORIG.csar";
140 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
141 resourceMetaData.setVersion("0.1");
142 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
144 String updatedCsarFile = "LDSA-DELETE-ADD.csar";
145 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
147 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
151 public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception{
154 throw new SkipException("Open bug 294400");
157 String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar";
158 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
159 resourceMetaData.setVersion("0.1");
160 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
162 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
164 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
165 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
166 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
167 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
169 String updatedCsarFile = "LDSA-ADD.csar";
170 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
172 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
174 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
175 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
180 public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception{
183 throw new SkipException("Open bug 294400");
186 String csarFile = "LDSA-SINGLE.csar";
187 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
188 resourceMetaData.setVersion("0.1");
189 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
191 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
192 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
193 for (String key : vfcKeys){
194 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
197 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
198 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
199 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
200 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
202 String updatedCsarFile = "LDSA-MULTI.csar";
203 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
205 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
206 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
207 for (String key : updatedVfcKeys){
208 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
209 if (vfcKeys.contains(key)){
210 VFCArtifactVerificator.verifyVFCArtifactNotChanged(key, resourceMetaData, getUser());
214 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
215 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
219 public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception{
220 String csarFile = "LDSA-ORIG.csar";
221 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
222 resourceMetaData.setVersion("0.1");
223 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
225 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
226 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
227 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
228 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
230 String updatedCsarFile = "LDSA-DELETE-ALL.csar";
231 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
233 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
235 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
236 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
240 public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception{
243 throw new SkipException("Open bug 294400");
246 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
248 String vnfFile = "vProbes_FE.zip";
249 String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip";
251 OnboardingUtils.createVendorLicense(getUser());
252 Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser());
253 String vspName = createVSP.left;
254 resourceMetaData.setName(vspName);
255 Map<String, String> resourceMeta = createVSP.right;
256 String vspid = resourceMeta.get("vspId");
257 OnboardingUtils.addVFCArtifacts(filePath, snmpFile, null, vspid, getUser());
258 OnboardingUtils.prepareVspForUse(getUser(), vspid);
260 String downloadDirectory = getWindowTest().getDownloadDirectory();
261 String csarFile = vspid + ".csar";
263 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
264 HomePage.showVspRepository();
265 OnboardingUtils.importVSP(createVSP);
266 resourceMetaData.setVersion("0.1");
268 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
270 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
271 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
276 public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception{
279 throw new SkipException("Open bug 294400");
282 //check of version is 1
283 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
285 String vnfFile = "vProbes_FE.zip";
286 String snmpPollFile = "vprobes-vLB.zip";
287 String updatedSnmpPollFile = "vprobes-vLBAgent.zip";
289 OnboardingUtils.createVendorLicense(getUser());
290 Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser());
291 String vspName = createVSP.left;
292 resourceMetaData.setName(vspName);
293 Map<String, String> resourceMeta = createVSP.right;
294 String vspid = resourceMeta.get("vspId");
295 String montoringComponentId = OnboardingUtils.addVFCArtifacts(filePath, snmpPollFile, null, vspid, getUser());
296 OnboardingUtils.prepareVspForUse(getUser(), vspid);
298 String downloadDirectory = getWindowTest().getDownloadDirectory();
299 String csarFile = vspid + ".csar";
301 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
302 HomePage.showVspRepository();
303 OnboardingUtils.importVSP(createVSP);
305 ResourceGeneralPage.clickSubmitForTestingButton(vspName);
307 reloginWithNewRole(UserRoleEnum.TESTER);
308 GeneralUIUtils.findComponentAndClick(vspName);
309 TesterOperationPage.certifyComponent(vspName);
311 reloginWithNewRole(UserRoleEnum.DESIGNER);
312 OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpPollFile, null, montoringComponentId, getUser());
313 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
314 HomePage.showVspRepository();
315 OnboardingUtils.updateVSP(createVSP);
316 resourceMetaData.setVersion("1.1");
318 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
319 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
321 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
326 public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception{
329 throw new SkipException("Open bug 294400");
332 //check of version is 2
333 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
335 String vnfFile = "vProbes_FE.zip";
336 String snmpFile = "vprobes-vLB.zip";
337 String updatedSnmpFile = "vprobes-vLB-Modified.zip";
339 OnboardingUtils.createVendorLicense(getUser());
340 Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser());
341 String vspName = createVSP.left;
342 resourceMetaData.setName(vspName);
343 Map<String, String> resourceMeta = createVSP.right;
344 String vspid = resourceMeta.get("vspId");
345 String monitoringId = OnboardingUtils.addVFCArtifacts(filePath, snmpFile, null, vspid, getUser());
346 OnboardingUtils.prepareVspForUse(getUser(), vspid);
348 String downloadDirectory = getWindowTest().getDownloadDirectory();
349 String csarFile = vspid + ".csar";
351 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
352 HomePage.showVspRepository();
353 OnboardingUtils.importVSP(createVSP);
355 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
356 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
357 for (String key : vfcKeys){
358 resourceMetaData.setVersion("0.1");
359 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
362 ResourceGeneralPage.clickSubmitForTestingButton(vspName);
364 reloginWithNewRole(UserRoleEnum.TESTER);
365 GeneralUIUtils.findComponentAndClick(vspName);
366 TesterOperationPage.certifyComponent(vspName);
368 reloginWithNewRole(UserRoleEnum.DESIGNER);
369 OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpFile, null, monitoringId, getUser());
370 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
371 HomePage.showVspRepository();
372 OnboardingUtils.updateVSP(createVSP);
373 resourceMetaData.setVersion("1.1");
375 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
376 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
378 Map<String, Object> artifactsFromCsarAfterUpdate = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
379 List<String> vfcKeysAfterUpdate = artifactsFromCsarAfterUpdate.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
380 for (String key : vfcKeysAfterUpdate){
381 verifyVfcInstanceArtifacts(resourceMetaData, null, artifactsFromCsarAfterUpdate, key);
382 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
395 protected UserRoleEnum getRole() {
396 return UserRoleEnum.DESIGNER;
399 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcArtifacts(String filepath, String csarFile,
400 ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception {
401 ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts");
402 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = null;
403 ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file");
404 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filepath + csarFile);
405 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
406 for (String key : vfcKeys){
407 expectedArtifactMap = verifyVfcInstanceArtifacts(resourceMetaData, getResponse, artifactsFromCsar, key);
409 return expectedArtifactMap;
412 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcInstanceArtifacts(
413 ResourceReqDetails resourceMetaData, RestResponse getResponse, Map<String, Object> artifactsFromCsar, String key) {
415 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap;
416 Map<String,LinkedList<HeatMetaFirstLevelDefinition>> vfcDeploymentArtifacts = (Map<String,LinkedList<HeatMetaFirstLevelDefinition>>)artifactsFromCsar.get(key);
417 LinkedList<HeatMetaFirstLevelDefinition> deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT);
418 LinkedList<HeatMetaFirstLevelDefinition> informationalList = (LinkedList<HeatMetaFirstLevelDefinition>) artifactsFromCsar.get(INFORMATIONAL);
420 expectedArtifactMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>();
421 if(deploymentList == null){
422 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
424 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, deploymentList);
426 if(informationalList == null){
427 expectedArtifactMap.put(ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
429 expectedArtifactMap.put(ARTIFACTS, informationalList);
433 VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse);
434 return expectedArtifactMap;