cdd95dcdfe569af66260809b70e1cfeeb9169ef5
[ccsdk/sli/adaptors.git] / resource-assignment / provider / src / test / java / jtest / org / onap / ccsdk / sli / adaptors / ra / TestReserve.java
1 package jtest.org.onap.ccsdk.sli.adaptors.ra;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Map;
7 import org.junit.Assert;
8 import org.junit.FixMethodOrder;
9 import org.junit.Test;
10 import org.junit.runner.RunWith;
11 import org.junit.runners.MethodSorters;
12 import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
13 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity;
14 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
15 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse;
16 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
17 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
18 import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
19 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
20 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.jdbc.core.JdbcTemplate;
25 import org.springframework.test.context.ContextConfiguration;
26 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
27 import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable;
28
29 @RunWith(SpringJUnit4ClassRunner.class)
30 @ContextConfiguration(locations = {"classpath:test-context.xml"})
31 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
32 public class TestReserve {
33
34     private static final Logger log = LoggerFactory.getLogger(TestReserve.class);
35
36     private JdbcTemplate jdbcTemplate;
37
38     private static final String[] RESOURCE_COLUMNS = {"asset_id", "resource_name", "resource_type", "lt_used"};
39
40     private static final String[] ALLOCATION_ITEM_COLUMNS = {"resource_id", "application_id", "resource_set_id",
41             "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time"};
42
43
44     @Autowired
45     public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
46         this.jdbcTemplate = jdbcTemplate;
47     }
48
49     @Autowired(required = true)
50     private ResourceAllocator resourceAllocator;
51
52     /*
53      * @Autowired(required = true) private ResourceAllocatorApi resourceAllocatorApi;
54      */
55
56     @Autowired(required = true)
57     private DataSetup dataSetup;
58
59     @Test
60     public void test001() throws Exception {
61         String t = "001";
62         log.info("============== reserve " + t + " ================================");
63         log.info("=== Test successful response - new start - all resources available");
64
65         // String service1 = "reserve" + t + "/service1";
66
67         dataSetup.cleanup();
68
69         TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
70         TestTable allocationItem =
71                 new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
72
73
74         SvcLogicContext ctx = new SvcLogicContext();
75         ctx.setAttribute("ra-input.service-model", "ADIG");
76         ctx.setAttribute("ra-input.check-only", "false");
77         ctx.setAttribute("ra-input.reservation-entity-type", "SI");
78         ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
79         ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
80         ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
81
82         ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
83         ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
84         ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
85         ctx.setAttribute("ra-input.reservation-target-type", "VNF");
86
87         ctx.setAttribute("ra-input.reservation-target-data.max-vpe-bandwidth-mbps", "5000");
88
89
90         QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
91
92         Assert.assertTrue(st == QueryStatus.SUCCESS);
93
94         resource.print();
95         allocationItem.print();
96
97         ctx.setAttribute("ra-input.service-model", "ADIG");
98         ctx.setAttribute("ra-input.check-only", "false");
99         ctx.setAttribute("ra-input.reservation-entity-type", "SI");
100         ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
101         ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
102         ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
103
104         ctx.setAttribute("ra-input.reservation-target-data.service-speed", "100");
105         ctx.setAttribute("ra-input.reservation-target-data.service-speed-unit", "Mbps");
106         ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
107         ctx.setAttribute("ra-input.reservation-target-type", "Port");
108
109
110         st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
111
112         Assert.assertTrue(st == QueryStatus.SUCCESS);
113
114         ctx.setAttribute("ra-input.service-model", "ADIG");
115         ctx.setAttribute("ra-input.check-only", "false");
116         ctx.setAttribute("ra-input.reservation-entity-type", "SI");
117         ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
118         ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
119         ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
120
121         ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
122         ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
123         ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
124         ctx.setAttribute("ra-input.reservation-target-type", "AffinityLink");
125
126
127         st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
128
129         Assert.assertTrue(st == QueryStatus.SUCCESS);
130
131         resource.print();
132         allocationItem.print();
133
134
135         /* Query Using ReservationEntityId using ServiceLogicContext */
136         ctx = new SvcLogicContext();
137         ctx.setAttribute("ra-input.service-model", "ADIG");
138         ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
139         ctx.setAttribute("ra-input.reservation-entity-type", "SI");
140
141
142         st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
143         Assert.assertTrue(st == QueryStatus.SUCCESS);
144
145
146         /* Query Using ReservationTargetId using ServiceLogicContext */
147         ctx = new SvcLogicContext();
148         ctx.setAttribute("ra-input.service-model", "ADIG");
149         ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
150         ctx.setAttribute("ra-input.reservation-target-type", "Port");
151         ctx.setAttribute("ra-input.resource-name", "Bandwidth");
152
153         st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
154         Assert.assertTrue(st == QueryStatus.SUCCESS);
155
156         log.info("========================  Query Using ResourceEntity==============================");
157         /* Query Using ResourceEntity bean */
158         ResourceEntity sd = new ResourceEntity();
159         sd.resourceEntityId = "ICOREPVCID-123456";
160         sd.resourceEntityType = "SI";
161
162
163         ResourceRequest rr = new ResourceRequest();
164         rr.serviceModel = "ADIG";
165         rr.resourceName = "cust-vlan-id";
166         rr.requestType = "New";
167         rr.rangeMaxOverride = -1;
168         rr.rangeMinOverride = -1;
169
170         List<ResourceResponse> rsList = new ArrayList<>();
171         resourceAllocator.query(sd, null, null, rsList);
172
173         rsList.forEach(r -> {
174             StrUtil.info(log, r);
175         });
176
177         log.info("========================  release Using ResourceEntity==============================");
178         rsList = new ArrayList<>();
179         AllocationStatus status = resourceAllocator.release(sd);
180         Assert.assertTrue(status == AllocationStatus.Success);
181
182
183         log.info("========================  Query Using ResourceEntity==============================");
184         rsList = new ArrayList<>();
185         resourceAllocator.query(sd, null, null, rsList);
186
187
188         rsList.forEach(r -> {
189             StrUtil.info(log, r);
190         });
191
192     }
193
194     @Test
195     public void test002() throws Exception {
196         String t = "002";
197         log.info("============== reserve " + t + " ================================");
198         log.info("=== Test successful response - new start - all resources available");
199
200         Map<String, String> data = new HashMap<>();
201         data.put("service-speed", "100");
202         data.put("service-speed-unit", "Mbps");
203
204         ResourceEntity sd = new ResourceEntity();
205         sd.resourceEntityId = "ICOREPVCID-123456";
206         sd.resourceEntityType = "SI";
207         sd.data = data;
208
209         data = new HashMap<>();
210         data.put("vnf-type", "VPE");
211         data.put("vpe-name", "mdt300vpe54");
212         data.put("max-vpe-bandwidth-mbps", "5000");
213
214         ResourceTarget rt = new ResourceTarget();
215         rt.resourceTargetId = "mdt300vpe54";
216         rt.resourceTargetType = "VNF";
217         rt.data = data;
218
219         ResourceRequest rr = new ResourceRequest();
220         rr.serviceModel = "ADIG";
221         // rr.resourceName = "cust-vlan-id";
222         rr.requestType = "New";
223         rr.rangeMaxOverride = -1;
224         rr.rangeMinOverride = -1;
225
226         List<ResourceResponse> rsList = new ArrayList<>();
227
228         resourceAllocator.reserve(sd, rt, rr, rsList);
229
230         rsList.forEach(r -> {
231             StrUtil.info(log, r);
232         });
233
234         log.info("========================  Query + t ==============================");
235         rsList = new ArrayList<>();
236         resourceAllocator.query(sd, null, rr, rsList);
237
238         rsList.forEach(r -> {
239             StrUtil.info(log, r);
240         });
241
242     }
243
244
245     @Test
246     public void test003() throws Exception {
247         String t = "003";
248         log.info("============== reserve " + t + " ================================");
249         log.info("=== Test successful response - new start - all resources available");
250
251         ResourceEntity sd = new ResourceEntity();
252         sd.resourceEntityId = "gblond2003me6";
253         sd.resourceEntityType = "VNF";
254
255         ResourceTarget rt = new ResourceTarget();
256         rt.resourceTargetId = "MDTWNJ21A5";
257         rt.resourceTargetType = "Site";
258
259
260         ResourceRequest rr = new ResourceRequest();
261         rr.serviceModel = "MY-SERV-MODEL";
262         rr.resourceName = "VPE-Cust";
263         // rr.requestType = "New";
264         // rr.rangeMaxOverride = 5;
265         // rr.rangeMinOverride = 5;
266
267         List<ResourceResponse> rsList = new ArrayList<>();
268         resourceAllocator.reserve(sd, rt, rr, rsList);
269
270         rsList.forEach(r -> {
271             StrUtil.info(log, r);
272         });
273
274         log.info("========================  Query + t ==============================");
275         rsList = new ArrayList<>();
276         resourceAllocator.query(sd, null, rr, rsList);
277
278         rsList.forEach(r -> {
279             StrUtil.info(log, r);
280         });
281
282     }
283
284
285
286     @Test
287     public void test004() throws Exception {
288         String t = "004";
289         log.info("============== reserve " + t + " ================================");
290         log.info("=== Test successful response - new start - all resources available");
291
292         ResourceEntity sd = new ResourceEntity();
293         sd.resourceEntityId = "gblond2003me6";
294         sd.resourceEntityType = "VNF";
295
296         ResourceTarget rt = new ResourceTarget();
297         rt.resourceTargetId = "MDTWNJ21A5";
298         rt.resourceTargetType = "Site";
299
300         List<ResourceRequest> rrs = new ArrayList<>();
301         ResourceRequest rr = new ResourceRequest();
302         rr.serviceModel = "MY-SERV-MODEL";
303         rr.resourceName = "VPE-Cust";
304         rrs.add(rr);
305
306         rr = new ResourceRequest();
307         rr.serviceModel = "MY-SERV-MODEL";
308         rr.resourceName = "VPE-Core1";
309         rrs.add(rr);
310
311         rr = new ResourceRequest();
312         rr.serviceModel = "MY-SERV-MODEL";
313         rr.resourceName = "VPE-Core2";
314         rrs.add(rr);
315
316
317
318         List<ResourceResponse> rsList = new ArrayList<>();
319         // resourceAllocator.reserve(sd, rt, rrs, rsList);
320
321         rsList.forEach(r -> {
322             StrUtil.info(log, r);
323         });
324
325         log.info("========================  Query + t ==============================");
326         rsList = new ArrayList<>();
327         resourceAllocator.query(sd, null, rr, rsList);
328
329         rsList.forEach(r -> {
330             StrUtil.info(log, r);
331         });
332
333     }
334
335
336     @Test
337     public void test005() throws Exception {
338         String t = "005";
339         log.info("============== reserve " + t + " ================================");
340         log.info("=== Test successful response - new start - all resources available");
341
342         // String service1 = "reserve" + t + "/service1";
343
344         dataSetup.cleanup();
345
346         TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
347         TestTable allocationItem =
348                 new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
349
350
351         SvcLogicContext ctx = new SvcLogicContext();
352         ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
353         ctx.setAttribute("ra-input.check-only", "false");
354         ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Cust");
355         ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
356
357         ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
358         ctx.setAttribute("ra-input.reservation-target-type", "Site");
359
360         ctx.setAttribute("ra-input.resource-name", "cust-vlan-id");
361
362
363         QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
364
365         Assert.assertTrue(st == QueryStatus.SUCCESS);
366
367         resource.print();
368         allocationItem.print();
369
370         ctx = new SvcLogicContext();
371         ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
372         ctx.setAttribute("ra-input.check-only", "false");
373         ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
374         ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
375
376         ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
377         ctx.setAttribute("ra-input.reservation-target-type", "Site");
378
379         ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
380
381
382         st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
383
384         Assert.assertTrue(st == QueryStatus.SUCCESS);
385
386         resource.print();
387         allocationItem.print();
388
389         ctx = new SvcLogicContext();
390         ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
391         ctx.setAttribute("ra-input.check-only", "false");
392         ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core2");
393         ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
394
395         ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
396         ctx.setAttribute("ra-input.reservation-target-type", "Site");
397
398         ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
399         ctx.setAttribute("ra-input.replace", "false");
400
401
402         st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
403
404         Assert.assertTrue(st == QueryStatus.SUCCESS);
405
406         resource.print();
407         allocationItem.print();
408
409
410         /* Query Using ReservationEntityId using ServiceLogicContext */
411         ctx = new SvcLogicContext();
412         ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
413         ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
414         ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
415
416
417         st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
418         Assert.assertTrue(st == QueryStatus.SUCCESS);
419
420
421         /* Query Using ReservationTargetId using ServiceLogicContext */
422         ctx = new SvcLogicContext();
423         ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
424         ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
425         ctx.setAttribute("ra-input.reservation-target-type", "Site");
426         ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
427
428         st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
429         Assert.assertTrue(st == QueryStatus.SUCCESS);
430
431         log.info("========================  Query Using ResourceEntity==============================");
432         /* Query Using ResourceEntity bean */
433         ResourceEntity sd = new ResourceEntity();
434         sd.resourceEntityId = "gblond2003me6";
435         sd.resourceEntityType = "VPE-Core1";
436
437
438         ResourceRequest rr = new ResourceRequest();
439         rr.serviceModel = "MY-SERV-MODEL-1";
440         rr.resourceName = "vlan-id-inner";
441         rr.requestType = "New";
442         rr.rangeMaxOverride = -1;
443         rr.rangeMinOverride = -1;
444
445         List<ResourceResponse> rsList = new ArrayList<>();
446         resourceAllocator.query(sd, null, null, rsList);
447
448         rsList.forEach(r -> {
449             StrUtil.info(log, r);
450         });
451
452         /*
453          * log.info("========================  release Using ResourceEntity==============================");
454          * rsList = new ArrayList<ResourceResponse>(); AllocationStatus status =
455          * resourceAllocator.release(sd); Assert.assertTrue(status == AllocationStatus.Success);
456          *
457          *
458          * log.info("========================  Query Using ResourceEntity==============================");
459          * rsList = new ArrayList<ResourceResponse>(); resourceAllocator.query(sd, null, null, rsList);
460          *
461          *
462          * rsList.forEach(r -> { StrUtil.info(log, r); });
463          */
464
465     }
466
467
468
469     @Test
470     public void test006() throws Exception {
471         String t = "006";
472         log.info("============== reserve " + t + " ================================");
473         log.info("=== Test successful response - new start - all resources available");
474
475         ResourceEntity sd = new ResourceEntity();
476         sd.resourceEntityId = "gblond2003me6";
477         sd.resourceEntityType = "VPE-Cust";
478
479         ResourceTarget rt = new ResourceTarget();
480         rt.resourceTargetId = "MDTWNJ21A5";
481         rt.resourceTargetType = "Site";
482
483
484         ResourceRequest rr = new ResourceRequest();
485         rr.serviceModel = "MY-SERV-MODEL-1";
486         rr.resourceName = "cust-vlan-id";
487
488
489         List<ResourceResponse> rsList = new ArrayList<>();
490         resourceAllocator.reserve(sd, rt, rr, rsList);
491
492         rsList.forEach(r -> {
493             StrUtil.info(log, r);
494         });
495
496         log.info("========================  Query + t ==============================");
497         rsList = new ArrayList<>();
498         resourceAllocator.query(sd, null, rr, rsList);
499
500         rsList.forEach(r -> {
501             StrUtil.info(log, r);
502         });
503
504     }
505
506     @Test
507     public void test007() throws Exception {
508         String t = "007";
509         log.info("============== reserve " + t + " ================================");
510         log.info("=== Test successful response - new start - all resources available");
511
512         dataSetup.cleanup();
513
514         TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
515         TestTable allocationItem =
516                 new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
517
518
519         ResourceEntity sd = new ResourceEntity();
520         sd.resourceEntityId = "gblond2003me6";
521         sd.resourceEntityType = "VPE";
522         sd.resourceEntityVersion = "1";
523
524         ResourceTarget rt = new ResourceTarget();
525         rt.resourceTargetId = "MDTWNJ21A5";
526         rt.resourceTargetType = "Site";
527
528
529         ResourceRequest rr = new ResourceRequest();
530         rr.serviceModel = "MY-SERV-MODEL";
531         // rr.resourceName = "vlan-id-outer";
532         rr.endPointPosition = "VPE-Cust";
533         rr.rangeMaxOverride = -1;
534         rr.rangeMinOverride = -1;
535
536
537         List<ResourceResponse> rsList = new ArrayList<>();
538         resourceAllocator.reserve(sd, rt, rr, rsList);
539
540         // VPE-Core1
541         sd = new ResourceEntity();
542         sd.resourceEntityId = "gblond2003me6";
543         sd.resourceEntityType = "VPE";
544         sd.resourceEntityVersion = "1";
545
546         rt = new ResourceTarget();
547         rt.resourceTargetId = "MDTWNJ21A5";
548         rt.resourceTargetType = "Site";
549
550
551         rr = new ResourceRequest();
552         rr.serviceModel = "MY-SERV-MODEL";
553         // rr.resourceName = "vlan-id-filter";
554         rr.endPointPosition = "VPE-Core1";
555         rr.rangeMaxOverride = -1;
556         rr.rangeMinOverride = -1;
557
558
559         rsList = new ArrayList<>();
560         resourceAllocator.reserve(sd, rt, rr, rsList);
561
562
563         // VPE-Core2
564         sd = new ResourceEntity();
565         sd.resourceEntityId = "gblond2003me6";
566         sd.resourceEntityType = "VPE";
567         sd.resourceEntityVersion = "1";
568
569         rt = new ResourceTarget();
570         rt.resourceTargetId = "MDTWNJ21A5";
571         rt.resourceTargetType = "Site";
572
573
574         rr = new ResourceRequest();
575         rr.serviceModel = "MY-SERV-MODEL";
576         // rr.resourceName = "vlan-id-filter";
577         rr.endPointPosition = "VPE-Core2";
578         rr.rangeMaxOverride = -1;
579         rr.rangeMinOverride = -1;
580
581
582         rsList = new ArrayList<>();
583         resourceAllocator.reserve(sd, rt, rr, rsList);
584
585
586         // VPE-Core3
587         sd = new ResourceEntity();
588         sd.resourceEntityId = "gblond2003me6";
589         sd.resourceEntityType = "VPE";
590         sd.resourceEntityVersion = "1";
591
592         rt = new ResourceTarget();
593         rt.resourceTargetId = "MDTWNJ21A5";
594         rt.resourceTargetType = "Site";
595
596
597         rr = new ResourceRequest();
598         rr.serviceModel = "MY-SERV-MODEL";
599         // rr.resourceName = "vlan-id-filter";
600         rr.endPointPosition = "VPE-Core3";
601         rr.rangeMaxOverride = -1;
602         rr.rangeMinOverride = -1;
603
604
605         rsList = new ArrayList<>();
606         resourceAllocator.reserve(sd, rt, rr, rsList);
607
608         rsList.forEach(r -> {
609             StrUtil.info(log, r);
610         });
611
612         resource.print();
613         allocationItem.print();
614
615         log.info("========================  Query + t ==============================");
616         rsList = new ArrayList<>();
617         resourceAllocator.query(sd, null, rr, rsList);
618
619         rsList.forEach(r -> {
620             StrUtil.info(log, r);
621         });
622
623
624
625         SvcLogicContext ctx = new SvcLogicContext();
626         ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
627         ctx.setAttribute("ra-input.reservation-entity-type", "VPE");
628
629
630         QueryStatus st = resourceAllocator.release("NetworkCapacity", "gblond2003me6", ctx);
631         Assert.assertTrue(st == QueryStatus.SUCCESS);
632
633     }
634
635     @Test
636     public void test008() throws Exception {
637         String t = "008";
638         log.info("============== reserve " + t + " ================================");
639         log.info("=== Test range-force-new-numbers = false");
640
641         String entityId = "reserve" + t;
642         String targetId = "port-id-1";
643         String resourceName = "cust-vlan-id";
644
645         String assetId = "VNF::" + targetId;
646         String resourceUnion = "SI::" + entityId;
647         String resourceSet1 = resourceUnion + "::1";
648         String resourceSet2 = resourceUnion + "::2";
649
650         dataSetup.cleanup();
651
652         dataSetup.setupRangeItem(resourceName, assetId, resourceSet1, resourceUnion, "201");
653
654         SvcLogicContext ctx = new SvcLogicContext();
655         ctx.setAttribute("ra-input.service-model", "ADIG");
656         ctx.setAttribute("ra-input.check-only", "false");
657
658         ctx.setAttribute("ra-input.resource-name", resourceName);
659         ctx.setAttribute("ra-input.range-force-new-numbers", "false");
660
661         ctx.setAttribute("ra-input.reservation-entity-type", "SI");
662         ctx.setAttribute("ra-input.reservation-entity-id", entityId);
663         ctx.setAttribute("ra-input.reservation-entity-version", "2");
664
665         ctx.setAttribute("ra-input.reservation-target-id", targetId);
666         ctx.setAttribute("ra-input.reservation-target-type", "VNF");
667
668         QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
669
670         Assert.assertTrue(st == QueryStatus.SUCCESS);
671         Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
672         Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
673     }
674
675     @Test
676     public void test009() throws Exception {
677         String t = "009";
678         log.info("============== reserve " + t + " ================================");
679         log.info("=== Test range-force-new-numbers = true");
680
681         String entityId = "reserve" + t;
682         String targetId = "port-id-1";
683         String resourceName = "cust-vlan-id";
684
685         String assetId = "VNF::" + targetId;
686         String resourceUnion = "SI::" + entityId;
687         String resourceSet1 = resourceUnion + "::1";
688         String resourceSet2 = resourceUnion + "::2";
689
690         dataSetup.cleanup();
691
692         dataSetup.setupRangeItem(resourceName, assetId, resourceSet1, resourceUnion, "201");
693
694         SvcLogicContext ctx = new SvcLogicContext();
695         ctx.setAttribute("ra-input.service-model", "ADIG");
696         ctx.setAttribute("ra-input.check-only", "false");
697
698         ctx.setAttribute("ra-input.resource-name", resourceName);
699         ctx.setAttribute("ra-input.range-force-new-numbers", "true");
700
701         ctx.setAttribute("ra-input.reservation-entity-type", "SI");
702         ctx.setAttribute("ra-input.reservation-entity-id", entityId);
703         ctx.setAttribute("ra-input.reservation-entity-version", "2");
704
705         ctx.setAttribute("ra-input.reservation-target-id", targetId);
706         ctx.setAttribute("ra-input.reservation-target-type", "VNF");
707
708         QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
709
710         Assert.assertTrue(st == QueryStatus.SUCCESS);
711         Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
712         Assert.assertFalse(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
713     }
714 }