2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common;
26 import org.junit.Ignore;
27 import org.junit.Test;
28 import org.onap.so.BaseIntegrationTest;
29 import org.onap.so.bpmn.core.WorkflowException;
30 import org.onap.so.bpmn.core.domain.AllottedResource;
31 import org.onap.so.bpmn.core.domain.HomingSolution;
32 import org.onap.so.bpmn.core.domain.ModelInfo;
33 import org.onap.so.bpmn.core.domain.NetworkResource;
34 import org.onap.so.bpmn.core.domain.Resource;
35 import org.onap.so.bpmn.core.domain.ServiceDecomposition;
36 import org.onap.so.bpmn.core.domain.ServiceInstance;
37 import org.onap.so.bpmn.core.domain.VnfResource;
38 import org.onap.so.bpmn.mock.FileUtil;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
42 import java.io.IOException;
43 import java.util.ArrayList;
44 import java.util.HashMap;
45 import java.util.List;
47 import java.util.UUID;
49 import static org.junit.Assert.assertEquals;
50 import static org.junit.Assert.assertNull;
51 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
52 import static org.onap.so.bpmn.mock.StubResponseOof.mockOof;
53 import static org.onap.so.bpmn.mock.StubResponseOof.mockOof_500;
57 * Test the OOF Homing subflow building block.
60 public class OofHomingTestIT extends BaseIntegrationTest {
62 Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
64 ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
65 String subscriber = "";
66 String subscriber2 = "";
68 private final CallbackSet callbacks = new CallbackSet();
70 public OofHomingTestIT() throws IOException {
71 String oofCallback = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackInfraVnf");
72 String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf");
73 String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net");
75 String oofCallbackNoSolution = FileUtil.
76 readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound");
77 String oofCallbackPolicyException = FileUtil.
78 readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException");
79 String oofCallbackServiceException = FileUtil.
80 readResourceFile("__files/BuildingBlocks/oofCallbackServiceException");
82 callbacks.put("oof", JSON, "oofResponse", oofCallback);
83 callbacks.put("oof2", JSON, "oofResponse", oofCallback2);
84 callbacks.put("oof3", JSON, "oofResponse", oofCallback3);
85 callbacks.put("oofNoSol", JSON, "oofResponse", oofCallbackNoSolution);
86 callbacks.put("oofPolicyEx", JSON, "oofResponse", oofCallbackPolicyException);
87 callbacks.put("oofServiceEx", JSON, "oofResponse", oofCallbackServiceException);
90 ModelInfo sModel = new ModelInfo();
91 sModel.setModelCustomizationName("testModelCustomizationName");
92 sModel.setModelInstanceName("testModelInstanceName");
93 sModel.setModelInvariantUuid("testModelInvariantId");
94 sModel.setModelName("testModelName");
95 sModel.setModelUuid("testModelUuid");
96 sModel.setModelVersion("testModelVersion");
98 ServiceInstance si = new ServiceInstance();
99 si.setInstanceId("testServiceInstanceId123");
100 // Allotted Resources
101 List<AllottedResource> arList = new ArrayList<AllottedResource>();
102 AllottedResource ar = new AllottedResource();
103 ar.setResourceId("testResourceIdAR");
104 ar.setResourceInstanceName("testARInstanceName");
105 ModelInfo arModel = new ModelInfo();
106 arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
107 arModel.setModelInvariantUuid("testModelInvariantIdAR");
108 arModel.setModelName("testModelNameAR");
109 arModel.setModelVersion("testModelVersionAR");
110 arModel.setModelUuid("testARModelUuid");
111 arModel.setModelType("testModelTypeAR");
112 ar.setModelInfo(arModel);
113 AllottedResource ar2 = new AllottedResource();
114 ar2.setResourceId("testResourceIdAR2");
115 ar2.setResourceInstanceName("testAR2InstanceName");
116 ModelInfo arModel2 = new ModelInfo();
117 arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
118 arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
119 arModel2.setModelName("testModelNameAR2");
120 arModel2.setModelVersion("testModelVersionAR2");
121 arModel2.setModelUuid("testAr2ModelUuid");
122 arModel2.setModelType("testModelTypeAR2");
123 ar2.setModelInfo(arModel2);
127 List<VnfResource> vnfList = new ArrayList<VnfResource>();
128 VnfResource vnf = new VnfResource();
129 vnf.setResourceId("testResourceIdVNF");
130 vnf.setResourceInstanceName("testVnfInstanceName");
131 vnf.getHomingSolution().setOofDirectives(
133 " \"directives\":[ \n" +
135 " \"vnfc_directives\":[ \n" +
137 " \"vnfc_id\":\"<ID of VNFC>\",\n" +
138 " \"directives\":[ \n" +
140 " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
141 " \"attributes\":[ \n" +
143 " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
144 " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
149 " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
150 " \"attributes\":[ \n" +
152 " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
153 " \"attribute_value\":\"<value such as direct/normal>\"\n" +
156 " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
157 " \"attribute_value\":\"<value such as physnet>\"\n" +
166 " \"vnf_directives\":{ \n" +
167 " \"directives\":[ \n" +
169 " \"directive_name\":\"<Name of directive>\",\n" +
170 " \"attributes\":[ \n" +
172 " \"attribute_name\":\"<name of attribute>\",\n" +
173 " \"attribute_value\":\"<value>\"\n" +
178 " \"directive_name\":\"<Name of directive>\",\n" +
179 " \"attributes\":[ \n" +
181 " \"attribute_name\":\"<name of attribute>\",\n" +
182 " \"attribute_value\":\"<value >\"\n" +
185 " \"attribute_name\":\"<name of attribute>\",\n" +
186 " \"attribute_value\":\"<value >\"\n" +
195 " \"sdnc_directives\":{ \n" +
196 " \"directives\":[ \n" +
198 " \"vnfc_directives\":[ \n" +
200 " \"vnfc_id\":\"<ID of VNFC>\",\n" +
201 " \"directives\":[ \n" +
203 " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
204 " \"attributes\":[ \n" +
206 " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
207 " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
212 " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
213 " \"attributes\":[ \n" +
215 " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
216 " \"attribute_value\":\"<value such as direct/normal>\"\n" +
219 " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
220 " \"attribute_value\":\"<value such as physnet>\"\n" +
229 " \"vnf_directives\":{ \n" +
230 " \"directives\":[ \n" +
232 " \"directive_name\":\"<Name of directive>\",\n" +
233 " \"attributes\":[ \n" +
235 " \"attribute_name\":\"<name of attribute>\",\n" +
236 " \"attribute_value\":\"<value>\"\n" +
241 " \"directive_name\":\"<Name of directive>\",\n" +
242 " \"attributes\":[ \n" +
244 " \"attribute_name\":\"<name of attribute>\",\n" +
245 " \"attribute_value\":\"<value >\"\n" +
248 " \"attribute_name\":\"<name of attribute>\",\n" +
249 " \"attribute_value\":\"<value >\"\n" +
258 ModelInfo vnfModel = new ModelInfo();
259 vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
260 vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
261 vnfModel.setModelName("testModelNameVNF");
262 vnfModel.setModelVersion("testModelVersionVNF");
263 vnfModel.setModelUuid("testVnfModelUuid");
264 vnfModel.setModelType("testModelTypeVNF");
265 vnf.setModelInfo(vnfModel);
267 logger.debug("SERVICE DECOMP: {}", serviceDecomposition.getServiceResourcesJsonString());
268 serviceDecomposition.setModelInfo(sModel);
269 serviceDecomposition.setAllottedResources(arList);
270 serviceDecomposition.setVnfResources(vnfList);
271 serviceDecomposition.setServiceInstance(si);
274 subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
275 subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
280 public void testHoming_success_2AR1Vnf() throws Exception {
284 String businessKey = UUID.randomUUID().toString();
285 Map<String, Object> variables = new HashMap<>();
286 setVariables(variables);
288 invokeSubProcess("Homing", businessKey, variables);
290 injectWorkflowMessages(callbacks, "oof2");
292 waitForProcessEnd(businessKey, 10000);
295 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
296 "WorkflowException");
297 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
298 "serviceDecomposition");
299 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
301 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
302 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
303 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
304 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
305 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
306 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
307 String resourceARHomingString = resourceARHoming.toString();
308 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
309 String resourceARHoming2String = resourceARHoming2.toString();
310 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
311 String resourceVNFHomingString = resourceVNFHoming.toString();
312 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
313 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
315 assertNull(workflowException);
316 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
317 resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
318 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
319 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
320 resourceARHomingString);
321 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
322 resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
323 null, null), resourceARHoming2String);
324 assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3",
325 true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
326 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
327 resourceVNFHomingString);
328 assertEquals(verifyOofRequest(), expectedOofRequest);
333 public void testHoming_success_2AR1Vnf2Net() throws Exception {
337 String businessKey = UUID.randomUUID().toString();
338 Map<String, Object> variables = new HashMap<>();
339 setVariables2(variables);
341 invokeSubProcess("Homing", businessKey, variables);
343 injectWorkflowMessages(callbacks, "oof3");
345 waitForProcessEnd(businessKey, 10000);
348 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
349 "WorkflowException");
350 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
351 "serviceDecomposition");
352 String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
354 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
355 HomingSolution resourceARHoming = resourceAR.getHomingSolution();
356 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
357 HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
358 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
359 HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
360 Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
361 HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
362 Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
363 HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
365 String resourceARHomingString = resourceARHoming.toString();
366 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
367 String resourceARHoming2String = resourceARHoming2.toString();
368 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
369 String resourceVNFHomingString = resourceVNFHoming.toString();
370 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
371 String resourceNetHomingString = resourceNetHoming.toString();
372 resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
373 String resourceNetHoming2String = resourceNetHoming2.toString();
374 resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
375 expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
378 assertNull(workflowException);
379 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
380 resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
381 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
382 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
383 resourceARHomingString);
384 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
385 resourceARHoming2.getVnf().getResourceId(),
386 "aic", "testCloudRegionId2",
387 null, null), resourceARHoming2String);
388 assertEquals(homingSolutionCloud("cloud","aic",
389 "testCloudRegionId3",
390 true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
391 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
392 resourceVNFHomingString);
393 assertEquals(homingSolutionService("service", "testServiceInstanceIdNet",
394 "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic",
395 "testCloudRegionIdNet",
396 null, null), resourceNetHomingString);
397 assertEquals(homingSolutionCloud("cloud", "aic",
398 "testCloudRegionIdNet2",
399 false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
400 "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
401 resourceNetHoming2String);
402 assertEquals(verifyOofRequest(), expectedOofRequest);
409 public void testHoming_success_vnfResourceList() throws Exception {
411 // Create a Service Decomposition
412 MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4",
413 "/BuildingBlocks/oofCatalogResp.json");
414 String busKey = UUID.randomUUID().toString();
415 Map<String, Object> vars = new HashMap<>();
416 setVariablesForServiceDecomposition(vars, "testRequestId123",
417 "ff5256d2-5a33-55df-13ab-12abad84e7ff");
418 invokeSubProcess("DecomposeService", busKey, vars);
420 ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey,
421 "serviceDecomposition");
422 logger.debug("In testHoming_success_vnfResourceList, ServiceDecomposition = {}", sd);
423 List<VnfResource> vnfResourceList = sd.getVnfResources();
424 vnfResourceList.get(0).setResourceId("test-resource-id-000");
430 String businessKey = UUID.randomUUID().toString();
431 Map<String, Object> variables = new HashMap<>();
432 variables.put("homingService", "oof");
433 variables.put("isDebugLogEnabled", "true");
434 variables.put("msoRequestId", "testRequestId");
435 variables.put("serviceInstanceId", "testServiceInstanceId");
436 variables.put("serviceDecomposition", sd);
437 variables.put("subscriberInfo", subscriber2);
438 HashMap customerLocation = new HashMap<String, Object>();
439 customerLocation.put("customerLatitude", "32.89748");
440 customerLocation.put("customerLongitude", "-97.040443");
441 customerLocation.put("customerName", "xyz");
442 variables.put("customerLatitude", "32.89748");
443 variables.put("customerLongitude", "-97.040443");
444 variables.put("customerName", "xyz");
445 variables.put("customerLocation", customerLocation);
446 variables.put("cloudOwner", "amazon");
447 variables.put("cloudRegionId", "TNZED");
449 invokeSubProcess("Homing", businessKey, variables);
450 injectWorkflowMessages(callbacks, "oof3");
451 waitForProcessEnd(businessKey, 10000);
455 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
456 "WorkflowException");
457 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
458 "serviceDecomposition");
459 logger.debug("serviceDecompositionExp is: {}", serviceDecompositionExp);
461 Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
462 logger.debug("resourceVnf is: {}", resourceVnf);
463 HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
465 String resourceVnfHomingString = resourceVnfHoming.toString();
466 logger.debug("resourceVnfHomingString is: {}", resourceVnfHomingString);
467 resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
468 logger.debug("Now resourceVnfHomingString is: {}", resourceVnfHomingString);
470 assertNull(workflowException);
473 String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
474 logger.debug("oofRequest is: {}", oofRequest);
475 assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").
476 replaceAll("\n", "").replaceAll("\r", "").
477 replaceAll("\t", ""), oofRequest.replaceAll("\n", "").
478 replaceAll("\r", "").replaceAll("\t", ""));
480 assertEquals(homingSolutionService("service", "service-instance-01234",
481 "MDTNJ01", "test-resource-id-000","CloudOwner",
483 "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," +
484 " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
485 "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," +
486 " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
490 public void testHoming_success_existingLicense() throws Exception {
494 String businessKey = UUID.randomUUID().toString();
495 Map<String, Object> variables = new HashMap<String, Object>();
496 setVariablesExistingLicense(variables);
498 invokeSubProcess("Homing", businessKey, variables);
500 injectWorkflowMessages(callbacks, "sniro");
502 waitForProcessEnd(businessKey, 10000);
505 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
506 ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
507 String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
509 Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
510 HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution();
511 Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
512 HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution();
513 Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
514 HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.getHomingSolution();
515 String resourceARHomingString = resourceARHoming.toString();
516 resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
517 String resourceARHoming2String = resourceARHoming2.toString();
518 resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
519 String resourceVNFHomingString = resourceVNFHoming.toString();
520 resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
521 oofRequest = oofRequest.replaceAll("\\s+", "");
523 assertNull(workflowException);
524 assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
525 "aic", "dfwtx", "KDTNJ01",
526 "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
527 "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
528 resourceARHomingString);
529 assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
530 resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
531 null, null), resourceARHoming2String);
532 assertEquals(homingSolutionCloud("cloud", "aic",
533 "testCloudRegionId3",
534 false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
535 "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
536 resourceVNFHomingString);
537 assertEquals(verifyOofRequestExistingLicense(), oofRequest);
542 public void testHoming_error_inputVariable() throws Exception {
544 String businessKey = UUID.randomUUID().toString();
545 Map<String, Object> variables = new HashMap<>();
546 setVariables3(variables);
548 invokeSubProcess("Homing", businessKey, variables);
550 waitForProcessEnd(businessKey, 10000);
553 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
554 "WorkflowException");
556 assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " +
557 "input variable is missing or null]", workflowException.toString());
562 public void testHoming_error_badResponse() throws Exception {
565 String businessKey = UUID.randomUUID().toString();
566 Map<String, Object> variables = new HashMap<>();
567 setVariables(variables);
569 invokeSubProcess("Homing", businessKey, variables);
571 waitForProcessEnd(businessKey, 10000);
574 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
575 "WorkflowException");
577 assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a " +
578 "Bad Sync Response from Sniro/OOF.]", workflowException.toString());
583 public void testHoming_error_oofNoSolution() throws Exception {
586 String businessKey = UUID.randomUUID().toString();
587 Map<String, Object> variables = new HashMap<>();
588 setVariables(variables);
590 invokeSubProcess("Homing", businessKey, variables);
592 injectWorkflowMessages(callbacks, "oofNoSol");
594 waitForProcessEnd(businessKey, 10000);
597 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
598 "WorkflowException");
600 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found " +
601 "for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString());
606 public void testHoming_error_oofPolicyException() throws Exception {
609 String businessKey = UUID.randomUUID().toString();
610 Map<String, Object> variables = new HashMap<>();
611 setVariables(variables);
613 invokeSubProcess("Homing", businessKey, variables);
615 injectWorkflowMessages(callbacks, "oofPolicyEx");
617 waitForProcessEnd(businessKey, 10000);
620 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
621 "WorkflowException");
623 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
624 "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " +
625 "limit]", workflowException.toString());
630 public void testHoming_error_oofServiceException() throws Exception {
633 String businessKey = UUID.randomUUID().toString();
634 Map<String, Object> variables = new HashMap<>();
635 setVariables(variables);
637 invokeSubProcess("Homing", businessKey, variables);
639 injectWorkflowMessages(callbacks, "oofServiceEx");
641 waitForProcessEnd(businessKey, 10000);
644 WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
645 "WorkflowException");
647 assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
648 "Response contains a Request Error Service Exception: OOF PlacementError: " +
649 "requests.exceptions.HTTPError: 404 Client Error: Not Found for " +
650 "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
651 workflowException.toString());
655 private void setVariables(Map<String, Object> variables) {
656 variables.put("homingService", "oof");
657 HashMap customerLocation = new HashMap<String, Object>();
658 customerLocation.put("customerLatitude", "32.89748");
659 customerLocation.put("customerLongitude", "-97.040443");
660 customerLocation.put("customerName", "xyz");
661 variables.put("customerLatitude", "32.89748");
662 variables.put("customerLongitude", "-97.040443");
663 variables.put("customerName", "xyz");
664 variables.put("customerLocation", customerLocation);
665 variables.put("cloudOwner", "amazon");
666 variables.put("cloudRegionId", "TNZED");
667 variables.put("isDebugLogEnabled", "true");
668 // variables.put("mso-request-id", "testRequestId");
669 variables.put("msoRequestId", "testRequestId");
670 variables.put("serviceInstanceId", "testServiceInstanceId");
671 variables.put("serviceDecomposition", serviceDecomposition);
672 variables.put("subscriberInfo", subscriber2);
675 private void setVariables2(Map<String, Object> variables) {
676 List<NetworkResource> netList = new ArrayList<NetworkResource>();
677 NetworkResource net = new NetworkResource();
678 net.setResourceId("testResourceIdNet");
679 ModelInfo netModel = new ModelInfo();
680 netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
681 netModel.setModelInvariantUuid("testModelInvariantIdNet");
682 netModel.setModelName("testModelNameNet");
683 netModel.setModelVersion("testModelVersionNet");
684 net.setModelInfo(netModel);
686 NetworkResource net2 = new NetworkResource();
687 net2.setResourceId("testResourceIdNet2");
688 ModelInfo netModel2 = new ModelInfo();
689 netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
690 netModel2.setModelCustomizationName("testModelCustomizationNameNet2");
691 netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
692 netModel2.setModelName("testModelNameNet2");
693 netModel2.setModelVersion("testModelVersionNet2");
694 net2.setModelInfo(netModel2);
696 serviceDecomposition.setNetworkResources(netList);
698 variables.put("homingService", "oof");
699 HashMap customerLocation = new HashMap<String, Object>();
700 customerLocation.put("customerLatitude", "32.89748");
701 customerLocation.put("customerLongitude", "-97.040443");
702 customerLocation.put("customerName", "xyz");
703 variables.put("customerLatitude", "32.89748");
704 variables.put("customerLongitude", "-97.040443");
705 variables.put("customerName", "xyz");
706 variables.put("customerLocation", customerLocation);
707 variables.put("cloudOwner", "amazon");
708 variables.put("cloudRegionId", "TNZED");
709 variables.put("isDebugLogEnabled", "true");
710 variables.put("msoRequestId", "testRequestId");
711 variables.put("serviceInstanceId", "testServiceInstanceId");
712 variables.put("serviceDecomposition", serviceDecomposition);
713 variables.put("subscriberInfo", subscriber2);
716 private void setVariables3(Map<String, Object> variables) {
717 variables.put("homingService", "oof");
718 HashMap customerLocation = new HashMap<String, Object>();
719 customerLocation.put("customerLatitude", "32.89748");
720 customerLocation.put("customerLongitude", "-97.040443");
721 customerLocation.put("customerName", "xyz");
722 variables.put("customerLatitude", "32.89748");
723 variables.put("customerLongitude", "-97.040443");
724 variables.put("customerName", "xyz");
725 variables.put("customerLocation", customerLocation);
726 variables.put("cloudOwner", "amazon");
727 variables.put("cloudRegionId", "TNZED");
728 variables.put("isDebugLogEnabled", "true");
729 // variables.put("mso-request-id", "testRequestId");
730 variables.put("msoRequestId", "testRequestId");
731 variables.put("serviceInstanceId", "testServiceInstanceId");
732 variables.put("serviceDecomposition", null);
733 variables.put("subscriberInfo", subscriber2);
736 private void setVariablesExistingLicense(Map<String, Object> variables) {
737 HomingSolution currentHomingSolution = new HomingSolution();
738 serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
739 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
740 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
742 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
743 serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
745 variables.put("isDebugLogEnabled", "true");
746 variables.put("msoRequestId", "testRequestId");
747 variables.put("serviceInstanceId", "testServiceInstanceId");
748 variables.put("serviceDecomposition", serviceDecomposition);
749 variables.put("subscriberInfo", subscriber2);
753 private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname,
754 String vnfResourceId, String cloudOwner,
755 String cloudRegionId, String enList,
758 String solution = "";
760 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
761 serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
762 cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId +
763 "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" +
764 " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," +
765 " \"rehome\" : false } }";
768 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
769 serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
770 cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" +
771 " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" +
772 " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" +
773 " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
778 private String homingSolutionCloud(String type, String cloudOwner,
779 String cloudRegionId, Boolean flavors, String enList,
781 String solution = "";
783 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
784 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
785 "\", \"license\" : { }, \"rehome\" : false } }";
786 } else if (flavors && enList == null){
787 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
788 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
789 "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
790 "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
791 "\"license\" : { }, \"rehome\" : false } }";
792 } else if (flavors) {
793 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
794 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
795 "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
796 "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
797 "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
798 licenseList + " ] }, \"rehome\" : false } }";
800 solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
801 cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
802 "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
803 licenseList + " ] }, \"rehome\" : false } }";
808 private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
809 variables.put("homingService", "oof");
810 variables.put("isDebugLogEnabled", "true");
811 variables.put("mso-request-id", requestId);
812 variables.put("msoRequestId", requestId);
813 variables.put("serviceInstanceId", siId);
814 HashMap customerLocation = new HashMap<String, Object>();
815 customerLocation.put("customerLatitude", "32.89748");
816 customerLocation.put("customerLongitude", "-97.040443");
817 customerLocation.put("customerName", "xyz");
818 variables.put("customerLatitude", "32.89748");
819 variables.put("customerLongitude", "-97.040443");
820 variables.put("customerName", "xyz");
821 variables.put("customerLocation", customerLocation);
822 variables.put("cloudOwner", "amazon");
823 variables.put("cloudRegionId", "TNZED");
826 String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" +
827 "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
828 variables.put("serviceModelInfo", serviceModelInfo);
831 private String verifyOofRequest() {
832 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
833 "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," +
834 "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," +
835 "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" +
836 "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" +
837 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
838 "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\"" +
839 ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" +
840 "\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," +
841 "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":" +
842 "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}}," +
843 "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\"," +
844 "\"tenantId\":\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," +
845 "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\"," +
846 "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\"," +
847 "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" +
848 "{\"serviceInstanceId\":\"testServiceInstanceId123\"," +
849 "\"serviceName\":\"null\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
850 "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," +
851 "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" +
852 "\"}},\"licenseInfo\":{\"licenseDemands\":[{\"resourceModuleName\":\"VNF\",\"serviceResourceId\":" +
853 "\"testResourceIdVNF\",\"resourceInstanceType\":\"VNF\",\"resourceModelInfo\":{\"modelInvariantId\":" +
854 "\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":" +
855 "\"testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
856 "\"modelCustomizationName\":\"\"}}]}}";
860 private String verifyOofRequestExistingLicense(){
861 String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
862 "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," +
863 "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," +
864 "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," +
865 "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" +
866 "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" +
867 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
868 "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" +
869 "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," +
870 "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," +
871 "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," +
872 "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" +
873 "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" +
874 "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" +
875 "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," +
876 "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," +
877 "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," +
878 "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" +
879 "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," +
880 "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" +
881 "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," +
882 "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
883 "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," +
884 "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," +
885 "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," +
886 "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" +
887 "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";