blob: 10cbb0d8fd93480f542b1ba54fc2f878c4c5e34a [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001import {TestBed, getTestBed} from '@angular/core/testing';
2import {
3 HttpClientTestingModule,
4 HttpTestingController
5} from '@angular/common/http/testing';
6import {AvailableModelsTreeService} from './available-models-tree.service';
7import {ServicePlanningService} from "../../services/service-planning.service";
8import {ServiceNodeTypes} from "../../shared/models/ServiceNodeTypes";
9import {NgRedux} from "@angular-redux/store";
10import {MockAppStore} from "../../services/service-planning.service.spec";
11
12describe('Available Models Tree Service', () => {
13 let injector;
14 let service: AvailableModelsTreeService;
15 let httpMock: HttpTestingController;
16
17 beforeEach(() => {
18
19 TestBed.configureTestingModule({
20 imports: [HttpClientTestingModule],
21 providers: [AvailableModelsTreeService,
22 ServicePlanningService,
23 {provide: NgRedux, useClass: MockAppStore}]
24 });
25
26 injector = getTestBed();
27 service = injector.get(AvailableModelsTreeService);
28 httpMock = injector.get(HttpTestingController);
29 });
30
31 describe('#shouldShowAddIcon', () => {
32 it('should return true if number of current vnf modules is under the max', (done: DoneFn) => {
33 let treeNode = {
34 data: {
35 children: [],
36 name: 'vf_vmee0..VfVmee..base_vmme..module-0'
37 }
38 };
39
40 let serviceHierarchy = getSericeServiceHierarchy();
41 let result = service.shouldShowAddIcon(treeNode, serviceHierarchy, '6e59c5de-f052-46fa-aa7e-2fca9d674c44', 0);
42 expect(result).toBeTruthy();
43 done();
44 });
45
46 it('should return false if number of current vnf modules are more than max', (done: DoneFn) => {
47 let treeNode = {
48 data: {
49 children: [],
50 name: 'vf_vmee0..VfVmee..base_vmme..module-0'
51 }
52 };
53
54 let serviceHierarchy = getSericeServiceHierarchy();
55 let result = service.shouldShowAddIcon(treeNode, serviceHierarchy, '6e59c5de-f052-46fa-aa7e-2fca9d674c44', 2);
56 expect(result).toBeFalsy();
57 done();
58 });
59
60 it('should return true if number of current vnf modules are more than max and max is null', (done: DoneFn) => {
61 let treeNode = {
62 data: {
63 children: [],
64 name: 'vf_vmee0..VfVmee..base_vmme..module-0'
65 }
66 };
67
68 let serviceHierarchy = getSericeServiceHierarchy();
69 let result = service.shouldShowAddIcon(treeNode, serviceHierarchy, '6e59c5de-f052-46fa-aa7e-2fca9d674c44', 0);
70 expect(result).toBeTruthy();
71 done();
72 });
73 });
74
75 describe('#shouldOpenModalDialogOnAddInstance', () => {
76 let serviceHierarchy = getSericeServiceHierarchy();
77
78 it('should open popup on add instance', (done: DoneFn) => {
79 // add vnf should return true
80 let result = service.shouldOpenDialog(ServiceNodeTypes.VF, [], false);
81 expect(result).toBeTruthy();
82
83 // add vfModule with user provided naming should return true
84 result = service.shouldOpenDialog(ServiceNodeTypes.VFmodule, [], true);
85 expect(result).toBeTruthy();
86
87 // add vfModule with dynamicInputs without defaultValues should return true
88 result = service.shouldOpenDialog(ServiceNodeTypes.VFmodule, [{
89 id: '2017488_adiodvpe0_vnf_config_template_version',
90 type: 'string',
91 name: '2017488_adiodvpe0_vnf_config_template_version',
92 isRequired: true,
93 description: 'VPE Software Version'
94 }], false);
95 expect(result).toBeTruthy();
96
97 // add vfModule with dynamicInputs with defaultValues should return false
98 result = service.shouldOpenDialog(ServiceNodeTypes.VFmodule, [{
99 id: '2017488_adiodvpe0_vnf_config_template_version',
100 type: 'string',
101 name: '2017488_adiodvpe0_vnf_config_template_version',
102 value: '17.2',
103 isRequired: true,
104 description: 'VPE Software Version'
105 }], false);
106 expect(result).toBeFalsy();
107 done();
108 });
109 });
110
111 function getSericeServiceHierarchy() {
112 return JSON.parse(JSON.stringify(
113 {
114 '6e59c5de-f052-46fa-aa7e-2fca9d674c44': {
115 'service': {
116 'uuid': '6e59c5de-f052-46fa-aa7e-2fca9d674c44',
117 'invariantUuid': 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0',
118 'name': 'ComplexService',
119 'version': '1.0',
120 'toscaModelURL': null,
121 'category': 'Mobility',
122 'serviceType': '',
123 'serviceRole': '',
124 'description': 'ComplexService',
125 'serviceEcompNaming': 'true',
126 'instantiationType': 'Macro',
127 'inputs': {}
128 },
129 'vnfs': {
130 'VF_vMee 0': {
131 'uuid': 'd6557200-ecf2-4641-8094-5393ae3aae60',
132 'invariantUuid': '4160458e-f648-4b30-a176-43881ffffe9e',
133 'description': 'VSP_vMee',
134 'name': 'VF_vMee',
135 'version': '2.0',
136 'customizationUuid': '91415b44-753d-494c-926a-456a9172bbb9',
137 'inputs': {},
138 'commands': {},
139 'properties': {
140 'gpb2_Internal2_mac': '00:80:37:0E:02:22',
141 'sctp-b-ipv6-egress_src_start_port': '0',
142 'sctp-a-ipv6-egress_rule_application': 'any',
143 'Internal2_allow_transit': 'true',
144 'sctp-b-IPv6_ethertype': 'IPv6',
145 'sctp-a-egress_rule_application': 'any',
146 'sctp-b-ingress_action': 'pass',
147 'sctp-b-ingress_rule_protocol': 'icmp',
148 'ncb2_Internal1_mac': '00:80:37:0E:0F:12',
149 'sctp-b-ipv6-ingress-src_start_port': '0.0',
150 'ncb1_Internal2_mac': '00:80:37:0E:09:12',
151 'fsb_volume_size_0': '320.0',
152 'sctp-b-egress_src_addresses': 'local',
153 'sctp-a-ipv6-ingress_ethertype': 'IPv4',
154 'sctp-a-ipv6-ingress-dst_start_port': '0',
155 'sctp-b-ipv6-ingress_rule_application': 'any',
156 'domain_name': 'default-domain',
157 'sctp-a-ingress_rule_protocol': 'icmp',
158 'sctp-b-egress-src_start_port': '0.0',
159 'sctp-a-egress_src_addresses': 'local',
160 'sctp-b-display_name': 'epc-sctp-b-ipv4v6-sec-group',
161 'sctp-a-egress-src_start_port': '0.0',
162 'sctp-a-ingress_ethertype': 'IPv4',
163 'sctp-b-ipv6-ingress-dst_end_port': '65535',
164 'sctp-b-dst_subnet_prefix_v6': '::',
165 'nf_naming': '{ecomp_generated_naming=true}',
166 'sctp-a-ipv6-ingress_src_subnet_prefix': '0.0.0.0',
167 'sctp-b-egress-dst_start_port': '0.0',
168 'ncb_flavor_name': 'nv.c20r64d1',
169 'gpb1_Internal1_mac': '00:80:37:0E:01:22',
170 'sctp-b-egress_dst_subnet_prefix_len': '0.0',
171 'Internal2_net_cidr': '169.255.0.0',
172 'sctp-a-ingress-dst_start_port': '0.0',
173 'sctp-a-egress-dst_start_port': '0.0',
174 'fsb1_Internal2_mac': '00:80:37:0E:0B:12',
175 'sctp-a-egress_ethertype': 'IPv4',
176 'vlc_st_service_mode': 'in-network-nat',
177 'sctp-a-ipv6-egress_ethertype': 'IPv4',
178 'sctp-a-egress-src_end_port': '65535.0',
179 'sctp-b-ipv6-egress_rule_application': 'any',
180 'sctp-b-egress_action': 'pass',
181 'sctp-a-ingress-src_subnet_prefix_len': '0.0',
182 'sctp-b-ipv6-ingress-src_end_port': '65535.0',
183 'sctp-b-name': 'epc-sctp-b-ipv4v6-sec-group',
184 'fsb2_Internal1_mac': '00:80:37:0E:0D:12',
185 'sctp-a-ipv6-ingress-src_start_port': '0.0',
186 'sctp-b-ipv6-egress_ethertype': 'IPv4',
187 'Internal1_net_cidr': '169.253.0.0',
188 'sctp-a-egress_dst_subnet_prefix': '0.0.0.0',
189 'fsb_flavor_name': 'nv.c20r64d1',
190 'sctp_rule_protocol': '132',
191 'sctp-b-ipv6-ingress_src_subnet_prefix_len': '0',
192 'sctp-a-ipv6-ingress_rule_application': 'any',
193 'sctp-a-IPv6_ethertype': 'IPv6',
194 'vlc2_Internal1_mac': '00:80:37:0E:02:12',
195 'vlc_st_virtualization_type': 'virtual-machine',
196 'sctp-b-ingress-dst_start_port': '0.0',
197 'sctp-b-ingress-dst_end_port': '65535.0',
198 'sctp-a-ipv6-ingress-src_end_port': '65535.0',
199 'sctp-a-display_name': 'epc-sctp-a-ipv4v6-sec-group',
200 'sctp-b-ingress_rule_application': 'any',
201 'int2_sec_group_name': 'int2-sec-group',
202 'vlc_flavor_name': 'nd.c16r64d1',
203 'sctp-b-ipv6-egress_src_addresses': 'local',
204 'vlc_st_interface_type_int1': 'other1',
205 'sctp-b-egress-src_end_port': '65535.0',
206 'sctp-a-ipv6-egress-dst_start_port': '0',
207 'vlc_st_interface_type_int2': 'other2',
208 'sctp-a-ipv6-egress_rule_protocol': 'any',
209 'Internal2_shared': 'false',
210 'sctp-a-ipv6-egress_dst_subnet_prefix_len': '0',
211 'Internal2_rpf': 'disable',
212 'vlc1_Internal1_mac': '00:80:37:0E:01:12',
213 'sctp-b-ipv6-egress_src_end_port': '65535',
214 'sctp-a-ipv6-egress_src_addresses': 'local',
215 'sctp-a-ingress-dst_end_port': '65535.0',
216 'sctp-a-ipv6-egress_src_end_port': '65535',
217 'Internal1_forwarding_mode': 'l2',
218 'Internal2_dhcp': 'false',
219 'sctp-a-dst_subnet_prefix_v6': '::',
220 'pxe_image_name': 'MME_PXE-Boot_16ACP04_GA.qcow2',
221 'vlc_st_interface_type_gtp': 'other0',
222 'ncb1_Internal1_mac': '00:80:37:0E:09:12',
223 'sctp-b-src_subnet_prefix_v6': '::',
224 'sctp-a-egress_dst_subnet_prefix_len': '0.0',
225 'int1_sec_group_name': 'int1-sec-group',
226 'Internal1_dhcp': 'false',
227 'sctp-a-ipv6-egress_dst_end_port': '65535',
228 'Internal2_forwarding_mode': 'l2',
229 'fsb2_Internal2_mac': '00:80:37:0E:0D:12',
230 'sctp-b-egress_dst_subnet_prefix': '0.0.0.0',
231 'Internal1_net_cidr_len': '17',
232 'gpb2_Internal1_mac': '00:80:37:0E:02:22',
233 'sctp-b-ingress-src_subnet_prefix_len': '0.0',
234 'sctp-a-ingress_dst_addresses': 'local',
235 'sctp-a-egress_action': 'pass',
236 'fsb_volume_type_0': 'SF-Default-SSD',
237 'ncb2_Internal2_mac': '00:80:37:0E:0F:12',
238 'vlc_st_interface_type_sctp_a': 'left',
239 'vlc_st_interface_type_sctp_b': 'right',
240 'sctp-a-src_subnet_prefix_v6': '::',
241 'vlc_st_version': '2',
242 'sctp-b-egress_ethertype': 'IPv4',
243 'sctp-a-ingress_rule_application': 'any',
244 'gpb1_Internal2_mac': '00:80:37:0E:01:22',
245 'instance_ip_family_v6': 'v6',
246 'sctp-a-ipv6-egress_src_start_port': '0',
247 'sctp-b-ingress-src_start_port': '0.0',
248 'sctp-b-ingress_dst_addresses': 'local',
249 'fsb1_Internal1_mac': '00:80:37:0E:0B:12',
250 'vlc_st_interface_type_oam': 'management',
251 'multi_stage_design': 'false',
252 'oam_sec_group_name': 'oam-sec-group',
253 'Internal2_net_gateway': '169.255.0.3',
254 'sctp-a-ipv6-ingress-dst_end_port': '65535',
255 'sctp-b-ipv6-egress-dst_start_port': '0',
256 'Internal1_net_gateway': '169.253.0.3',
257 'sctp-b-ipv6-egress_rule_protocol': 'any',
258 'gtp_sec_group_name': 'gtp-sec-group',
259 'sctp-a-ipv6-egress_dst_subnet_prefix': '0.0.0.0',
260 'sctp-b-ipv6-egress_dst_subnet_prefix_len': '0',
261 'sctp-a-ipv6-ingress_dst_addresses': 'local',
262 'sctp-a-egress_rule_protocol': 'icmp',
263 'sctp-b-ipv6-egress_action': 'pass',
264 'sctp-a-ipv6-egress_action': 'pass',
265 'Internal1_shared': 'false',
266 'sctp-b-ipv6-ingress_rule_protocol': 'any',
267 'Internal2_net_cidr_len': '17',
268 'sctp-a-name': 'epc-sctp-a-ipv4v6-sec-group',
269 'sctp-a-ingress-src_end_port': '65535.0',
270 'sctp-b-ipv6-ingress_src_subnet_prefix': '0.0.0.0',
271 'sctp-a-egress-dst_end_port': '65535.0',
272 'sctp-a-ingress_action': 'pass',
273 'sctp-b-egress_rule_protocol': 'icmp',
274 'sctp-b-ipv6-ingress_action': 'pass',
275 'vlc_st_service_type': 'firewall',
276 'sctp-b-ipv6-egress_dst_end_port': '65535',
277 'sctp-b-ipv6-ingress-dst_start_port': '0',
278 'vlc2_Internal2_mac': '00:80:37:0E:02:12',
279 'vlc_st_availability_zone': 'true',
280 'fsb_volume_image_name_1': 'MME_FSB2_16ACP04_GA.qcow2',
281 'sctp-b-ingress-src_subnet_prefix': '0.0.0.0',
282 'sctp-a-ipv6-ingress_src_subnet_prefix_len': '0',
283 'Internal1_allow_transit': 'true',
284 'gpb_flavor_name': 'nv.c20r64d1',
285 'availability_zone_max_count': '1',
286 'fsb_volume_image_name_0': 'MME_FSB1_16ACP04_GA.qcow2',
287 'sctp-b-ipv6-ingress_dst_addresses': 'local',
288 'sctp-b-ipv6-egress_dst_subnet_prefix': '0.0.0.0',
289 'sctp-b-ipv6-ingress_ethertype': 'IPv4',
290 'vlc1_Internal2_mac': '00:80:37:0E:01:12',
291 'sctp-a-ingress-src_subnet_prefix': '0.0.0.0',
292 'sctp-a-ipv6-ingress_action': 'pass',
293 'Internal1_rpf': 'disable',
294 'sctp-b-ingress_ethertype': 'IPv4',
295 'sctp-b-egress_rule_application': 'any',
296 'sctp-b-ingress-src_end_port': '65535.0',
297 'sctp-a-ipv6-ingress_rule_protocol': 'any',
298 'sctp-a-ingress-src_start_port': '0.0',
299 'sctp-b-egress-dst_end_port': '65535.0'
300 },
301 'type': 'VF',
302 'modelCustomizationName': 'VF_vMee 0',
303 'vfModules': {
304 'vf_vmee0..VfVmee..vmme_vlc..module-1': {
305 'uuid': '522159d5-d6e0-4c2a-aa44-5a542a12a830',
306 'invariantUuid': '98a7c88b-b577-476a-90e4-e25a5871e02b',
307 'customizationUuid': '55b1be94-671a-403e-a26c-667e9c47d091',
308 'description': null,
309 'name': 'VfVmee..vmme_vlc..module-1',
310 'version': '2',
311 'modelCustomizationName': 'VfVmee..vmme_vlc..module-1',
312 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
313 'commands': {},
314 'volumeGroupAllowed': false
315 },
316 'vf_vmee0..VfVmee..vmme_gpb..module-2': {
317 'uuid': '41708296-e443-4c71-953f-d9a010f059e1',
318 'invariantUuid': '1cca90b8-3490-495e-87da-3f3e4c57d5b9',
319 'customizationUuid': '6add59e0-7fe1-4bc4-af48-f8812422ae7c',
320 'description': null,
321 'name': 'VfVmee..vmme_gpb..module-2',
322 'version': '2',
323 'modelCustomizationName': 'VfVmee..vmme_gpb..module-2',
324 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
325 'commands': {},
326 'volumeGroupAllowed': false
327 },
328 'vf_vmee0..VfVmee..base_vmme..module-0': {
329 'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
330 'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
331 'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
332 'description': null,
333 'name': 'VfVmee..base_vmme..module-0',
334 'version': '2',
335 'modelCustomizationName': 'VfVmee..base_vmme..module-0',
336 'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1},
337 'commands': {},
338 'volumeGroupAllowed': true
339 }
340 },
341 'volumeGroups': {
342 'vf_vmee0..VfVmee..base_vmme..module-0': {
343 'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
344 'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
345 'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
346 'description': null,
347 'name': 'VfVmee..base_vmme..module-0',
348 'version': '2',
349 'modelCustomizationName': 'VfVmee..base_vmme..module-0',
350 'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1}
351 }
352 }
353 }
354 },
355 'networks': {
356 'ExtVL 0': {
357 'uuid': 'ddc3f20c-08b5-40fd-af72-c6d14636b986',
358 'invariantUuid': '379f816b-a7aa-422f-be30-17114ff50b7c',
359 'description': 'ECOMP generic virtual link (network) base type for all other service-level and global networks',
360 'name': 'ExtVL',
361 'version': '37.0',
362 'customizationUuid': '94fdd893-4a36-4d70-b16a-ec29c54c184f',
363 'inputs': {},
364 'commands': {},
365 'properties': {
366 'network_assignments': '{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}',
367 'exVL_naming': '{ecomp_generated_naming=true}',
368 'network_flows': '{is_network_policy=false, is_bound_to_vpn=false}',
369 'network_homing': '{ecomp_selected_instance_node_target=false}'
370 },
371 'type': 'VL',
372 'modelCustomizationName': 'ExtVL 0'
373 }
374 },
375 'configurations': {
376 'Port Mirroring Configuration By Policy 0': {
377 'uuid': 'b4398538-e89d-4f13-b33d-ca323434ba50',
378 'invariantUuid': '6ef0ca40-f366-4897-951f-abd65d25f6f7',
379 'description': 'A port mirroring configuration by policy object',
380 'name': 'Port Mirroring Configuration By Policy',
381 'version': '27.0',
382 'customizationUuid': '3c3b7b8d-8669-4b3b-8664-61970041fad2',
383 'inputs': {},
384 'commands': {},
385 'properties': {},
386 'type': 'Configuration',
387 'modelCustomizationName': 'Port Mirroring Configuration By Policy 0',
388 'sourceNodes': [],
389 'collectorNodes': null,
390 'configurationByPolicy': false
391 }
392 },
393 'serviceProxies': {},
394 'vfModules': {
395 'vf_vmee0..VfVmee..vmme_vlc..module-1': {
396 'uuid': '522159d5-d6e0-4c2a-aa44-5a542a12a830',
397 'invariantUuid': '98a7c88b-b577-476a-90e4-e25a5871e02b',
398 'customizationUuid': '55b1be94-671a-403e-a26c-667e9c47d091',
399 'description': null,
400 'name': 'VfVmee..vmme_vlc..module-1',
401 'version': '2',
402 'modelCustomizationName': 'VfVmee..vmme_vlc..module-1',
403 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
404 'commands': {},
405 'volumeGroupAllowed': false
406 },
407 'vf_vmee0..VfVmee..vmme_gpb..module-2': {
408 'uuid': '41708296-e443-4c71-953f-d9a010f059e1',
409 'invariantUuid': '1cca90b8-3490-495e-87da-3f3e4c57d5b9',
410 'customizationUuid': '6add59e0-7fe1-4bc4-af48-f8812422ae7c',
411 'description': null,
412 'name': 'VfVmee..vmme_gpb..module-2',
413 'version': '2',
414 'modelCustomizationName': 'VfVmee..vmme_gpb..module-2',
415 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
416 'commands': {},
417 'volumeGroupAllowed': false
418 },
419 'vf_vmee0..VfVmee..base_vmme..module-0': {
420 'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
421 'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
422 'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
423 'description': null,
424 'name': 'VfVmee..base_vmme..module-0',
425 'version': '2',
426 'modelCustomizationName': 'VfVmee..base_vmme..module-0',
427 'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1},
428 'commands': {},
429 'volumeGroupAllowed': true
430 }
431 },
432 'volumeGroups': {
433 'vf_vmee0..VfVmee..base_vmme..module-0': {
434 'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
435 'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
436 'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
437 'description': null,
438 'name': 'VfVmee..base_vmme..module-0',
439 'version': '2',
440 'modelCustomizationName': 'VfVmee..base_vmme..module-0',
441 'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1}
442 }
443 },
444 'pnfs': {}
445 }
446 }
447 ));
448 }
449
450});