tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.flow.impl; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 2 | |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 3 | import static org.junit.Assert.assertEquals; |
| 4 | import static org.junit.Assert.assertFalse; |
| 5 | import static org.junit.Assert.assertNotNull; |
| 6 | import static org.junit.Assert.assertTrue; |
| 7 | import static org.junit.Assert.fail; |
alshabib | 9704490 | 2014-09-18 14:52:16 -0700 | [diff] [blame] | 8 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADDED; |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 9 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADD_REQUESTED; |
alshabib | 9704490 | 2014-09-18 14:52:16 -0700 | [diff] [blame] | 10 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVED; |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 11 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVE_REQUESTED; |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 12 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_UPDATED; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 13 | |
| 14 | import java.util.ArrayList; |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 15 | import java.util.Collections; |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 16 | import java.util.HashMap; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 17 | import java.util.List; |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 18 | import java.util.Map; |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 19 | import java.util.Set; |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 20 | import java.util.concurrent.ExecutionException; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 21 | import java.util.concurrent.Executor; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 22 | import java.util.concurrent.Future; |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 23 | import java.util.concurrent.TimeUnit; |
| 24 | import java.util.concurrent.TimeoutException; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 25 | |
| 26 | import org.junit.After; |
| 27 | import org.junit.Before; |
| 28 | import org.junit.Test; |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 29 | import org.onlab.onos.ApplicationId; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 30 | import org.onlab.onos.event.impl.TestEventDispatcher; |
alshabib | 92c65ad | 2014-10-08 21:56:05 -0700 | [diff] [blame] | 31 | import org.onlab.onos.impl.DefaultApplicationId; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 32 | import org.onlab.onos.net.DefaultDevice; |
| 33 | import org.onlab.onos.net.Device; |
| 34 | import org.onlab.onos.net.Device.Type; |
| 35 | import org.onlab.onos.net.DeviceId; |
| 36 | import org.onlab.onos.net.MastershipRole; |
| 37 | import org.onlab.onos.net.Port; |
| 38 | import org.onlab.onos.net.PortNumber; |
| 39 | import org.onlab.onos.net.device.DeviceListener; |
| 40 | import org.onlab.onos.net.device.DeviceService; |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 41 | import org.onlab.onos.net.flow.BatchOperation; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 42 | import org.onlab.onos.net.flow.CompletedBatchOperation; |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 43 | import org.onlab.onos.net.flow.DefaultFlowEntry; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 44 | import org.onlab.onos.net.flow.DefaultFlowRule; |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 45 | import org.onlab.onos.net.flow.FlowEntry; |
| 46 | import org.onlab.onos.net.flow.FlowEntry.FlowEntryState; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 47 | import org.onlab.onos.net.flow.FlowRule; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 48 | import org.onlab.onos.net.flow.FlowRuleBatchEntry; |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 49 | import org.onlab.onos.net.flow.FlowRuleBatchOperation; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 50 | import org.onlab.onos.net.flow.FlowRuleEvent; |
| 51 | import org.onlab.onos.net.flow.FlowRuleListener; |
| 52 | import org.onlab.onos.net.flow.FlowRuleProvider; |
| 53 | import org.onlab.onos.net.flow.FlowRuleProviderRegistry; |
| 54 | import org.onlab.onos.net.flow.FlowRuleProviderService; |
| 55 | import org.onlab.onos.net.flow.FlowRuleService; |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 56 | import org.onlab.onos.net.flow.StoredFlowEntry; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 57 | import org.onlab.onos.net.flow.TrafficSelector; |
| 58 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 59 | import org.onlab.onos.net.flow.criteria.Criterion; |
| 60 | import org.onlab.onos.net.flow.instructions.Instruction; |
| 61 | import org.onlab.onos.net.provider.AbstractProvider; |
| 62 | import org.onlab.onos.net.provider.ProviderId; |
tom | ea961ff | 2014-10-01 12:45:15 -0700 | [diff] [blame] | 63 | import org.onlab.onos.store.trivial.impl.SimpleFlowRuleStore; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 64 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 65 | import com.google.common.collect.ImmutableList; |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 66 | import com.google.common.collect.ImmutableMap; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 67 | import com.google.common.collect.Lists; |
| 68 | import com.google.common.collect.Sets; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 69 | import com.google.common.util.concurrent.ListenableFuture; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 70 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 71 | /** |
| 72 | * Test codifying the flow rule service & flow rule provider service contracts. |
| 73 | */ |
tom | 202175a | 2014-09-19 19:00:11 -0700 | [diff] [blame] | 74 | public class FlowRuleManagerTest { |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 75 | |
alshabib | 92c65ad | 2014-10-08 21:56:05 -0700 | [diff] [blame] | 76 | |
| 77 | |
tom | f6ab215 | 2014-09-18 12:08:29 -0700 | [diff] [blame] | 78 | private static final ProviderId PID = new ProviderId("of", "foo"); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 79 | private static final DeviceId DID = DeviceId.deviceId("of:001"); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 80 | private static final int TIMEOUT = 10; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 81 | private static final Device DEV = new DefaultDevice( |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 82 | PID, DID, Type.SWITCH, "", "", "", "", null); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 83 | |
tom | 202175a | 2014-09-19 19:00:11 -0700 | [diff] [blame] | 84 | private FlowRuleManager mgr; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 85 | |
| 86 | protected FlowRuleService service; |
| 87 | protected FlowRuleProviderRegistry registry; |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 88 | protected FlowRuleProviderService providerService; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 89 | protected TestProvider provider; |
| 90 | protected TestListener listener = new TestListener(); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 91 | private ApplicationId appId; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 92 | |
| 93 | @Before |
| 94 | public void setUp() { |
tom | 202175a | 2014-09-19 19:00:11 -0700 | [diff] [blame] | 95 | mgr = new FlowRuleManager(); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 96 | mgr.store = new SimpleFlowRuleStore(); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 97 | mgr.eventDispatcher = new TestEventDispatcher(); |
| 98 | mgr.deviceService = new TestDeviceService(); |
| 99 | service = mgr; |
| 100 | registry = mgr; |
| 101 | |
| 102 | mgr.activate(); |
| 103 | mgr.addListener(listener); |
| 104 | provider = new TestProvider(PID); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 105 | providerService = registry.register(provider); |
alshabib | 92c65ad | 2014-10-08 21:56:05 -0700 | [diff] [blame] | 106 | appId = new TestApplicationId((short) 0, "FlowRuleManagerTest"); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 107 | assertTrue("provider should be registered", |
| 108 | registry.getProviders().contains(provider.id())); |
| 109 | } |
| 110 | |
| 111 | @After |
| 112 | public void tearDown() { |
| 113 | registry.unregister(provider); |
| 114 | assertFalse("provider should not be registered", |
alshabib | 9704490 | 2014-09-18 14:52:16 -0700 | [diff] [blame] | 115 | registry.getProviders().contains(provider.id())); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 116 | service.removeListener(listener); |
| 117 | mgr.deactivate(); |
| 118 | mgr.eventDispatcher = null; |
| 119 | mgr.deviceService = null; |
| 120 | } |
| 121 | |
| 122 | private FlowRule flowRule(int tsval, int trval) { |
| 123 | TestSelector ts = new TestSelector(tsval); |
| 124 | TestTreatment tr = new TestTreatment(trval); |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 125 | return new DefaultFlowRule(DID, ts, tr, 10, appId, TIMEOUT, false); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 126 | } |
| 127 | |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 128 | |
| 129 | private FlowRule addFlowRule(int hval) { |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 130 | FlowRule rule = flowRule(hval, hval); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 131 | service.applyFlowRules(rule); |
| 132 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 133 | assertNotNull("rule should be found", service.getFlowEntries(DID)); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 134 | return rule; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | private void validateEvents(FlowRuleEvent.Type ... events) { |
| 138 | if (events == null) { |
| 139 | assertTrue("events generated", listener.events.isEmpty()); |
| 140 | } |
| 141 | |
| 142 | int i = 0; |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 143 | System.err.println("events :" + listener.events); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 144 | for (FlowRuleEvent e : listener.events) { |
| 145 | assertTrue("unexpected event", e.type().equals(events[i])); |
| 146 | i++; |
| 147 | } |
| 148 | |
| 149 | assertEquals("mispredicted number of events", |
| 150 | events.length, listener.events.size()); |
| 151 | |
| 152 | listener.events.clear(); |
| 153 | } |
| 154 | |
| 155 | private int flowCount() { |
| 156 | return Sets.newHashSet(service.getFlowEntries(DID)).size(); |
| 157 | } |
| 158 | @Test |
| 159 | public void getFlowEntries() { |
| 160 | assertTrue("store should be empty", |
| 161 | Sets.newHashSet(service.getFlowEntries(DID)).isEmpty()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 162 | FlowRule f1 = addFlowRule(1); |
| 163 | FlowRule f2 = addFlowRule(2); |
| 164 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 165 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 166 | FlowEntry fe2 = new DefaultFlowEntry(f2); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 167 | assertEquals("2 rules should exist", 2, flowCount()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 168 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 169 | providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2)); |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 170 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, |
| 171 | RULE_ADDED, RULE_ADDED); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 172 | |
| 173 | addFlowRule(1); |
| 174 | assertEquals("should still be 2 rules", 2, flowCount()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 175 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 176 | providerService.pushFlowMetrics(DID, ImmutableList.of(fe1)); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 177 | validateEvents(RULE_UPDATED); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 178 | } |
| 179 | |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 180 | |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 181 | // TODO: If preserving iteration order is a requirement, redo FlowRuleStore. |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 182 | //backing store is sensitive to the order of additions/removals |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 183 | private boolean validateState(Map<FlowRule, FlowEntryState> expected) { |
| 184 | Map<FlowRule, FlowEntryState> expectedToCheck = new HashMap<>(expected); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 185 | Iterable<FlowEntry> rules = service.getFlowEntries(DID); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 186 | for (FlowEntry f : rules) { |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 187 | assertTrue("Unexpected FlowRule " + f, expectedToCheck.containsKey(f)); |
| 188 | assertEquals("FlowEntry" + f, expectedToCheck.get(f), f.state()); |
| 189 | expectedToCheck.remove(f); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 190 | } |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 191 | assertEquals(Collections.emptySet(), expectedToCheck.entrySet()); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 192 | return true; |
| 193 | } |
| 194 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 195 | @Test |
| 196 | public void applyFlowRules() { |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 197 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 198 | FlowRule r1 = flowRule(1, 1); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 199 | FlowRule r2 = flowRule(2, 2); |
| 200 | FlowRule r3 = flowRule(3, 3); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 201 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 202 | assertTrue("store should be empty", |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 203 | Sets.newHashSet(service.getFlowEntries(DID)).isEmpty()); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 204 | mgr.applyFlowRules(r1, r2, r3); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 205 | assertEquals("3 rules should exist", 3, flowCount()); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 206 | assertTrue("Entries should be pending add.", |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 207 | validateState(ImmutableMap.of( |
| 208 | r1, FlowEntryState.PENDING_ADD, |
| 209 | r2, FlowEntryState.PENDING_ADD, |
| 210 | r3, FlowEntryState.PENDING_ADD))); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | @Test |
| 214 | public void removeFlowRules() { |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 215 | FlowRule f1 = addFlowRule(1); |
| 216 | FlowRule f2 = addFlowRule(2); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 217 | FlowRule f3 = addFlowRule(3); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 218 | assertEquals("3 rules should exist", 3, flowCount()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 219 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 220 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 221 | FlowEntry fe2 = new DefaultFlowEntry(f2); |
| 222 | FlowEntry fe3 = new DefaultFlowEntry(f3); |
| 223 | providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2, fe3)); |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 224 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, |
| 225 | RULE_ADDED, RULE_ADDED, RULE_ADDED); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 226 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 227 | mgr.removeFlowRules(f1, f2); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 228 | //removing from north, so no events generated |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 229 | validateEvents(RULE_REMOVE_REQUESTED, RULE_REMOVE_REQUESTED); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 230 | assertEquals("3 rule should exist", 3, flowCount()); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 231 | assertTrue("Entries should be pending remove.", |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 232 | validateState(ImmutableMap.of( |
| 233 | f1, FlowEntryState.PENDING_REMOVE, |
| 234 | f2, FlowEntryState.PENDING_REMOVE, |
| 235 | f3, FlowEntryState.ADDED))); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 236 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 237 | mgr.removeFlowRules(f1); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 238 | assertEquals("3 rule should still exist", 3, flowCount()); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | @Test |
| 242 | public void flowRemoved() { |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 243 | FlowRule f1 = addFlowRule(1); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 244 | FlowRule f2 = addFlowRule(2); |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 245 | StoredFlowEntry fe1 = new DefaultFlowEntry(f1); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 246 | FlowEntry fe2 = new DefaultFlowEntry(f2); |
| 247 | providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2)); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 248 | service.removeFlowRules(f1); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 249 | fe1.setState(FlowEntryState.REMOVED); |
| 250 | providerService.flowRemoved(fe1); |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 251 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, |
| 252 | RULE_ADDED, RULE_REMOVE_REQUESTED, RULE_REMOVED); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 253 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 254 | providerService.flowRemoved(fe1); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 255 | validateEvents(); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 256 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 257 | FlowRule f3 = flowRule(3, 3); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 258 | FlowEntry fe3 = new DefaultFlowEntry(f3); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 259 | service.applyFlowRules(f3); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 260 | providerService.pushFlowMetrics(DID, Collections.singletonList(fe3)); |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 261 | validateEvents(RULE_ADD_REQUESTED, RULE_ADDED); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 262 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 263 | providerService.flowRemoved(fe3); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 264 | validateEvents(); |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 265 | } |
| 266 | |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 267 | @Test |
| 268 | public void flowMetrics() { |
| 269 | FlowRule f1 = flowRule(1, 1); |
| 270 | FlowRule f2 = flowRule(2, 2); |
| 271 | FlowRule f3 = flowRule(3, 3); |
| 272 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 273 | mgr.applyFlowRules(f1, f2, f3); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 274 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 275 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 276 | FlowEntry fe2 = new DefaultFlowEntry(f2); |
| 277 | |
| 278 | |
| 279 | //FlowRule updatedF1 = flowRule(f1, FlowRuleState.ADDED); |
| 280 | //FlowRule updatedF2 = flowRule(f2, FlowRuleState.ADDED); |
| 281 | |
| 282 | providerService.pushFlowMetrics(DID, Lists.newArrayList(fe1, fe2)); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 283 | |
| 284 | assertTrue("Entries should be added.", |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 285 | validateState(ImmutableMap.of( |
| 286 | f1, FlowEntryState.ADDED, |
| 287 | f2, FlowEntryState.ADDED, |
| 288 | f3, FlowEntryState.PENDING_ADD))); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 289 | |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 290 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, |
| 291 | RULE_ADDED, RULE_ADDED); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | @Test |
| 295 | public void extraneousFlow() { |
| 296 | FlowRule f1 = flowRule(1, 1); |
| 297 | FlowRule f2 = flowRule(2, 2); |
| 298 | FlowRule f3 = flowRule(3, 3); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 299 | mgr.applyFlowRules(f1, f2); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 300 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 301 | // FlowRule updatedF1 = flowRule(f1, FlowRuleState.ADDED); |
| 302 | // FlowRule updatedF2 = flowRule(f2, FlowRuleState.ADDED); |
| 303 | // FlowRule updatedF3 = flowRule(f3, FlowRuleState.ADDED); |
| 304 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 305 | FlowEntry fe2 = new DefaultFlowEntry(f2); |
| 306 | FlowEntry fe3 = new DefaultFlowEntry(f3); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 307 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 308 | |
| 309 | providerService.pushFlowMetrics(DID, Lists.newArrayList(fe1, fe2, fe3)); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 310 | |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 311 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 312 | |
| 313 | } |
| 314 | |
| 315 | /* |
| 316 | * Tests whether a rule that was marked for removal but no flowRemoved was received |
| 317 | * is indeed removed at the next stats update. |
| 318 | */ |
| 319 | @Test |
| 320 | public void flowMissingRemove() { |
| 321 | FlowRule f1 = flowRule(1, 1); |
| 322 | FlowRule f2 = flowRule(2, 2); |
| 323 | FlowRule f3 = flowRule(3, 3); |
| 324 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 325 | // FlowRule updatedF1 = flowRule(f1, FlowRuleState.ADDED); |
| 326 | // FlowRule updatedF2 = flowRule(f2, FlowRuleState.ADDED); |
| 327 | |
| 328 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 329 | FlowEntry fe2 = new DefaultFlowEntry(f2); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 330 | mgr.applyFlowRules(f1, f2, f3); |
| 331 | |
| 332 | mgr.removeFlowRules(f3); |
| 333 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 334 | providerService.pushFlowMetrics(DID, Lists.newArrayList(fe1, fe2)); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 335 | |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 336 | validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, |
| 337 | RULE_REMOVE_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_REMOVED); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 338 | |
| 339 | } |
| 340 | |
| 341 | @Test |
| 342 | public void getByAppId() { |
| 343 | FlowRule f1 = flowRule(1, 1); |
| 344 | FlowRule f2 = flowRule(2, 2); |
| 345 | mgr.applyFlowRules(f1, f2); |
| 346 | |
| 347 | assertTrue("should have two rules", |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 348 | Lists.newLinkedList(mgr.getFlowRulesById(appId)).size() == 2); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | @Test |
| 352 | public void removeByAppId() { |
| 353 | FlowRule f1 = flowRule(1, 1); |
| 354 | FlowRule f2 = flowRule(2, 2); |
| 355 | mgr.applyFlowRules(f1, f2); |
| 356 | |
| 357 | |
| 358 | mgr.removeFlowRulesById(appId); |
| 359 | |
| 360 | //only check that we are in pending remove. Events and actual remove state will |
| 361 | // be set by flowRemoved call. |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 362 | validateState(ImmutableMap.of( |
| 363 | f1, FlowEntryState.PENDING_REMOVE, |
| 364 | f2, FlowEntryState.PENDING_REMOVE)); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 365 | } |
| 366 | |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 367 | @Test |
| 368 | public void applyBatch() { |
| 369 | FlowRule f1 = flowRule(1, 1); |
| 370 | FlowRule f2 = flowRule(2, 2); |
| 371 | |
| 372 | |
| 373 | mgr.applyFlowRules(f1); |
| 374 | |
| 375 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 376 | providerService.pushFlowMetrics(DID, Collections.<FlowEntry>singletonList(fe1)); |
| 377 | |
| 378 | FlowRuleBatchEntry fbe1 = new FlowRuleBatchEntry( |
| 379 | FlowRuleBatchEntry.FlowRuleOperation.REMOVE, f1); |
| 380 | |
| 381 | FlowRuleBatchEntry fbe2 = new FlowRuleBatchEntry( |
| 382 | FlowRuleBatchEntry.FlowRuleOperation.ADD, f2); |
| 383 | |
| 384 | FlowRuleBatchOperation fbo = new FlowRuleBatchOperation( |
| 385 | Lists.newArrayList(fbe1, fbe2)); |
| 386 | Future<CompletedBatchOperation> future = mgr.applyBatch(fbo); |
| 387 | assertTrue("Entries in wrong state", |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 388 | validateState(ImmutableMap.of( |
| 389 | f1, FlowEntryState.PENDING_REMOVE, |
| 390 | f2, FlowEntryState.PENDING_ADD))); |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 391 | CompletedBatchOperation completed = null; |
| 392 | try { |
| 393 | completed = future.get(); |
| 394 | } catch (InterruptedException | ExecutionException e) { |
| 395 | fail("Unexpected exception: " + e); |
| 396 | } |
| 397 | if (!completed.isSuccess()) { |
| 398 | fail("Installation should be a success"); |
| 399 | } |
| 400 | |
| 401 | } |
| 402 | |
| 403 | @Test |
| 404 | public void cancelBatch() { |
| 405 | FlowRule f1 = flowRule(1, 1); |
| 406 | FlowRule f2 = flowRule(2, 2); |
| 407 | |
| 408 | |
| 409 | mgr.applyFlowRules(f1); |
| 410 | |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 411 | assertTrue("Entries in wrong state", |
| 412 | validateState(ImmutableMap.of( |
| 413 | f1, FlowEntryState.PENDING_ADD))); |
| 414 | |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 415 | FlowEntry fe1 = new DefaultFlowEntry(f1); |
| 416 | providerService.pushFlowMetrics(DID, Collections.<FlowEntry>singletonList(fe1)); |
| 417 | |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 418 | assertTrue("Entries in wrong state", |
| 419 | validateState(ImmutableMap.of( |
| 420 | f1, FlowEntryState.ADDED))); |
| 421 | |
| 422 | |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 423 | FlowRuleBatchEntry fbe1 = new FlowRuleBatchEntry( |
| 424 | FlowRuleBatchEntry.FlowRuleOperation.REMOVE, f1); |
| 425 | |
| 426 | FlowRuleBatchEntry fbe2 = new FlowRuleBatchEntry( |
| 427 | FlowRuleBatchEntry.FlowRuleOperation.ADD, f2); |
| 428 | |
| 429 | FlowRuleBatchOperation fbo = new FlowRuleBatchOperation( |
| 430 | Lists.newArrayList(fbe1, fbe2)); |
| 431 | Future<CompletedBatchOperation> future = mgr.applyBatch(fbo); |
| 432 | |
| 433 | future.cancel(true); |
| 434 | |
| 435 | assertTrue(flowCount() == 2); |
| 436 | |
| 437 | /* |
| 438 | * Rule f1 should be re-added to the list and therefore be in a pending add |
| 439 | * state. |
| 440 | */ |
| 441 | assertTrue("Entries in wrong state", |
Yuta HIGUCHI | 605347c | 2014-10-17 21:05:23 -0700 | [diff] [blame] | 442 | validateState(ImmutableMap.of( |
| 443 | f2, FlowEntryState.PENDING_REMOVE, |
| 444 | f1, FlowEntryState.PENDING_ADD))); |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 445 | |
| 446 | |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | |
| 450 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 451 | private static class TestListener implements FlowRuleListener { |
| 452 | final List<FlowRuleEvent> events = new ArrayList<>(); |
| 453 | |
| 454 | @Override |
| 455 | public void event(FlowRuleEvent event) { |
| 456 | events.add(event); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | private static class TestDeviceService implements DeviceService { |
| 461 | |
| 462 | @Override |
| 463 | public int getDeviceCount() { |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | @Override |
| 468 | public Iterable<Device> getDevices() { |
| 469 | return null; |
| 470 | } |
| 471 | |
| 472 | @Override |
| 473 | public Device getDevice(DeviceId deviceId) { |
| 474 | return DEV; |
| 475 | } |
| 476 | |
| 477 | @Override |
| 478 | public MastershipRole getRole(DeviceId deviceId) { |
| 479 | return null; |
| 480 | } |
| 481 | |
| 482 | @Override |
| 483 | public List<Port> getPorts(DeviceId deviceId) { |
| 484 | return null; |
| 485 | } |
| 486 | |
| 487 | @Override |
| 488 | public Port getPort(DeviceId deviceId, PortNumber portNumber) { |
| 489 | return null; |
| 490 | } |
| 491 | |
| 492 | @Override |
| 493 | public boolean isAvailable(DeviceId deviceId) { |
| 494 | return false; |
| 495 | } |
| 496 | |
| 497 | @Override |
| 498 | public void addListener(DeviceListener listener) { |
| 499 | } |
| 500 | |
| 501 | @Override |
| 502 | public void removeListener(DeviceListener listener) { |
| 503 | } |
| 504 | |
| 505 | } |
| 506 | |
| 507 | private class TestProvider extends AbstractProvider implements FlowRuleProvider { |
| 508 | |
| 509 | protected TestProvider(ProviderId id) { |
| 510 | super(PID); |
| 511 | } |
| 512 | |
| 513 | @Override |
| 514 | public void applyFlowRule(FlowRule... flowRules) { |
| 515 | } |
| 516 | |
| 517 | @Override |
| 518 | public void removeFlowRule(FlowRule... flowRules) { |
| 519 | } |
| 520 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 521 | @Override |
| 522 | public void removeRulesById(ApplicationId id, FlowRule... flowRules) { |
| 523 | } |
| 524 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 525 | @Override |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 526 | public ListenableFuture<CompletedBatchOperation> executeBatch( |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 527 | BatchOperation<FlowRuleBatchEntry> batch) { |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 528 | return new TestInstallationFuture(); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 529 | } |
| 530 | |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 531 | private class TestInstallationFuture |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 532 | implements ListenableFuture<CompletedBatchOperation> { |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 533 | |
| 534 | @Override |
| 535 | public boolean cancel(boolean mayInterruptIfRunning) { |
| 536 | return true; |
| 537 | } |
| 538 | |
| 539 | @Override |
| 540 | public boolean isCancelled() { |
| 541 | return true; |
| 542 | } |
| 543 | |
| 544 | @Override |
| 545 | public boolean isDone() { |
| 546 | return false; |
| 547 | } |
| 548 | |
| 549 | @Override |
| 550 | public CompletedBatchOperation get() |
| 551 | throws InterruptedException, ExecutionException { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 552 | return new CompletedBatchOperation(true, Collections.<FlowEntry>emptySet()); |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | @Override |
| 556 | public CompletedBatchOperation get(long timeout, TimeUnit unit) |
| 557 | throws InterruptedException, |
| 558 | ExecutionException, TimeoutException { |
| 559 | return null; |
| 560 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 561 | |
| 562 | @Override |
| 563 | public void addListener(Runnable task, Executor executor) { |
| 564 | // TODO: add stuff. |
| 565 | } |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 566 | } |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 567 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | private class TestSelector implements TrafficSelector { |
| 571 | |
| 572 | //for controlling hashcode uniqueness; |
alshabib | 9704490 | 2014-09-18 14:52:16 -0700 | [diff] [blame] | 573 | private final int testval; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 574 | |
| 575 | public TestSelector(int val) { |
| 576 | testval = val; |
| 577 | } |
| 578 | |
| 579 | @Override |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 580 | public Set<Criterion> criteria() { |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 581 | return null; |
| 582 | } |
| 583 | |
| 584 | @Override |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 585 | public Criterion getCriterion( |
| 586 | org.onlab.onos.net.flow.criteria.Criterion.Type type) { |
| 587 | return null; |
| 588 | } |
| 589 | |
| 590 | @Override |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 591 | public int hashCode() { |
| 592 | return testval; |
| 593 | } |
| 594 | |
| 595 | @Override |
| 596 | public boolean equals(Object o) { |
| 597 | if (o instanceof TestSelector) { |
| 598 | return this.testval == ((TestSelector) o).testval; |
| 599 | } |
| 600 | return false; |
| 601 | } |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 602 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | private class TestTreatment implements TrafficTreatment { |
| 606 | |
| 607 | //for controlling hashcode uniqueness; |
alshabib | 9704490 | 2014-09-18 14:52:16 -0700 | [diff] [blame] | 608 | private final int testval; |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 609 | |
| 610 | public TestTreatment(int val) { |
| 611 | testval = val; |
| 612 | } |
| 613 | |
| 614 | @Override |
| 615 | public List<Instruction> instructions() { |
| 616 | return null; |
| 617 | } |
| 618 | |
| 619 | @Override |
| 620 | public int hashCode() { |
| 621 | return testval; |
| 622 | } |
| 623 | |
| 624 | @Override |
| 625 | public boolean equals(Object o) { |
| 626 | if (o instanceof TestTreatment) { |
| 627 | return this.testval == ((TestTreatment) o).testval; |
| 628 | } |
| 629 | return false; |
| 630 | } |
| 631 | |
| 632 | } |
| 633 | |
alshabib | 92c65ad | 2014-10-08 21:56:05 -0700 | [diff] [blame] | 634 | public class TestApplicationId extends DefaultApplicationId { |
| 635 | |
| 636 | public TestApplicationId(short id, String name) { |
| 637 | super(id, name); |
| 638 | } |
| 639 | } |
| 640 | |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 641 | } |