2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package jtest.org.onap.ccsdk.sli.adaptors.ra;
24 import org.junit.Assert;
25 import org.junit.FixMethodOrder;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.MethodSorters;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
32 import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.test.context.ContextConfiguration;
37 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
39 @RunWith(SpringJUnit4ClassRunner.class)
40 @ContextConfiguration(locations = { "classpath:test-context.xml" })
41 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
42 public class TestReserve {
44 private static final Logger log = LoggerFactory.getLogger(TestReserve.class);
46 @Autowired(required = true)
47 private ResourceAllocator resourceAllocator;
49 @Autowired(required = true)
50 private DataSetup dataSetup;
53 public void test001() throws Exception {
55 log.info("============== reserve " + t + " ================================");
56 log.info("=== Test successful response - new start - all resources available");
58 String service1 = "reserve" + t + "/service1";
61 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
62 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
63 dataSetup.setupPserver("server1", "MTSNJA4LCP1");
65 SvcLogicContext ctx = new SvcLogicContext();
66 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
67 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
68 ctx.setAttribute("tmp.resource-allocator.speed", "300");
69 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
70 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
72 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
74 log.info("Result: " + st);
75 log.info(" tmp.resource-allocator-output.max-available-speed: " +
76 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
77 log.info(" tmp.resource-allocator-output.speed-unit: " +
78 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
80 Assert.assertTrue(st == QueryStatus.SUCCESS);
81 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 300000));
85 public void test002() throws Exception {
87 log.info("============== reserve " + t + " ================================");
88 log.info("=== Test successful response - new start supp - all resources available");
90 String service1 = "reserve" + t + "/service1";
93 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
94 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
95 dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
97 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
99 SvcLogicContext ctx = new SvcLogicContext();
100 // ctx.setAttribute("tmp.resource-allocator.request-type", "New"); - Default is New
101 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
102 ctx.setAttribute("tmp.resource-allocator.speed", "400");
103 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
104 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
106 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
108 log.info("Result: " + st);
109 log.info(" tmp.resource-allocator-output.max-available-speed: " +
110 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
111 log.info(" tmp.resource-allocator-output.speed-unit: " +
112 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
114 Assert.assertTrue(st == QueryStatus.SUCCESS);
115 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
116 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
120 public void test003() throws Exception {
122 log.info("============== reserve " + t + " ================================");
123 log.info("=== Test successful response - change - all resources available");
125 String service1 = "reserve" + t + "/service1";
128 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
129 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
130 dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
132 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
134 SvcLogicContext ctx = new SvcLogicContext();
135 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
136 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
137 ctx.setAttribute("tmp.resource-allocator.speed", "400");
138 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
139 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
141 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
143 log.info("Result: " + st);
144 log.info(" tmp.resource-allocator-output.max-available-speed: " +
145 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
146 log.info(" tmp.resource-allocator-output.speed-unit: " +
147 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
149 Assert.assertTrue(st == QueryStatus.SUCCESS);
150 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
151 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
155 public void test004() throws Exception {
157 log.info("============== reserve " + t + " ================================");
158 log.info("=== Test successful response - change supp - all resources available");
160 String service1 = "reserve" + t + "/service1";
163 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
164 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
165 dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
166 dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
168 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
169 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
171 SvcLogicContext ctx = new SvcLogicContext();
172 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
173 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
174 ctx.setAttribute("tmp.resource-allocator.speed", "500");
175 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
176 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
178 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
180 log.info("Result: " + st);
181 log.info(" tmp.resource-allocator-output.max-available-speed: " +
182 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
183 log.info(" tmp.resource-allocator-output.speed-unit: " +
184 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
186 Assert.assertTrue(st == QueryStatus.SUCCESS);
187 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
188 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 4, 500000));
189 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
193 public void test005() throws Exception {
195 log.info("============== reserve " + t + " ================================");
196 log.info("=== Test successful response - change - check that hard limits are applied, not soft for change");
198 String service1 = "reserve" + t + "/service1";
201 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
202 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
203 dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
205 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
207 SvcLogicContext ctx = new SvcLogicContext();
208 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
209 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
210 ctx.setAttribute("tmp.resource-allocator.speed", "1200000");
211 ctx.setAttribute("tmp.resource-allocator.speed-unit", "kbps");
212 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
214 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
216 log.info("Result: " + st);
217 log.info(" tmp.resource-allocator-output.max-available-speed: " +
218 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
219 log.info(" tmp.resource-allocator-output.speed-unit: " +
220 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
222 Assert.assertTrue(st == QueryStatus.SUCCESS);
223 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
224 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 1200000));
228 public void test006() throws Exception {
230 log.info("============== reserve " + t + " ================================");
231 log.info("=== Test capacity not found - new start");
233 String service1 = "reserve" + t + "/service1";
236 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
237 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
239 SvcLogicContext ctx = new SvcLogicContext();
240 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
241 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
242 ctx.setAttribute("tmp.resource-allocator.speed", "300");
243 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
244 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
246 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
248 log.info("Result: " + st);
250 Assert.assertTrue(st == QueryStatus.NOT_FOUND);
251 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
255 public void test007() throws Exception {
257 log.info("============== reserve " + t + " ================================");
258 log.info("=== Test capacity not found - new start supp");
260 String service1 = "reserve" + t + "/service1";
263 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
264 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
265 dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
267 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
269 SvcLogicContext ctx = new SvcLogicContext();
270 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
271 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
272 ctx.setAttribute("tmp.resource-allocator.speed", "2000");
273 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
274 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
276 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
278 log.info("Result: " + st);
280 Assert.assertTrue(st == QueryStatus.NOT_FOUND);
281 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
282 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
286 public void test008() throws Exception {
288 log.info("============== reserve " + t + " ================================");
289 log.info("=== Test capacity not found - change");
291 String service1 = "reserve" + t + "/service1";
294 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
295 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
296 dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
298 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
300 SvcLogicContext ctx = new SvcLogicContext();
301 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
302 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
303 ctx.setAttribute("tmp.resource-allocator.speed", "2000");
304 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
305 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
307 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
309 log.info("Result: " + st);
311 Assert.assertTrue(st == QueryStatus.NOT_FOUND);
312 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
313 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
317 public void test009() throws Exception {
319 log.info("============== reserve " + t + " ================================");
320 log.info("=== Test capacity not found - change supp");
322 String service1 = "reserve" + t + "/service1";
325 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
326 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
327 dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
328 dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
330 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
331 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
333 SvcLogicContext ctx = new SvcLogicContext();
334 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
335 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
336 ctx.setAttribute("tmp.resource-allocator.speed", "2000");
337 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
338 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
340 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
342 log.info("Result: " + st);
344 Assert.assertTrue(st == QueryStatus.NOT_FOUND);
345 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
346 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
347 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 4));
351 public void test010() throws Exception {
353 log.info("============== reserve " + t + " ================================");
354 log.info("=== Test border condition - connection limit - new start - adding connection " +
355 "when we are on the limit should fail");
357 String service1 = "reserve" + t + "/service1";
360 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
361 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
362 for (int i = 1; i <= 40; i++)
363 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
364 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
365 for (int i = 1; i <= 40; i += 4)
366 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
367 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
369 SvcLogicContext ctx = new SvcLogicContext();
370 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
371 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
372 ctx.setAttribute("tmp.resource-allocator.speed", "1");
373 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
374 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
376 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
378 log.info("Result: " + st);
380 Assert.assertTrue(st == QueryStatus.NOT_FOUND);
381 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
385 public void test011() throws Exception {
387 log.info("============== reserve " + t + " ================================");
389 "=== Test border condition - connection limit - new start supp should succeed as no new connection being added");
391 String service1 = "reserve" + t + "/service1";
394 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
395 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
396 for (int i = 1; i <= 39; i++)
397 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
398 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
399 for (int i = 1; i <= 39; i += 4)
400 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
401 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
403 dataSetup.setupService(service1, "Pending", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
405 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 1000));
407 SvcLogicContext ctx = new SvcLogicContext();
408 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
409 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
410 ctx.setAttribute("tmp.resource-allocator.speed", "5");
411 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
412 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
414 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
416 log.info("Result: " + st);
418 Assert.assertTrue(st == QueryStatus.SUCCESS);
419 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
420 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
424 public void test012() throws Exception {
426 log.info("============== reserve " + t + " ================================");
428 "=== Test border condition - connection limit - change should succeed as no new connection being added");
430 String service1 = "reserve" + t + "/service1";
433 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
434 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
435 for (int i = 1; i <= 39; i++)
436 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
437 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
438 for (int i = 1; i <= 39; i += 4)
439 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
440 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
442 dataSetup.setupService(service1, "Active", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
444 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
446 SvcLogicContext ctx = new SvcLogicContext();
447 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
448 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
449 ctx.setAttribute("tmp.resource-allocator.speed", "5");
450 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
451 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
453 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
455 log.info("Result: " + st);
457 Assert.assertTrue(st == QueryStatus.SUCCESS);
458 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
459 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
463 public void test013() throws Exception {
465 log.info("============== reserve " + t + " ================================");
467 "=== Test border condition - connection limit - change supp should succeed as no new connection being added");
469 String service1 = "reserve" + t + "/service1";
472 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
473 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
474 for (int i = 1; i <= 39; i++)
475 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
476 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
477 for (int i = 1; i <= 39; i += 4)
478 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
479 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
481 dataSetup.setupService(service1, "Active", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
482 dataSetup.setupService(service1, "Pending", 3, 5000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
484 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
485 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
487 SvcLogicContext ctx = new SvcLogicContext();
488 ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
489 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
490 ctx.setAttribute("tmp.resource-allocator.speed", "10");
491 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
492 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
494 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
496 log.info("Result: " + st);
498 Assert.assertTrue(st == QueryStatus.SUCCESS);
499 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
500 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 4, 10000));
501 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
505 public void test014() throws Exception {
507 log.info("============== reserve " + t + " ================================");
508 log.info("=== Test input validations - invalid request-type in input");
510 String service1 = "reserve" + t + "/service1";
512 SvcLogicContext ctx = new SvcLogicContext();
513 ctx.setAttribute("tmp.resource-allocator.request-type", "xxxxx");
514 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
515 ctx.setAttribute("tmp.resource-allocator.speed", "10");
516 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
517 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
520 resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
521 } catch (SvcLogicException e) {
522 Assert.assertTrue(e.getMessage().equals(
523 "Invalid tmp.resource-allocator.request-type: xxxxx. Supported values are New, Change."));
526 Assert.fail("SvcLogicException expected");
530 public void test015() throws Exception {
532 log.info("============== reserve " + t + " ================================");
533 log.info("=== Test server bw limit depends on number of servers - limit is 960Mbps for 1 server, 1920 for 2");
535 String service1 = "reserve" + t + "/service1";
538 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
539 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
540 dataSetup.setupPserver("server1", "MTSNJA4LCP1");
541 dataSetup.setupPserver("server2", "MTSNJA4LCP1");
542 dataSetup.setupPserver("server3", "MTSNJA4LCP1");
543 dataSetup.setupPserver("server4", "MTSNJA4LCP1");
545 SvcLogicContext ctx = new SvcLogicContext();
546 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
547 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
548 ctx.setAttribute("tmp.resource-allocator.speed", "1200");
549 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
550 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
552 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
554 log.info("Result: " + st);
555 log.info(" tmp.resource-allocator-output.max-available-speed: " +
556 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
557 log.info(" tmp.resource-allocator-output.speed-unit: " +
558 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
560 Assert.assertTrue(st == QueryStatus.SUCCESS);
561 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1200000));
565 public void test016() throws Exception {
567 log.info("============== reserve " + t + " ================================");
568 log.info("=== Test resource threshold output");
570 String service1 = "reserve" + t + "/service1";
573 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
574 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
575 dataSetup.setupPserver("server1", "MTSNJA4LCP1");
576 dataSetup.setupPserver("server2", "MTSNJA4LCP1");
577 dataSetup.setupPserver("server3", "MTSNJA4LCP1");
578 dataSetup.setupPserver("server4", "MTSNJA4LCP1");
580 SvcLogicContext ctx = new SvcLogicContext();
581 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
582 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
583 ctx.setAttribute("tmp.resource-allocator.speed", "1605");
584 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
585 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
587 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
589 log.info("Result: " + st);
590 for (String key : ctx.getAttributeKeySet())
591 if (key.startsWith("tmp.resource-allocator-output"))
592 log.info(" " + key + ": " + ctx.getAttribute(key));
594 Assert.assertTrue(st == QueryStatus.SUCCESS);
595 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1605000));
599 public void test017() throws Exception {
601 log.info("============== reserve " + t + " ================================");
602 log.info("=== Test if evc_count lookup in MAX_SERVER_SPEED depends on the number of primary servers.");
603 log.info("=== For 10 existing EVC, it should take the first row, not the second (see data.sql).");
604 log.info("=== Applied limit should be 1920Mbps, not 1680Mbps.");
606 String service1 = "reserve" + t + "/service1";
609 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
610 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
611 dataSetup.setupPserver("server1", "MTSNJA4LCP1");
612 dataSetup.setupPserver("server2", "MTSNJA4LCP1");
613 dataSetup.setupPserver("server3", "MTSNJA4LCP1");
614 dataSetup.setupPserver("server4", "MTSNJA4LCP1");
616 for (int i = 1; i <= 10; i++)
617 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 100000, "mtanjrsv126",
618 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
620 SvcLogicContext ctx = new SvcLogicContext();
621 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
622 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
623 ctx.setAttribute("tmp.resource-allocator.speed", "800"); // 10*100Mbps existing + 800 = 1800
624 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
625 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
627 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
629 log.info("Result: " + st);
630 log.info(" tmp.resource-allocator-output.max-available-speed: " +
631 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
632 log.info(" tmp.resource-allocator-output.speed-unit: " +
633 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
635 Assert.assertTrue(st == QueryStatus.SUCCESS);
636 Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 800000));
640 public void test018() throws Exception {
642 log.info("============== reserve " + t + " ================================");
643 log.info("=== Test if evc_count lookup in MAX_SERVER_SPEED depends on the number of primary servers.");
644 log.info("=== For 11 existing EVC, it should take the second row (see data.sql).");
645 log.info("=== Applied limit should be 1680Mbps. We have 11*100 + 700, so this should fail.");
647 String service1 = "reserve" + t + "/service1";
650 dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
651 dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
652 dataSetup.setupPserver("server1", "MTSNJA4LCP1");
653 dataSetup.setupPserver("server2", "MTSNJA4LCP1");
654 dataSetup.setupPserver("server3", "MTSNJA4LCP1");
655 dataSetup.setupPserver("server4", "MTSNJA4LCP1");
657 for (int i = 1; i <= 11; i++)
658 dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 100000, "mtanjrsv126",
659 "mtsnj303vr1", "MTSNJA4LCP1/Server1");
661 SvcLogicContext ctx = new SvcLogicContext();
662 ctx.setAttribute("tmp.resource-allocator.request-type", "New");
663 ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
664 ctx.setAttribute("tmp.resource-allocator.speed", "700"); // 11*100Mbps existing + 700 = 1800
665 ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
666 ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
668 QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
670 log.info("Result: " + st);
671 log.info(" tmp.resource-allocator-output.max-available-speed: " +
672 ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
673 log.info(" tmp.resource-allocator-output.speed-unit: " +
674 ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
676 log.info("Result: " + st);
678 Assert.assertTrue(st == QueryStatus.NOT_FOUND);
679 Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));