1 package jtest.org.onap.ccsdk.sli.adaptors.ra;
3 import static org.junit.Assert.assertNotNull;
4 import java.util.ArrayList;
5 import java.util.Arrays;
6 import java.util.HashMap;
9 import org.junit.Assert;
10 import org.junit.FixMethodOrder;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.junit.runners.MethodSorters;
14 import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
15 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity;
16 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
17 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse;
18 import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
19 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
20 import org.onap.ccsdk.sli.adaptors.rm.data.Range;
21 import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
22 import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
23 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
24 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.jdbc.core.JdbcTemplate;
29 import org.springframework.test.context.ContextConfiguration;
30 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
31 import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable;
33 @RunWith(SpringJUnit4ClassRunner.class)
34 @ContextConfiguration(locations = { "classpath:test-context.xml" })
35 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
36 public class TestReserve {
38 private static final Logger log = LoggerFactory.getLogger(TestReserve.class);
40 private JdbcTemplate jdbcTemplate;
42 private static final String[] RESOURCE_COLUMNS = { "asset_id", "resource_name", "resource_type", "lt_used" };
44 private static final String[] ALLOCATION_ITEM_COLUMNS = { "resource_id", "application_id", "resource_set_id",
45 "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time" };
48 public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
49 this.jdbcTemplate = jdbcTemplate;
52 @Autowired(required = true)
53 private ResourceAllocator resourceAllocator;
56 * @Autowired(required = true) private ResourceAllocatorApi
57 * resourceAllocatorApi;
60 @Autowired(required = true)
61 private DataSetup dataSetup;
64 public void test001() throws Exception {
66 log.info("============== reserve " + t + " ================================");
67 log.info("=== Test successful response - new start - all resources available");
69 // String service1 = "reserve" + t + "/service1";
73 TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
74 TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
75 ALLOCATION_ITEM_COLUMNS);
77 SvcLogicContext ctx = new SvcLogicContext();
78 ctx.setAttribute("ra-input.service-model", "ADIG");
79 ctx.setAttribute("ra-input.check-only", "false");
80 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
81 ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
82 ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
83 ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
85 ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
86 ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
87 ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
88 ctx.setAttribute("ra-input.reservation-target-type", "VNF");
90 ctx.setAttribute("ra-input.reservation-target-data.max-vpe-bandwidth-mbps", "5000");
92 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
94 Assert.assertTrue(st == QueryStatus.SUCCESS);
97 allocationItem.print();
99 ctx.setAttribute("ra-input.service-model", "ADIG");
100 ctx.setAttribute("ra-input.check-only", "false");
101 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
102 ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
103 ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
104 ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
106 ctx.setAttribute("ra-input.reservation-target-data.service-speed", "100");
107 ctx.setAttribute("ra-input.reservation-target-data.service-speed-unit", "Mbps");
108 ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
109 ctx.setAttribute("ra-input.reservation-target-type", "Port");
111 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
113 Assert.assertTrue(st == QueryStatus.SUCCESS);
115 ctx.setAttribute("ra-input.service-model", "ADIG");
116 ctx.setAttribute("ra-input.check-only", "false");
117 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
118 ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
119 ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
120 ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
122 ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
123 ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
124 ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
125 ctx.setAttribute("ra-input.reservation-target-type", "AffinityLink");
127 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
129 Assert.assertTrue(st == QueryStatus.SUCCESS);
132 allocationItem.print();
134 /* Query Using ReservationEntityId using ServiceLogicContext */
135 ctx = new SvcLogicContext();
136 ctx.setAttribute("ra-input.service-model", "ADIG");
137 ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
138 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
140 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
141 Assert.assertTrue(st == QueryStatus.SUCCESS);
143 /* Query Using ReservationTargetId using ServiceLogicContext */
144 ctx = new SvcLogicContext();
145 ctx.setAttribute("ra-input.service-model", "ADIG");
146 ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
147 ctx.setAttribute("ra-input.reservation-target-type", "Port");
148 ctx.setAttribute("ra-input.resource-name", "Bandwidth");
150 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
151 Assert.assertTrue(st == QueryStatus.SUCCESS);
153 log.info("======================== Query Using ResourceEntity==============================");
154 /* Query Using ResourceEntity bean */
155 ResourceEntity sd = new ResourceEntity();
156 sd.resourceEntityId = "ICOREPVCID-123456";
157 sd.resourceEntityType = "SI";
159 ResourceRequest rr = new ResourceRequest();
160 rr.serviceModel = "ADIG";
161 rr.resourceName = "cust-vlan-id";
162 rr.requestType = "New";
163 rr.rangeMaxOverride = -1;
164 rr.rangeMinOverride = -1;
166 List<ResourceResponse> rsList = new ArrayList<>();
167 resourceAllocator.query(sd, null, null, rsList);
169 rsList.forEach(r -> {
170 StrUtil.info(log, r);
173 log.info("======================== release Using ResourceEntity==============================");
174 rsList = new ArrayList<>();
175 AllocationStatus status = resourceAllocator.release(sd);
176 Assert.assertTrue(status == AllocationStatus.Success);
178 log.info("======================== Query Using ResourceEntity==============================");
179 rsList = new ArrayList<>();
180 resourceAllocator.query(sd, null, null, rsList);
182 rsList.forEach(r -> {
183 StrUtil.info(log, r);
189 public void test002() throws Exception {
191 log.info("============== reserve " + t + " ================================");
192 log.info("=== Test successful response - new start - all resources available");
194 Map<String, String> data = new HashMap<>();
195 data.put("service-speed", "100");
196 data.put("service-speed-unit", "Mbps");
198 ResourceEntity sd = new ResourceEntity();
199 sd.resourceEntityId = "ICOREPVCID-123456";
200 sd.resourceEntityType = "SI";
203 data = new HashMap<>();
204 data.put("vnf-type", "VPE");
205 data.put("vpe-name", "mdt300vpe54");
206 data.put("max-vpe-bandwidth-mbps", "5000");
208 ResourceTarget rt = new ResourceTarget();
209 rt.resourceTargetId = "mdt300vpe54";
210 rt.resourceTargetType = "VNF";
213 ResourceRequest rr = new ResourceRequest();
214 rr.serviceModel = "ADIG";
215 // rr.resourceName = "cust-vlan-id";
216 rr.requestType = "New";
217 rr.rangeMaxOverride = -1;
218 rr.rangeMinOverride = -1;
220 List<ResourceResponse> rsList = new ArrayList<>();
222 resourceAllocator.reserve(sd, rt, rr, rsList);
224 rsList.forEach(r -> {
225 StrUtil.info(log, r);
228 log.info("======================== Query + t ==============================");
229 rsList = new ArrayList<>();
230 resourceAllocator.query(sd, null, rr, rsList);
232 rsList.forEach(r -> {
233 StrUtil.info(log, r);
235 assertNotNull(rsList);
240 public void test003() throws Exception {
242 log.info("============== reserve " + t + " ================================");
243 log.info("=== Test successful response - new start - all resources available");
245 ResourceEntity sd = new ResourceEntity();
246 sd.resourceEntityId = "gblond2003me6";
247 sd.resourceEntityType = "VNF";
249 ResourceTarget rt = new ResourceTarget();
250 rt.resourceTargetId = "MDTWNJ21A5";
251 rt.resourceTargetType = "Site";
253 ResourceRequest rr = new ResourceRequest();
254 rr.serviceModel = "MY-SERV-MODEL";
255 rr.resourceName = "VPE-Cust";
256 // rr.requestType = "New";
257 // rr.rangeMaxOverride = 5;
258 // rr.rangeMinOverride = 5;
260 List<ResourceResponse> rsList = new ArrayList<>();
261 resourceAllocator.reserve(sd, rt, rr, rsList);
263 rsList.forEach(r -> {
264 StrUtil.info(log, r);
267 log.info("======================== Query + t ==============================");
268 rsList = new ArrayList<>();
269 resourceAllocator.query(sd, null, rr, rsList);
271 rsList.forEach(r -> {
272 StrUtil.info(log, r);
279 public void test004() throws Exception {
281 log.info("============== reserve " + t + " ================================");
282 log.info("=== Test successful response - new start - all resources available");
284 ResourceEntity sd = new ResourceEntity();
285 sd.resourceEntityId = "gblond2003me6";
286 sd.resourceEntityType = "VNF";
288 ResourceTarget rt = new ResourceTarget();
289 rt.resourceTargetId = "MDTWNJ21A5";
290 rt.resourceTargetType = "Site";
292 List<ResourceRequest> rrs = new ArrayList<>();
293 ResourceRequest rr = new ResourceRequest();
294 rr.serviceModel = "MY-SERV-MODEL";
295 rr.resourceName = "VPE-Cust";
298 rr = new ResourceRequest();
299 rr.serviceModel = "MY-SERV-MODEL";
300 rr.resourceName = "VPE-Core1";
303 rr = new ResourceRequest();
304 rr.serviceModel = "MY-SERV-MODEL";
305 rr.resourceName = "VPE-Core2";
308 List<ResourceResponse> rsList = new ArrayList<>();
309 // resourceAllocator.reserve(sd, rt, rrs, rsList);
311 rsList.forEach(r -> {
312 StrUtil.info(log, r);
315 log.info("======================== Query + t ==============================");
316 rsList = new ArrayList<>();
317 resourceAllocator.query(sd, null, rr, rsList);
319 rsList.forEach(r -> {
320 StrUtil.info(log, r);
327 public void test005() throws Exception {
329 log.info("============== reserve " + t + " ================================");
330 log.info("=== Test successful response - new start - all resources available");
332 // String service1 = "reserve" + t + "/service1";
336 TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
337 TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
338 ALLOCATION_ITEM_COLUMNS);
340 SvcLogicContext ctx = new SvcLogicContext();
341 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
342 ctx.setAttribute("ra-input.check-only", "false");
343 ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Cust");
344 ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
346 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
347 ctx.setAttribute("ra-input.reservation-target-type", "Site");
349 ctx.setAttribute("ra-input.resource-name", "cust-vlan-id");
351 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
353 Assert.assertTrue(st == QueryStatus.SUCCESS);
356 allocationItem.print();
358 ctx = new SvcLogicContext();
359 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
360 ctx.setAttribute("ra-input.check-only", "false");
361 ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
362 ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
364 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
365 ctx.setAttribute("ra-input.reservation-target-type", "Site");
367 ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
369 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
371 Assert.assertTrue(st == QueryStatus.SUCCESS);
374 allocationItem.print();
376 ctx = new SvcLogicContext();
377 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
378 ctx.setAttribute("ra-input.check-only", "false");
379 ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core2");
380 ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
382 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
383 ctx.setAttribute("ra-input.reservation-target-type", "Site");
385 ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
386 ctx.setAttribute("ra-input.replace", "false");
388 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
390 Assert.assertTrue(st == QueryStatus.SUCCESS);
393 allocationItem.print();
395 /* Query Using ReservationEntityId using ServiceLogicContext */
396 ctx = new SvcLogicContext();
397 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
398 ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
399 ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
401 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
402 Assert.assertTrue(st == QueryStatus.SUCCESS);
404 /* Query Using ReservationTargetId using ServiceLogicContext */
405 ctx = new SvcLogicContext();
406 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
407 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
408 ctx.setAttribute("ra-input.reservation-target-type", "Site");
409 ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
411 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
412 Assert.assertTrue(st == QueryStatus.SUCCESS);
414 log.info("======================== Query Using ResourceEntity==============================");
415 /* Query Using ResourceEntity bean */
416 ResourceEntity sd = new ResourceEntity();
417 sd.resourceEntityId = "gblond2003me6";
418 sd.resourceEntityType = "VPE-Core1";
420 ResourceRequest rr = new ResourceRequest();
421 rr.serviceModel = "MY-SERV-MODEL-1";
422 rr.resourceName = "vlan-id-inner";
423 rr.requestType = "New";
424 rr.rangeMaxOverride = -1;
425 rr.rangeMinOverride = -1;
427 List<ResourceResponse> rsList = new ArrayList<>();
428 resourceAllocator.query(sd, null, null, rsList);
430 rsList.forEach(r -> {
431 StrUtil.info(log, r);
436 * info("======================== release Using ResourceEntity=============================="
437 * ); rsList = new ArrayList<ResourceResponse>(); AllocationStatus status =
438 * resourceAllocator.release(sd); Assert.assertTrue(status ==
439 * AllocationStatus.Success);
443 * info("======================== Query Using ResourceEntity=============================="
444 * ); rsList = new ArrayList<ResourceResponse>(); resourceAllocator.query(sd,
445 * null, null, rsList);
448 * rsList.forEach(r -> { StrUtil.info(log, r); });
454 public void test006() throws Exception {
456 log.info("============== reserve " + t + " ================================");
457 log.info("=== Test successful response - new start - all resources available");
459 ResourceEntity sd = new ResourceEntity();
460 sd.resourceEntityId = "gblond2003me6";
461 sd.resourceEntityType = "VPE-Cust";
463 ResourceTarget rt = new ResourceTarget();
464 rt.resourceTargetId = "MDTWNJ21A5";
465 rt.resourceTargetType = "Site";
467 ResourceRequest rr = new ResourceRequest();
468 rr.serviceModel = "MY-SERV-MODEL-1";
469 rr.resourceName = "cust-vlan-id";
471 List<ResourceResponse> rsList = new ArrayList<>();
472 resourceAllocator.reserve(sd, rt, rr, rsList);
474 rsList.forEach(r -> {
475 StrUtil.info(log, r);
478 log.info("======================== Query + t ==============================");
479 rsList = new ArrayList<>();
480 resourceAllocator.query(sd, null, rr, rsList);
482 rsList.forEach(r -> {
483 StrUtil.info(log, r);
485 assertNotNull(rsList);
490 public void test007() throws Exception {
492 log.info("============== reserve " + t + " ================================");
493 log.info("=== Test successful response - new start - all resources available");
497 TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
498 TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
499 ALLOCATION_ITEM_COLUMNS);
501 ResourceEntity sd = new ResourceEntity();
502 sd.resourceEntityId = "gblond2003me6";
503 sd.resourceEntityType = "VPE";
504 sd.resourceEntityVersion = "1";
506 ResourceTarget rt = new ResourceTarget();
507 rt.resourceTargetId = "MDTWNJ21A5";
508 rt.resourceTargetType = "Site";
510 ResourceRequest rr = new ResourceRequest();
511 rr.serviceModel = "MY-SERV-MODEL";
512 // rr.resourceName = "vlan-id-outer";
513 rr.endPointPosition = "VPE-Cust";
514 rr.rangeMaxOverride = -1;
515 rr.rangeMinOverride = -1;
517 List<ResourceResponse> rsList = new ArrayList<>();
518 resourceAllocator.reserve(sd, rt, rr, rsList);
521 sd = new ResourceEntity();
522 sd.resourceEntityId = "gblond2003me6";
523 sd.resourceEntityType = "VPE";
524 sd.resourceEntityVersion = "1";
526 rt = new ResourceTarget();
527 rt.resourceTargetId = "MDTWNJ21A5";
528 rt.resourceTargetType = "Site";
530 rr = new ResourceRequest();
531 rr.serviceModel = "MY-SERV-MODEL";
532 // rr.resourceName = "vlan-id-filter";
533 rr.endPointPosition = "VPE-Core1";
534 rr.rangeMaxOverride = -1;
535 rr.rangeMinOverride = -1;
537 rsList = new ArrayList<>();
538 resourceAllocator.reserve(sd, rt, rr, rsList);
541 sd = new ResourceEntity();
542 sd.resourceEntityId = "gblond2003me6";
543 sd.resourceEntityType = "VPE";
544 sd.resourceEntityVersion = "1";
546 rt = new ResourceTarget();
547 rt.resourceTargetId = "MDTWNJ21A5";
548 rt.resourceTargetType = "Site";
550 rr = new ResourceRequest();
551 rr.serviceModel = "MY-SERV-MODEL";
552 // rr.resourceName = "vlan-id-filter";
553 rr.endPointPosition = "VPE-Core2";
554 rr.rangeMaxOverride = -1;
555 rr.rangeMinOverride = -1;
557 rsList = new ArrayList<>();
558 resourceAllocator.reserve(sd, rt, rr, rsList);
561 sd = new ResourceEntity();
562 sd.resourceEntityId = "gblond2003me6";
563 sd.resourceEntityType = "VPE";
564 sd.resourceEntityVersion = "1";
566 rt = new ResourceTarget();
567 rt.resourceTargetId = "MDTWNJ21A5";
568 rt.resourceTargetType = "Site";
570 rr = new ResourceRequest();
571 rr.serviceModel = "MY-SERV-MODEL";
572 // rr.resourceName = "vlan-id-filter";
573 rr.endPointPosition = "VPE-Core3";
574 rr.rangeMaxOverride = -1;
575 rr.rangeMinOverride = -1;
577 rsList = new ArrayList<>();
578 resourceAllocator.reserve(sd, rt, rr, rsList);
580 rsList.forEach(r -> {
581 StrUtil.info(log, r);
585 allocationItem.print();
587 log.info("======================== Query + t ==============================");
588 rsList = new ArrayList<>();
589 resourceAllocator.query(sd, null, rr, rsList);
591 rsList.forEach(r -> {
592 StrUtil.info(log, r);
595 SvcLogicContext ctx = new SvcLogicContext();
596 ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
597 ctx.setAttribute("ra-input.reservation-entity-type", "VPE");
599 QueryStatus st = resourceAllocator.release("NetworkCapacity", "gblond2003me6", ctx);
600 Assert.assertTrue(st == QueryStatus.SUCCESS);
605 public void test008() throws Exception {
607 log.info("============== reserve " + t + " ================================");
608 log.info("=== Test range-force-new-numbers = false");
610 String entityId = "reserve" + t;
611 String targetId = "port-id-1";
612 String resourceName = "cust-vlan-id";
614 String assetId = "VNF::" + targetId;
615 String resourceUnion = "SI::" + entityId;
616 String resourceSet1 = resourceUnion + "::1";
617 String resourceSet2 = resourceUnion + "::2";
621 dataSetup.setupRangeItem(resourceName, assetId, resourceSet1, resourceUnion, "201");
623 SvcLogicContext ctx = new SvcLogicContext();
624 ctx.setAttribute("ra-input.service-model", "ADIG");
625 ctx.setAttribute("ra-input.check-only", "false");
627 ctx.setAttribute("ra-input.resource-name", resourceName);
628 ctx.setAttribute("ra-input.range-force-new-numbers", "false");
630 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
631 ctx.setAttribute("ra-input.reservation-entity-id", entityId);
632 ctx.setAttribute("ra-input.reservation-entity-version", "2");
634 ctx.setAttribute("ra-input.reservation-target-id", targetId);
635 ctx.setAttribute("ra-input.reservation-target-type", "VNF");
637 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
639 Assert.assertTrue(st == QueryStatus.SUCCESS);
640 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
641 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
643 Assert.assertEquals(ctx.getAttribute("resource-list_length"), "1");
644 Assert.assertEquals(ctx.getAttribute("resource-list[0].resource-name"), "cust-vlan-id");
645 Assert.assertEquals(ctx.getAttribute("resource-list[0].resource-target-type"), "VNF");
646 Assert.assertEquals(ctx.getAttribute("resource-list[0].resource-target-id"), "port-id-1");
647 Assert.assertEquals(ctx.getAttribute("resource-list[0].status"), "Success");
648 Assert.assertEquals(ctx.getAttribute("resource-list[0].allocated"), "201");
649 Assert.assertEquals(ctx.getAttribute("resource-list[0].used"), "201");
650 Assert.assertEquals(ctx.getAttribute("resource-list[0].range-list_length"), "1");
651 Assert.assertEquals(ctx.getAttribute("resource-list[0].range-list[0].min"), "2");
652 Assert.assertEquals(ctx.getAttribute("resource-list[0].range-list[0].max"), "1000");
656 public void test009() throws Exception {
658 log.info("============== reserve " + t + " ================================");
659 log.info("=== Test range-force-new-numbers = true");
661 String entityId = "reserve" + t;
662 String targetId = "port-id-1";
663 String resourceName = "cust-vlan-id";
665 String assetId = "VNF::" + targetId;
666 String resourceUnion = "SI::" + entityId;
667 String resourceSet1 = resourceUnion + "::1";
668 String resourceSet2 = resourceUnion + "::2";
672 dataSetup.setupRangeItem(resourceName, assetId, resourceSet1, resourceUnion, "201");
674 SvcLogicContext ctx = new SvcLogicContext();
675 ctx.setAttribute("ra-input.service-model", "ADIG");
676 ctx.setAttribute("ra-input.check-only", "false");
678 ctx.setAttribute("ra-input.resource-name", resourceName);
679 ctx.setAttribute("ra-input.range-force-new-numbers", "true");
681 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
682 ctx.setAttribute("ra-input.reservation-entity-id", entityId);
683 ctx.setAttribute("ra-input.reservation-entity-version", "2");
685 ctx.setAttribute("ra-input.reservation-target-id", targetId);
686 ctx.setAttribute("ra-input.reservation-target-type", "VNF");
688 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
690 Assert.assertTrue(st == QueryStatus.SUCCESS);
691 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
692 Assert.assertFalse(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
696 public void test0010_vlantag_with_resourcemodel() throws Exception {
699 log.info("============== reserve " + t + " ================================");
703 TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
704 TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
705 ALLOCATION_ITEM_COLUMNS);
707 ResourceEntity sd = new ResourceEntity();
708 sd.resourceEntityId = "gblond2003me6";
709 sd.resourceEntityType = "VNF";
710 sd.resourceEntityVersion = "1";
712 ResourceTarget rt = new ResourceTarget();
713 rt.resourceTargetId = "MDTWNJ21A5";
714 rt.resourceTargetType = "Site";
716 ResourceRequest rr = new ResourceRequest();
717 rr.serviceModel = "MY-SERV-MODEL_3456";
718 rr.resourceName = "vlan-id-outer";
719 rr.endPointPosition = "VPE-Core1";
720 rr.rangeMaxOverride = 3901;
721 rr.rangeMinOverride = 3900;
722 rr.resourceType = ResourceType.Range;
724 List<ResourceResponse> rsList = new ArrayList<>();
725 resourceAllocator.reserve(sd, rt, rr, rsList);
728 allocationItem.print();
730 Range range = new Range();
734 sd = new ResourceEntity();
735 sd.resourceEntityId = "gblond2003me6";
736 sd.resourceEntityType = "VNF";
737 sd.resourceEntityVersion = "1";
739 rt = new ResourceTarget();
740 rt.resourceTargetId = "MDTWNJ21A5";
741 rt.resourceTargetType = "Site";
743 rr = new ResourceRequest();
744 rr.serviceModel = "MY-SERV-MODEL_3456";
745 rr.resourceName = "vlan-id-outer";
746 rr.endPointPosition = "VPE-Core2";
747 rr.rangeMaxOverride = -1;
748 rr.rangeMinOverride = -1;
749 rr.rangeOverrideList = Arrays.asList(range);
750 rr.resourceType = ResourceType.Range;
752 rsList = new ArrayList<>();
753 resourceAllocator.reserve(sd, rt, rr, rsList);
756 allocationItem.print();
758 sd = new ResourceEntity();
759 sd.resourceEntityId = "gblond2003me6";
760 sd.resourceEntityType = "VNF";
761 sd.resourceEntityVersion = "1";
763 rt = new ResourceTarget();
764 rt.resourceTargetId = "MDTWNJ21A5";
765 rt.resourceTargetType = "Site";
767 Range range1 = new Range();
771 Range range2 = new Range();
775 rr = new ResourceRequest();
776 rr.serviceModel = "MY-SERV-MODEL_3456";
777 rr.resourceName = "vlan-id-outer";
778 rr.endPointPosition = "VPE-Core3";
779 rr.rangeMaxOverride = -1;
780 rr.rangeMinOverride = -1;
781 rr.rangeOverrideList = new ArrayList<>();
782 rr.rangeOverrideList.add(range1);
783 rr.rangeOverrideList.add(range2);
784 rr.resourceType = ResourceType.Range;
786 rsList = new ArrayList<>();
787 AllocationStatus status = resourceAllocator.reserve(sd, rt, rr, rsList);
788 Assert.assertTrue(status == AllocationStatus.Success);
791 allocationItem.print();
793 sd = new ResourceEntity();
794 sd.resourceEntityId = "gblond2003me6";
795 sd.resourceEntityType = "VNF";
796 sd.resourceEntityVersion = "1";
798 rr = new ResourceRequest();
799 rr.endPointPosition = "VPE-Core2";
800 status = resourceAllocator.release(sd, rr);
801 Assert.assertTrue(status == AllocationStatus.Success);
804 allocationItem.print();
809 public void test011() throws Exception {
811 log.info("============== reserve " + t + " ================================");
812 log.info("=== Test range-next-in-sequence = true");
814 String entityId = "reserve" + t;
815 String targetId = "port-id-1";
816 String resourceName = "vlan-id-filter";
818 String assetId = "Site::" + targetId;
819 String resourceUnion = "SI::" + entityId;
820 String resourceSet = resourceUnion + "::1";
823 dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, "1002,1004,1006,1008");
825 SvcLogicContext ctx = new SvcLogicContext();
826 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL");
827 ctx.setAttribute("ra-input.endpoint-position", "VPE-Core2");
828 ctx.setAttribute("ra-input.check-only", "false");
830 ctx.setAttribute("ra-input.resource-name", resourceName);
831 ctx.setAttribute("ra-input.range-next-in-sequence", "true");
833 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
834 ctx.setAttribute("ra-input.reservation-entity-id", entityId + "_test");
835 ctx.setAttribute("ra-input.reservation-entity-version", "1");
837 ctx.setAttribute("ra-input.reservation-target-id", targetId);
838 ctx.setAttribute("ra-input.reservation-target-type", "Site");
840 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
842 Assert.assertTrue(st == QueryStatus.SUCCESS);
843 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "1009"));
847 public void test012() throws Exception {
849 log.info("============== reserve " + t + " ================================");
850 log.info("=== Test range-next-in-sequence = false");
852 String entityId = "reserve" + t;
853 String targetId = "port-id-1";
854 String resourceName = "vlan-id-filter";
856 String assetId = "Site::" + targetId;
857 String resourceUnion = "SI::" + entityId;
858 String resourceSet = resourceUnion + "::1";
861 dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, "1002,1004,1006,1008");
863 SvcLogicContext ctx = new SvcLogicContext();
864 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL");
865 ctx.setAttribute("ra-input.endpoint-position", "VPE-Core2");
866 ctx.setAttribute("ra-input.check-only", "false");
868 ctx.setAttribute("ra-input.resource-name", resourceName);
869 ctx.setAttribute("ra-input.range-next-in-sequence", "false");
871 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
872 ctx.setAttribute("ra-input.reservation-entity-id", entityId + "_test");
873 ctx.setAttribute("ra-input.reservation-entity-version", "1");
875 ctx.setAttribute("ra-input.reservation-target-id", targetId);
876 ctx.setAttribute("ra-input.reservation-target-type", "Site");
878 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
880 Assert.assertTrue(st == QueryStatus.SUCCESS);
881 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "1003"));
885 public void test013() throws Exception {
887 log.info("============== reserve " + t + " ================================");
888 log.info("=== Test range-next-in-sequence = true - multiple ranges");
890 String entityId = "reserve" + t;
891 String targetId = "port-id-1";
892 String resourceName = "vlan-id-filter";
894 String assetId = "Site::" + targetId;
895 String resourceUnion = "SI::" + entityId;
896 String resourceSet = resourceUnion + "::1";
899 dataSetup.setupRangeItem(resourceName, assetId, resourceSet, resourceUnion, "1002,1004,1006,1008,2205-2221");
901 SvcLogicContext ctx = new SvcLogicContext();
902 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL");
903 ctx.setAttribute("ra-input.endpoint-position", "VPE-Core2");
904 ctx.setAttribute("ra-input.check-only", "false");
906 ctx.setAttribute("ra-input.resource-name", resourceName);
907 ctx.setAttribute("ra-input.range-next-in-sequence", "true");
909 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
910 ctx.setAttribute("ra-input.reservation-entity-id", entityId + "_test");
911 ctx.setAttribute("ra-input.reservation-entity-version", "1");
913 ctx.setAttribute("ra-input.reservation-target-id", targetId);
914 ctx.setAttribute("ra-input.reservation-target-type", "Site");
916 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
918 Assert.assertTrue(st == QueryStatus.SUCCESS);
919 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "2222"));
923 public void test014() throws Exception {
925 log.info("============== reserve " + t + " ================================");
926 log.info("=== Test range-next-in-sequence = true - no previously reserved numbers");
928 String entityId = "reserve" + t;
929 String targetId = "port-id-1";
930 String resourceName = "vlan-id-filter";
932 String assetId = "Site::" + targetId;
936 SvcLogicContext ctx = new SvcLogicContext();
937 ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL");
938 ctx.setAttribute("ra-input.endpoint-position", "VPE-Core2");
939 ctx.setAttribute("ra-input.check-only", "false");
941 ctx.setAttribute("ra-input.resource-name", resourceName);
942 ctx.setAttribute("ra-input.range-next-in-sequence", "true");
944 ctx.setAttribute("ra-input.reservation-entity-type", "SI");
945 ctx.setAttribute("ra-input.reservation-entity-id", entityId + "_test");
946 ctx.setAttribute("ra-input.reservation-entity-version", "1");
948 ctx.setAttribute("ra-input.reservation-target-id", targetId);
949 ctx.setAttribute("ra-input.reservation-target-type", "Site");
951 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
953 Assert.assertTrue(st == QueryStatus.SUCCESS);
954 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "1002"));