diff options
Diffstat (limited to 'node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance')
12 files changed, 247 insertions, 240 deletions
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java index 42661bdfdd0..d98ca5d84f2 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java @@ -14,8 +14,8 @@ import com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder; import com.yahoo.vespa.hosted.node.admin.task.util.fs.ContainerPath; import com.yahoo.vespa.hosted.node.admin.task.util.process.TestTerminal; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.FileSystem; @@ -29,7 +29,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -51,7 +51,7 @@ public class StorageMaintainerTest { fileSystem.getPath("/data/vespa/storage/container-archive")); @Test - public void testDiskUsed() { + void testDiskUsed() { NodeAgentContext context = NodeAgentContextImpl.builder("host-1.domain.tld").fileSystem(fileSystem).build(); terminal.expectCommand("du -xsk /data/vespa/storage/host-1 2>&1", 0, "321\t/data/vespa/storage/host-1/"); @@ -62,13 +62,13 @@ public class StorageMaintainerTest { } @Test - public void testNonExistingDiskUsed() { + void testNonExistingDiskUsed() { DiskSize size = storageMaintainer.getDiskUsed(null, Paths.get("/fake/path")); assertEquals(DiskSize.ZERO, size); } @Test - public void archive_container_data_test() throws IOException { + void archive_container_data_test() throws IOException { // Create some files in containers NodeAgentContext context1 = createNodeAgentContextAndContainerStorage(fileSystem, "container-1"); createNodeAgentContextAndContainerStorage(fileSystem, "container-2"); @@ -141,7 +141,7 @@ public class StorageMaintainerTest { } @Test - public void not_run_if_not_enough_used() throws IOException { + void not_run_if_not_enough_used() throws IOException { NodeAgentContext context = NodeAgentContextImpl.builder( NodeSpec.Builder.testSpec("h123a.domain.tld").realResources(new NodeResources(1, 1, 1, 1)).build()) .fileSystem(fileSystem).build(); @@ -152,7 +152,7 @@ public class StorageMaintainerTest { } @Test - public void deletes_correct_amount() throws IOException { + void deletes_correct_amount() throws IOException { NodeAgentContext context = NodeAgentContextImpl.builder( NodeSpec.Builder.testSpec("h123a.domain.tld").realResources(new NodeResources(1, 1, 1, 1)).build()) .fileSystem(fileSystem).build(); @@ -164,7 +164,7 @@ public class StorageMaintainerTest { verify(diskCleanup).cleanup(eq(context), any(), eq(272_800_000L)); } - @After + @AfterEach public void after() { terminal.verifyAllCommandsExecuted(); } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainerTest.java index 80fde82a89f..6b2ac98ad0b 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainerTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainerTest.java @@ -10,15 +10,15 @@ import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddressesMock; import com.yahoo.vespa.hosted.node.admin.task.util.network.IPVersion; import com.yahoo.vespa.hosted.node.admin.task.util.process.CommandResult; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.nio.file.FileSystem; import java.util.ArrayList; import java.util.List; import java.util.function.Function; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.endsWith; import static org.mockito.ArgumentMatchers.eq; @@ -45,7 +45,7 @@ public class AclMaintainerTest { private final List<String> writtenFileContents = new ArrayList<>(); @Test - public void configures_full_container_acl_from_empty() { + void configures_full_container_acl_from_empty() { Acl acl = new Acl.Builder().withTrustedPorts(22, 4443) .withTrustedNode("hostname1", "3001::abcd") .withTrustedNode("hostname2", "3001::1234") @@ -71,54 +71,54 @@ public class AclMaintainerTest { List<String> expected = List.of( // IPv4 filter table restore "*filter\n" + - "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p icmp -j ACCEPT\n" + - "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + - "-A INPUT -s 172.16.5.234/32 -j ACCEPT\n" + - "-A INPUT -s 192.168.0.5/32 -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp-port-unreachable\n" + - "COMMIT\n", + "-P INPUT ACCEPT\n" + + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p icmp -j ACCEPT\n" + + "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + + "-A INPUT -s 172.16.5.234/32 -j ACCEPT\n" + + "-A INPUT -s 192.168.0.5/32 -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp-port-unreachable\n" + + "COMMIT\n", // IPv6 filter table restore "*filter\n" + - "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p ipv6-icmp -j ACCEPT\n" + - "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + - "-A INPUT -s 3001::1234/128 -j ACCEPT\n" + - "-A INPUT -s 3001::abcd/128 -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n" + - "COMMIT\n", + "-P INPUT ACCEPT\n" + + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p ipv6-icmp -j ACCEPT\n" + + "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + + "-A INPUT -s 3001::1234/128 -j ACCEPT\n" + + "-A INPUT -s 3001::abcd/128 -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n" + + "COMMIT\n", // IPv4 nat table restore "*nat\n" + - "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 10.0.0.1/32 -j REDIRECT\n" + - "COMMIT\n", + "-P PREROUTING ACCEPT\n" + + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 10.0.0.1/32 -j REDIRECT\n" + + "COMMIT\n", // IPv6 nat table restore "*nat\n" + - "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 2001::1/128 -j REDIRECT\n" + - "COMMIT\n"); + "-P PREROUTING ACCEPT\n" + + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 2001::1/128 -j REDIRECT\n" + + "COMMIT\n"); assertEquals(expected, writtenFileContents); } @Test - public void configures_minimal_container_acl_from_empty() { + void configures_minimal_container_acl_from_empty() { // The ACL spec is empty and our this node's addresses do not resolve Acl acl = new Acl.Builder().withTrustedPorts().build(); NodeAgentContext context = contextGenerator.apply(acl); @@ -138,30 +138,30 @@ public class AclMaintainerTest { List<String> expected = List.of( // IPv4 filter table restore "*filter\n" + - "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p icmp -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp-port-unreachable\n" + - "COMMIT\n", + "-P INPUT ACCEPT\n" + + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p icmp -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp-port-unreachable\n" + + "COMMIT\n", // IPv6 filter table restore "*filter\n" + - "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p ipv6-icmp -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n" + - "COMMIT\n"); + "-P INPUT ACCEPT\n" + + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p ipv6-icmp -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n" + + "COMMIT\n"); assertEquals(expected, writtenFileContents); } @Test - public void only_configure_iptables_for_ipversion_that_differs() { + void only_configure_iptables_for_ipversion_that_differs() { Acl acl = new Acl.Builder().withTrustedPorts(22, 4443).withTrustedNode("hostname1", "3001::abcd").build(); NodeAgentContext context = contextGenerator.apply(acl); @@ -170,20 +170,20 @@ public class AclMaintainerTest { whenListRules(context, "filter", IPVersion.IPv4, EMPTY_FILTER_TABLE); whenListRules(context, "filter", IPVersion.IPv6, "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p ipv6-icmp -j ACCEPT\n" + - "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + - "-A INPUT -s 3001::abcd/128 -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n"); + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p ipv6-icmp -j ACCEPT\n" + + "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + + "-A INPUT -s 3001::abcd/128 -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n"); whenListRules(context, "nat", IPVersion.IPv6, "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 2001::1/128 -j REDIRECT\n"); + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 2001::1/128 -j REDIRECT\n"); aclMaintainer.converge(context); @@ -194,20 +194,20 @@ public class AclMaintainerTest { List<String> expected = List.of( "*filter\n" + - "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p icmp -j ACCEPT\n" + - "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp-port-unreachable\n" + - "COMMIT\n"); + "-P INPUT ACCEPT\n" + + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p icmp -j ACCEPT\n" + + "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp-port-unreachable\n" + + "COMMIT\n"); assertEquals(expected, writtenFileContents); } @Test - public void rollback_is_attempted_when_applying_acl_fail() { + void rollback_is_attempted_when_applying_acl_fail() { Acl acl = new Acl.Builder().withTrustedPorts(22, 4443).withTrustedNode("hostname1", "3001::abcd").build(); NodeAgentContext context = contextGenerator.apply(acl); @@ -216,20 +216,20 @@ public class AclMaintainerTest { whenListRules(context, "filter", IPVersion.IPv4, EMPTY_FILTER_TABLE); whenListRules(context, "filter", IPVersion.IPv6, "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p ipv6-icmp -j ACCEPT\n" + - "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + - "-A INPUT -s 3001::abcd/128 -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n"); + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p ipv6-icmp -j ACCEPT\n" + + "-A INPUT -p tcp -m multiport --dports 22,4443 -j ACCEPT\n" + + "-A INPUT -s 3001::abcd/128 -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp6-port-unreachable\n"); whenListRules(context, "nat", IPVersion.IPv6, "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 2001::1/128 -j REDIRECT\n"); + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 2001::1/128 -j REDIRECT\n"); when(containerOperations.executeCommandInNetworkNamespace(eq(context), eq("iptables-restore"), any())) .thenThrow(new RuntimeException("iptables restore failed")); @@ -244,7 +244,7 @@ public class AclMaintainerTest { aclMaintainer.converge(context); } - @Before + @BeforeEach public void setup() { doAnswer(invoc -> { String path = invoc.getArgument(2); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/FilterTableLineEditorTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/FilterTableLineEditorTest.java index 6aa3a0420ff..6cd4038975b 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/FilterTableLineEditorTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/FilterTableLineEditorTest.java @@ -4,12 +4,12 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.acl; import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.Acl; import com.yahoo.vespa.hosted.node.admin.task.util.file.Editor; import com.yahoo.vespa.hosted.node.admin.task.util.network.IPVersion; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author freva @@ -17,44 +17,44 @@ import static org.junit.Assert.assertEquals; public class FilterTableLineEditorTest { @Test - public void filter_set_wanted_rules() { + void filter_set_wanted_rules() { Acl acl = new Acl.Builder().withTrustedPorts(22).withTrustedNode("hostname", "3001::1").build(); assertFilterTableLineEditorResult( acl, IPVersion.IPv6, "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n", + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n", "-P INPUT ACCEPT\n" + - "-P FORWARD ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + - "-A INPUT -i lo -j ACCEPT\n" + - "-A INPUT -p ipv6-icmp -j ACCEPT\n" + - "-A INPUT -p tcp -m multiport --dports 22 -j ACCEPT\n" + - "-A INPUT -s 3001::1/128 -j ACCEPT\n" + - "-A INPUT -j REJECT --reject-with icmp6-port-unreachable"); + "-P FORWARD ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n" + + "-A INPUT -i lo -j ACCEPT\n" + + "-A INPUT -p ipv6-icmp -j ACCEPT\n" + + "-A INPUT -p tcp -m multiport --dports 22 -j ACCEPT\n" + + "-A INPUT -s 3001::1/128 -j ACCEPT\n" + + "-A INPUT -j REJECT --reject-with icmp6-port-unreachable"); } @Test - public void produces_minimal_diff_simple() { + void produces_minimal_diff_simple() { assertFilterTableDiff(List.of(2, 5, 3, 6, 1, 4), List.of(2, 5, 6, 1, 4), "Patching file table:\n" + - "--A INPUT -s 2001::3/128 -j ACCEPT\n"); + "--A INPUT -s 2001::3/128 -j ACCEPT\n"); } @Test - public void produces_minimal_diff_complex() { + void produces_minimal_diff_complex() { assertFilterTableDiff(List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), List.of(5, 11, 6, 3, 10, 4, 8, 12), "Patching file table:\n" + - "--A INPUT -s 2001::1/128 -j ACCEPT\n" + - "--A INPUT -s 2001::2/128 -j ACCEPT\n" + - "+-A INPUT -s 2001::11/128 -j ACCEPT\n" + - "+-A INPUT -s 2001::12/128 -j ACCEPT\n" + - "--A INPUT -s 2001::7/128 -j ACCEPT\n" + - "--A INPUT -s 2001::9/128 -j ACCEPT\n"); + "--A INPUT -s 2001::1/128 -j ACCEPT\n" + + "--A INPUT -s 2001::2/128 -j ACCEPT\n" + + "+-A INPUT -s 2001::11/128 -j ACCEPT\n" + + "+-A INPUT -s 2001::12/128 -j ACCEPT\n" + + "--A INPUT -s 2001::7/128 -j ACCEPT\n" + + "--A INPUT -s 2001::9/128 -j ACCEPT\n"); } private static void assertFilterTableLineEditorResult( diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/NatTableLineEditorTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/NatTableLineEditorTest.java index 015181c7ca4..999b7bda9bb 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/NatTableLineEditorTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/NatTableLineEditorTest.java @@ -2,11 +2,11 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.acl; import com.yahoo.vespa.hosted.node.admin.task.util.file.Editor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author freva @@ -14,74 +14,74 @@ import static org.junit.Assert.assertEquals; public class NatTableLineEditorTest { @Test - public void nat_set_redirect_rule_without_touching_docker_rules() { + void nat_set_redirect_rule_without_touching_docker_rules() { assertNatTableLineEditorResult( "-A OUTPUT -d 3001::1/128 -j REDIRECT", "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-N DOCKER_OUTPUT\n" + - "-N DOCKER_POSTROUTING\n" + - "-A OUTPUT -d 127.0.0.11/32 -j DOCKER_OUTPUT\n" + - "-A POSTROUTING -d 127.0.0.11/32 -j DOCKER_POSTROUTING\n" + - "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 127.0.0.11:43500\n" + - "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p udp -m udp --dport 53 -j DNAT --to-destination 127.0.0.11:57392\n" + - "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p tcp -m tcp --sport 43500 -j SNAT --to-source :53\n" + - "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 57392 -j SNAT --to-source :53\n", + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-N DOCKER_OUTPUT\n" + + "-N DOCKER_POSTROUTING\n" + + "-A OUTPUT -d 127.0.0.11/32 -j DOCKER_OUTPUT\n" + + "-A POSTROUTING -d 127.0.0.11/32 -j DOCKER_POSTROUTING\n" + + "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 127.0.0.11:43500\n" + + "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p udp -m udp --dport 53 -j DNAT --to-destination 127.0.0.11:57392\n" + + "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p tcp -m tcp --sport 43500 -j SNAT --to-source :53\n" + + "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 57392 -j SNAT --to-source :53\n", "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-N DOCKER_OUTPUT\n" + - "-N DOCKER_POSTROUTING\n" + - "-A OUTPUT -d 127.0.0.11/32 -j DOCKER_OUTPUT\n" + - "-A POSTROUTING -d 127.0.0.11/32 -j DOCKER_POSTROUTING\n" + - "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 127.0.0.11:43500\n" + - "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p udp -m udp --dport 53 -j DNAT --to-destination 127.0.0.11:57392\n" + - "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p tcp -m tcp --sport 43500 -j SNAT --to-source :53\n" + - "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 57392 -j SNAT --to-source :53\n" + - "-A OUTPUT -d 3001::1/128 -j REDIRECT"); + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-N DOCKER_OUTPUT\n" + + "-N DOCKER_POSTROUTING\n" + + "-A OUTPUT -d 127.0.0.11/32 -j DOCKER_OUTPUT\n" + + "-A POSTROUTING -d 127.0.0.11/32 -j DOCKER_POSTROUTING\n" + + "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 127.0.0.11:43500\n" + + "-A DOCKER_OUTPUT -d 127.0.0.11/32 -p udp -m udp --dport 53 -j DNAT --to-destination 127.0.0.11:57392\n" + + "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p tcp -m tcp --sport 43500 -j SNAT --to-source :53\n" + + "-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 57392 -j SNAT --to-source :53\n" + + "-A OUTPUT -d 3001::1/128 -j REDIRECT"); } @Test - public void nat_cleanup_wrong_redirect_rules() { + void nat_cleanup_wrong_redirect_rules() { assertNatTableLineEditorResult( "-A OUTPUT -d 3001::1/128 -j REDIRECT", "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 3001::2/128 -j REDIRECT\n", + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 3001::2/128 -j REDIRECT\n", "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 3001::1/128 -j REDIRECT"); + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 3001::1/128 -j REDIRECT"); } @Test - public void nat_delete_duplicate_rules() { + void nat_delete_duplicate_rules() { assertNatTableLineEditorResult( "-A OUTPUT -d 3001::1/128 -j REDIRECT", "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 3001::2/128 -j REDIRECT\n" + - "-A OUTPUT -d 3001::1/128 -j REDIRECT\n" + - "-A OUTPUT -d 3001::4/128 -j REDIRECT\n", + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 3001::2/128 -j REDIRECT\n" + + "-A OUTPUT -d 3001::1/128 -j REDIRECT\n" + + "-A OUTPUT -d 3001::4/128 -j REDIRECT\n", "-P PREROUTING ACCEPT\n" + - "-P INPUT ACCEPT\n" + - "-P OUTPUT ACCEPT\n" + - "-P POSTROUTING ACCEPT\n" + - "-A OUTPUT -d 3001::1/128 -j REDIRECT"); + "-P INPUT ACCEPT\n" + + "-P OUTPUT ACCEPT\n" + + "-P POSTROUTING ACCEPT\n" + + "-A OUTPUT -d 3001::1/128 -j REDIRECT"); } private static void assertNatTableLineEditorResult(String redirectRule, String currentNatTable, String expectedNatTable) { diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java index 5c334837040..c0bf6ebbeb3 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java @@ -7,15 +7,15 @@ import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContextImpl; import com.yahoo.vespa.hosted.node.admin.task.util.fs.ContainerPath; import com.yahoo.vespa.hosted.node.admin.task.util.process.CommandResult; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.GDB_PATH_RHEL8; import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.JAVA_HEAP_DUMP_METADATA; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -37,7 +37,7 @@ public class CoreCollectorTest { "#0 0x00000000004004d8 in main (argv=...) at main.c:4"); @Test - public void extractsBinaryPathTest() { + void extractsBinaryPathTest() { final String[] cmd = {"file", TEST_CORE_PATH.pathInContainer()}; mockExec(cmd, @@ -73,7 +73,7 @@ public class CoreCollectorTest { } @Test - public void extractsBinaryPathUsingGdbTest() { + void extractsBinaryPathUsingGdbTest() { final String[] cmd = new String[]{"/bin/sh", "-c", GDB_PATH_RHEL8 + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"}; @@ -91,14 +91,14 @@ public class CoreCollectorTest { } @Test - public void extractsBacktraceUsingGdb() { + void extractsBacktraceUsingGdb() { mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "set print frame-arguments none", - "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, + "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, String.join("\n", GDB_BACKTRACE)); assertEquals(GDB_BACKTRACE, coreCollector.readBacktrace(context, TEST_CORE_PATH, TEST_BIN_PATH, false)); mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "set print frame-arguments none", - "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, + "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, "", "Failure"); try { coreCollector.readBacktrace(context, TEST_CORE_PATH, TEST_BIN_PATH, false); @@ -111,7 +111,7 @@ public class CoreCollectorTest { } @Test - public void extractsBacktraceFromAllThreadsUsingGdb() { + void extractsBacktraceFromAllThreadsUsingGdb() { mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "set print frame-arguments none", "-ex", "thread apply all bt", "-batch", @@ -121,15 +121,15 @@ public class CoreCollectorTest { } @Test - public void collectsDataTest() { + void collectsDataTest() { mockExec(new String[]{"file", TEST_CORE_PATH.pathInContainer()}, "/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from " + "'/usr/bin/program'"); mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "set print frame-arguments none", - "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, + "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, String.join("\n", GDB_BACKTRACE)); mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "set print frame-arguments none", - "-ex", "thread apply all bt", "-batch", + "-ex", "thread apply all bt", "-batch", "/usr/bin/program", "/tmp/core.1234"}, String.join("\n", GDB_BACKTRACE)); @@ -141,7 +141,7 @@ public class CoreCollectorTest { } @Test - public void collectsPartialIfBacktraceFailsTest() { + void collectsPartialIfBacktraceFailsTest() { mockExec(new String[]{"file", TEST_CORE_PATH.pathInContainer()}, "/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from " + "'/usr/bin/program'"); @@ -153,7 +153,7 @@ public class CoreCollectorTest { } @Test - public void reportsJstackInsteadOfGdbForJdkCores() { + void reportsJstackInsteadOfGdbForJdkCores() { mockExec(new String[]{"file", TEST_CORE_PATH.pathInContainer()}, "dump.core.5954: ELF 64-bit LSB core file x86-64, version 1 (SYSV), too many program header sections (33172)"); @@ -171,7 +171,7 @@ public class CoreCollectorTest { } @Test - public void metadata_for_java_heap_dump() { + void metadata_for_java_heap_dump() { assertEquals(JAVA_HEAP_DUMP_METADATA, coreCollector.collect(context, context.paths().of("/dump_java_pid123.hprof"))); } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java index 5c681ddc129..31579fb7c9b 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java @@ -9,8 +9,8 @@ import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContextImpl; import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath; import com.yahoo.vespa.hosted.node.admin.task.util.fs.ContainerPath; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.FileSystem; @@ -28,8 +28,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static com.yahoo.yolean.Exceptions.uncheck; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -59,7 +58,7 @@ public class CoredumpHandlerTest { @Test - public void coredump_enqueue_test() throws IOException { + void coredump_enqueue_test() throws IOException { ContainerPath crashPath = context.paths().of("/some/crash/path"); ContainerPath processingDir = context.paths().of("/some/other/processing"); @@ -93,7 +92,7 @@ public class CoredumpHandlerTest { } @Test - public void enqueue_with_hs_err_files() throws IOException { + void enqueue_with_hs_err_files() throws IOException { ContainerPath crashPath = context.paths().of("/some/crash/path"); ContainerPath processingDir = context.paths().of("/some/other/processing"); Files.createDirectories(crashPath); @@ -114,7 +113,7 @@ public class CoredumpHandlerTest { } @Test - public void coredump_to_process_test() throws IOException { + void coredump_to_process_test() throws IOException { ContainerPath processingDir = context.paths().of("/some/other/processing"); // Initially there are no core dumps @@ -138,7 +137,7 @@ public class CoredumpHandlerTest { } @Test - public void get_metadata_test() throws IOException { + void get_metadata_test() throws IOException { Map<String, Object> metadata = new HashMap<>(); metadata.put("bin_path", "/bin/bash"); metadata.put("backtrace", List.of("call 1", "function 2", "something something")); @@ -174,21 +173,25 @@ public class CoredumpHandlerTest { verify(coreCollector, times(1)).collect(any(), any()); } - @Test(expected = IllegalStateException.class) - public void cant_get_metadata_if_no_core_file() throws IOException { - coredumpHandler.getMetadata(context, context.paths().of("/fake/path"), Map::of); + @Test + void cant_get_metadata_if_no_core_file() throws IOException { + assertThrows(IllegalStateException.class, () -> { + coredumpHandler.getMetadata(context, context.paths().of("/fake/path"), Map::of); + }); } - @Test(expected = IllegalStateException.class) - public void fails_to_get_core_file_if_only_compressed() throws IOException { - ContainerPath coredumpDirectory = context.paths().of("/path/to/coredump/proccessing/id-123"); - Files.createDirectories(coredumpDirectory); - Files.createFile(coredumpDirectory.resolve("dump_bash.core.431.zstd")); - coredumpHandler.findCoredumpFileInProcessingDirectory(coredumpDirectory); + @Test + void fails_to_get_core_file_if_only_compressed() throws IOException { + assertThrows(IllegalStateException.class, () -> { + ContainerPath coredumpDirectory = context.paths().of("/path/to/coredump/proccessing/id-123"); + Files.createDirectories(coredumpDirectory); + Files.createFile(coredumpDirectory.resolve("dump_bash.core.431.zstd")); + coredumpHandler.findCoredumpFileInProcessingDirectory(coredumpDirectory); + }); } @Test - public void process_single_coredump_test() throws IOException { + void process_single_coredump_test() throws IOException { ContainerPath coredumpDirectory = context.paths().of("/path/to/coredump/proccessing/id-123"); Files.createDirectories(coredumpDirectory); Files.write(coredumpDirectory.resolve("metadata.json"), "metadata".getBytes()); @@ -204,7 +207,7 @@ public class CoredumpHandlerTest { } @Test - public void report_enqueued_and_processed_metrics() throws IOException { + void report_enqueued_and_processed_metrics() throws IOException { Path processingPath = containerCrashPath.resolve("processing"); Files.createFile(containerCrashPath.resolve("dump-1")); Files.createFile(containerCrashPath.resolve("dump-2")); @@ -225,7 +228,7 @@ public class CoredumpHandlerTest { assertEquals(1, values.get("coredumps.processed").intValue()); } - @Before + @BeforeEach public void setup() throws IOException { Files.createDirectories(containerCrashPath.pathOnHost()); } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/CoredumpCleanupRuleTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/CoredumpCleanupRuleTest.java index 272fdba7e9a..9bd746e3ddf 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/CoredumpCleanupRuleTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/CoredumpCleanupRuleTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.disk; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.FileSystem; @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import static com.yahoo.vespa.hosted.node.admin.maintenance.disk.DiskCleanupRule.PrioritizedFileAttributes; import static com.yahoo.vespa.hosted.node.admin.maintenance.disk.DiskCleanupRule.Priority; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author freva @@ -26,7 +26,7 @@ public class CoredumpCleanupRuleTest { private final FileSystem fileSystem = TestFileSystem.create(); @Test - public void for_container_test() throws IOException { + void for_container_test() throws IOException { Path path = fileSystem.getPath("/test/path"); DiskCleanupRule rule = CoredumpCleanupRule.forContainer(path); @@ -56,7 +56,7 @@ public class CoredumpCleanupRuleTest { } @Test - public void for_host_test() throws IOException { + void for_host_test() throws IOException { Path path = fileSystem.getPath("/test/path"); DiskCleanupRule rule = CoredumpCleanupRule.forHost(path); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/DiskCleanupTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/DiskCleanupTest.java index 1386177d17a..44367f37dd9 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/DiskCleanupTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/DiskCleanupTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.disk; import com.yahoo.vespa.hosted.node.admin.component.TestTaskContext; import com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.FileSystem; @@ -21,10 +21,10 @@ import java.util.Set; import java.util.stream.Collectors; import static com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder.FileAttributes; +import static org.junit.jupiter.api.Assertions.assertEquals; import static com.yahoo.vespa.hosted.node.admin.maintenance.disk.DiskCleanupRule.Priority; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author freva @@ -36,7 +36,7 @@ public class DiskCleanupTest { private final DiskCleanup diskCleanup = new DiskCleanup(); @Test - public void nothing_deleted() throws IOException { + void nothing_deleted() throws IOException { assertFalse(diskCleanup.cleanup(context, List.of(), 0)); assertFalse(diskCleanup.cleanup(context, List.of(), 10)); @@ -56,7 +56,7 @@ public class DiskCleanupTest { } @Test - public void delete_test() throws IOException { + void delete_test() throws IOException { tester.createFile("/opt/vespa/var/db/do-not-delete-1.db", 1); tester.createFile("/opt/vespa/var/db/do-not-delete-2.db", 1); tester.createFile("/opt/vespa/var/zookeeper/do-not-delete-3", 1); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/LinearCleanupRuleTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/LinearCleanupRuleTest.java index 55a379054d4..1ef876d7e04 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/LinearCleanupRuleTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/disk/LinearCleanupRuleTest.java @@ -1,16 +1,17 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.maintenance.disk; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import static com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder.FileAttributes; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static com.yahoo.vespa.hosted.node.admin.maintenance.disk.DiskCleanupRule.PrioritizedFileAttributes; import static com.yahoo.vespa.hosted.node.admin.maintenance.disk.DiskCleanupRule.Priority; -import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; /** @@ -19,27 +20,29 @@ import static org.mockito.Mockito.mock; public class LinearCleanupRuleTest { @Test - public void basic() { + void basic() { assertRule(Map.of(), Priority.LOWEST, Priority.HIGHEST); assertRule(Map.of(0.0, Priority.LOW, 0.5, Priority.LOW, 1.0, Priority.LOW), Priority.LOW, Priority.LOW); assertRule(Map.of(0.0, Priority.LOW, 0.5, Priority.MEDIUM, 1.0, Priority.MEDIUM), Priority.LOW, Priority.MEDIUM); assertRule(Map.of( - -5.0, Priority.LOW, - 0.0, Priority.LOW, - 0.2, Priority.LOW, - 0.35, Priority.MEDIUM, - 0.65, Priority.MEDIUM, - 0.8, Priority.HIGH, - 1.0, Priority.HIGH, - 5.0, Priority.HIGH), + -5.0, Priority.LOW, + 0.0, Priority.LOW, + 0.2, Priority.LOW, + 0.35, Priority.MEDIUM, + 0.65, Priority.MEDIUM, + 0.8, Priority.HIGH, + 1.0, Priority.HIGH, + 5.0, Priority.HIGH), Priority.LOW, Priority.HIGH); } - @Test(expected = IllegalArgumentException.class) - public void fail_if_high_priority_lower_than_low() { - assertRule(Map.of(), Priority.HIGHEST, Priority.LOWEST); + @Test + void fail_if_high_priority_lower_than_low() { + assertThrows(IllegalArgumentException.class, () -> { + assertRule(Map.of(), Priority.HIGHEST, Priority.LOWEST); + }); } private static void assertRule(Map<Double, Priority> expectedPriorities, Priority low, Priority high) { diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/ArtifactProducersTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/ArtifactProducersTest.java index 4e34d936d85..fd7d0d8c1c0 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/ArtifactProducersTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/ArtifactProducersTest.java @@ -6,7 +6,8 @@ import org.junit.jupiter.api.Test; import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author bjorncs diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/SyncFileInfoTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/SyncFileInfoTest.java index 94c2ce6d106..8be1ef23bb2 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/SyncFileInfoTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/SyncFileInfoTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.sync; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath; import com.yahoo.vespa.test.file.TestFileSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.file.FileSystem; @@ -15,7 +15,7 @@ import java.util.Optional; import static com.yahoo.vespa.hosted.node.admin.maintenance.sync.SyncFileInfo.Compression.NONE; import static com.yahoo.vespa.hosted.node.admin.maintenance.sync.SyncFileInfo.Compression.ZSTD; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author freva @@ -37,7 +37,7 @@ public class SyncFileInfoTest { private static final Path zkLogPath1 = fileSystem.getPath("/opt/vespa/logs/zookeeper.configserver.1.log"); @Test - public void access_logs() { + void access_logs() { assertForLogFile(accessLogPath1, null, null, true); assertForLogFile(accessLogPath1, "s3://vespa-data-bucket/vespa/music/main/h432a/logs/access/access.log.20210211.zst", ZSTD, false); @@ -52,7 +52,7 @@ public class SyncFileInfoTest { } @Test - public void connection_logs() { + void connection_logs() { assertForLogFile(connectionLogPath1, null, null, true); assertForLogFile(connectionLogPath1, "s3://vespa-data-bucket/vespa/music/main/h432a/logs/connection/ConnectionLog.20210210.zst", ZSTD, false); @@ -61,7 +61,7 @@ public class SyncFileInfoTest { } @Test - public void vespa_logs() { + void vespa_logs() { assertForLogFile(vespaLogPath1, "s3://vespa-data-bucket/vespa/music/main/h432a/logs/vespa/vespa.log.zst", ZSTD, Duration.ofHours(1), true); assertForLogFile(vespaLogPath1, "s3://vespa-data-bucket/vespa/music/main/h432a/logs/vespa/vespa.log.zst", ZSTD, Duration.ZERO, false); @@ -70,7 +70,7 @@ public class SyncFileInfoTest { } @Test - public void zookeeper_logs() { + void zookeeper_logs() { assertForLogFile(zkLogPath0, "s3://vespa-data-bucket/vespa/music/main/h432a/logs/zookeeper/zookeeper.log.zst", ZSTD, Duration.ofHours(1), true); assertForLogFile(zkLogPath0, "s3://vespa-data-bucket/vespa/music/main/h432a/logs/zookeeper/zookeeper.log.zst", ZSTD, Duration.ZERO, false); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java index ab43c3fd5fc..e6963175977 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.maintenance.sync; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -10,8 +10,8 @@ import java.io.UncheckedIOException; import java.util.Random; import static com.yahoo.vespa.hosted.node.admin.maintenance.sync.ZstdCompressingInputStream.compressor; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author freva @@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals; public class ZstdCompressingInputStreamTest { @Test - public void compression_test() throws Exception { + void compression_test() throws Exception { Random rnd = new Random(); byte[] data = new byte[(int) (100_000 * (10 + rnd.nextDouble()))]; rnd.nextBytes(data); @@ -27,9 +27,9 @@ public class ZstdCompressingInputStreamTest { } @Test - public void compress_empty_file_test() { + void compress_empty_file_test() { byte[] compressedData = compress(new byte[0], 1 << 10); - assertEquals("zstd compressing an empty file results in a 13 bytes file", 13, compressedData.length); + assertEquals(13, compressedData.length, "zstd compressing an empty file results in a 13 bytes file"); } private static void assertCompression(byte[] data, int bufferSize) { |