2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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 fj.data.Either;
25 import org.openecomp.sdc.be.model.*;
26 import org.openecomp.sdc.be.model.Service;
27 import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders;
28 import org.openecomp.sdc.ci.tests.datatypes.*;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
33 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
34 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
35 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
36 import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis;
37 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
38 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
39 import org.openecomp.sdc.ci.tests.utils.general.*;
40 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
41 import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator;
42 import org.testng.Assert;
43 import org.testng.annotations.Test;
46 import java.util.HashMap;
47 import java.util.List;
49 import java.util.Map.Entry;
51 import static org.testng.AssertJUnit.assertTrue;
53 public class OnboardingFlowsThroughAPI extends SetupCDTest{
55 protected boolean skipReport = false;
56 protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
59 // https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestPlan&id=6184
62 public void addVesFileToVsp() throws Exception{
63 String vnfFile = "vMME_Ericsson_small_v2.zip";
64 String vesArtifactFile = "VES.zip";
65 String filePath = FileHandling.getFilePath("VFCArtifacts");
66 String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile;
67 List<String> vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
68 List<String> tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
69 Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
70 cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation);
71 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
73 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
74 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
75 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, cvfcArtifacts);
76 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
77 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
78 List<ComponentInstance> componentInstances = resource.getComponentInstances();
79 for(ComponentInstance componentInstance : componentInstances){
80 if(componentInstance.getDeploymentArtifacts() !=null && !componentInstance.getDeploymentArtifacts().isEmpty()){
81 Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts();
82 for(Entry<String, ArtifactDefinition> entry : deploymentArtifacts.entrySet()){
83 if(entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())){
84 for(String vesArtifact : vesArtifacts){
85 if(entry.getValue().getArtifactName().equals(vesArtifact)){
86 tempVesArtifacts.remove(vesArtifact);
93 assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty());
96 // 741433: Update Old VSP
97 // 2. Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF
98 // 3. Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF
99 // @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
100 // public void create2(String filePath, String vnfFile) throws Exception{
105 // 741509: E2E flow using old VLM
107 public void VlmReuse() throws Exception{
108 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
109 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder);
110 String filePath = FileHandling.getVnfRepositoryPath();
111 String vnfFile = newRandomFileNamesFromFolder.get(0);
112 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
114 getExtendTest().log(Status.INFO, "Create Vendor License");
115 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
116 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
117 getExtendTest().log(Status.INFO, "Create Vendor Software Product: " + resourceReqDetails.getName());
118 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
119 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
120 getExtendTest().log(Status.INFO, "Create Resource: " + resourceReqDetails.getName());
121 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
122 getExtendTest().log(Status.INFO, "Certify the Resource: " + resourceReqDetails.getName());
123 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
125 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
126 getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName());
127 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
129 getExtendTest().log(Status.INFO, "Add VF to service");
130 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
131 addComponentInstanceToComponentContainer.left().value();
132 getExtendTest().log(Status.INFO, "Certify the service");
133 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
134 getExtendTest().log(Status.INFO, "Start distributing the service");
135 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
136 getExtendTest().log(Status.INFO, "Service distributed");
137 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
140 vnfFile = newRandomFileNamesFromFolder.get(1);
141 getExtendTest().log(Status.INFO, "Going to update VLM with new file " + vnfFile);
142 VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails, false);
143 vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
144 getExtendTest().log(Status.INFO, "Create new VSP: " + vendorSoftwareProductObject.getName());
145 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
146 getExtendTest().log(Status.INFO, "Create new resource: " + resourceReqDetails.getName());
147 resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
148 getExtendTest().log(Status.INFO, "Certify the resource");
149 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
151 serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
152 getExtendTest().log(Status.INFO, "Create new service: " + serviceReqDetails.getName());
153 service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
155 getExtendTest().log(Status.INFO, "Add VF to service");
156 addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
157 addComponentInstanceToComponentContainer.left().value();
158 getExtendTest().log(Status.INFO, "Certify the service");
159 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
160 getExtendTest().log(Status.INFO, "Start distributing the service");
161 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
162 getExtendTest().log(Status.INFO, "Service distributed");
163 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
167 // 741607: E2E flow using old VSP
169 public void updateVfiVersionOnServiceLevel() throws Throwable{
170 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
171 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder);
172 String filePath = FileHandling.getVnfRepositoryPath();
173 String vnfFile = newRandomFileNamesFromFolder.get(0);
174 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
175 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
176 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
177 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
178 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
179 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
180 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
182 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
183 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
185 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
186 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
187 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
188 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
189 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
191 // update resource to v2.0
192 String updateVnfFile = newRandomFileNamesFromFolder.get(1);
193 getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile);
194 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, updateVnfFile);
195 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
196 resourceReqDetails.setUniqueId(resource.getUniqueId());
197 resourceReqDetails.setVersion(resource.getVersion());
198 resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
199 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
201 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
202 AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
204 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
205 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
206 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
210 // 741608: E2E flow using old Service
211 // @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
212 // public void create5(String filePath, String vnfFile) throws Exception{
214 // // 1. Create Service with old resource -> Certify this Service - > Distribute
215 // // 2. Service is distributed
216 // // 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute
217 // // 4. Service is distributed
220 // 741633: Update HEAT parameter value
222 public void updateHeatParametersValue() throws Throwable{
223 String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully";
224 getExtendTest().log(Status.INFO, msg);
227 // temporaly disabled, until fixed
229 public void updateVSPNameTest() throws Throwable
231 // External Defect: 430425
233 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
234 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder);
235 String filePath = FileHandling.getVnfRepositoryPath();
236 String vnfFile = newRandomFileNamesFromFolder.get(0);
237 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
238 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
239 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
240 getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName());
241 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
242 getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
243 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
245 // Create VF, certify - v1.0 is created
246 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
247 getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
248 Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
249 getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
250 AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
252 // Update VSP to v2.0 wih the zip from v1.0, update VSP name
253 getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
254 String origVspName = vendorSoftwareProductObject.getName();
255 vendorSoftwareProductObject.setName("Upd" + ElementFactory.generateUUIDforSufix());
256 vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1);
257 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
259 //Validate that VF cannot be found by the updated VSP name
260 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
261 CatalogUIUtilitis.catalogSearchBox(vendorSoftwareProductObject.getName());
262 int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader();
263 assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 0, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 0 );
265 //Update VF with the new VSP version
266 GeneralUIUtils.findComponentAndClick(origVspName);
267 GeneralPageElements.clickCheckoutButton();
268 GeneralPageElements.clickBrowseButton();
269 OnboardingUiUtils.updateVSP(vendorSoftwareProductObject);
272 //Validate that VF name in v1.1 is not changed to new VSP name (it is required to keep the name if at least one certification was done)
273 Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText()));
275 //Validate that VF name in v1.0 is the old VF name
276 GeneralPageElements.selectVersion("V1.0");
277 Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText()));
281 public void UpdateVSPRevertToEarlierVersion() throws Throwable
284 // 1. Import VSP v1.0
285 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
286 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder);
287 String filePath = FileHandling.getVnfRepositoryPath();
288 String vnfFile = newRandomFileNamesFromFolder.get(0);
289 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
290 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
291 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
292 getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName());
293 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
294 getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
295 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
296 // 2. Create VF, certify - v1.0 is created
297 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
298 getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
299 Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
300 getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
301 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
302 // 3. Update VSP to v2.0
303 getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
304 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile);
305 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
306 // 4. Update the VF with v2.0 of the VSP
307 getExtendTest().log(Status.INFO, "Checkout VF v1.1");
308 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
309 resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
310 resourceReqDetails.setVersion("1.1");
311 resourceReqDetails.setCsarVersion("2.0");
312 getExtendTest().log(Status.INFO, "Update VF to v2.0");
313 resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
314 getExtendTest().log(Status.INFO, "Certify VF");
315 Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
316 // 5. Update VSP to v3.0 wih the zip from v1.0
317 getExtendTest().log(Status.INFO, "Update VSP to version 3.0");
318 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, false);
319 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
320 getExtendTest().log(Status.INFO, "Checkout VF v2.1");
321 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
322 resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
323 resourceReqDetails.setVersion("2.1");
324 resourceReqDetails.setCsarVersion("3.0");
325 getExtendTest().log(Status.INFO, "Update VF to v3.0");
326 ResourceRestUtils.updateResource(resourceReqDetails,sdncDesignerDetails1,resource_v1.getUniqueId());
327 // 6. Update VF to v3.0
328 getExtendTest().log(Status.INFO, "Certify VF");
329 Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
330 // 7. Compare versions v1.0 and v3.0 - should be the same
331 // TODO: Shay add resource comparison.
332 // 8. Add each of the versions to service, certify - OK
333 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1);
334 getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName() );
335 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
336 getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service");
337 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true);
338 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true);
339 getExtendTest().log(Status.INFO, "Certify Service");
340 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
341 System.out.println("");
344 @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "updateList")
345 public void updateVSPFlowFromOnboardToDistribution(String vnfFile1, String vnfFile2) throws Throwable
347 setLog(String.format("Create VSP from %s , update VSP with %s ", vnfFile1, vnfFile2));
348 // 1. Import VSP v1.0
349 String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
350 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
351 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
352 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
353 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
354 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
355 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
356 // 2. Create VF, certify - v1.0 is created
357 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
358 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
359 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
360 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
361 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
362 // 3. Create Service add to it the certified VF and certify the Service v1.0
363 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
364 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
365 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
366 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
367 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
368 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
369 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
370 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
371 // 4. Distribute the Service v1.0
372 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
373 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
374 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
375 // 5. Update VSP to v2.0
376 getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
377 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile2);
378 getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: " ,vnfFile2));
379 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
380 // 6. Update the VF with v2.0 of the VSP and certify the VF
381 getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 " ,resourceReqDetails.getName()));
382 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
383 resourceReqDetails.setUniqueId(resource.getUniqueId());
384 resourceReqDetails.setVersion("1.1");
385 resourceReqDetails.setCsarVersion("2.0");
386 getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 " ,resourceReqDetails.getName(),vendorSoftwareProductObject.getName()));
387 resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
388 getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0"));
389 Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
390 // 7. Update the Service with the VFi version 2.0
391 getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1"));
392 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
393 getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0"));
394 AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
395 getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0"));
396 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
397 // 8. Distribute the service v2.0
398 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
399 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
400 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
403 @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "VNF_List")
404 public void fromOnboardToDistribution(String filePath, String vnfFile) throws Throwable
406 // String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip";
407 // String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip";
408 setLog(String.format("%s", vnfFile));
409 // 1. Import VSP v1.0
410 //String filePath = FileHandling.getVnfRepositoryPath();
411 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
412 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
413 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
414 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
415 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile));
416 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
417 // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
418 // 2. Create VF, certify - v1.0 is created
419 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
420 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
421 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
422 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
423 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
424 // 3. Create Service add to it the certified VF and certify the Service v1.0
425 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
426 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
427 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
428 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
429 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
430 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
431 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
432 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
433 // 4. Distribute the Service v1.0
434 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
435 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
436 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
440 public void onboardE2EviaAPI() throws Throwable
442 // 1. Import VSP v1.0
443 String filePath = FileHandling.getVnfRepositoryPath();
444 String vnfFile1 = "1-VF-vCSCF-StateDB-new-update_v3.0.zip";
445 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
446 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
447 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
448 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
449 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
450 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
451 // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct);
452 // 2. Create VF, certify - v1.0 is created
453 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
454 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
455 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
456 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
457 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
458 // 3. Create Service add to it the certified VF and certify the Service v1.0
459 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
460 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
461 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
462 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
463 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
464 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
465 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
466 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
467 // 4. Distribute the Service v1.0
468 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
469 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
470 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
474 protected UserRoleEnum getRole() {
475 return UserRoleEnum.DESIGNER;