summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortoby <smorgrav@yahoo-inc.com>2018-03-06 14:57:21 +0100
committertoby <smorgrav@yahoo-inc.com>2018-03-06 14:57:21 +0100
commitdb18ddbeb1342ac9726061b570bd61fe69cf5526 (patch)
tree4cd3f62b981712a9a43a2abc6f0bf076ab71a078
parent71408b1fbf2a72987384a62ded3ee3b8aa16773f (diff)
Update tests after IPAddresses refactoring and do prefixtranslation on byte granularity
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java4
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java3
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/network/IPAddressesTest.java18
3 files changed, 17 insertions, 8 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
index 8496d968730..938da553d9d 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
@@ -99,14 +99,14 @@ public class DockerOperationsImpl implements DockerOperations {
Inet6Address ipV6Address = this.retriever.getIPv6Address(nodeSpec.hostname).orElseThrow(
() -> new RuntimeException("Unable to find a valid IPv6 address. Missing an AAAA DNS entry?"));
InetAddress ipV6Prefix = InetAddress.getByName(IPV6_NPT_PREFIX);
- InetAddress ipV6Local = IPAddresses.prefixTranslate(ipV6Address, ipV6Prefix, 64);
+ InetAddress ipV6Local = IPAddresses.prefixTranslate(ipV6Address, ipV6Prefix, 8);
command.withIpAddress(ipV6Local);
// IPv4 - Only present for some containers
Optional<Inet4Address> ipV4Address = this.retriever.getIPv4Address(nodeSpec.hostname);
if (ipV4Address.isPresent()) {
InetAddress ipV4Prefix = InetAddress.getByName(IPV4_NPT_PREFIX);
- InetAddress ipV4Local = IPAddresses.prefixTranslate(ipV4Address.get(), ipV4Prefix, 16);
+ InetAddress ipV4Local = IPAddresses.prefixTranslate(ipV4Address.get(), ipV4Prefix, 2);
command.withIpAddress(ipV4Local);
}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java
index 2968c1737a8..ba176305173 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java
@@ -15,6 +15,7 @@ import com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminStateUpdaterImpl;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl;
import com.yahoo.vespa.hosted.node.admin.component.Environment;
+import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddressesImpl;
import com.yahoo.vespa.hosted.node.admin.util.InetAddressResolver;
import com.yahoo.vespa.hosted.node.admin.component.PathResolver;
@@ -65,7 +66,7 @@ public class DockerTester implements AutoCloseable {
.pathResolver(new PathResolver(pathToVespaHome, Paths.get("/tmp"), Paths.get("/tmp")))
.build();
Clock clock = Clock.systemUTC();
- DockerOperations dockerOperations = new DockerOperationsImpl(dockerMock, environment, null);
+ DockerOperations dockerOperations = new DockerOperationsImpl(dockerMock, environment, null, new IPAddressesImpl());
StorageMaintainerMock storageMaintainer = new StorageMaintainerMock(dockerOperations, null, environment, callOrderVerifier, clock);
AclMaintainer aclMaintainer = mock(AclMaintainer.class);
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/network/IPAddressesTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/network/IPAddressesTest.java
index cac05bcf96c..71f02364afa 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/network/IPAddressesTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/network/IPAddressesTest.java
@@ -21,7 +21,7 @@ public class IPAddressesTest {
.addAddress("localhost", "fe80::1")
.addAddress("localhost", "2001::1");
- Assert.assertEquals("10.0.2.2", mock.getIPv4Address("localhost"));
+ Assert.assertTrue(equals("10.0.2.2", mock.getIPv4Address("localhost").get()));
}
@Test
@@ -31,7 +31,7 @@ public class IPAddressesTest {
.addAddress("localhost", "fe80::1")
.addAddress("localhost", "2001::1");
- Assert.assertEquals("2001::1", mock.getIPv6Address("localhost"));
+ Assert.assertTrue(equals("2001::1", mock.getIPv6Address("localhost").get()));
}
@Test(expected = RuntimeException.class)
@@ -55,17 +55,25 @@ public class IPAddressesTest {
// Test simplest possible address
Inet6Address original = (Inet6Address) InetAddress.getByName("2001:db8::1");
Inet6Address prefix = (Inet6Address) InetAddress.getByName("fd00::");
- InetAddress translated = IPAddresses.prefixTranslate(original, prefix, 64);
+ InetAddress translated = IPAddresses.prefixTranslate(original, prefix, 8);
Assert.assertEquals("fd00:0:0:0:0:0:0:1", translated.getHostAddress());
// Test an actual aws address we use
original = (Inet6Address) InetAddress.getByName("2600:1f16:f34:5300:ccc6:1703:b7c2:369d");
- translated = IPAddresses.prefixTranslate(original, prefix, 64);
+ translated = IPAddresses.prefixTranslate(original, prefix, 8);
Assert.assertEquals("fd00:0:0:0:ccc6:1703:b7c2:369d", translated.getHostAddress());
// Test different subnet size
- translated = IPAddresses.prefixTranslate(original, prefix, 48);
+ translated = IPAddresses.prefixTranslate(original, prefix, 6);
Assert.assertEquals("fd00:0:0:5300:ccc6:1703:b7c2:369d", translated.getHostAddress());
}
+
+ boolean equals(String a, InetAddress b) {
+ try {
+ return InetAddress.getByName(a).equals(b);
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ }
}