1 package org.openecomp.sdc.ci.tests.execute.sanity;
3 import com.aventstack.extentreports.Status;
4 import com.clearspring.analytics.util.Pair;
6 import org.openecomp.sdc.be.model.*;
7 import org.openecomp.sdc.be.model.Service;
8 import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders;
9 import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
10 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
11 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
12 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
13 import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum;
14 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
15 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
16 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
17 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
18 import org.openecomp.sdc.ci.tests.utils.general.*;
19 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
20 import org.testng.annotations.Test;
23 import java.util.HashMap;
24 import java.util.List;
26 import java.util.Map.Entry;
28 import static org.testng.AssertJUnit.assertTrue;
30 public class OnboardingFlowsThroughAPI extends SetupCDTest{
32 protected boolean skipReport = false;
33 protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
36 // 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
39 public void addVesFileToVsp() throws Exception{
40 String vnfFile = "vMME_Ericsson_small_v2.zip";
41 String vesArtifactFile = "VES.zip";
42 String filePath = FileHandling.getFilePath("VFCArtifacts");
43 String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile;
44 List<String> vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
45 List<String> tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
46 Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
47 cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation);
48 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
50 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
51 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
52 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, cvfcArtifacts);
53 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
54 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
55 List<ComponentInstance> componentInstances = resource.getComponentInstances();
56 for(ComponentInstance componentInstance : componentInstances){
57 if(componentInstance.getDeploymentArtifacts() !=null && !componentInstance.getDeploymentArtifacts().isEmpty()){
58 Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts();
59 for(Entry<String, ArtifactDefinition> entry : deploymentArtifacts.entrySet()){
60 if(entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())){
61 for(String vesArtifact : vesArtifacts){
62 if(entry.getValue().getArtifactName().equals(vesArtifact)){
63 tempVesArtifacts.remove(vesArtifact);
70 assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty());
73 // 741433: Update Old VSP
74 // 2. Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF
75 // 3. Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF
76 // @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
77 // public void create2(String filePath, String vnfFile) throws Exception{
82 // 741509: E2E flow using old VLM
84 public void VlmReuse() throws Exception{
85 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
86 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder);
87 String filePath = FileHandling.getVnfRepositoryPath();
88 String vnfFile = newRandomFileNamesFromFolder.get(0);
89 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
91 getExtendTest().log(Status.INFO, "Create Vendor License");
92 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
93 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
94 getExtendTest().log(Status.INFO, "Create Vendor Software Product: " + resourceReqDetails.getName());
95 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
96 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
97 getExtendTest().log(Status.INFO, "Create Resource: " + resourceReqDetails.getName());
98 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
99 getExtendTest().log(Status.INFO, "Certify the Resource: " + resourceReqDetails.getName());
100 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
102 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
103 getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName());
104 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
106 getExtendTest().log(Status.INFO, "Add VF to service");
107 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
108 addComponentInstanceToComponentContainer.left().value();
109 getExtendTest().log(Status.INFO, "Certify the service");
110 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
111 getExtendTest().log(Status.INFO, "Start distributing the service");
112 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
113 getExtendTest().log(Status.INFO, "Service distributed");
114 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
117 vnfFile = newRandomFileNamesFromFolder.get(1);
118 getExtendTest().log(Status.INFO, "Going to update VLM with new file " + vnfFile);
119 VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails, false);
120 vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
121 getExtendTest().log(Status.INFO, "Create new VSP: " + vendorSoftwareProductObject.getName());
122 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
123 getExtendTest().log(Status.INFO, "Create new resource: " + resourceReqDetails.getName());
124 resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
125 getExtendTest().log(Status.INFO, "Certify the resource");
126 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
128 serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
129 getExtendTest().log(Status.INFO, "Create new service: " + serviceReqDetails.getName());
130 service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
132 getExtendTest().log(Status.INFO, "Add VF to service");
133 addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
134 addComponentInstanceToComponentContainer.left().value();
135 getExtendTest().log(Status.INFO, "Certify the service");
136 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
137 getExtendTest().log(Status.INFO, "Start distributing the service");
138 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
139 getExtendTest().log(Status.INFO, "Service distributed");
140 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
144 // 741607: E2E flow using old VSP
146 public void updateVfiVersionOnServiceLevel() throws Throwable{
147 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
148 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder);
149 String filePath = FileHandling.getVnfRepositoryPath();
150 String vnfFile = newRandomFileNamesFromFolder.get(0);
151 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
152 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser());
153 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
154 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
155 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
156 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
157 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
159 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
160 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
162 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
163 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
164 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
165 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
166 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
168 // update resource to v2.0
169 String updateVnfFile = newRandomFileNamesFromFolder.get(1);
170 getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile);
171 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, updateVnfFile);
172 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
173 resourceReqDetails.setUniqueId(resource.getUniqueId());
174 resourceReqDetails.setVersion(resource.getVersion());
175 resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
176 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
178 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
179 AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
181 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
182 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
183 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
187 // 741608: E2E flow using old Service
188 // @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
189 // public void create5(String filePath, String vnfFile) throws Exception{
191 // // 1. Create Service with old resource -> Certify this Service - > Distribute
192 // // 2. Service is distributed
193 // // 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute
194 // // 4. Service is distributed
197 // 741633: Update HEAT parameter value
199 public void updateHeatParametersValue() throws Throwable{
200 String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully";
201 getExtendTest().log(Status.INFO, msg);
205 public void UpdateVSPRevertToEarlierVersion() throws Throwable
208 // 1. Import VSP v1.0
209 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
210 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder);
211 String filePath = FileHandling.getVnfRepositoryPath();
212 String vnfFile = newRandomFileNamesFromFolder.get(0);
213 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
214 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
215 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
216 getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName());
217 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
218 getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
219 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
220 // 2. Create VF, certify - v1.0 is created
221 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
222 getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
223 Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
224 getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
225 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
226 // 3. Update VSP to v2.0
227 getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
228 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile);
229 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
230 // 4. Update the VF with v2.0 of the VSP
231 getExtendTest().log(Status.INFO, "Checkout VF v1.1");
232 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
233 resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
234 resourceReqDetails.setVersion("1.1");
235 resourceReqDetails.setCsarVersion("2.0");
236 getExtendTest().log(Status.INFO, "Update VF to v2.0");
237 resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
238 getExtendTest().log(Status.INFO, "Certify VF");
239 Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
240 // 5. Update VSP to v3.0 wih the zip from v1.0
241 getExtendTest().log(Status.INFO, "Update VSP to version 3.0");
242 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, false);
243 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
244 getExtendTest().log(Status.INFO, "Checkout VF v2.1");
245 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
246 resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
247 resourceReqDetails.setVersion("2.1");
248 resourceReqDetails.setCsarVersion("3.0");
249 getExtendTest().log(Status.INFO, "Update VF to v3.0");
250 ResourceRestUtils.updateResource(resourceReqDetails,sdncDesignerDetails1,resource_v1.getUniqueId());
251 // 6. Update VF to v3.0
252 getExtendTest().log(Status.INFO, "Certify VF");
253 Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
254 // 7. Compare versions v1.0 and v3.0 - should be the same
255 // TODO: Shay add resource comparison.
256 // 8. Add each of the versions to service, certify - OK
257 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1);
258 getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName() );
259 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
260 getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service");
261 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true);
262 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true);
263 getExtendTest().log(Status.INFO, "Certify Service");
264 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
265 System.out.println("");
268 @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "updateList")
269 public void updateVSPFlowFromOnboardToDistribution(String vnfFile1, String vnfFile2) throws Throwable
271 setLog(String.format("Create VSP from %s , update VSP with %s ", vnfFile1, vnfFile2));
272 // 1. Import VSP v1.0
273 String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
274 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
275 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
276 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
277 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
278 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
279 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
280 // 2. Create VF, certify - v1.0 is created
281 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
282 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
283 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
284 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
285 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
286 // 3. Create Service add to it the certified VF and certify the Service v1.0
287 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
288 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
289 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
290 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
291 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
292 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
293 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
294 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
295 // 4. Distribute the Service v1.0
296 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
297 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
298 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
299 // 5. Update VSP to v2.0
300 getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
301 VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile2);
302 getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: " ,vnfFile2));
303 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
304 // 6. Update the VF with v2.0 of the VSP and certify the VF
305 getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 " ,resourceReqDetails.getName()));
306 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
307 resourceReqDetails.setUniqueId(resource.getUniqueId());
308 resourceReqDetails.setVersion("1.1");
309 resourceReqDetails.setCsarVersion("2.0");
310 getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 " ,resourceReqDetails.getName(),vendorSoftwareProductObject.getName()));
311 resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
312 getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0"));
313 Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
314 // 7. Update the Service with the VFi version 2.0
315 getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1"));
316 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
317 getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0"));
318 AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
319 getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0"));
320 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
321 // 8. Distribute the service v2.0
322 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
323 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
324 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
327 @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "VNF_List")
328 public void fromOnboardToDistribution(String filePath, String vnfFile) throws Throwable
330 // String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip";
331 // String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip";
332 setLog(String.format("%s", vnfFile));
333 // 1. Import VSP v1.0
334 //String filePath = FileHandling.getVnfRepositoryPath();
335 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
336 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
337 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
338 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
339 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile));
340 Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
341 // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
342 VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
343 // 2. Create VF, certify - v1.0 is created
344 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
345 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
346 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
347 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
348 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
349 // 3. Create Service add to it the certified VF and certify the Service v1.0
350 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
351 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
352 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
353 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
354 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
355 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
356 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
357 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
358 // 4. Distribute the Service v1.0
359 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
360 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
361 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
365 public void onboardE2EviaAPI() throws Throwable
367 // 1. Import VSP v1.0
368 String filePath = FileHandling.getVnfRepositoryPath();
369 String vnfFile1 = "1-VF-vCSCF-StateDB-new-update_v3.0.zip";
370 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
371 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
372 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
373 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
374 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
375 Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
376 // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct);
377 VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
378 // 2. Create VF, certify - v1.0 is created
379 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
380 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
381 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
382 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
383 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
384 // 3. Create Service add to it the certified VF and certify the Service v1.0
385 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
386 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
387 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
388 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
389 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
390 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
391 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
392 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
393 // 4. Distribute the Service v1.0
394 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
395 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
396 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
400 protected UserRoleEnum getRole() {
401 return UserRoleEnum.DESIGNER;