General Test related fixes
- Enable console output during test run.
There were sign of test code bugs in those messages.
Exposing them to console to catch them early.
- Add default LogBack configuration used while unit-test run.
log level currently set to WARN
- Configured hazelcast to follow the above.
- BugFix: ControllerTest.java
-- Stop starting LinkDiscovery, which was starting a thread
not necessary for the test case
-- notifyAll must be called in synchronized block
Change-Id: Ica94dfc3a46a871b69800615e75232107b06771e
diff --git a/pom.xml b/pom.xml
index 6a07d5a..29b8520 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,8 +130,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
- <argLine>-XX:MaxPermSize=256m</argLine>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <argLine>-XX:MaxPermSize=256m -Dhazelcast.logging.type=slf4j</argLine>
+ <redirectTestOutputToFile>false</redirectTestOutputToFile>
<excludedGroups>net.onrc.onos.core.util.IntegrationTest</excludedGroups>
</configuration>
</plugin>
diff --git a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
index eb63904..617ee65 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
@@ -131,7 +131,7 @@
cm.startUp(fmc);
tp.startUp(fmc);
sr.startUp(fmc);
- linkDiscovery.startUp(fmc);
+ //linkDiscovery.startUp(fmc);
}
public Controller getController() {
@@ -177,6 +177,7 @@
* Run the controller's main loop so that updates are processed
*/
protected class ControllerRunThread extends Thread {
+ @Override
public void run() {
controller.openFlowPort = 0; // Don't listen
controller.run();
@@ -412,22 +413,25 @@
nPortChanged = 0;
}
+ @Override
public synchronized void addedSwitch(IOFSwitch sw) {
nAdded++;
notifyAll();
}
+ @Override
public synchronized void removedSwitch(IOFSwitch sw) {
nRemoved++;
notifyAll();
}
+ @Override
public String getName() {
return "dummy";
}
@Override
- public void switchPortChanged(Long switchId) {
+ public synchronized void switchPortChanged(Long switchId) {
nPortChanged++;
notifyAll();
}
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..791b236
--- /dev/null
+++ b/src/test/resources/logback-test.xml
@@ -0,0 +1,19 @@
+<configuration scan="true" debug="false">
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${basedir}/onos-logs/test.log</file>
+ <encoder>
+ <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
+ <immediateFlush>false</immediateFlush>
+ </encoder>
+ </appender>
+
+ <logger name="org" level="WARN"/>
+ <logger name="LogService" level="WARN"/> <!-- Restlet access logging -->
+ <logger name="net.floodlightcontroller.logging" level="WARN"/>
+ <logger name="com.hazelcast" level="WARN"/>
+
+ <root level="TRACE">
+ <appender-ref ref="FILE" />
+ </root>
+</configuration>
+