blob: 5d60e29f76e78c46b227a60c1b4fe22929b87a72 [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001import {ServicePlanningService} from "./service-planning.service";
2import {ReflectiveInjector} from "@angular/core";
3import {NgRedux} from "@angular-redux/store";
4import {ServiceNodeTypes} from "../shared/models/ServiceNodeTypes";
5
6export class MockAppStore<T> {
7}
8
9describe('Service planning service', () => {
10 let injector;
11 let service: ServicePlanningService;
12
13 beforeEach(() => {
14
15 let injector = ReflectiveInjector.resolveAndCreate([
16 ServicePlanningService,
17 {provide: NgRedux, useClass: MockAppStore}
18 ]);
19
20 service = injector.get(ServicePlanningService);
21 });
22
23 describe('#updateDynamicInputsVnfDataFromModel', () => {
24 it('get vfModule instance params', (done: DoneFn) => {
25 //get vfModule instance params
26 let dynamicInputs = service.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VFmodule, generateVFModule());
27 expect(dynamicInputs).toEqual([{
28 id: '2017488_adiodvpe0_vnf_config_template_version',
29 type: 'string',
30 name: '2017488_adiodvpe0_vnf_config_template_version',
31 value: '17.2',
32 isRequired: true,
33 description: 'VPE Software Version'
34 }, {
35 id: '2017488_adiodvpe0_AIC_CLLI',
36 type: 'string',
37 name: '2017488_adiodvpe0_AIC_CLLI',
38 value: 'ATLMY8GA',
39 isRequired: true,
40 description: 'AIC Site CLLI'
41 }]);
42
43 //get vfModule with no instance params should return empty array
44 dynamicInputs = service.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VFmodule, generateVFModule2);
45 expect(dynamicInputs).toEqual([]);
46
47 //get vf instance params should be undefined
48 dynamicInputs = service.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VF, generateVNF());
49 expect(dynamicInputs).toEqual([]);
50 done();
51 });
52 });
53
54 describe('#isUserProvidedNaming', () => {
55 it('get vfModule with generate ecompNaming should return userProvided false', (done: DoneFn) => {
56 //get vfModule with generate ecompNaming should return userProvided false
57 let isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VFmodule, generateVFModule(), generateVNF());
58 expect(isUserProvidedNaming).toBeFalsy();
59
60 //get vfModule without generate ecompNaming should return userProvided true
61 isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VFmodule, generateVFModule(), generateVNF_ecompNamingFalse());
62 expect(isUserProvidedNaming).toBeTruthy();
63
64 //get vnf with generate ecompNaming should return userProvided false
65 isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VF, generateVNF(), null);
66 expect(isUserProvidedNaming).toBeFalsy();
67
68 //get vnf without generate ecompNaming should return userProvided true
69 isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VF, generateVNF_ecompNamingFalse(), null);
70 expect(isUserProvidedNaming).toBeTruthy();
71 done();
72 });
73 });
74
75 function generateVFModule() {
76 return {
77 'uuid': '25284168-24bb-4698-8cb4-3f509146eca5',
78 'invariantUuid': '7253ff5c-97f0-4b8b-937c-77aeb4d79aa1',
79 'customizationUuid': 'f7e7c365-60cf-49a9-9ebf-a1aa11b9d401',
80 'description': null,
81 'name': '2017488AdiodVpe..ADIOD_vRE_BV..module-1',
82 'version': '6',
83 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vRE_BV..module-1',
84 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
85 'commands': {},
86 'volumeGroupAllowed': true,
87 'inputs': {
88 '2017488_adiodvpe0_vnf_config_template_version': {
89 'type': 'string',
90 'description': 'VPE Software Version',
91 'entry_schema': null,
92 'constraints': [],
93 'required': true,
94 'default': '17.2'
95 },
96 '2017488_adiodvpe0_AIC_CLLI': {
97 'type': 'string',
98 'description': 'AIC Site CLLI',
99 'entry_schema': null,
100 'constraints': [],
101 'required': true,
102 'default': 'ATLMY8GA'
103 }
104 }
105 };
106 }
107
108 function generateVFModule2() {
109 return {
110 'uuid': '0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a',
111 'invariantUuid': 'eff8cc59-53a1-4101-aed7-8cf24ecf8339',
112 'customizationUuid': '3cd946bb-50e0-40d8-96d3-c9023520b557',
113 'description': null,
114 'name': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2',
115 'version': '6',
116 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2',
117 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
118 'commands': {},
119 'volumeGroupAllowed': true,
120 'inputs': {}
121 };
122 }
123
124 function generateVNF() {
125 return {
126 'uuid': '0903e1c0-8e03-4936-b5c2-260653b96413',
127 'invariantUuid': '00beb8f9-6d39-452f-816d-c709b9cbb87d',
128 'description': 'Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM',
129 'name': '2017-388_ADIOD-vPE',
130 'version': '1.0',
131 'customizationUuid': '280dec31-f16d-488b-9668-4aae55d6648a',
132 'inputs': {
133 'vnf_config_template_version': {
134 'type': 'string',
135 'description': 'VPE Software Version',
136 'entry_schema': null,
137 'constraints': [],
138 'required': true,
139 'default': '17.2'
140 },
141 'bandwidth_units': {
142 'type': 'string',
143 'description': 'Units of bandwidth',
144 'entry_schema': null,
145 'constraints': [],
146 'required': true,
147 'default': 'Gbps'
148 },
149 'bandwidth': {
150 'type': 'string',
151 'description': 'Requested VPE bandwidth',
152 'entry_schema': null,
153 'constraints': [],
154 'required': true,
155 'default': '10'
156 },
157 'AIC_CLLI': {
158 'type': 'string',
159 'description': 'AIC Site CLLI',
160 'entry_schema': null,
161 'constraints': [],
162 'required': true,
163 'default': 'ATLMY8GA'
164 },
165 'ASN': {
166 'type': 'string',
167 'description': 'AV/PE',
168 'entry_schema': null,
169 'constraints': [],
170 'required': true,
171 'default': 'AV_vPE'
172 },
173 'vnf_instance_name': {
174 'type': 'string',
175 'description': 'The hostname assigned to the vpe.',
176 'entry_schema': null,
177 'constraints': [],
178 'required': true,
179 'default': 'mtnj309me6'
180 }
181 },
182 'commands': {
183 'vnf_config_template_version': {
184 'displayName': 'vnf_config_template_version',
185 'command': 'get_input',
186 'inputName': '2017488_adiodvpe0_vnf_config_template_version'
187 },
188 'bandwidth_units': {
189 'displayName': 'bandwidth_units',
190 'command': 'get_input',
191 'inputName': 'adiodvpe0_bandwidth_units'
192 },
193 'bandwidth': {'displayName': 'bandwidth', 'command': 'get_input', 'inputName': 'adiodvpe0_bandwidth'},
194 'AIC_CLLI': {'displayName': 'AIC_CLLI', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_AIC_CLLI'},
195 'ASN': {'displayName': 'ASN', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_ASN'},
196 'vnf_instance_name': {
197 'displayName': 'vnf_instance_name',
198 'command': 'get_input',
199 'inputName': '2017488_adiodvpe0_vnf_instance_name'
200 }
201 },
202 'properties': {
203 'vmxvre_retype': 'RE-VMX',
204 'vnf_config_template_version': 'get_input:2017488_adiodvpe0_vnf_config_template_version',
205 'sriov44_net_id': '48d399b3-11ee-48a8-94d2-f0ea94d6be8d',
206 'int_ctl_net_id': '2f323477-6936-4d01-ac53-d849430281d9',
207 'vmxvpfe_sriov41_0_port_mac': '00:11:22:EF:AC:DF',
208 'int_ctl_net_name': 'VMX-INTXI',
209 'vmx_int_ctl_prefix': '128.0.0.0',
210 'sriov43_net_id': 'da349ca1-6de9-4548-be88-2d88e99bfef5',
211 'sriov42_net_id': '760669ba-013d-4d9b-b0e7-4151fe2e6279',
212 'sriov41_net_id': '25ad52d5-c165-40f8-b3b0-ddfc2373280a',
213 'nf_type': 'vPE',
214 'vmxvpfe_int_ctl_ip_1': '128.0.0.16',
215 'is_AVPN_service': 'false',
216 'vmx_RSG_name': 'vREXI-affinity',
217 'vmx_int_ctl_forwarding': 'l2',
218 'vmxvre_oam_ip_0': '10.40.123.5',
219 'vmxvpfe_sriov44_0_port_mac': '00:11:22:EF:AC:DF',
220 'vmxvpfe_sriov41_0_port_vlanstrip': 'false',
221 'vmxvpfe_sriov42_0_port_vlanfilter': '4001',
222 'vmxvpfe_sriov44_0_port_unknownunicastallow': 'true',
223 'vmxvre_image_name_0': 'VRE-ENGINE_17.2-S2.1.qcow2',
224 'vmxvre_instance': '0',
225 'vmxvpfe_sriov43_0_port_mac': '00:11:22:EF:AC:DF',
226 'vmxvre_flavor_name': 'ns.c1r16d32.v5',
227 'vmxvpfe_volume_size_0': '40.0',
228 'vmxvpfe_sriov43_0_port_vlanfilter': '4001',
229 'nf_naming': '{ecomp_generated_naming=true}',
230 'nf_naming_code': 'Navneet',
231 'vmxvre_name_0': 'vREXI',
232 'vmxvpfe_sriov42_0_port_vlanstrip': 'false',
233 'vmxvpfe_volume_name_0': 'vPFEXI_FBVolume',
234 'vmx_RSG_id': 'bd89a33c-13c3-4a04-8fde-1a57eb123141',
235 'vmxvpfe_image_name_0': 'VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2',
236 'vmxvpfe_sriov43_0_port_unknownunicastallow': 'true',
237 'vmxvpfe_sriov44_0_port_unknownmulticastallow': 'true',
238 'vmxvre_console': 'vidconsole',
239 'vmxvpfe_sriov44_0_port_vlanfilter': '4001',
240 'vmxvpfe_sriov42_0_port_mac': '00:11:22:EF:AC:DF',
241 'vmxvpfe_volume_id_0': '47cede15-da2f-4397-a101-aa683220aff3',
242 'vmxvpfe_sriov42_0_port_unknownmulticastallow': 'true',
243 'vmxvpfe_sriov44_0_port_vlanstrip': 'false',
244 'vf_module_id': '123',
245 'nf_function': 'JAI',
246 'vmxvpfe_sriov43_0_port_unknownmulticastallow': 'true',
247 'vmxvre_int_ctl_ip_0': '128.0.0.1',
248 'AIC_CLLI': 'get_input:2017488_adiodvpe0_AIC_CLLI',
249 'vnf_name': 'mtnj309me6vre',
250 'vmxvpfe_sriov41_0_port_unknownunicastallow': 'true',
251 'vmxvre_volume_type_1': 'HITACHI',
252 'vmxvpfe_sriov44_0_port_broadcastallow': 'true',
253 'vmxvre_volume_type_0': 'HITACHI',
254 'vmxvpfe_volume_type_0': 'HITACHI',
255 'vmxvpfe_sriov43_0_port_broadcastallow': 'true',
256 'bandwidth_units': 'get_input:adiodvpe0_bandwidth_units',
257 'vnf_id': '123',
258 'vmxvre_oam_prefix': '24',
259 'availability_zone_0': 'mtpocfo-kvm-az01',
260 'ASN': 'get_input:2017488_adiodvpe0_ASN',
261 'vmxvre_chassis_i2cid': '161',
262 'vmxvpfe_name_0': 'vPFEXI',
263 'bandwidth': 'get_input:adiodvpe0_bandwidth',
264 'availability_zone_max_count': '1',
265 'vmxvre_volume_size_0': '45.0',
266 'vmxvre_volume_size_1': '50.0',
267 'vmxvpfe_sriov42_0_port_broadcastallow': 'true',
268 'vmxvre_oam_gateway': '10.40.123.1',
269 'vmxvre_volume_name_1': 'vREXI_FAVolume',
270 'vmxvre_ore_present': '0',
271 'vmxvre_volume_name_0': 'vREXI_FBVolume',
272 'vmxvre_type': '0',
273 'vnf_instance_name': 'get_input:2017488_adiodvpe0_vnf_instance_name',
274 'vmxvpfe_sriov41_0_port_unknownmulticastallow': 'true',
275 'oam_net_id': 'b95eeb1d-d55d-4827-abb4-8ebb94941429',
276 'vmx_int_ctl_len': '24',
277 'vmxvpfe_sriov43_0_port_vlanstrip': 'false',
278 'vmxvpfe_sriov41_0_port_broadcastallow': 'true',
279 'vmxvre_volume_id_1': '6e86797e-03cd-4fdc-ba72-2957119c746d',
280 'vmxvpfe_sriov41_0_port_vlanfilter': '4001',
281 'nf_role': 'Testing',
282 'vmxvre_volume_id_0': 'f4eacb79-f687-4e9d-b760-21847c8bb15a',
283 'vmxvpfe_sriov42_0_port_unknownunicastallow': 'true',
284 'vmxvpfe_flavor_name': 'ns.c20r16d25.v5'
285 },
286 'type': 'VF',
287 'modelCustomizationName': '2017-388_ADIOD-vPE 1',
288 'vfModules': {},
289 'volumeGroups': {}
290 };
291 }
292
293 function generateVNF_ecompNamingFalse() {
294 return {
295 'uuid': '0903e1c0-8e03-4936-b5c2-260653b96413',
296 'invariantUuid': '00beb8f9-6d39-452f-816d-c709b9cbb87d',
297 'description': 'Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM',
298 'name': '2017-388_ADIOD-vPE',
299 'version': '1.0',
300 'customizationUuid': '280dec31-f16d-488b-9668-4aae55d6648a',
301 'inputs': {
302 'vnf_config_template_version': {
303 'type': 'string',
304 'description': 'VPE Software Version',
305 'entry_schema': null,
306 'constraints': [],
307 'required': true,
308 'default': '17.2'
309 },
310 'bandwidth_units': {
311 'type': 'string',
312 'description': 'Units of bandwidth',
313 'entry_schema': null,
314 'constraints': [],
315 'required': true,
316 'default': 'Gbps'
317 },
318 'bandwidth': {
319 'type': 'string',
320 'description': 'Requested VPE bandwidth',
321 'entry_schema': null,
322 'constraints': [],
323 'required': true,
324 'default': '10'
325 },
326 'AIC_CLLI': {
327 'type': 'string',
328 'description': 'AIC Site CLLI',
329 'entry_schema': null,
330 'constraints': [],
331 'required': true,
332 'default': 'ATLMY8GA'
333 },
334 'ASN': {
335 'type': 'string',
336 'description': 'AV/PE',
337 'entry_schema': null,
338 'constraints': [],
339 'required': true,
340 'default': 'AV_vPE'
341 },
342 'vnf_instance_name': {
343 'type': 'string',
344 'description': 'The hostname assigned to the vpe.',
345 'entry_schema': null,
346 'constraints': [],
347 'required': true,
348 'default': 'mtnj309me6'
349 }
350 },
351 'commands': {
352 'vnf_config_template_version': {
353 'displayName': 'vnf_config_template_version',
354 'command': 'get_input',
355 'inputName': '2017488_adiodvpe0_vnf_config_template_version'
356 },
357 'bandwidth_units': {
358 'displayName': 'bandwidth_units',
359 'command': 'get_input',
360 'inputName': 'adiodvpe0_bandwidth_units'
361 },
362 'bandwidth': {'displayName': 'bandwidth', 'command': 'get_input', 'inputName': 'adiodvpe0_bandwidth'},
363 'AIC_CLLI': {'displayName': 'AIC_CLLI', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_AIC_CLLI'},
364 'ASN': {'displayName': 'ASN', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_ASN'},
365 'vnf_instance_name': {
366 'displayName': 'vnf_instance_name',
367 'command': 'get_input',
368 'inputName': '2017488_adiodvpe0_vnf_instance_name'
369 }
370 },
371 'properties': {
372 'ecomp_generated_naming': "false",
373 'vmxvre_retype': 'RE-VMX',
374 'vnf_config_template_version': 'get_input:2017488_adiodvpe0_vnf_config_template_version',
375 'sriov44_net_id': '48d399b3-11ee-48a8-94d2-f0ea94d6be8d',
376 'int_ctl_net_id': '2f323477-6936-4d01-ac53-d849430281d9',
377 'vmxvpfe_sriov41_0_port_mac': '00:11:22:EF:AC:DF',
378 'int_ctl_net_name': 'VMX-INTXI',
379 'vmx_int_ctl_prefix': '128.0.0.0',
380 'sriov43_net_id': 'da349ca1-6de9-4548-be88-2d88e99bfef5',
381 'sriov42_net_id': '760669ba-013d-4d9b-b0e7-4151fe2e6279',
382 'sriov41_net_id': '25ad52d5-c165-40f8-b3b0-ddfc2373280a',
383 'nf_type': 'vPE',
384 'vmxvpfe_int_ctl_ip_1': '128.0.0.16',
385 'is_AVPN_service': 'false',
386 'vmx_RSG_name': 'vREXI-affinity',
387 'vmx_int_ctl_forwarding': 'l2',
388 'vmxvre_oam_ip_0': '10.40.123.5',
389 'vmxvpfe_sriov44_0_port_mac': '00:11:22:EF:AC:DF',
390 'vmxvpfe_sriov41_0_port_vlanstrip': 'false',
391 'vmxvpfe_sriov42_0_port_vlanfilter': '4001',
392 'vmxvpfe_sriov44_0_port_unknownunicastallow': 'true',
393 'vmxvre_image_name_0': 'VRE-ENGINE_17.2-S2.1.qcow2',
394 'vmxvre_instance': '0',
395 'vmxvpfe_sriov43_0_port_mac': '00:11:22:EF:AC:DF',
396 'vmxvre_flavor_name': 'ns.c1r16d32.v5',
397 'vmxvpfe_volume_size_0': '40.0',
398 'vmxvpfe_sriov43_0_port_vlanfilter': '4001',
399 'nf_naming': '{ecomp_generated_naming=false}',
400 'nf_naming_code': 'Navneet',
401 'vmxvre_name_0': 'vREXI',
402 'vmxvpfe_sriov42_0_port_vlanstrip': 'false',
403 'vmxvpfe_volume_name_0': 'vPFEXI_FBVolume',
404 'vmx_RSG_id': 'bd89a33c-13c3-4a04-8fde-1a57eb123141',
405 'vmxvpfe_image_name_0': 'VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2',
406 'vmxvpfe_sriov43_0_port_unknownunicastallow': 'true',
407 'vmxvpfe_sriov44_0_port_unknownmulticastallow': 'true',
408 'vmxvre_console': 'vidconsole',
409 'vmxvpfe_sriov44_0_port_vlanfilter': '4001',
410 'vmxvpfe_sriov42_0_port_mac': '00:11:22:EF:AC:DF',
411 'vmxvpfe_volume_id_0': '47cede15-da2f-4397-a101-aa683220aff3',
412 'vmxvpfe_sriov42_0_port_unknownmulticastallow': 'true',
413 'vmxvpfe_sriov44_0_port_vlanstrip': 'false',
414 'vf_module_id': '123',
415 'nf_function': 'JAI',
416 'vmxvpfe_sriov43_0_port_unknownmulticastallow': 'true',
417 'vmxvre_int_ctl_ip_0': '128.0.0.1',
418 'AIC_CLLI': 'get_input:2017488_adiodvpe0_AIC_CLLI',
419 'vnf_name': 'mtnj309me6vre',
420 'vmxvpfe_sriov41_0_port_unknownunicastallow': 'true',
421 'vmxvre_volume_type_1': 'HITACHI',
422 'vmxvpfe_sriov44_0_port_broadcastallow': 'true',
423 'vmxvre_volume_type_0': 'HITACHI',
424 'vmxvpfe_volume_type_0': 'HITACHI',
425 'vmxvpfe_sriov43_0_port_broadcastallow': 'true',
426 'bandwidth_units': 'get_input:adiodvpe0_bandwidth_units',
427 'vnf_id': '123',
428 'vmxvre_oam_prefix': '24',
429 'availability_zone_0': 'mtpocfo-kvm-az01',
430 'ASN': 'get_input:2017488_adiodvpe0_ASN',
431 'vmxvre_chassis_i2cid': '161',
432 'vmxvpfe_name_0': 'vPFEXI',
433 'bandwidth': 'get_input:adiodvpe0_bandwidth',
434 'availability_zone_max_count': '1',
435 'vmxvre_volume_size_0': '45.0',
436 'vmxvre_volume_size_1': '50.0',
437 'vmxvpfe_sriov42_0_port_broadcastallow': 'true',
438 'vmxvre_oam_gateway': '10.40.123.1',
439 'vmxvre_volume_name_1': 'vREXI_FAVolume',
440 'vmxvre_ore_present': '0',
441 'vmxvre_volume_name_0': 'vREXI_FBVolume',
442 'vmxvre_type': '0',
443 'vnf_instance_name': 'get_input:2017488_adiodvpe0_vnf_instance_name',
444 'vmxvpfe_sriov41_0_port_unknownmulticastallow': 'true',
445 'oam_net_id': 'b95eeb1d-d55d-4827-abb4-8ebb94941429',
446 'vmx_int_ctl_len': '24',
447 'vmxvpfe_sriov43_0_port_vlanstrip': 'false',
448 'vmxvpfe_sriov41_0_port_broadcastallow': 'true',
449 'vmxvre_volume_id_1': '6e86797e-03cd-4fdc-ba72-2957119c746d',
450 'vmxvpfe_sriov41_0_port_vlanfilter': '4001',
451 'nf_role': 'Testing',
452 'vmxvre_volume_id_0': 'f4eacb79-f687-4e9d-b760-21847c8bb15a',
453 'vmxvpfe_sriov42_0_port_unknownunicastallow': 'true',
454 'vmxvpfe_flavor_name': 'ns.c20r16d25.v5'
455 },
456 'type': 'VF',
457 'modelCustomizationName': '2017-388_ADIOD-vPE 1',
458 'vfModules': {},
459 'volumeGroups': {}
460 };
461 }
462
463});
464
465
466
467