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 com.clearspring.analytics.util.Pair;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
27 import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
28 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
29 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
30 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
34 import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar;
35 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
36 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
37 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
38 import org.openecomp.sdc.ci.tests.pages.HomePage;
39 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
40 import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
41 import org.openecomp.sdc.ci.tests.utilities.*;
42 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
43 import org.openecomp.sdc.ci.tests.verificator.VFCArtifactVerificator;
44 import org.testng.annotations.BeforeClass;
45 import org.testng.annotations.Test;
47 import java.util.HashMap;
48 import java.util.LinkedList;
49 import java.util.List;
51 import java.util.stream.Collectors;
53 import static org.testng.Assert.assertTrue;
54 import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils;
55 import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils;
57 public class VFCArtifacts extends SetupCDTest {
59 private static final String DEPLOYMENT = "Deployment";
60 private static final String INFORMATIONAL = "Informational";
61 private static final String ARTIFACTS = "artifacts";
62 private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts";
63 private String filePath;
65 public void beforeClass(){
66 filePath = FileHandling.getFilePath("VFCArtifacts");
70 public void ImportMultiVFCTest_TC1407998() throws Exception{
72 String csarFile = "Import_Multi_VFC.csar";
74 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
75 resourceMetaData.setVersion("0.1");
76 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
78 RestResponse getResponse = RestCDUtils.getResource(resourceMetaData, getUser());
79 assertTrue(getResponse.getErrorCode().intValue() == 200);
81 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = verifyVfcArtifacts(filePath, csarFile, resourceMetaData, getResponse);
83 VFCArtifactVerificator.verifyVFCArtifactsNotInVFArtifactList(resourceMetaData, getUser(), getResponse, expectedArtifactMap);
89 public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception{
91 String csarFile = "LDSA-ORIG.csar";
92 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
93 resourceMetaData.setVersion("0.1");
94 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
96 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
97 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
98 for (String key : vfcKeys){
99 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
102 String updatedCsarFile = "LDSA-MODIFY.csar";
103 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
105 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
106 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
107 for (String key : updatedVfcKeys){
108 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
109 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
114 public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception{
116 String csarFile = "LDSA-ORIG.csar";
117 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
118 resourceMetaData.setVersion("0.1");
119 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
121 String updatedCsarFile = "LDSA-DELETE-ADD.csar";
122 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
124 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
128 public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception{
130 String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar";
131 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
132 resourceMetaData.setVersion("0.1");
133 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
135 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
137 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
138 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
139 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
140 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
142 String updatedCsarFile = "LDSA-ADD.csar";
143 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
145 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
147 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
148 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
153 public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception{
155 String csarFile = "LDSA-SINGLE.csar";
156 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
157 resourceMetaData.setVersion("0.1");
158 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
160 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
161 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
162 for (String key : vfcKeys){
163 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
166 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
167 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
168 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
169 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
171 String updatedCsarFile = "LDSA-MULTI.csar";
172 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
174 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
175 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
176 for (String key : updatedVfcKeys){
177 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
178 if (vfcKeys.contains(key)){
179 VFCArtifactVerificator.verifyVFCArtifactNotChanged(key, resourceMetaData, getUser());
183 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
184 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
188 public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception{
190 String csarFile = "LDSA-ORIG.csar";
191 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
192 resourceMetaData.setVersion("0.1");
193 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
195 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
196 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
197 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
198 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
200 String updatedCsarFile = "LDSA-DELETE-ALL.csar";
201 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
203 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
205 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
206 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
210 public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception{
212 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
214 String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip";
215 String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip";
217 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
218 Pair<String, VendorSoftwareProductObject> createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers);
219 String vspName = createVSP.left;
220 resourceMetaData.setName(vspName);
221 VendorSoftwareProductObject resourceMeta = createVSP.right;
222 String vspid = resourceMeta.getVspId();
223 VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, resourceMeta, getUser());
224 VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), resourceMeta, true);
226 String downloadDirectory = getWindowTest().getDownloadDirectory();
227 String csarFile = vspid + ".csar";
229 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
230 HomePage.showVspRepository();
231 OnboardingUiUtils.importVSP(createVSP);
232 resourceMetaData.setVersion("0.1");
234 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
236 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
237 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
242 public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception{
244 //check of version is 1
245 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
247 String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip";
248 String snmpPollFile = "vprobes-vLB.zip";
249 String updatedSnmpPollFile = "vprobes-vLBAgent.zip";
251 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
252 Pair<String, VendorSoftwareProductObject> createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers);
253 String vspName = createVSP.left;
254 resourceMetaData.setName(vspName);
255 VendorSoftwareProductObject resourceMeta = createVSP.right;
256 String vspid = resourceMeta.getVspId();
257 String montoringComponentId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpPollFile, null, resourceMeta, getUser());
258 VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), resourceMeta, true);
260 String downloadDirectory = getWindowTest().getDownloadDirectory();
261 String csarFile = vspid + ".csar";
263 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
264 HomePage.showVspRepository();
265 OnboardingUiUtils.importVSP(createVSP);
267 ResourceGeneralPage.clickSubmitForTestingButton(vspName);
269 reloginWithNewRole(UserRoleEnum.TESTER);
270 GeneralUIUtils.findComponentAndClick(vspName);
271 TesterOperationPage.certifyComponent(vspName);
273 reloginWithNewRole(UserRoleEnum.DESIGNER);
274 VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpPollFile, null, montoringComponentId, getUser(), resourceMeta);
275 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
276 HomePage.showVspRepository();
277 OnboardingUiUtils.updateVSP(createVSP);
278 resourceMetaData.setVersion("1.1");
280 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
281 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
283 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
288 public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception{
290 //check of version is 2
291 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
293 String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip";
294 String snmpFile = "vprobes-vLB.zip";
295 String updatedSnmpFile = "vprobes-vLB-Modified.zip";
297 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
298 Pair<String, VendorSoftwareProductObject> createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers);
299 String vspName = createVSP.left;
300 resourceMetaData.setName(vspName);
301 VendorSoftwareProductObject resourceMeta = createVSP.right;
302 String vspid = resourceMeta.getVspId();
303 String monitoringId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, resourceMeta, getUser());
304 VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), resourceMeta, true);
306 String downloadDirectory = getWindowTest().getDownloadDirectory();
307 String csarFile = vspid + ".csar";
309 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
310 HomePage.showVspRepository();
311 OnboardingUiUtils.importVSP(createVSP);
313 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
314 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
315 for (String key : vfcKeys){
316 resourceMetaData.setVersion("0.1");
317 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
320 ResourceGeneralPage.clickSubmitForTestingButton(vspName);
322 reloginWithNewRole(UserRoleEnum.TESTER);
323 GeneralUIUtils.findComponentAndClick(vspName);
324 TesterOperationPage.certifyComponent(vspName);
326 reloginWithNewRole(UserRoleEnum.DESIGNER);
327 VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpFile, null, monitoringId, getUser(), resourceMeta);
328 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
329 HomePage.showVspRepository();
330 OnboardingUiUtils.updateVSP(createVSP);
331 resourceMetaData.setVersion("1.1");
333 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
334 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
336 Map<String, Object> artifactsFromCsarAfterUpdate = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
337 List<String> vfcKeysAfterUpdate = artifactsFromCsarAfterUpdate.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
338 for (String key : vfcKeysAfterUpdate){
339 verifyVfcInstanceArtifacts(resourceMetaData, null, artifactsFromCsarAfterUpdate, key);
340 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
347 protected UserRoleEnum getRole() {
348 return UserRoleEnum.DESIGNER;
351 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcArtifacts(String filepath, String csarFile,
352 ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception {
354 ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts");
355 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = null;
356 ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file");
357 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filepath + csarFile);
358 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
359 for (String key : vfcKeys){
360 expectedArtifactMap = verifyVfcInstanceArtifacts(resourceMetaData, getResponse, artifactsFromCsar, key);
362 return expectedArtifactMap;
365 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcInstanceArtifacts(
366 ResourceReqDetails resourceMetaData, RestResponse getResponse, Map<String, Object> artifactsFromCsar, String key) {
368 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap;
369 Map<String,LinkedList<HeatMetaFirstLevelDefinition>> vfcDeploymentArtifacts = (Map<String,LinkedList<HeatMetaFirstLevelDefinition>>)artifactsFromCsar.get(key);
370 LinkedList<HeatMetaFirstLevelDefinition> deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT);
371 LinkedList<HeatMetaFirstLevelDefinition> informationalList = (LinkedList<HeatMetaFirstLevelDefinition>) vfcDeploymentArtifacts.get(INFORMATIONAL);
373 expectedArtifactMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>();
374 if(deploymentList == null){
375 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
377 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, deploymentList);
379 if(informationalList == null){
380 expectedArtifactMap.put(ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
382 expectedArtifactMap.put(ARTIFACTS, informationalList);
385 VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse);
386 return expectedArtifactMap;