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