Suppress unnecessary PathIntent operations when rerouting
Change-Id: If06fc6937d5a69f4f5ff829dbff5103b0fa1736d
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
index c9e2115..8b374ee 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
@@ -449,7 +449,7 @@
final IntentOperationList pathIntentOpListAfterReroute =
runtime.executeIntentOperations(opListForReroute);
assertThat(pathIntentOpListAfterReroute, notNullValue());
- assertThat(pathIntentOpListAfterReroute, hasSize(2));
+ assertThat(pathIntentOpListAfterReroute, hasSize(0));
// Check the high level intents.
final IntentMap highLevelIntentsAfterReroute = runtime.getHighLevelIntents();
@@ -467,7 +467,7 @@
// Check the states of the high level intents
// Check that switch 1 was correctly processed
assertThat(highLevelIntents,
- hasIntentWithIdAndState("1", IntentState.REROUTE_REQ));
+ hasIntentWithIdAndState("1", IntentState.INST_ACK));
// Check that switch 2 was correctly processed
assertThat(highLevelIntents,
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
index 30e2845..bd42884 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
@@ -15,7 +15,6 @@
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.restserver.IRestApiService;
-
import net.onrc.onos.core.datagrid.IDatagridService;
import net.onrc.onos.core.datagrid.IEventChannel;
import net.onrc.onos.core.datagrid.IEventChannelListener;
@@ -274,10 +273,51 @@
removedLinkEvents,
addedDeviceEvents,
removedDeviceEvents);
- System.out.println("Link goes down.");
+ System.out.println("*** Link goes down. ***");
+
+ // send notification
+ IntentStateList isl = new IntentStateList();
+ isl.put("1___0", IntentState.DEL_ACK);
+ isl.put("1___1", IntentState.INST_ACK);
+ isl.domainSwitchDpids.add(1L);
+ isl.domainSwitchDpids.add(2L);
+ isl.domainSwitchDpids.add(4L);
+ runtime1.entryUpdated(isl);
// show results step2
showResult((PathIntentMap) runtime1.getPathIntents());
+
+ // link up
+ ((MockTopology) topology).addBidirectionalLinks(1L, 12L, 2L, 21L);
+ linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
+ linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
+ removedLinkEvents.clear();
+ addedLinkEvents.clear();
+ addedLinkEvents.add(linkEvent1);
+ addedLinkEvents.add(linkEvent2);
+ runtime1.topologyEvents(
+ addedSwitchEvents,
+ removedSwitchEvents,
+ addedPortEvents,
+ removedPortEvents,
+ addedLinkEvents,
+ removedLinkEvents,
+ addedDeviceEvents,
+ removedDeviceEvents);
+ System.out.println("*** Link goes up. ***");
+
+ // send notification
+ isl = new IntentStateList();
+ isl.put("1___1", IntentState.DEL_ACK);
+ isl.put("1___2", IntentState.INST_ACK);
+ isl.domainSwitchDpids.add(1L);
+ isl.domainSwitchDpids.add(2L);
+ isl.domainSwitchDpids.add(4L);
+ runtime1.entryUpdated(isl);
+
+ // show results step3
+ showResult((PathIntentMap) runtime1.getPathIntents());
+
// TODO: show results of plan computation
}