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{
83 String csarFile = "Import_Multi_VFC.csar";
85 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
86 resourceMetaData.setVersion("0.1");
87 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
89 RestResponse getResponse = RestCDUtils.getResource(resourceMetaData, getUser());
90 assertTrue(getResponse.getErrorCode().intValue() == 200);
92 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = verifyVfcArtifacts(filePath, csarFile, resourceMetaData, getResponse);
94 VFCArtifactVerificator.verifyVFCArtifactsNotInVFArtifactList(resourceMetaData, getUser(), getResponse, expectedArtifactMap);
100 public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception{
102 String csarFile = "LDSA-ORIG.csar";
103 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
104 resourceMetaData.setVersion("0.1");
105 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
107 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
108 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
109 for (String key : vfcKeys){
110 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
113 String updatedCsarFile = "LDSA-MODIFY.csar";
114 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
116 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
117 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
118 for (String key : updatedVfcKeys){
119 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
120 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
125 public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception{
126 String csarFile = "LDSA-ORIG.csar";
127 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
128 resourceMetaData.setVersion("0.1");
129 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
131 String updatedCsarFile = "LDSA-DELETE-ADD.csar";
132 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
134 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
138 public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception{
140 String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar";
141 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
142 resourceMetaData.setVersion("0.1");
143 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
145 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
147 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
148 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
149 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
150 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
152 String updatedCsarFile = "LDSA-ADD.csar";
153 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
155 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
157 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
158 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
163 public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception{
165 String csarFile = "LDSA-SINGLE.csar";
166 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
167 resourceMetaData.setVersion("0.1");
168 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
170 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
171 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
172 for (String key : vfcKeys){
173 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
176 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
177 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
178 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
179 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
181 String updatedCsarFile = "LDSA-MULTI.csar";
182 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
184 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
185 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
186 for (String key : updatedVfcKeys){
187 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
188 if (vfcKeys.contains(key)){
189 VFCArtifactVerificator.verifyVFCArtifactNotChanged(key, resourceMetaData, getUser());
193 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
194 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
198 public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception{
199 String csarFile = "LDSA-ORIG.csar";
200 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
201 resourceMetaData.setVersion("0.1");
202 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
204 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
205 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
206 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
207 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
209 String updatedCsarFile = "LDSA-DELETE-ALL.csar";
210 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
212 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
214 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
215 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
219 public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception{
220 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
222 String vnfFile = "vProbes_FE.zip";
223 String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip";
225 OnboardingUtils.createVendorLicense(getUser());
226 Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser());
227 String vspName = createVSP.left;
228 resourceMetaData.setName(vspName);
229 Map<String, String> resourceMeta = createVSP.right;
230 String vspid = resourceMeta.get("vspId");
231 OnboardingUtils.addVFCArtifacts(filePath, snmpFile, null, vspid, getUser());
232 OnboardingUtils.prepareVspForUse(getUser(), vspid);
234 String downloadDirectory = getWindowTest().getDownloadDirectory();
235 String csarFile = vspid + ".csar";
237 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
238 HomePage.showVspRepository();
239 OnboardingUtils.importVSP(createVSP);
240 resourceMetaData.setVersion("0.1");
242 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
244 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
245 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
250 public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception{
252 //check of version is 1
253 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
255 String vnfFile = "vProbes_FE.zip";
256 String snmpPollFile = "vprobes-vLB.zip";
257 String updatedSnmpPollFile = "vprobes-vLBAgent.zip";
259 OnboardingUtils.createVendorLicense(getUser());
260 Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser());
261 String vspName = createVSP.left;
262 resourceMetaData.setName(vspName);
263 Map<String, String> resourceMeta = createVSP.right;
264 String vspid = resourceMeta.get("vspId");
265 String montoringComponentId = OnboardingUtils.addVFCArtifacts(filePath, snmpPollFile, null, vspid, getUser());
266 OnboardingUtils.prepareVspForUse(getUser(), vspid);
268 String downloadDirectory = getWindowTest().getDownloadDirectory();
269 String csarFile = vspid + ".csar";
271 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
272 HomePage.showVspRepository();
273 OnboardingUtils.importVSP(createVSP);
275 ResourceGeneralPage.clickSubmitForTestingButton(vspName);
277 reloginWithNewRole(UserRoleEnum.TESTER);
278 GeneralUIUtils.findComponentAndClick(vspName);
279 TesterOperationPage.certifyComponent(vspName);
281 reloginWithNewRole(UserRoleEnum.DESIGNER);
282 OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpPollFile, null, montoringComponentId, getUser());
283 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
284 HomePage.showVspRepository();
285 OnboardingUtils.updateVSP(createVSP);
286 resourceMetaData.setVersion("1.1");
288 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
289 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
291 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
296 public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception{
298 //check of version is 2
299 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
301 String vnfFile = "vProbes_FE.zip";
302 String snmpFile = "vprobes-vLB.zip";
303 String updatedSnmpFile = "vprobes-vLB-Modified.zip";
305 OnboardingUtils.createVendorLicense(getUser());
306 Pair<String, Map<String, String>> createVSP = OnboardingUtils.createVSP(vnfFile, filePath, getUser());
307 String vspName = createVSP.left;
308 resourceMetaData.setName(vspName);
309 Map<String, String> resourceMeta = createVSP.right;
310 String vspid = resourceMeta.get("vspId");
311 String monitoringId = OnboardingUtils.addVFCArtifacts(filePath, snmpFile, null, vspid, getUser());
312 OnboardingUtils.prepareVspForUse(getUser(), vspid);
314 String downloadDirectory = getWindowTest().getDownloadDirectory();
315 String csarFile = vspid + ".csar";
317 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
318 HomePage.showVspRepository();
319 OnboardingUtils.importVSP(createVSP);
321 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
322 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
323 for (String key : vfcKeys){
324 resourceMetaData.setVersion("0.1");
325 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
328 ResourceGeneralPage.clickSubmitForTestingButton(vspName);
330 reloginWithNewRole(UserRoleEnum.TESTER);
331 GeneralUIUtils.findComponentAndClick(vspName);
332 TesterOperationPage.certifyComponent(vspName);
334 reloginWithNewRole(UserRoleEnum.DESIGNER);
335 OnboardingUtils.updateVspWithVfcArtifacts(filePath, vspid, updatedSnmpFile, null, monitoringId, getUser());
336 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
337 HomePage.showVspRepository();
338 OnboardingUtils.updateVSP(createVSP);
339 resourceMetaData.setVersion("1.1");
341 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
342 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
344 Map<String, Object> artifactsFromCsarAfterUpdate = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
345 List<String> vfcKeysAfterUpdate = artifactsFromCsarAfterUpdate.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
346 for (String key : vfcKeysAfterUpdate){
347 verifyVfcInstanceArtifacts(resourceMetaData, null, artifactsFromCsarAfterUpdate, key);
348 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
361 protected UserRoleEnum getRole() {
362 return UserRoleEnum.DESIGNER;
365 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcArtifacts(String filepath, String csarFile,
366 ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception {
367 ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts");
368 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = null;
369 ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file");
370 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filepath + csarFile);
371 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
372 for (String key : vfcKeys){
373 expectedArtifactMap = verifyVfcInstanceArtifacts(resourceMetaData, getResponse, artifactsFromCsar, key);
375 return expectedArtifactMap;
378 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcInstanceArtifacts(
379 ResourceReqDetails resourceMetaData, RestResponse getResponse, Map<String, Object> artifactsFromCsar, String key) {
381 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap;
382 Map<String,LinkedList<HeatMetaFirstLevelDefinition>> vfcDeploymentArtifacts = (Map<String,LinkedList<HeatMetaFirstLevelDefinition>>)artifactsFromCsar.get(key);
383 LinkedList<HeatMetaFirstLevelDefinition> deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT);
384 LinkedList<HeatMetaFirstLevelDefinition> informationalList = (LinkedList<HeatMetaFirstLevelDefinition>) artifactsFromCsar.get(INFORMATIONAL);
386 expectedArtifactMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>();
387 if(deploymentList == null){
388 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
390 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, deploymentList);
392 if(informationalList == null){
393 expectedArtifactMap.put(ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
395 expectedArtifactMap.put(ARTIFACTS, informationalList);
399 VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse);
400 return expectedArtifactMap;