Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowprogrammer; |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 2 | |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 3 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 4 | import static org.easymock.EasyMock.anyInt; |
| 5 | import static org.easymock.EasyMock.anyLong; |
| 6 | import static org.easymock.EasyMock.anyObject; |
| 7 | import static org.easymock.EasyMock.anyShort; |
| 8 | import static org.easymock.EasyMock.createMock; |
| 9 | import static org.easymock.EasyMock.eq; |
| 10 | import static org.easymock.EasyMock.expect; |
| 11 | import static org.easymock.EasyMock.expectLastCall; |
| 12 | import static org.easymock.EasyMock.replay; |
| 13 | import static org.easymock.EasyMock.verify; |
Naoki Shiota | 4799310 | 2014-07-09 14:00:54 -0700 | [diff] [blame] | 14 | import static org.junit.Assert.assertNotNull; |
| 15 | import static org.junit.Assert.assertTrue; |
| 16 | import static org.junit.Assert.fail; |
| 17 | |
| 18 | import java.io.IOException; |
| 19 | import java.util.ArrayList; |
| 20 | import java.util.HashMap; |
| 21 | import java.util.List; |
| 22 | import java.util.Map; |
| 23 | import java.util.concurrent.ScheduledExecutorService; |
| 24 | import java.util.concurrent.TimeUnit; |
| 25 | |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 26 | import net.floodlightcontroller.core.FloodlightContext; |
| 27 | import net.floodlightcontroller.core.IFloodlightProviderService; |
| 28 | import net.floodlightcontroller.core.IOFSwitch; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 29 | import net.floodlightcontroller.core.internal.OFMessageFuture; |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 30 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 31 | import net.floodlightcontroller.threadpool.IThreadPoolService; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 32 | import net.onrc.onos.core.intent.FlowEntry; |
| 33 | import net.onrc.onos.core.intent.IntentOperation.Operator; |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 34 | import net.onrc.onos.core.util.Dpid; |
Ray Milkey | 1064357 | 2014-06-10 15:17:39 -0700 | [diff] [blame] | 35 | import net.onrc.onos.core.util.IntegrationTest; |
Naoki Shiota | 4799310 | 2014-07-09 14:00:54 -0700 | [diff] [blame] | 36 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 37 | import org.junit.Ignore; |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 38 | import org.junit.Test; |
Ray Milkey | 1064357 | 2014-06-10 15:17:39 -0700 | [diff] [blame] | 39 | import org.junit.experimental.categories.Category; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 40 | import org.projectfloodlight.openflow.protocol.OFBarrierReply; |
| 41 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; |
| 42 | import org.projectfloodlight.openflow.protocol.OFFactories; |
| 43 | import org.projectfloodlight.openflow.protocol.OFFactory; |
| 44 | import org.projectfloodlight.openflow.protocol.OFFlowModify; |
| 45 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 46 | import org.projectfloodlight.openflow.protocol.OFType; |
| 47 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 48 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 49 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 50 | import org.projectfloodlight.openflow.types.OFBufferId; |
| 51 | import org.projectfloodlight.openflow.types.OFPort; |
| 52 | import org.projectfloodlight.openflow.types.U64; |
Jonathan Hart | ce07f32 | 2014-08-13 14:40:53 -0700 | [diff] [blame] | 53 | import org.projectfloodlight.openflow.util.HexString; |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 54 | |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 55 | |
Ray Milkey | 1064357 | 2014-06-10 15:17:39 -0700 | [diff] [blame] | 56 | @Category(IntegrationTest.class) |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 57 | public class FlowPusherTest { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 58 | private FlowPusher pusher; |
| 59 | private FloodlightContext context; |
| 60 | private FloodlightModuleContext modContext; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 61 | private IFloodlightProviderService flProviderService; |
| 62 | private IThreadPoolService threadPoolService; |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 63 | |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 64 | private OFFactory factory10 = OFFactories.getFactory(OFVersion.OF_10); |
| 65 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 66 | /** |
Jonathan Hart | 51bb27c | 2014-08-11 16:00:31 -0700 | [diff] [blame] | 67 | * Test single OFMessage is correctly sent to single switch. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 68 | */ |
| 69 | @Test |
| 70 | public void testAddMessage() { |
| 71 | beginInitMock(); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 72 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 73 | Dpid dpid = new Dpid(1L); |
| 74 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 75 | OFMessage msg = createMock(OFMessage.class); |
| 76 | expect(msg.getXid()).andReturn((long) 1).anyTimes(); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 77 | replay(msg); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 78 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 79 | IOFSwitch sw = createConnectedSwitchMock(dpid.value()); |
Naoki Shiota | d6ef3b3 | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 80 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 81 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 82 | sw.write(eq(msg), eq((FloodlightContext) null)); |
| 83 | expectLastCall().once(); |
| 84 | replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 85 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 86 | fail("Failed in IOFSwitch#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 87 | } |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 88 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 89 | endInitMock(); |
| 90 | initPusher(1); |
Naoki Shiota | d6ef3b3 | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 91 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 92 | boolean addResult = pusher.add(dpid, msg); |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 93 | assertTrue(addResult); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 94 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 95 | try { |
| 96 | // wait until message is processed. |
| 97 | Thread.sleep(1000); |
| 98 | } catch (InterruptedException e) { |
| 99 | fail("Failed in Thread.sleep()"); |
| 100 | } |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 101 | verify(msg); |
| 102 | verify(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 103 | verifyAll(); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 104 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 105 | pusher.stop(); |
| 106 | } |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 107 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 108 | /** |
Jonathan Hart | 51bb27c | 2014-08-11 16:00:31 -0700 | [diff] [blame] | 109 | * Test bunch of OFMessages are correctly sent to single switch. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 110 | */ |
| 111 | @Test |
| 112 | public void testMassiveAddMessage() { |
Yuta HIGUCHI | 7c39c84 | 2014-06-09 16:33:03 -0700 | [diff] [blame] | 113 | // Some number larger than FlowPusher.MAX_MESSAGE_SEND |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 114 | final int numMsg = FlowPusher.MAX_MESSAGE_SEND * 2; |
Naoki Shiota | d6ef3b3 | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 115 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 116 | beginInitMock(); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 117 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 118 | Dpid dpid = new Dpid(1L); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 119 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 120 | IOFSwitch sw = createConnectedSwitchMock(dpid.value()); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 121 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 122 | List<OFMessage> messages = new ArrayList<OFMessage>(); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 123 | |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 124 | for (int i = 0; i < numMsg; ++i) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 125 | OFMessage msg = createMock(OFMessage.class); |
| 126 | expect(msg.getXid()).andReturn((long) i).anyTimes(); |
| 127 | replay(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 128 | messages.add(msg); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 129 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 130 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 131 | sw.write(eq(msg), eq((FloodlightContext) null)); |
| 132 | expectLastCall().once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 133 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 134 | fail("Failed in IOFSwitch#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 135 | } |
| 136 | } |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 137 | replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 138 | endInitMock(); |
| 139 | initPusher(1); |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 140 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 141 | for (OFMessage msg : messages) { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 142 | boolean addResult = pusher.add(dpid, msg); |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 143 | assertTrue(addResult); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 144 | } |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 145 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 146 | try { |
| 147 | // wait until message is processed. |
Yuta HIGUCHI | 7c39c84 | 2014-06-09 16:33:03 -0700 | [diff] [blame] | 148 | Thread.sleep(1000); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 149 | } catch (InterruptedException e) { |
| 150 | fail("Failed in Thread.sleep()"); |
| 151 | } |
Naoki Shiota | d6ef3b3 | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 152 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 153 | for (OFMessage msg : messages) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 154 | verify(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 155 | } |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 156 | verify(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 157 | verifyAll(); |
| 158 | |
| 159 | pusher.stop(); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Test bunch of OFMessages are correctly sent to multiple switches with single threads. |
| 164 | */ |
| 165 | @Test |
| 166 | public void testMultiSwitchAddMessage() { |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 167 | final int numSwitch = 10; |
| 168 | final int numMsg = 100; // messages per thread |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 169 | |
| 170 | beginInitMock(); |
| 171 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 172 | Map<IOFSwitch, List<OFMessage>> swMap = new HashMap<>(); |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 173 | for (int i = 0; i < numSwitch; ++i) { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 174 | Dpid dpid = new Dpid(i); |
| 175 | |
| 176 | IOFSwitch sw = createConnectedSwitchMock(dpid.value()); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 177 | |
| 178 | List<OFMessage> messages = new ArrayList<OFMessage>(); |
| 179 | |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 180 | for (int j = 0; j < numMsg; ++j) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 181 | OFMessage msg = createMock(OFMessage.class); |
| 182 | expect(msg.getXid()).andReturn((long) j).anyTimes(); |
| 183 | replay(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 184 | messages.add(msg); |
| 185 | |
| 186 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 187 | sw.write(eq(msg), eq((FloodlightContext) null)); |
| 188 | expectLastCall().once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 189 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 190 | fail("Failed in IOFWrite#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 191 | } |
| 192 | } |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 193 | swMap.put(sw, messages); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 194 | replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | endInitMock(); |
| 198 | initPusher(1); |
| 199 | |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 200 | for (IOFSwitch sw : swMap.keySet()) { |
| 201 | for (OFMessage msg : swMap.get(sw)) { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 202 | boolean addResult = pusher.add(new Dpid(sw.getId()), msg); |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 203 | assertTrue(addResult); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
| 207 | try { |
| 208 | // wait until message is processed. |
| 209 | Thread.sleep(1000); |
| 210 | } catch (InterruptedException e) { |
| 211 | fail("Failed in Thread.sleep()"); |
| 212 | } |
| 213 | |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 214 | for (IOFSwitch sw : swMap.keySet()) { |
| 215 | for (OFMessage msg : swMap.get(sw)) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 216 | verify(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 219 | verify(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 220 | } |
| 221 | verifyAll(); |
| 222 | |
| 223 | pusher.stop(); |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Test bunch of OFMessages are correctly sent to multiple switches using multiple threads. |
| 228 | */ |
| 229 | @Test |
| 230 | public void testMultiThreadedAddMessage() { |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 231 | final int numThreads = 10; |
| 232 | final int numMsg = 100; // messages per thread |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 233 | |
| 234 | beginInitMock(); |
| 235 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 236 | Map<IOFSwitch, List<OFMessage>> swMap = new HashMap<>(); |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 237 | for (int i = 0; i < numThreads; ++i) { |
Jonathan Hart | ce07f32 | 2014-08-13 14:40:53 -0700 | [diff] [blame] | 238 | IOFSwitch sw = createConnectedSwitchMock(i); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 239 | //EasyMock.replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 240 | |
| 241 | List<OFMessage> messages = new ArrayList<OFMessage>(); |
| 242 | |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 243 | for (int j = 0; j < numMsg; ++j) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 244 | OFMessage msg = createMock(OFMessage.class); |
| 245 | expect(msg.getXid()).andReturn((long) j).anyTimes(); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 246 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 247 | replay(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 248 | messages.add(msg); |
| 249 | |
| 250 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 251 | sw.write(eq(msg), eq((FloodlightContext) null)); |
| 252 | expectLastCall().once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 253 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 254 | fail("Failed in IOFWrite#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 255 | } |
| 256 | } |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 257 | swMap.put(sw, messages); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 258 | replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | endInitMock(); |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 262 | initPusher(numThreads); |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 263 | for (IOFSwitch sw : swMap.keySet()) { |
| 264 | for (OFMessage msg : swMap.get(sw)) { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 265 | boolean addResult = pusher.add(new Dpid(sw.getId()), msg); |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 266 | assertTrue(addResult); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
| 270 | try { |
| 271 | // wait until message is processed. |
| 272 | Thread.sleep(1000); |
| 273 | } catch (InterruptedException e) { |
| 274 | fail("Failed in Thread.sleep()"); |
| 275 | } |
| 276 | |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 277 | for (IOFSwitch sw : swMap.keySet()) { |
| 278 | for (OFMessage msg : swMap.get(sw)) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 279 | verify(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 282 | verify(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 283 | } |
| 284 | verifyAll(); |
| 285 | |
| 286 | pusher.stop(); |
| 287 | } |
| 288 | |
| 289 | private long barrierTime = 0; |
| 290 | |
| 291 | /** |
| 292 | * Test rate limitation of messages works correctly. |
| 293 | */ |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 294 | // XXX Disabling this test for now. |
| 295 | // This test doesn't seem to be correctly testing the rate limiting feature. |
| 296 | // It tries to measure the time taken to push a set of messages, however the |
| 297 | // 'end' timestamp is actually taken when the expectation is set up, before |
| 298 | // any messages have been pushed. This means generally when measuredRate is |
| 299 | // calculated it is a negative value, so is always less than the allowedRate |
| 300 | // and the test passes. |
| 301 | // However I was seeing some random failures caused by a divide-by-zero |
| 302 | // error, which occurs when the 'end' and 'start' timestamps are taken in |
| 303 | // the same millisecond. |
| 304 | // Furthermore, rate limits are set in bytes/ms and the rate limiter relies |
| 305 | // on being able to get the size of the packets, which is not possible |
| 306 | // with Loxi messages. Therefore the rate limiter currently does not work. |
| 307 | @Ignore |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 308 | @Test |
| 309 | public void testRateLimitedAddMessage() { |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 310 | final long limitRate = 100; // [bytes/ms] |
| 311 | final int numMsg = 1000; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 312 | |
| 313 | // Accuracy of FlowPusher's rate calculation can't be measured by unit test |
| 314 | // because switch doesn't return BARRIER_REPLY. |
| 315 | // In unit test we use approximate way to measure rate. This value is |
| 316 | // acceptable margin of measured rate. |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 317 | final double acceptableRate = limitRate * 1.2; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 318 | |
| 319 | beginInitMock(); |
| 320 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 321 | Dpid dpid = new Dpid(1L); |
| 322 | |
| 323 | IOFSwitch sw = createConnectedSwitchMock(dpid.value()); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 324 | |
| 325 | List<OFMessage> messages = new ArrayList<OFMessage>(); |
| 326 | |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 327 | for (int i = 0; i < numMsg; ++i) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 328 | OFMessage msg = createMock(OFMessage.class); |
| 329 | expect(msg.getXid()).andReturn((long) 1).anyTimes(); |
| 330 | replay(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 331 | messages.add(msg); |
| 332 | |
| 333 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 334 | sw.write(eq(msg), eq((FloodlightContext) null)); |
| 335 | expectLastCall().once(); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 336 | } catch (IOException e1) { |
| 337 | fail("Failed in IOFWrite#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | |
| 341 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 342 | sw.write(anyObject(OFBarrierRequest.class), eq((FloodlightContext) null)); |
| 343 | expectLastCall().once(); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 344 | barrierTime = System.currentTimeMillis(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 345 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 346 | fail("Failed in IOFWrite#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 347 | } |
| 348 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 349 | replay(sw); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 350 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 351 | endInitMock(); |
| 352 | initPusher(1); |
| 353 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 354 | pusher.createQueue(dpid); |
| 355 | pusher.setRate(dpid, limitRate); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 356 | |
| 357 | long beginTime = System.currentTimeMillis(); |
| 358 | for (OFMessage msg : messages) { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 359 | boolean addResult = pusher.add(dpid, msg); |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 360 | assertTrue(addResult); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 363 | pusher.barrierAsync(dpid); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 364 | |
| 365 | try { |
| 366 | do { |
| 367 | Thread.sleep(1000); |
| 368 | } while (barrierTime == 0); |
| 369 | } catch (InterruptedException e) { |
| 370 | fail("Failed to sleep"); |
| 371 | } |
| 372 | |
Yuta HIGUCHI | 91a8f50 | 2014-06-17 10:15:29 -0700 | [diff] [blame] | 373 | double measuredRate = numMsg * 100 / (barrierTime - beginTime); |
| 374 | assertTrue(measuredRate < acceptableRate); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 375 | |
| 376 | for (OFMessage msg : messages) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 377 | verify(msg); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 378 | } |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 379 | verify(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 380 | verifyAll(); |
| 381 | |
| 382 | pusher.stop(); |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * Test barrier message is correctly sent to a switch. |
| 387 | */ |
| 388 | @Test |
| 389 | public void testBarrierMessage() { |
| 390 | beginInitMock(); |
| 391 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 392 | Dpid dpid = new Dpid(1L); |
| 393 | |
| 394 | IOFSwitch sw = createConnectedSwitchMock(dpid.value()); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 395 | expect(sw.getOFVersion()).andReturn(OFVersion.OF_10).once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 396 | |
| 397 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 398 | sw.write((OFMessage) anyObject(), eq((FloodlightContext) null)); |
| 399 | expectLastCall().once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 400 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 401 | fail("Failed in IOFWrite#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 402 | } |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 403 | replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 404 | endInitMock(); |
| 405 | initPusher(1); |
| 406 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 407 | OFMessageFuture<OFBarrierReply> future = pusher.barrierAsync(dpid); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 408 | |
| 409 | assertNotNull(future); |
| 410 | |
| 411 | try { |
| 412 | Thread.sleep(1000); |
| 413 | } catch (InterruptedException e) { |
| 414 | fail("Failed to sleep"); |
| 415 | } |
| 416 | |
| 417 | verifyAll(); |
| 418 | |
| 419 | pusher.stop(); |
| 420 | } |
| 421 | |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 422 | static final long XID_TO_VERIFY = 100; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 423 | static final long DPID_TO_VERIFY = 10; |
| 424 | |
| 425 | /** |
| 426 | * Test FlowObject is correctly converted to message and is sent to a switch. |
| 427 | */ |
| 428 | @SuppressWarnings("unchecked") |
| 429 | @Test |
| 430 | public void testAddFlow() { |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 431 | Dpid dpid = new Dpid(DPID_TO_VERIFY); |
| 432 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 433 | // instantiate required objects |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 434 | FlowEntry flowEntry1 = |
| 435 | new FlowEntry(DPID_TO_VERIFY, 1, 11, null, |
| 436 | null, 0, 0, Operator.ADD); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 437 | |
| 438 | beginInitMock(); |
| 439 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 440 | OFFlowModify fm = createMock(OFFlowModify.class); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 441 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 442 | OFFlowModify.Builder bld = createMock(OFFlowModify.Builder.class); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 443 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 444 | expect(bld.setIdleTimeout(anyInt())).andReturn(bld); |
| 445 | expect(bld.setHardTimeout(anyInt())).andReturn(bld); |
| 446 | expect(bld.setPriority(anyShort())).andReturn(bld); |
| 447 | expect(bld.setBufferId(OFBufferId.NO_BUFFER)).andReturn(bld); |
| 448 | expect(bld.setCookie(U64.of(anyLong()))).andReturn(bld); |
| 449 | expect(bld.setMatch(anyObject(Match.class))).andReturn(bld); |
| 450 | expect(bld.setActions((List<OFAction>) anyObject())).andReturn(bld); |
| 451 | expect(bld.setOutPort(OFPort.of(anyInt()))).andReturn(bld).atLeastOnce(); |
| 452 | expect(bld.build()).andReturn(fm); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 453 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 454 | expect(fm.getXid()).andReturn(XID_TO_VERIFY).anyTimes(); |
| 455 | expect(fm.getType()).andReturn(OFType.FLOW_MOD).anyTimes(); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 456 | |
Jonathan Hart | ce07f32 | 2014-08-13 14:40:53 -0700 | [diff] [blame] | 457 | IOFSwitch sw = createConnectedSwitchMock(DPID_TO_VERIFY); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 458 | |
| 459 | try { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 460 | sw.write(anyObject(OFMessage.class), eq((FloodlightContext) null)); |
| 461 | expectLastCall().once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 462 | } catch (IOException e1) { |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 463 | fail("Failed in IOFWrite#write()"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 464 | } |
| 465 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 466 | replay(bld, fm); |
| 467 | replay(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 468 | |
| 469 | endInitMock(); |
| 470 | initPusher(1); |
| 471 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 472 | pusher.pushFlowEntry(dpid, flowEntry1); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 473 | |
| 474 | try { |
| 475 | Thread.sleep(1000); |
| 476 | } catch (InterruptedException e) { |
| 477 | fail("Failed to sleep"); |
| 478 | } |
| 479 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 480 | verify(sw); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 481 | verifyAll(); |
| 482 | |
| 483 | pusher.stop(); |
| 484 | } |
| 485 | |
| 486 | private void beginInitMock() { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 487 | context = createMock(FloodlightContext.class); |
| 488 | modContext = createMock(FloodlightModuleContext.class); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 489 | // AAS: I don't think we should mock factories... the rabbit whole is too deep. |
| 490 | //factory10 = EasyMock.createMock(OFFactories.getFactory(OFVersion.OF_10).getClass()); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 491 | flProviderService = createMock(IFloodlightProviderService.class); |
| 492 | threadPoolService = createMock(IThreadPoolService.class); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 493 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 494 | expect(modContext.getServiceImpl(eq(IThreadPoolService.class))) |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 495 | .andReturn(threadPoolService).once(); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 496 | expect(modContext.getServiceImpl(eq(IFloodlightProviderService.class))) |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 497 | .andReturn(flProviderService).once(); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 498 | // AAS: FlowPusher doesn't call the following anymore. |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 499 | flProviderService.addOFMessageListener(eq(OFType.BARRIER_REPLY), |
| 500 | anyObject(FlowPusher.class)); |
| 501 | expectLastCall().once(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 502 | |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 503 | ScheduledExecutorService executor = createMock(ScheduledExecutorService.class); |
| 504 | expect(executor.schedule((Runnable) anyObject(), anyLong(), |
| 505 | (TimeUnit) anyObject())).andReturn(null).once(); |
| 506 | replay(executor); |
| 507 | expect(threadPoolService.getScheduledExecutor()).andReturn(executor).anyTimes(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | private void endInitMock() { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 511 | replay(threadPoolService); |
| 512 | replay(flProviderService); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 513 | //EasyMock.replay(factory10); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 514 | replay(modContext); |
| 515 | replay(context); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | private void verifyAll() { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 519 | verify(threadPoolService); |
| 520 | verify(flProviderService); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 521 | //EasyMock.verify(factory10); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 522 | verify(modContext); |
| 523 | verify(context); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 524 | } |
| 525 | |
Yuta HIGUCHI | 44a0b35 | 2014-05-14 21:32:48 -0700 | [diff] [blame] | 526 | private void initPusher(int numThread) { |
| 527 | pusher = new FlowPusher(numThread); |
Brian O'Connor | c67f9fa | 2014-08-07 18:17:46 -0700 | [diff] [blame] | 528 | pusher.init(modContext); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 529 | pusher.start(); |
| 530 | } |
| 531 | |
Jonathan Hart | ce07f32 | 2014-08-13 14:40:53 -0700 | [diff] [blame] | 532 | private IOFSwitch createConnectedSwitchMock(long dpid) { |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 533 | IOFSwitch sw = createMock(IOFSwitch.class); |
| 534 | expect(sw.isConnected()).andReturn(true).anyTimes(); |
| 535 | expect(sw.getId()).andReturn(dpid).anyTimes(); |
Jonathan Hart | ce07f32 | 2014-08-13 14:40:53 -0700 | [diff] [blame] | 536 | expect(sw.getStringId()).andReturn(HexString.toHexString(dpid)) |
| 537 | .anyTimes(); |
| 538 | expect(sw.getNextTransactionId()).andReturn(1).times(0, 1); |
| 539 | // TODO 1.3ize |
| 540 | expect(sw.getFactory()).andReturn(factory10).anyTimes(); |
Naoki Shiota | 4799310 | 2014-07-09 14:00:54 -0700 | [diff] [blame] | 541 | sw.flush(); |
Sho SHIMIZU | 107344e | 2014-08-13 16:11:53 -0700 | [diff] [blame] | 542 | expectLastCall().anyTimes(); |
Naoki Shiota | 4799310 | 2014-07-09 14:00:54 -0700 | [diff] [blame] | 543 | |
Jonathan Hart | 5302b6c | 2014-08-13 15:57:59 -0700 | [diff] [blame^] | 544 | expect(flProviderService.getMasterSwitch(dpid)).andReturn(sw) |
| 545 | .anyTimes(); |
| 546 | |
Naoki Shiota | 4799310 | 2014-07-09 14:00:54 -0700 | [diff] [blame] | 547 | return sw; |
| 548 | } |
| 549 | |
Naoki Shiota | 75b7dd6 | 2013-12-03 18:09:21 -0800 | [diff] [blame] | 550 | } |