diff options
Diffstat (limited to 'node-repository/src/test/java/com')
-rw-r--r-- | node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java index 88fe88dbaad..ecf7697f781 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.provision.node; import com.google.common.collect.ImmutableSet; +import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeFlavors; import com.yahoo.config.provision.NodeType; @@ -29,9 +30,12 @@ public class IPTest { private static final NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default"); private static final LockedNodeList emptyList = new LockedNodeList(List.of(), () -> {}); - private final MockNameResolver resolver = new MockNameResolver().explicitReverseRecords(); + private IP.Allocation.Context contextOf(boolean exclave) { + return IP.Allocation.Context.from(CloudName.AWS, exclave, resolver); + } + @Test public void test_natural_order() { Set<String> ipAddresses = Set.of( @@ -85,7 +89,8 @@ public class IPTest { resolver.addReverseRecord("::1", "host3"); resolver.addReverseRecord("::2", "host1"); - Optional<IP.Allocation> allocation = pool.findAllocation(emptyList, resolver, true); + var context = contextOf(false); + Optional<IP.Allocation> allocation = pool.findAllocation(context, emptyList); assertEquals(Optional.of("::1"), allocation.get().ipv6Address()); assertFalse(allocation.get().ipv4Address().isPresent()); assertEquals("host3", allocation.get().hostname()); @@ -93,7 +98,7 @@ public class IPTest { // Allocation fails if DNS record is missing resolver.removeRecord("host3"); try { - pool.findAllocation(emptyList, resolver, true); + pool.findAllocation(context, emptyList); fail("Expected exception"); } catch (Exception e) { assertEquals("java.net.UnknownHostException: Could not resolve: host3", e.getMessage()); @@ -103,7 +108,7 @@ public class IPTest { @Test public void test_find_allocation_ipv4_only() { var pool = testPool(false); - var allocation = pool.findAllocation(emptyList, resolver, true); + var allocation = pool.findAllocation(contextOf(false), emptyList); assertFalse("Found allocation", allocation.isEmpty()); assertEquals(Optional.of("127.0.0.1"), allocation.get().ipv4Address()); assertTrue("No IPv6 address", allocation.get().ipv6Address().isEmpty()); @@ -112,7 +117,7 @@ public class IPTest { @Test public void test_find_allocation_dual_stack() { IP.Pool pool = testPool(true); - Optional<IP.Allocation> allocation = pool.findAllocation(emptyList, resolver, true); + Optional<IP.Allocation> allocation = pool.findAllocation(contextOf(false), emptyList); assertEquals(Optional.of("::1"), allocation.get().ipv6Address()); assertEquals("127.0.0.2", allocation.get().ipv4Address().get()); assertEquals("host3", allocation.get().hostname()); @@ -123,7 +128,7 @@ public class IPTest { IP.Pool pool = testPool(true); resolver.addRecord("host3", "127.0.0.127"); try { - pool.findAllocation(emptyList, resolver, true); + pool.findAllocation(contextOf(false), emptyList); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("Hostname host3 resolved to more than 1 IPv4 address: [127.0.0.2, 127.0.0.127]", @@ -137,7 +142,7 @@ public class IPTest { resolver.removeRecord("127.0.0.2") .addReverseRecord("127.0.0.2", "host5"); try { - pool.findAllocation(emptyList, resolver, true); + pool.findAllocation(contextOf(false), emptyList); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("Hostnames resolved from each IP address do not point to the same hostname " + @@ -158,7 +163,7 @@ public class IPTest { Set.of("2600:1f10:::2", "2600:1f10:::3"), List.of(HostName.of("node1"), HostName.of("node2"))); IP.Pool pool = config.pool(); - Optional<IP.Allocation> allocation = pool.findAllocation(emptyList, resolver, false); + Optional<IP.Allocation> allocation = pool.findAllocation(contextOf(true), emptyList); } private IP.Pool testPool(boolean dualStack) { @@ -193,7 +198,7 @@ public class IPTest { } IP.Pool pool = node.ipConfig().pool(); - assertNotEquals(dualStack, pool.ipAddresses().protocol() == IP.IpAddresses.Protocol.ipv4); + assertNotEquals(dualStack, pool.ipAddresses().stack() == IP.IpAddresses.Stack.ipv4); return pool; } |