blob: be7834c21aae382393d4995dc479975786172903 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.flowprogrammer;
Naoki Shiota75b7dd62013-12-03 18:09:21 -08002
Jonathan Harta88fd242014-04-03 11:24:54 -07003import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNotNull;
5import static org.junit.Assert.assertTrue;
6import static org.junit.Assert.fail;
Naoki Shiota75b7dd62013-12-03 18:09:21 -08007
8import java.io.IOException;
9import java.util.ArrayList;
10import java.util.HashMap;
11import java.util.List;
12import java.util.Map;
13import java.util.concurrent.ScheduledExecutorService;
14import java.util.concurrent.TimeUnit;
15
16import net.floodlightcontroller.core.FloodlightContext;
17import net.floodlightcontroller.core.IFloodlightProviderService;
18import net.floodlightcontroller.core.IOFSwitch;
19import net.floodlightcontroller.core.module.FloodlightModuleContext;
20import net.floodlightcontroller.threadpool.IThreadPoolService;
21import net.floodlightcontroller.util.OFMessageDamper;
Jonathan Hart23701d12014-04-03 10:45:48 -070022import net.onrc.onos.core.util.Dpid;
23import net.onrc.onos.core.util.FlowEntry;
24import net.onrc.onos.core.util.FlowEntryActions;
25import net.onrc.onos.core.util.FlowEntryErrorState;
26import net.onrc.onos.core.util.FlowEntryId;
27import net.onrc.onos.core.util.FlowEntryMatch;
28import net.onrc.onos.core.util.FlowEntryUserState;
29import net.onrc.onos.core.util.FlowId;
30import net.onrc.onos.core.util.Port;
Naoki Shiota75b7dd62013-12-03 18:09:21 -080031
32import org.easymock.EasyMock;
33import org.easymock.IAnswer;
Naoki Shiota75b7dd62013-12-03 18:09:21 -080034import org.junit.Test;
35import org.openflow.protocol.OFBarrierRequest;
36import org.openflow.protocol.OFFlowMod;
37import org.openflow.protocol.OFMatch;
38import org.openflow.protocol.OFMessage;
39import org.openflow.protocol.OFType;
40import org.openflow.protocol.action.OFAction;
41import org.openflow.protocol.factory.BasicFactory;
42
43public class FlowPusherTest {
44 private FlowPusher pusher;
45 private FloodlightContext context;
46 private FloodlightModuleContext modContext;
47 private BasicFactory factory;
48 private OFMessageDamper damper;
Naoki Shiota71fff002013-12-04 15:20:09 -080049 private IFloodlightProviderService flProviderService;
50 private IThreadPoolService threadPoolService;
Naoki Shiota75b7dd62013-12-03 18:09:21 -080051
52 /**
53 * Test single OFMessage is correctly sent to single switch via MessageDamper.
54 */
55 @Test
56 public void testAddMessage() {
57 beginInitMock();
58
59 OFMessage msg = EasyMock.createMock(OFMessage.class);
60 EasyMock.expect(msg.getXid()).andReturn(1).anyTimes();
61 EasyMock.expect(msg.getLength()).andReturn((short)100).anyTimes();
62 EasyMock.replay(msg);
63
64 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
65 EasyMock.expect(sw.getId()).andReturn((long)1).anyTimes();
66 sw.flush();
67 EasyMock.expectLastCall().once();
68 EasyMock.replay(sw);
69
70 try {
Naoki Shiota71fff002013-12-04 15:20:09 -080071 EasyMock.expect(damper.write(EasyMock.eq(sw), EasyMock.eq(msg), EasyMock.eq(context)))
72 .andReturn(true).once();
Naoki Shiota75b7dd62013-12-03 18:09:21 -080073 } catch (IOException e1) {
74 fail("Failed in OFMessageDamper#write()");
75 }
76
77 endInitMock();
78 initPusher(1);
79
80 boolean add_result = pusher.add(sw, msg);
81 assertTrue(add_result);
82
83 try {
84 // wait until message is processed.
85 Thread.sleep(1000);
86 } catch (InterruptedException e) {
87 fail("Failed in Thread.sleep()");
88 }
Naoki Shiota75b7dd62013-12-03 18:09:21 -080089 EasyMock.verify(msg);
90 EasyMock.verify(sw);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -070091 verifyAll();
Naoki Shiota75b7dd62013-12-03 18:09:21 -080092
93 pusher.stop();
94 }
95
96 /**
97 * Test bunch of OFMessages are correctly sent to single switch via MessageDamper.
98 */
99 @Test
100 public void testMassiveAddMessage() {
101 final int NUM_MSG = 10000;
102
103 beginInitMock();
104
105 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
106 EasyMock.expect(sw.getId()).andReturn((long)1).anyTimes();
107 sw.flush();
108 EasyMock.expectLastCall().atLeastOnce();
109 EasyMock.replay(sw);
110
111 List<OFMessage> messages = new ArrayList<OFMessage>();
112
113 for (int i = 0; i < NUM_MSG; ++i) {
114 OFMessage msg = EasyMock.createMock(OFMessage.class);
115 EasyMock.expect(msg.getXid()).andReturn(i).anyTimes();
116 EasyMock.expect(msg.getLength()).andReturn((short)100).anyTimes();
117 EasyMock.replay(msg);
118 messages.add(msg);
119
120 try {
121 EasyMock.expect(damper.write(EasyMock.eq(sw), EasyMock.eq(msg), EasyMock.eq(context)))
122 .andReturn(true).once();
123 } catch (IOException e1) {
124 fail("Failed in OFMessageDamper#write()");
125 }
126 }
127
128 endInitMock();
129 initPusher(1);
130
131 for (OFMessage msg : messages) {
132 boolean add_result = pusher.add(sw, msg);
133 assertTrue(add_result);
134 }
135
136 try {
137 // wait until message is processed.
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700138 Thread.sleep(5000);
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800139 } catch (InterruptedException e) {
140 fail("Failed in Thread.sleep()");
141 }
142
143 for (OFMessage msg : messages) {
144 EasyMock.verify(msg);
145 }
146 EasyMock.verify(sw);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700147 verifyAll();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800148
149 pusher.stop();
150 }
151
152 /**
153 * Test bunch of OFMessages are correctly sent to multiple switches with single threads.
154 */
155 @Test
156 public void testMultiSwitchAddMessage() {
157 final int NUM_SWITCH = 10;
158 final int NUM_MSG = 100; // messages per thread
159
160 beginInitMock();
161
162 Map<IOFSwitch, List<OFMessage>> sw_map = new HashMap<IOFSwitch, List<OFMessage>>();
163 for (int i = 0; i < NUM_SWITCH; ++i) {
164 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
165 EasyMock.expect(sw.getId()).andReturn((long)i).anyTimes();
166 sw.flush();
167 EasyMock.expectLastCall().atLeastOnce();
168 EasyMock.replay(sw);
169
170 List<OFMessage> messages = new ArrayList<OFMessage>();
171
172 for (int j = 0; j < NUM_MSG; ++j) {
173 OFMessage msg = EasyMock.createMock(OFMessage.class);
174 EasyMock.expect(msg.getXid()).andReturn(j).anyTimes();
175 EasyMock.expect(msg.getLength()).andReturn((short)100).anyTimes();
176 EasyMock.replay(msg);
177 messages.add(msg);
178
179 try {
180 EasyMock.expect(damper.write(EasyMock.eq(sw), EasyMock.eq(msg), EasyMock.eq(context)))
181 .andReturn(true).once();
182 } catch (IOException e1) {
183 fail("Failed in OFMessageDamper#write()");
184 }
185 }
186 sw_map.put(sw, messages);
187 }
188
189 endInitMock();
190 initPusher(1);
191
192 for (IOFSwitch sw : sw_map.keySet()) {
193 for (OFMessage msg : sw_map.get(sw)) {
194 boolean add_result = pusher.add(sw, msg);
195 assertTrue(add_result);
196 }
197 }
198
199 try {
200 // wait until message is processed.
201 Thread.sleep(1000);
202 } catch (InterruptedException e) {
203 fail("Failed in Thread.sleep()");
204 }
205
206 for (IOFSwitch sw : sw_map.keySet()) {
207 for (OFMessage msg : sw_map.get(sw)) {
208 EasyMock.verify(msg);
209 }
210
211 EasyMock.verify(sw);
212 }
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700213 verifyAll();
214
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800215 pusher.stop();
216 }
217
218 /**
219 * Test bunch of OFMessages are correctly sent to multiple switches using multiple threads.
220 */
221 @Test
222 public void testMultiThreadedAddMessage() {
223 final int NUM_THREAD = 10;
224 final int NUM_MSG = 100; // messages per thread
225
226 beginInitMock();
227
228 Map<IOFSwitch, List<OFMessage>> sw_map = new HashMap<IOFSwitch, List<OFMessage>>();
229 for (int i = 0; i < NUM_THREAD; ++i) {
230 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
231 EasyMock.expect(sw.getId()).andReturn((long)i).anyTimes();
232 sw.flush();
233 EasyMock.expectLastCall().atLeastOnce();
234 EasyMock.replay(sw);
235
236 List<OFMessage> messages = new ArrayList<OFMessage>();
237
238 for (int j = 0; j < NUM_MSG; ++j) {
239 OFMessage msg = EasyMock.createMock(OFMessage.class);
240 EasyMock.expect(msg.getXid()).andReturn(j).anyTimes();
241 EasyMock.expect(msg.getLength()).andReturn((short)100).anyTimes();
242 EasyMock.replay(msg);
243 messages.add(msg);
244
245 try {
246 EasyMock.expect(damper.write(EasyMock.eq(sw), EasyMock.eq(msg), EasyMock.eq(context)))
247 .andReturn(true).once();
248 } catch (IOException e1) {
249 fail("Failed in OFMessageDamper#write()");
250 }
251 }
252 sw_map.put(sw, messages);
253 }
254
255 endInitMock();
256 initPusher(NUM_THREAD);
257
258 for (IOFSwitch sw : sw_map.keySet()) {
259 for (OFMessage msg : sw_map.get(sw)) {
260 boolean add_result = pusher.add(sw, msg);
261 assertTrue(add_result);
262 }
263 }
264
265 try {
266 // wait until message is processed.
267 Thread.sleep(1000);
268 } catch (InterruptedException e) {
269 fail("Failed in Thread.sleep()");
270 }
271
272 for (IOFSwitch sw : sw_map.keySet()) {
273 for (OFMessage msg : sw_map.get(sw)) {
274 EasyMock.verify(msg);
275 }
276
277 EasyMock.verify(sw);
278 }
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700279 verifyAll();
280
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800281 pusher.stop();
282 }
283
284 private long barrierTime = 0;
285 /**
286 * Test rate limitation of messages works correctly.
287 */
288 @Test
289 public void testRateLimitedAddMessage() {
290 final long LIMIT_RATE = 100; // [bytes/ms]
291 final int NUM_MSG = 1000;
292
293 // Accuracy of FlowPusher's rate calculation can't be measured by unit test
294 // because switch doesn't return BARRIER_REPLY.
295 // In unit test we use approximate way to measure rate. This value is
296 // acceptable margin of measured rate.
297 final double ACCEPTABLE_RATE = LIMIT_RATE * 1.2;
298
299 beginInitMock();
300
301 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
302 EasyMock.expect(sw.getId()).andReturn((long)1).anyTimes();
303 sw.flush();
304 EasyMock.expectLastCall().atLeastOnce();
305 prepareBarrier(sw);
306 EasyMock.replay(sw);
307
308 List<OFMessage> messages = new ArrayList<OFMessage>();
309
310 for (int i = 0; i < NUM_MSG; ++i) {
311 OFMessage msg = EasyMock.createMock(OFMessage.class);
312 EasyMock.expect(msg.getXid()).andReturn(1).anyTimes();
313 EasyMock.expect(msg.getLength()).andReturn((short)100).anyTimes();
314 EasyMock.expect(msg.getLengthU()).andReturn(100).anyTimes();
315 EasyMock.replay(msg);
316 messages.add(msg);
317
318 try {
319 EasyMock.expect(damper.write(EasyMock.eq(sw), EasyMock.eq(msg), EasyMock.eq(context)))
320 .andReturn(true).once();
321 } catch (IOException e) {
322 fail("Failed in OFMessageDamper#write()");
323 }
324 }
325
326 try {
327 EasyMock.expect(damper.write(EasyMock.eq(sw), (OFMessage)EasyMock.anyObject(), EasyMock.eq(context)))
328 .andAnswer(new IAnswer<Boolean>() {
329 @Override
330 public Boolean answer() throws Throwable {
331 OFMessage msg = (OFMessage)EasyMock.getCurrentArguments()[1];
332 if (msg.getType() == OFType.BARRIER_REQUEST) {
333 barrierTime = System.currentTimeMillis();
334 }
335 return true;
336 }
337 }).once();
338 } catch (IOException e1) {
339 fail("Failed in OFMessageDamper#write()");
340 }
341
342 endInitMock();
343 initPusher(1);
344
345 pusher.createQueue(sw);
346 pusher.setRate(sw, LIMIT_RATE);
347
348 long beginTime = System.currentTimeMillis();
349 for (OFMessage msg : messages) {
350 boolean add_result = pusher.add(sw, msg);
351 assertTrue(add_result);
352 }
353
354 pusher.barrierAsync(sw);
355
356 try {
357 do {
358 Thread.sleep(1000);
359 } while (barrierTime == 0);
360 } catch (InterruptedException e) {
361 fail("Failed to sleep");
362 }
363
364 double measured_rate = NUM_MSG * 100 / (barrierTime - beginTime);
365 assertTrue(measured_rate < ACCEPTABLE_RATE);
366
367 for (OFMessage msg : messages) {
368 EasyMock.verify(msg);
369 }
370 EasyMock.verify(sw);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700371 verifyAll();
372
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800373 pusher.stop();
374 }
375
376 /**
377 * Test barrier message is correctly sent to a switch.
378 */
379 @Test
380 public void testBarrierMessage() {
381 beginInitMock();
382
383 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
384 EasyMock.expect(sw.getId()).andReturn((long)1).anyTimes();
385 sw.flush();
386 EasyMock.expectLastCall().atLeastOnce();
387 prepareBarrier(sw);
388 EasyMock.replay(sw);
389
390 try {
391 EasyMock.expect(damper.write(EasyMock.eq(sw), (OFMessage)EasyMock.anyObject(), EasyMock.eq(context)))
392 .andReturn(true).once();
393 } catch (IOException e1) {
394 fail("Failed in OFMessageDamper#write()");
395 }
396
397 endInitMock();
398 initPusher(1);
399
400 OFBarrierReplyFuture future = pusher.barrierAsync(sw);
401
402 assertNotNull(future);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700403
404 try {
405 Thread.sleep(1000);
406 } catch (InterruptedException e) {
407 fail("Failed to sleep");
408 }
409
410 verifyAll();
411
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800412 pusher.stop();
413 }
414
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700415 static final int XID_TO_VERIFY = 100;
416 static final long DPID_TO_VERIFY = 10;
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800417 /**
418 * Test FlowObject is correctly converted to message and is sent to a switch.
419 */
420 @SuppressWarnings("unchecked")
421 @Test
422 public void testAddFlow() {
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800423 // instantiate required objects
424 FlowEntry flowEntry1 = new FlowEntry();
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700425 flowEntry1.setDpid(new Dpid(DPID_TO_VERIFY));
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800426 flowEntry1.setFlowId(new FlowId(1));
427 flowEntry1.setInPort(new Port((short) 1));
428 flowEntry1.setOutPort(new Port((short) 11));
429 flowEntry1.setFlowEntryId(new FlowEntryId(1));
430 flowEntry1.setFlowEntryMatch(new FlowEntryMatch());
431 flowEntry1.setFlowEntryActions(new FlowEntryActions());
432 flowEntry1.setFlowEntryErrorState(new FlowEntryErrorState());
433 flowEntry1.setFlowEntryUserState(FlowEntryUserState.FE_USER_ADD);
434
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800435 beginInitMock();
436
437 OFFlowMod msg = EasyMock.createMock(OFFlowMod.class);
438 EasyMock.expect(msg.setIdleTimeout(EasyMock.anyShort())).andReturn(msg);
439 EasyMock.expect(msg.setHardTimeout(EasyMock.anyShort())).andReturn(msg);
440 EasyMock.expect(msg.setPriority(EasyMock.anyShort())).andReturn(msg);
441 EasyMock.expect(msg.setBufferId(EasyMock.anyInt())).andReturn(msg);
442 EasyMock.expect(msg.setCookie(EasyMock.anyLong())).andReturn(msg);
443 EasyMock.expect(msg.setCommand(EasyMock.anyShort())).andReturn(msg);
444 EasyMock.expect(msg.setMatch(EasyMock.anyObject(OFMatch.class))).andReturn(msg);
445 EasyMock.expect(msg.setActions((List<OFAction>)EasyMock.anyObject())).andReturn(msg);
446 EasyMock.expect(msg.setLengthU(EasyMock.anyShort())).andReturn(msg);
447 EasyMock.expect(msg.setOutPort(EasyMock.anyShort())).andReturn(msg).atLeastOnce();
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700448 EasyMock.expect(msg.getXid()).andReturn(XID_TO_VERIFY).anyTimes();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800449 EasyMock.expect(msg.getType()).andReturn(OFType.FLOW_MOD).anyTimes();
450 EasyMock.expect(msg.getLength()).andReturn((short)100).anyTimes();
451 EasyMock.replay(msg);
452
453 EasyMock.expect(factory.getMessage(EasyMock.eq(OFType.FLOW_MOD))).andReturn(msg);
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800454
455 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700456 EasyMock.expect(sw.getId()).andReturn(DPID_TO_VERIFY).anyTimes();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800457 EasyMock.expect(sw.getStringId()).andReturn("1").anyTimes();
458 sw.flush();
459 EasyMock.expectLastCall().once();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800460
461 try {
462 EasyMock.expect(damper.write(EasyMock.eq(sw), EasyMock.anyObject(OFMessage.class), EasyMock.eq(context)))
463 .andAnswer(new IAnswer<Boolean>() {
464 @Override
465 public Boolean answer() throws Throwable {
466 OFMessage msg = (OFMessage)EasyMock.getCurrentArguments()[1];
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700467 if (msg.getType() == OFType.FLOW_MOD) {
468 assertEquals(msg.getXid(), XID_TO_VERIFY);
469 }
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800470 return true;
471 }
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700472 }).atLeastOnce();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800473 } catch (IOException e1) {
474 fail("Failed in OFMessageDamper#write()");
475 }
476
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700477 EasyMock.replay(sw);
478
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800479 endInitMock();
480 initPusher(1);
481
Pavlin Radoslavov24a09152013-12-05 12:35:17 -0800482 pusher.pushFlowEntry(sw, flowEntry1);
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800483
484 try {
485 Thread.sleep(1000);
486 } catch (InterruptedException e) {
487 fail("Failed to sleep");
488 }
489
490 EasyMock.verify(sw);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700491 verifyAll();
492
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800493 pusher.stop();
494 }
495
496 private void beginInitMock() {
497 context = EasyMock.createMock(FloodlightContext.class);
498 modContext = EasyMock.createMock(FloodlightModuleContext.class);
499 factory = EasyMock.createMock(BasicFactory.class);
500 damper = EasyMock.createMock(OFMessageDamper.class);
Naoki Shiota71fff002013-12-04 15:20:09 -0800501 flProviderService = EasyMock.createMock(IFloodlightProviderService.class);
502 threadPoolService = EasyMock.createMock(IThreadPoolService.class);
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800503
504 EasyMock.expect(modContext.getServiceImpl(EasyMock.eq(IThreadPoolService.class)))
Naoki Shiota71fff002013-12-04 15:20:09 -0800505 .andReturn(threadPoolService).once();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800506 EasyMock.expect(modContext.getServiceImpl(EasyMock.eq(IFloodlightProviderService.class)))
Naoki Shiota71fff002013-12-04 15:20:09 -0800507 .andReturn(flProviderService).once();
Naoki Shiota71fff002013-12-04 15:20:09 -0800508 flProviderService.addOFMessageListener(EasyMock.eq(OFType.BARRIER_REPLY),
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800509 (FlowPusher) EasyMock.anyObject());
510 EasyMock.expectLastCall().once();
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700511
512 ScheduledExecutorService executor = EasyMock.createMock(ScheduledExecutorService.class);
513 EasyMock.expect(executor.schedule((Runnable)EasyMock.anyObject(), EasyMock.anyLong(),
514 (TimeUnit)EasyMock.anyObject())).andReturn(null).once();
515 EasyMock.replay(executor);
516 EasyMock.expect(threadPoolService.getScheduledExecutor()).andReturn(executor).anyTimes();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800517 }
518
519 private void endInitMock() {
Naoki Shiota71fff002013-12-04 15:20:09 -0800520 EasyMock.replay(threadPoolService);
521 EasyMock.replay(flProviderService);
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800522 EasyMock.replay(damper);
523 EasyMock.replay(factory);
524 EasyMock.replay(modContext);
525 EasyMock.replay(context);
526 }
527
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700528 private void verifyAll() {
529 EasyMock.verify(threadPoolService);
530 EasyMock.verify(flProviderService);
531 EasyMock.verify(damper);
532 EasyMock.verify(factory);
533 EasyMock.verify(modContext);
534 EasyMock.verify(context);
535 }
536
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800537 private void initPusher(int num_thread) {
538 pusher = new FlowPusher(num_thread);
539 pusher.init(context, modContext, factory, damper);
540 pusher.start();
541 }
542
543 private void prepareBarrier(IOFSwitch sw) {
544 OFBarrierRequest req = EasyMock.createMock(OFBarrierRequest.class);
545 req.setXid(EasyMock.anyInt());
546 EasyMock.expectLastCall().once();
547 EasyMock.expect(req.getXid()).andReturn(1).anyTimes();
548 EasyMock.expect(req.getType()).andReturn(OFType.BARRIER_REQUEST).anyTimes();
549 EasyMock.expect(req.getLength()).andReturn((short)100).anyTimes();
550 EasyMock.replay(req);
Naoki Shiotad6ef3b32014-03-13 18:42:23 -0700551 EasyMock.expect(factory.getMessage(EasyMock.eq(OFType.BARRIER_REQUEST))).andReturn(req).anyTimes();
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800552 EasyMock.expect(sw.getNextTransactionId()).andReturn(1);
553 }
554
Naoki Shiota75b7dd62013-12-03 18:09:21 -0800555}