From ee0eb3cec23a5bd85dae6a126cf7b0466605496c Mon Sep 17 00:00:00 2001 From: meiyangbigswitch <mei.yang@bigswitch.com> Date: Thu, 18 Oct 2012 17:34:02 -0700 Subject: [PATCH] fix the junit test failure --- .../net/floodlightcontroller/core/internal/Controller.java | 6 ++++-- .../floodlightcontroller/core/internal/ControllerTest.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 5abc1df62..e95cc5e16 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -827,7 +827,9 @@ public class Controller implements IFloodlightProviderService, // flow-table. The end result would be that the flow // table for a newly connected switch is never // flushed. Not sure how to handle that case though... - sw.clearAllFlowMods(); + if (!isActive){ + sw.clearAllFlowMods(); + } log.debug("First role reply from master switch {}, " + "clear FlowTable to active switch list", HexString.toHexString(sw.getId())); @@ -848,7 +850,7 @@ public class Controller implements IFloodlightProviderService, HexString.toHexString(sw.getId())); } - else if (isActive && !sw.isActive()) { + else if (isActive) { // Transition from MASTER to SLAVE: remove switch // from active switch list. log.debug("Removed slave switch {} from active switch" + diff --git a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java index fb063df4c..8d4bcbea4 100644 --- a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java +++ b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java @@ -1163,7 +1163,7 @@ public class ControllerTest extends FloodlightTestCase { expect(chdlr.sw.getStringId()).andReturn("00:00:00:00:00:00:00:01") .anyTimes(); controller.activeSwitches.put(1L, chdlr.sw); - expect(chdlr.sw.isActive()).andReturn(false); + expect(chdlr.sw.isActive()).andReturn(false).anyTimes(); expect(chdlr.sw.isConnected()).andReturn(true); chdlr.sw.cancelAllStatisticsReplies(); chdlr.state.firstRoleReplyReceived = false; -- GitLab