You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2018/07/10 04:00:43 UTC
[1/2] storm git commit: STORM-3056: Add a test for quickly rebinding
to a port
Repository: storm
Updated Branches:
refs/heads/master 9109b617b -> 2d7c7d316
STORM-3056: Add a test for quickly rebinding to a port
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/1ee9558d
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/1ee9558d
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/1ee9558d
Branch: refs/heads/master
Commit: 1ee9558d9ae356e4d332dd57c79debd89b147634
Parents: db86bad
Author: Raghav Kumar Gautam <ra...@apache.org>
Authored: Fri Jul 6 15:37:04 2018 -0700
Committer: Raghav Kumar Gautam <ra...@apache.org>
Committed: Fri Jul 6 15:37:04 2018 -0700
----------------------------------------------------------------------
.../apache/storm/messaging/netty/NettyTest.java | 39 ++++++++++++++++++++
1 file changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/1ee9558d/storm-core/test/jvm/org/apache/storm/messaging/netty/NettyTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/messaging/netty/NettyTest.java b/storm-core/test/jvm/org/apache/storm/messaging/netty/NettyTest.java
index 702f58e..4b84e55 100644
--- a/storm-core/test/jvm/org/apache/storm/messaging/netty/NettyTest.java
+++ b/storm-core/test/jvm/org/apache/storm/messaging/netty/NettyTest.java
@@ -17,6 +17,7 @@
package org.apache.storm.messaging.netty;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThat;
import java.nio.charset.StandardCharsets;
@@ -45,6 +46,7 @@ import org.apache.storm.messaging.TaskMessage;
import org.apache.storm.messaging.TransportFactory;
import org.apache.storm.utils.Utils;
import org.junit.Test;
+import org.mockito.internal.matchers.LessThan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -398,4 +400,41 @@ public class NettyTest {
public void testServerAlwaysReconnectsWithSasl() throws Exception {
doTestServerAlwaysReconnects(withSaslConf(basicConf()));
}
+
+ private void connectToFixedPort(Map<String, Object> stormConf, int port) throws Exception {
+ LOG.info("7. Should be able to rebind to a port quickly");
+ String reqMessage = "0123456789abcdefghijklmnopqrstuvwxyz";
+ IContext context = TransportFactory.makeContext(stormConf);
+ try {
+ AtomicReference<TaskMessage> response = new AtomicReference<>();
+ try (IConnection server = context.bind(null, port);
+ IConnection client = context.connect(null, "localhost", server.getPort(), remoteBpStatus)) {
+ server.registerRecv(mkConnectionCallback(response::set));
+ waitUntilReady(client, server);
+ byte[] messageBytes = reqMessage.getBytes(StandardCharsets.UTF_8);
+
+ send(client, taskId, messageBytes);
+
+ waitForNotNull(response);
+ TaskMessage responseMessage = response.get();
+ assertThat(responseMessage.task(), is(taskId));
+ assertThat(responseMessage.message(), is(messageBytes));
+ }
+ } finally {
+ context.term();
+ }
+ }
+
+ @Test
+ public void testRebind() throws Exception {
+ for (int i = 0; i < 10; ++i) {
+ final long startTime = System.nanoTime();
+ LOG.info("Binding to port 6700 iter: " + (i+1));
+ connectToFixedPort(basicConf(), 6700);
+ final long endTime = System.nanoTime();
+ LOG.info("Expected time taken should be less than 5 sec, actual time is: " + (endTime-startTime)/1_000_000 + " ms");
+ assertThat((endTime-startTime)/1_000_000, lessThan(5_000L));
+ }
+ }
+
}
[2/2] storm git commit: Merge branch 'master' of
https://github.com/raghavgautam/storm into STORM-3056-merge
Posted by ka...@apache.org.
Merge branch 'master' of https://github.com/raghavgautam/storm into STORM-3056-merge
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/2d7c7d31
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/2d7c7d31
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/2d7c7d31
Branch: refs/heads/master
Commit: 2d7c7d31679b16a8797f39ff3f1c8df2b63952d7
Parents: 9109b61 1ee9558
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue Jul 10 13:00:34 2018 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Tue Jul 10 13:00:34 2018 +0900
----------------------------------------------------------------------
.../apache/storm/messaging/netty/NettyTest.java | 39 ++++++++++++++++++++
1 file changed, 39 insertions(+)
----------------------------------------------------------------------