Committed by
Gerrit Code Review
IntentPushTestCommand: ignore IntentEvent submitted by others
- Note: command must specify non-overlapping appId using 4th and 5th arguments Change-Id: I4dcfe57fc1d3de63c47e88d99d647b48ab80d86c
Showing
1 changed file
with
14 additions
and
3 deletions
... | @@ -17,6 +17,7 @@ package org.onosproject.cli.net; | ... | @@ -17,6 +17,7 @@ package org.onosproject.cli.net; |
17 | 17 | ||
18 | import com.google.common.collect.ArrayListMultimap; | 18 | import com.google.common.collect.ArrayListMultimap; |
19 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
20 | + | ||
20 | import org.apache.karaf.shell.commands.Argument; | 21 | import org.apache.karaf.shell.commands.Argument; |
21 | import org.apache.karaf.shell.commands.Command; | 22 | import org.apache.karaf.shell.commands.Command; |
22 | import org.apache.karaf.shell.commands.Option; | 23 | import org.apache.karaf.shell.commands.Option; |
... | @@ -41,7 +42,9 @@ import org.onlab.packet.Ethernet; | ... | @@ -41,7 +42,9 @@ import org.onlab.packet.Ethernet; |
41 | import org.onlab.packet.MacAddress; | 42 | import org.onlab.packet.MacAddress; |
42 | 43 | ||
43 | import java.util.EnumSet; | 44 | import java.util.EnumSet; |
45 | +import java.util.HashSet; | ||
44 | import java.util.List; | 46 | import java.util.List; |
47 | +import java.util.Set; | ||
45 | import java.util.concurrent.CountDownLatch; | 48 | import java.util.concurrent.CountDownLatch; |
46 | import java.util.concurrent.TimeUnit; | 49 | import java.util.concurrent.TimeUnit; |
47 | 50 | ||
... | @@ -100,6 +103,7 @@ public class IntentPushTestCommand extends AbstractShellCommand | ... | @@ -100,6 +103,7 @@ public class IntentPushTestCommand extends AbstractShellCommand |
100 | private int appIdBase; | 103 | private int appIdBase; |
101 | private int count; | 104 | private int count; |
102 | private boolean add; | 105 | private boolean add; |
106 | + private final Set<ApplicationId> myAppIds = new HashSet<>(); | ||
103 | 107 | ||
104 | @Override | 108 | @Override |
105 | protected void execute() { | 109 | protected void execute() { |
... | @@ -153,7 +157,7 @@ public class IntentPushTestCommand extends AbstractShellCommand | ... | @@ -153,7 +157,7 @@ public class IntentPushTestCommand extends AbstractShellCommand |
153 | for (int app = 0; app < apps; app++) { | 157 | for (int app = 0; app < apps; app++) { |
154 | for (int i = 1; i <= intentsPerApp; i++) { | 158 | for (int i = 1; i <= intentsPerApp; i++) { |
155 | TrafficSelector s = selector | 159 | TrafficSelector s = selector |
156 | - .matchEthSrc(MacAddress.valueOf(i + app * intentsPerApp)) | 160 | + .matchEthSrc(MacAddress.valueOf(i + (app + appIdBase) * intentsPerApp)) |
157 | .build(); | 161 | .build(); |
158 | intents.put(app, new PointToPointIntent(appId(app), s, treatment, | 162 | intents.put(app, new PointToPointIntent(appId(app), s, treatment, |
159 | ingress, egress)); | 163 | ingress, egress)); |
... | @@ -204,8 +208,11 @@ public class IntentPushTestCommand extends AbstractShellCommand | ... | @@ -204,8 +208,11 @@ public class IntentPushTestCommand extends AbstractShellCommand |
204 | * @return command-line application identifier | 208 | * @return command-line application identifier |
205 | */ | 209 | */ |
206 | protected ApplicationId appId(Integer id) { | 210 | protected ApplicationId appId(Integer id) { |
207 | - return get(CoreService.class).registerApplication("org.onosproject.cli-" | 211 | + ApplicationId appId = get(CoreService.class) |
208 | - + (id + appIdBase)); | 212 | + .registerApplication("org.onosproject.cli-" |
213 | + + (id + appIdBase)); | ||
214 | + myAppIds.add(appId); | ||
215 | + return appId; | ||
209 | } | 216 | } |
210 | 217 | ||
211 | /** | 218 | /** |
... | @@ -240,6 +247,10 @@ public class IntentPushTestCommand extends AbstractShellCommand | ... | @@ -240,6 +247,10 @@ public class IntentPushTestCommand extends AbstractShellCommand |
240 | = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ); | 247 | = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ); |
241 | @Override | 248 | @Override |
242 | public synchronized void event(IntentEvent event) { | 249 | public synchronized void event(IntentEvent event) { |
250 | + if (!myAppIds.contains(event.subject().appId())) { | ||
251 | + // not my event, ignore | ||
252 | + return; | ||
253 | + } | ||
243 | Type expected = add ? Type.INSTALLED : Type.WITHDRAWN; | 254 | Type expected = add ? Type.INSTALLED : Type.WITHDRAWN; |
244 | if (event.type() == expected) { | 255 | if (event.type() == expected) { |
245 | end = Math.max(end, event.time()); | 256 | end = Math.max(end, event.time()); | ... | ... |
-
Please register or login to post a comment