You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by ch...@apache.org on 2015/02/19 21:16:48 UTC
[4/8] incubator-twill git commit: (TWILL-113) Fix ZK related
unit-tests in Travis-CI
(TWILL-113) Fix ZK related unit-tests in Travis-CI
Introduced a new system property, "twill.zk.server.localhost" for InMemoryZKServer to determine if it binds to localhost or any host.
Signed-off-by: Terence Yim <ch...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-twill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-twill/commit/0bdf1968
Tree: http://git-wip-us.apache.org/repos/asf/incubator-twill/tree/0bdf1968
Diff: http://git-wip-us.apache.org/repos/asf/incubator-twill/diff/0bdf1968
Branch: refs/heads/site
Commit: 0bdf1968856366d7521947421b9c67772ecbb52c
Parents: e45db18
Author: Terence Yim <ch...@apache.org>
Authored: Mon Jan 26 16:00:22 2015 -0800
Committer: Terence Yim <ch...@apache.org>
Committed: Thu Feb 19 12:15:05 2015 -0800
----------------------------------------------------------------------
.travis.yml | 2 +-
.../apache/twill/internal/zookeeper/InMemoryZKServer.java | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/0bdf1968/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index d5fe88b..3ed78f2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,7 +27,7 @@ branches:
- /^branch\-.*$/
- /^feature\/.*$/
-script: mvn test -P $PROFILE -Dsurefire.redirectTestOutputToFile=false
+script: mvn test -P $PROFILE -Dsurefire.redirectTestOutputToFile=false -Dtwill.zk.server.localhost=false
install: mvn install -P $PROFILE -DskipTests=true
http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/0bdf1968/twill-zookeeper/src/main/java/org/apache/twill/internal/zookeeper/InMemoryZKServer.java
----------------------------------------------------------------------
diff --git a/twill-zookeeper/src/main/java/org/apache/twill/internal/zookeeper/InMemoryZKServer.java b/twill-zookeeper/src/main/java/org/apache/twill/internal/zookeeper/InMemoryZKServer.java
index c4eed59..f962b68 100644
--- a/twill-zookeeper/src/main/java/org/apache/twill/internal/zookeeper/InMemoryZKServer.java
+++ b/twill-zookeeper/src/main/java/org/apache/twill/internal/zookeeper/InMemoryZKServer.java
@@ -104,8 +104,14 @@ public final class InMemoryZKServer implements Service {
private InetSocketAddress getAddress(int port) {
try {
-// return new InetSocketAddress(InetAddress.getByAddress(new byte[] {127, 0, 0, 1}), port < 0 ? 0 : port);
- return new InetSocketAddress(InetAddress.getLocalHost(), port < 0 ? 0 : port);
+ int socketPort = port < 0 ? 0 : port;
+ // This property is needed so that in certain CI environment (e.g. Travis-CI) it can only works properly if
+ // it is binded to the wildcard (0.0.0.0) address
+ if (Boolean.parseBoolean(System.getProperties().getProperty("twill.zk.server.localhost", "true"))) {
+ return new InetSocketAddress(InetAddress.getLocalHost(), socketPort);
+ } else {
+ return new InetSocketAddress(socketPort);
+ }
} catch (UnknownHostException e) {
throw Throwables.propagate(e);
}