1 package jtest.org.onap.ccsdk.sli.adaptors.ra;
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.HashMap;
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;
32 @RunWith(SpringJUnit4ClassRunner.class)
33 @ContextConfiguration(locations = { "classpath:test-context.xml" })
34 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
35 public class TestReserve {
37 private static final Logger log = LoggerFactory.getLogger(TestReserve.class);
39 private JdbcTemplate jdbcTemplate;
41 private static final String[] RESOURCE_COLUMNS = { "asset_id", "resource_name", "resource_type", "lt_used" };
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" };
47 public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
48 this.jdbcTemplate = jdbcTemplate;
51 @Autowired(required = true)
52 private ResourceAllocator resourceAllocator;
55 * @Autowired(required = true) private ResourceAllocatorApi
56 * resourceAllocatorApi;
59 @Autowired(required = true)
60 private DataSetup dataSetup;
63 public void test001() throws Exception {
65 log.info("============== reserve " + t + " ================================");
66 log.info("=== Test successful response - new start - all resources available");
68 // String service1 = "reserve" + t + "/service1";
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);
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");
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");
89 ctx.setAttribute("ra-input.reservation-target-data.max-vpe-bandwidth-mbps", "5000");
91 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
93 Assert.assertTrue(st == QueryStatus.SUCCESS);
96 allocationItem.print();
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");
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");
110 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
112 Assert.assertTrue(st == QueryStatus.SUCCESS);
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");
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");
126 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
128 Assert.assertTrue(st == QueryStatus.SUCCESS);
131 allocationItem.print();
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");
139 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
140 Assert.assertTrue(st == QueryStatus.SUCCESS);
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");
149 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
150 Assert.assertTrue(st == QueryStatus.SUCCESS);
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";
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;
165 List<ResourceResponse> rsList = new ArrayList<>();
166 resourceAllocator.query(sd, null, null, rsList);
168 rsList.forEach(r -> {
169 StrUtil.info(log, r);
172 log.info("======================== release Using ResourceEntity==============================");
173 rsList = new ArrayList<>();
174 AllocationStatus status = resourceAllocator.release(sd);
175 Assert.assertTrue(status == AllocationStatus.Success);
177 log.info("======================== Query Using ResourceEntity==============================");
178 rsList = new ArrayList<>();
179 resourceAllocator.query(sd, null, null, rsList);
181 rsList.forEach(r -> {
182 StrUtil.info(log, r);
188 public void test002() throws Exception {
190 log.info("============== reserve " + t + " ================================");
191 log.info("=== Test successful response - new start - all resources available");
193 Map<String, String> data = new HashMap<>();
194 data.put("service-speed", "100");
195 data.put("service-speed-unit", "Mbps");
197 ResourceEntity sd = new ResourceEntity();
198 sd.resourceEntityId = "ICOREPVCID-123456";
199 sd.resourceEntityType = "SI";
202 data = new HashMap<>();
203 data.put("vnf-type", "VPE");
204 data.put("vpe-name", "mdt300vpe54");
205 data.put("max-vpe-bandwidth-mbps", "5000");
207 ResourceTarget rt = new ResourceTarget();
208 rt.resourceTargetId = "mdt300vpe54";
209 rt.resourceTargetType = "VNF";
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;
219 List<ResourceResponse> rsList = new ArrayList<>();
221 resourceAllocator.reserve(sd, rt, rr, rsList);
223 rsList.forEach(r -> {
224 StrUtil.info(log, r);
227 log.info("======================== Query + t ==============================");
228 rsList = new ArrayList<>();
229 resourceAllocator.query(sd, null, rr, rsList);
231 rsList.forEach(r -> {
232 StrUtil.info(log, r);
238 public void test003() throws Exception {
240 log.info("============== reserve " + t + " ================================");
241 log.info("=== Test successful response - new start - all resources available");
243 ResourceEntity sd = new ResourceEntity();
244 sd.resourceEntityId = "gblond2003me6";
245 sd.resourceEntityType = "VNF";
247 ResourceTarget rt = new ResourceTarget();
248 rt.resourceTargetId = "MDTWNJ21A5";
249 rt.resourceTargetType = "Site";
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;
258 List<ResourceResponse> rsList = new ArrayList<>();
259 resourceAllocator.reserve(sd, rt, rr, rsList);
261 rsList.forEach(r -> {
262 StrUtil.info(log, r);
265 log.info("======================== Query + t ==============================");
266 rsList = new ArrayList<>();
267 resourceAllocator.query(sd, null, rr, rsList);
269 rsList.forEach(r -> {
270 StrUtil.info(log, r);
276 public void test004() throws Exception {
278 log.info("============== reserve " + t + " ================================");
279 log.info("=== Test successful response - new start - all resources available");
281 ResourceEntity sd = new ResourceEntity();
282 sd.resourceEntityId = "gblond2003me6";
283 sd.resourceEntityType = "VNF";
285 ResourceTarget rt = new ResourceTarget();
286 rt.resourceTargetId = "MDTWNJ21A5";
287 rt.resourceTargetType = "Site";
289 List<ResourceRequest> rrs = new ArrayList<>();
290 ResourceRequest rr = new ResourceRequest();
291 rr.serviceModel = "MY-SERV-MODEL";
292 rr.resourceName = "VPE-Cust";
295 rr = new ResourceRequest();
296 rr.serviceModel = "MY-SERV-MODEL";
297 rr.resourceName = "VPE-Core1";
300 rr = new ResourceRequest();
301 rr.serviceModel = "MY-SERV-MODEL";
302 rr.resourceName = "VPE-Core2";
305 List<ResourceResponse> rsList = new ArrayList<>();
306 // resourceAllocator.reserve(sd, rt, rrs, rsList);
308 rsList.forEach(r -> {
309 StrUtil.info(log, r);
312 log.info("======================== Query + t ==============================");
313 rsList = new ArrayList<>();
314 resourceAllocator.query(sd, null, rr, rsList);
316 rsList.forEach(r -> {
317 StrUtil.info(log, r);
323 public void test005() throws Exception {
325 log.info("============== reserve " + t + " ================================");
326 log.info("=== Test successful response - new start - all resources available");
328 // String service1 = "reserve" + t + "/service1";
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);
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");
342 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
343 ctx.setAttribute("ra-input.reservation-target-type", "Site");
345 ctx.setAttribute("ra-input.resource-name", "cust-vlan-id");
347 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
349 Assert.assertTrue(st == QueryStatus.SUCCESS);
352 allocationItem.print();
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");
360 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
361 ctx.setAttribute("ra-input.reservation-target-type", "Site");
363 ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
365 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
367 Assert.assertTrue(st == QueryStatus.SUCCESS);
370 allocationItem.print();
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");
378 ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
379 ctx.setAttribute("ra-input.reservation-target-type", "Site");
381 ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
382 ctx.setAttribute("ra-input.replace", "false");
384 st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
386 Assert.assertTrue(st == QueryStatus.SUCCESS);
389 allocationItem.print();
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");
397 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
398 Assert.assertTrue(st == QueryStatus.SUCCESS);
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");
407 st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
408 Assert.assertTrue(st == QueryStatus.SUCCESS);
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";
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;
423 List<ResourceResponse> rsList = new ArrayList<>();
424 resourceAllocator.query(sd, null, null, rsList);
426 rsList.forEach(r -> {
427 StrUtil.info(log, r);
432 * info("======================== release Using ResourceEntity=============================="
433 * ); rsList = new ArrayList<ResourceResponse>(); AllocationStatus status =
434 * resourceAllocator.release(sd); Assert.assertTrue(status ==
435 * AllocationStatus.Success);
439 * info("======================== Query Using ResourceEntity=============================="
440 * ); rsList = new ArrayList<ResourceResponse>(); resourceAllocator.query(sd,
441 * null, null, rsList);
444 * rsList.forEach(r -> { StrUtil.info(log, r); });
450 public void test006() throws Exception {
452 log.info("============== reserve " + t + " ================================");
453 log.info("=== Test successful response - new start - all resources available");
455 ResourceEntity sd = new ResourceEntity();
456 sd.resourceEntityId = "gblond2003me6";
457 sd.resourceEntityType = "VPE-Cust";
459 ResourceTarget rt = new ResourceTarget();
460 rt.resourceTargetId = "MDTWNJ21A5";
461 rt.resourceTargetType = "Site";
463 ResourceRequest rr = new ResourceRequest();
464 rr.serviceModel = "MY-SERV-MODEL-1";
465 rr.resourceName = "cust-vlan-id";
467 List<ResourceResponse> rsList = new ArrayList<>();
468 resourceAllocator.reserve(sd, rt, rr, rsList);
470 rsList.forEach(r -> {
471 StrUtil.info(log, r);
474 log.info("======================== Query + t ==============================");
475 rsList = new ArrayList<>();
476 resourceAllocator.query(sd, null, rr, rsList);
478 rsList.forEach(r -> {
479 StrUtil.info(log, r);
485 public void test007() throws Exception {
487 log.info("============== reserve " + t + " ================================");
488 log.info("=== Test successful response - new start - all resources available");
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);
496 ResourceEntity sd = new ResourceEntity();
497 sd.resourceEntityId = "gblond2003me6";
498 sd.resourceEntityType = "VPE";
499 sd.resourceEntityVersion = "1";
501 ResourceTarget rt = new ResourceTarget();
502 rt.resourceTargetId = "MDTWNJ21A5";
503 rt.resourceTargetType = "Site";
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;
512 List<ResourceResponse> rsList = new ArrayList<>();
513 resourceAllocator.reserve(sd, rt, rr, rsList);
516 sd = new ResourceEntity();
517 sd.resourceEntityId = "gblond2003me6";
518 sd.resourceEntityType = "VPE";
519 sd.resourceEntityVersion = "1";
521 rt = new ResourceTarget();
522 rt.resourceTargetId = "MDTWNJ21A5";
523 rt.resourceTargetType = "Site";
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;
532 rsList = new ArrayList<>();
533 resourceAllocator.reserve(sd, rt, rr, rsList);
536 sd = new ResourceEntity();
537 sd.resourceEntityId = "gblond2003me6";
538 sd.resourceEntityType = "VPE";
539 sd.resourceEntityVersion = "1";
541 rt = new ResourceTarget();
542 rt.resourceTargetId = "MDTWNJ21A5";
543 rt.resourceTargetType = "Site";
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;
552 rsList = new ArrayList<>();
553 resourceAllocator.reserve(sd, rt, rr, rsList);
556 sd = new ResourceEntity();
557 sd.resourceEntityId = "gblond2003me6";
558 sd.resourceEntityType = "VPE";
559 sd.resourceEntityVersion = "1";
561 rt = new ResourceTarget();
562 rt.resourceTargetId = "MDTWNJ21A5";
563 rt.resourceTargetType = "Site";
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;
572 rsList = new ArrayList<>();
573 resourceAllocator.reserve(sd, rt, rr, rsList);
575 rsList.forEach(r -> {
576 StrUtil.info(log, r);
580 allocationItem.print();
582 log.info("======================== Query + t ==============================");
583 rsList = new ArrayList<>();
584 resourceAllocator.query(sd, null, rr, rsList);
586 rsList.forEach(r -> {
587 StrUtil.info(log, r);
590 SvcLogicContext ctx = new SvcLogicContext();
591 ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
592 ctx.setAttribute("ra-input.reservation-entity-type", "VPE");
594 QueryStatus st = resourceAllocator.release("NetworkCapacity", "gblond2003me6", ctx);
595 Assert.assertTrue(st == QueryStatus.SUCCESS);
600 public void test008() throws Exception {
602 log.info("============== reserve " + t + " ================================");
603 log.info("=== Test range-force-new-numbers = false");
605 String entityId = "reserve" + t;
606 String targetId = "port-id-1";
607 String resourceName = "cust-vlan-id";
609 String assetId = "VNF::" + targetId;
610 String resourceUnion = "SI::" + entityId;
611 String resourceSet1 = resourceUnion + "::1";
612 String resourceSet2 = resourceUnion + "::2";
616 dataSetup.setupRangeItem(resourceName, assetId, resourceSet1, resourceUnion, "201");
618 SvcLogicContext ctx = new SvcLogicContext();
619 ctx.setAttribute("ra-input.service-model", "ADIG");
620 ctx.setAttribute("ra-input.check-only", "false");
622 ctx.setAttribute("ra-input.resource-name", resourceName);
623 ctx.setAttribute("ra-input.range-force-new-numbers", "false");
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");
629 ctx.setAttribute("ra-input.reservation-target-id", targetId);
630 ctx.setAttribute("ra-input.reservation-target-type", "VNF");
632 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
634 Assert.assertTrue(st == QueryStatus.SUCCESS);
635 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
636 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
640 public void test009() throws Exception {
642 log.info("============== reserve " + t + " ================================");
643 log.info("=== Test range-force-new-numbers = true");
645 String entityId = "reserve" + t;
646 String targetId = "port-id-1";
647 String resourceName = "cust-vlan-id";
649 String assetId = "VNF::" + targetId;
650 String resourceUnion = "SI::" + entityId;
651 String resourceSet1 = resourceUnion + "::1";
652 String resourceSet2 = resourceUnion + "::2";
656 dataSetup.setupRangeItem(resourceName, assetId, resourceSet1, resourceUnion, "201");
658 SvcLogicContext ctx = new SvcLogicContext();
659 ctx.setAttribute("ra-input.service-model", "ADIG");
660 ctx.setAttribute("ra-input.check-only", "false");
662 ctx.setAttribute("ra-input.resource-name", resourceName);
663 ctx.setAttribute("ra-input.range-force-new-numbers", "true");
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");
669 ctx.setAttribute("ra-input.reservation-target-id", targetId);
670 ctx.setAttribute("ra-input.reservation-target-type", "VNF");
672 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
674 Assert.assertTrue(st == QueryStatus.SUCCESS);
675 Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
676 Assert.assertFalse(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
680 public void test0010_vlantag_with_resourcemodel() throws Exception {
683 log.info("============== reserve " + t + " ================================");
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);
691 ResourceEntity sd = new ResourceEntity();
692 sd.resourceEntityId = "gblond2003me6";
693 sd.resourceEntityType = "VNF";
694 sd.resourceEntityVersion = "1";
696 ResourceTarget rt = new ResourceTarget();
697 rt.resourceTargetId = "MDTWNJ21A5";
698 rt.resourceTargetType = "Site";
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;
708 List<ResourceResponse> rsList = new ArrayList<>();
709 resourceAllocator.reserve(sd, rt, rr, rsList);
712 allocationItem.print();
714 Range range = new Range();
718 sd = new ResourceEntity();
719 sd.resourceEntityId = "gblond2003me6";
720 sd.resourceEntityType = "VNF";
721 sd.resourceEntityVersion = "1";
723 rt = new ResourceTarget();
724 rt.resourceTargetId = "MDTWNJ21A5";
725 rt.resourceTargetType = "Site";
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;
736 rsList = new ArrayList<>();
737 resourceAllocator.reserve(sd, rt, rr, rsList);
740 allocationItem.print();
742 sd = new ResourceEntity();
743 sd.resourceEntityId = "gblond2003me6";
744 sd.resourceEntityType = "VNF";
745 sd.resourceEntityVersion = "1";
747 rt = new ResourceTarget();
748 rt.resourceTargetId = "MDTWNJ21A5";
749 rt.resourceTargetType = "Site";
751 Range range1 = new Range();
755 Range range2 = new Range();
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;
770 rsList = new ArrayList<>();
771 AllocationStatus status = resourceAllocator.reserve(sd, rt, rr, rsList);
772 Assert.assertTrue(status == AllocationStatus.Success);
775 allocationItem.print();
777 sd = new ResourceEntity();
778 sd.resourceEntityId = "gblond2003me6";
779 sd.resourceEntityType = "VNF";
780 sd.resourceEntityVersion = "1";
782 rr = new ResourceRequest();
783 rr.endPointPosition = "VPE-Core2";
784 status = resourceAllocator.release(sd, rr);
785 Assert.assertTrue(status == AllocationStatus.Success);
788 allocationItem.print();