summaryrefslogtreecommitdiffstats
path: root/zkfacade/src/test
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2018-01-12 11:33:56 +0100
committerHåkon Hallingstad <hakon@oath.com>2018-01-12 11:33:56 +0100
commit6d7cec2dbeaae824a2163fef7167f53d7f8bb934 (patch)
tree75b36b8b3675442d63684314a6aaa4eadb366bec /zkfacade/src/test
parenta6442d127d3bd311542842cdee2ee6dbba7b3629 (diff)
Build proper connect string instead of just hostname
Diffstat (limited to 'zkfacade/src/test')
-rw-r--r--zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
index 2fc4c2a7fc4..c5227fcbaa5 100644
--- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
+++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.curator;
import com.yahoo.cloud.config.ConfigserverConfig;
+import com.yahoo.net.HostName;
import org.apache.curator.test.TestingServer;
import org.junit.After;
import org.junit.Before;
@@ -72,6 +73,22 @@ public class CuratorTest {
}
}
+ @Test
+ public void localhost_affinity() {
+ String localhostHostName = "myhost";
+ int localhostPort = 123;
+
+ ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
+ builder.zookeeperserver(createZKBuilder(localhostHostName, localhostPort));
+ builder.zookeeperserver(createZKBuilder("otherhost", 345));
+ ConfigserverConfig config = new ConfigserverConfig(builder);
+
+ HostName.setHostNameForTestingOnly(localhostHostName);
+
+ String localhostSpec = localhostHostName + ":" + localhostPort;
+ assertThat(Curator.createConnectionSpecForLocalhost(config), is(localhostSpec));
+ }
+
private ConfigserverConfig createTestConfig() {
ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
builder.zookeeperserver(createZKBuilder("localhost", port1));