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.apache.http.HttpStatus;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
27 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
28 import org.openecomp.sdc.ci.tests.datatypes.VendorLicenseModel;
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.utilities.DownloadManager;
41 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
42 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
43 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
44 import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
45 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
46 import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils;
47 import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils;
48 import org.openecomp.sdc.ci.tests.verificator.VFCArtifactVerificator;
49 import org.testng.annotations.BeforeClass;
50 import org.testng.annotations.Test;
52 import java.util.HashMap;
53 import java.util.LinkedList;
54 import java.util.List;
56 import java.util.stream.Collectors;
58 import static org.testng.Assert.assertTrue;
60 public class VFCArtifacts extends SetupCDTest {
62 private static final String DEPLOYMENT = "Deployment";
63 private static final String INFORMATIONAL = "Informational";
64 private static final String ARTIFACTS = "artifacts";
65 private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts";
66 private String filePath;
69 public void beforeClass() {
70 filePath = FileHandling.getFilePath("VFCArtifacts");
74 public void ImportMultiVFCTest_TC1407998() throws Exception {
76 String csarFile = "Import_Multi_VFC.csar";
78 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
79 resourceMetaData.setVersion("0.1");
80 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
82 RestResponse getResponse = RestCDUtils.getResource(resourceMetaData, getUser());
83 assertTrue(getResponse.getErrorCode().intValue() == HttpStatus.SC_OK);
85 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = verifyVfcArtifacts(filePath, csarFile, resourceMetaData, getResponse);
87 VFCArtifactVerificator.verifyVFCArtifactsNotInVFArtifactList(resourceMetaData, getUser(), getResponse, expectedArtifactMap);
93 public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception {
95 String csarFile = "LDSA-ORIG.csar";
96 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
97 resourceMetaData.setVersion("0.1");
98 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
100 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
101 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
102 for (String key : vfcKeys) {
103 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
106 String updatedCsarFile = "LDSA-MODIFY.csar";
107 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
109 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
110 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
111 for (String key : updatedVfcKeys) {
112 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
113 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
118 public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception {
120 String csarFile = "LDSA-ORIG.csar";
121 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
122 resourceMetaData.setVersion("0.1");
123 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
125 String updatedCsarFile = "LDSA-DELETE-ADD.csar";
126 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
128 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
132 public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception {
134 String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar";
135 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
136 resourceMetaData.setVersion("0.1");
137 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
139 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
141 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
142 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
143 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
144 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
146 String updatedCsarFile = "LDSA-ADD.csar";
147 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
149 verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null);
151 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
152 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
157 public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception {
159 String csarFile = "LDSA-SINGLE.csar";
160 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
161 resourceMetaData.setVersion("0.1");
162 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
164 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile);
165 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
166 for (String key : vfcKeys) {
167 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
170 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
171 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
172 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
173 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
175 String updatedCsarFile = "LDSA-MULTI.csar";
176 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
178 Map<String, Object> updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile);
179 List<String> updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
180 for (String key : updatedVfcKeys) {
181 verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key);
182 if (vfcKeys.contains(key)) {
183 VFCArtifactVerificator.verifyVFCArtifactNotChanged(key, resourceMetaData, getUser());
187 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
188 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
192 public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception {
194 String csarFile = "LDSA-ORIG.csar";
195 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
196 resourceMetaData.setVersion("0.1");
197 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser());
199 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
200 String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile);
201 String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile);
202 DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen();
204 String updatedCsarFile = "LDSA-DELETE-ALL.csar";
205 ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile);
207 VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null);
209 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
210 DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate);
214 public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception {
216 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
218 String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip";
219 String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip";
221 VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
222 VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(),
224 String vspName = createVSP.getName();
225 resourceMetaData.setName(vspName);
226 // VendorSoftwareProductObject resourceMeta = createVSP.right;
227 String vspid = createVSP.getVspId();
228 VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser());
229 VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true);
231 String downloadDirectory = getWindowTest().getDownloadDirectory();
232 String csarFile = vspid + ".csar";
234 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
235 HomePage.showVspRepository();
236 OnboardingUiUtils.importVSP(createVSP);
237 resourceMetaData.setVersion("0.1");
239 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
241 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
242 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
247 public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception {
249 //check of version is 1
250 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
252 String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip";
253 String snmpPollFile = "vprobes-vLB.zip";
254 String updatedSnmpPollFile = "vprobes-vLBAgent.zip";
256 VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
257 VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(),
259 String vspName = createVSP.getName();
260 resourceMetaData.setName(vspName);
261 String vspid = createVSP.getVspId();
262 String monitoringComponentId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpPollFile, null, createVSP, getUser());
263 VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true);
265 String downloadDirectory = getWindowTest().getDownloadDirectory();
266 String csarFile = vspid + ".csar";
268 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
269 HomePage.showVspRepository();
270 OnboardingUiUtils.importVSP(createVSP);
271 ResourceGeneralPage.clickCertifyButton(vspName);
273 VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpPollFile, null, monitoringComponentId, getUser(), createVSP);
274 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
275 HomePage.showVspRepository();
276 OnboardingUiUtils.updateVSP(createVSP);
277 resourceMetaData.setVersion("1.1");
279 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
280 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
282 verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null);
287 public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception {
289 //check of version is 2
290 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
292 String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip";
293 String snmpFile = "vprobes-vLB.zip";
294 String updatedSnmpFile = "vprobes-vLB-Modified.zip";
296 VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
297 VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(),
299 String vspName = createVSP.getName();
300 resourceMetaData.setName(vspName);
301 String vspid = createVSP.getVspId();
302 String monitoringId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser());
303 VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true);
305 String downloadDirectory = getWindowTest().getDownloadDirectory();
306 String csarFile = vspid + ".csar";
308 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
309 HomePage.showVspRepository();
310 OnboardingUiUtils.importVSP(createVSP);
312 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
313 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
314 for (String key : vfcKeys) {
315 resourceMetaData.setVersion("0.1");
316 VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser());
319 ResourceGeneralPage.clickCertifyButton(vspName);
320 VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpFile, null, monitoringId, getUser(), createVSP);
321 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid);
322 HomePage.showVspRepository();
323 OnboardingUiUtils.updateVSP(createVSP);
324 resourceMetaData.setVersion("1.1");
326 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
327 DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile);
329 Map<String, Object> artifactsFromCsarAfterUpdate = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile);
330 List<String> vfcKeysAfterUpdate = artifactsFromCsarAfterUpdate.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
331 for (String key : vfcKeysAfterUpdate) {
332 verifyVfcInstanceArtifacts(resourceMetaData, null, artifactsFromCsarAfterUpdate, key);
333 VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser());
340 protected UserRoleEnum getRole() {
341 return UserRoleEnum.DESIGNER;
344 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcArtifacts(String filepath, String csarFile,
345 ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception {
347 ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts");
348 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap = null;
349 ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file");
350 Map<String, Object> artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filepath + csarFile);
351 List<String> vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList());
352 for (String key : vfcKeys) {
353 expectedArtifactMap = verifyVfcInstanceArtifacts(resourceMetaData, getResponse, artifactsFromCsar, key);
355 return expectedArtifactMap;
358 private Map<String, LinkedList<HeatMetaFirstLevelDefinition>> verifyVfcInstanceArtifacts(
359 ResourceReqDetails resourceMetaData, RestResponse getResponse, Map<String, Object> artifactsFromCsar, String key) {
361 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> expectedArtifactMap;
362 Map<String, LinkedList<HeatMetaFirstLevelDefinition>> vfcDeploymentArtifacts = (Map<String, LinkedList<HeatMetaFirstLevelDefinition>>) artifactsFromCsar.get(key);
363 LinkedList<HeatMetaFirstLevelDefinition> deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT);
364 LinkedList<HeatMetaFirstLevelDefinition> informationalList = (LinkedList<HeatMetaFirstLevelDefinition>) vfcDeploymentArtifacts.get(INFORMATIONAL);
366 expectedArtifactMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>();
367 if (deploymentList == null) {
368 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
370 expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, deploymentList);
372 if (informationalList == null) {
373 expectedArtifactMap.put(ARTIFACTS, new LinkedList<HeatMetaFirstLevelDefinition>());
375 expectedArtifactMap.put(ARTIFACTS, informationalList);
378 VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse);
379 return expectedArtifactMap;