Corrected some IO loop tests.
diff --git a/utils/nio/src/test/java/org/onlab/nio/IOLoopIntegrationTest.java b/utils/nio/src/test/java/org/onlab/nio/IOLoopIntegrationTest.java
index b7f706e..e61f6e2 100644
--- a/utils/nio/src/test/java/org/onlab/nio/IOLoopIntegrationTest.java
+++ b/utils/nio/src/test/java/org/onlab/nio/IOLoopIntegrationTest.java
@@ -1,12 +1,12 @@
package org.onlab.nio;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import java.net.InetAddress;
-import java.text.DecimalFormat;
import java.util.Random;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import static org.onlab.junit.TestTools.delay;
@@ -15,55 +15,51 @@
*/
public class IOLoopIntegrationTest {
- private static final int MILLION = 1000000;
- private static final int TIMEOUT = 60;
-
private static final int THREADS = 6;
- private static final int MSG_COUNT = 20 * MILLION;
- private static final int MSG_SIZE = 128;
+ private static final int TIMEOUT = 60;
+ private static final int MESSAGE_LENGTH = 128;
- private static final long MIN_MPS = 10 * MILLION;
+ private static final int MILLION = 1000000;
+ private static final int MSG_COUNT = 40 * MILLION;
@Before
public void warmUp() throws Exception {
+ Logger.getLogger("").setLevel(Level.SEVERE);
try {
- run(MILLION, MSG_SIZE, 15, 0);
+ runTest(MILLION, MESSAGE_LENGTH, 15);
} catch (Throwable e) {
System.err.println("Failed warmup but moving on.");
e.printStackTrace();
}
}
- @Ignore
+
@Test
public void basic() throws Exception {
- run(MSG_COUNT, MSG_SIZE, TIMEOUT, MIN_MPS);
+ runTest(MILLION, MESSAGE_LENGTH, TIMEOUT);
}
+ public void longHaul() throws Exception {
+ runTest(MSG_COUNT, MESSAGE_LENGTH, TIMEOUT);
+ }
- private void run(int count, int size, int timeout, double mps) throws Exception {
- DecimalFormat f = new DecimalFormat("#,##0");
- System.out.print(f.format(count * THREADS) +
- (mps > 0.0 ? " messages: " : " message warm-up: "));
-
- // Setup the test on a random port to avoid intermittent test failures
- // due to the port being already bound.
- int port = IOLoopServer.PORT + new Random().nextInt(100);
+ private void runTest(int count, int size, int timeout) throws Exception {
+ // Use a random port to prevent conflicts.
+ int port = IOLoopTestServer.PORT + new Random().nextInt(100);
InetAddress ip = InetAddress.getLoopbackAddress();
- IOLoopServer sss = new IOLoopServer(ip, THREADS, size, port);
- IOLoopClient ssc = new IOLoopClient(ip, THREADS, count, size, port);
+ IOLoopTestServer server = new IOLoopTestServer(ip, THREADS, size, port);
+ IOLoopTestClient client = new IOLoopTestClient(ip, THREADS, count, size, port);
- sss.start();
- ssc.start();
- delay(250); // give the server and client a chance to go
+ server.start();
+ client.start();
+ delay(100); // Pause to allow loops to get going
- ssc.await(timeout);
- ssc.report();
+ client.await(timeout);
+ client.report();
- delay(1000);
- sss.stop();
- sss.report();
+ server.stop();
+ server.report();
}
}