aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2022-07-29 15:44:31 +0200
committerGitHub <noreply@github.com>2022-07-29 15:44:31 +0200
commit372f6d7371d42ef23b543d4349cfeabf25ac400b (patch)
tree9af9d03b14f4a3cf4747428071574ec668e3f3f7
parent5aa9bb607b7d4262c8ea13d20671f7264c3c59c5 (diff)
parent4b53d0d135fcacc5964b2720678642f182fd15d1 (diff)
Merge pull request #23555 from vespa-engine/bjorncs/more-junit5v8.26.15
Bjorncs/more junit5
-rw-r--r--application-preprocessor/pom.xml27
-rw-r--r--application-preprocessor/src/test/java/com/yahoo/application/preprocessor/ApplicationPreprocessorTest.java26
-rw-r--r--application/pom.xml29
-rw-r--r--application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java53
-rw-r--r--application/src/test/java/com/yahoo/application/ApplicationTest.java99
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java80
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java23
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java62
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java48
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java24
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerTest.java35
-rw-r--r--application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java77
-rw-r--r--application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java10
-rw-r--r--bundle-plugin-test/integration-test/pom.xml13
-rw-r--r--bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java36
-rw-r--r--bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java18
-rw-r--r--bundle-plugin/pom.xml15
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java20
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java58
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.java26
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java6
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/mojo/GenerateSourcesMojoTest.java10
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ExportPackageParserTest.java24
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java40
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/util/TestBundleDependencyScopeTranslatorTest.java18
-rw-r--r--clustercontroller-apps/pom.xml27
-rw-r--r--clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java26
-rw-r--r--clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java20
-rw-r--r--clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StateRestApiV2HandlerTest.java8
-rw-r--r--clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StatusHandlerTest.java4
-rw-r--r--clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscHttpRequestHandlerTest.java16
-rw-r--r--clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscMetricWrapperTest.java10
-rw-r--r--clustercontroller-core/pom.xml21
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java36
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java51
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java134
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java28
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java18
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java8
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsTest.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java22
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java21
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java17
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java58
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java19
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerContextImplTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java39
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java10
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java57
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java30
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java10
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java16
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java89
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MetricReporterTest.java14
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeInfoTest.java24
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java10
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java71
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceExhaustionCalculatorTest.java73
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStatsTest.java15
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java144
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java44
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java18
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java311
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java60
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java42
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraintTest.java16
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java9
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java44
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java21
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/StorageNodeStatsBridgeTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java91
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java102
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java160
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java72
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java48
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java11
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java192
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java143
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java18
-rw-r--r--clustercontroller-utils/pom.xml15
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java32
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java34
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java10
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java22
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java30
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java335
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/server/RestApiHandlerTest.java6
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/CertainlyCloneableTest.java10
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/ClockTest.java6
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/JSONObjectWrapperTest.java8
-rw-r--r--clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/MetricReporterTest.java42
-rwxr-xr-xcomponent/pom.xml15
-rw-r--r--component/src/test/java/com/yahoo/component/VersionCompatibilityTest.java32
-rw-r--r--component/src/test/java/com/yahoo/component/VersionSpecificationTestCase.java118
-rw-r--r--component/src/test/java/com/yahoo/component/VersionTestCase.java150
-rw-r--r--config-lib/pom.xml15
-rw-r--r--config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java8
-rw-r--r--config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java78
-rw-r--r--config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java36
-rw-r--r--config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java10
-rw-r--r--config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java12
-rw-r--r--config-lib/src/test/java/com/yahoo/config/FileNodeTest.java12
-rw-r--r--config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java10
-rw-r--r--config-lib/src/test/java/com/yahoo/config/LongNodeTest.java10
-rw-r--r--config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java97
-rw-r--r--config-lib/src/test/java/com/yahoo/config/PathNodeTest.java10
-rw-r--r--config-lib/src/test/java/com/yahoo/config/StringNodeTest.java19
-rw-r--r--config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java6
-rw-r--r--config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java10
-rw-r--r--config-proxy/pom.xml21
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java105
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java19
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java16
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java6
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java8
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java14
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java44
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java25
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java32
-rw-r--r--configgen/pom.xml9
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java59
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java41
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java40
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java115
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java102
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java20
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java18
134 files changed, 2818 insertions, 2630 deletions
diff --git a/application-preprocessor/pom.xml b/application-preprocessor/pom.xml
index 2cc75b885a9..aae9f6bb13a 100644
--- a/application-preprocessor/pom.xml
+++ b/application-preprocessor/pom.xml
@@ -19,9 +19,9 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>config-model-api</artifactId>
- <version>${project.version}</version>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>config-model-api</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
@@ -33,10 +33,10 @@
<artifactId>config-model</artifactId>
<version>${project.version}</version>
<exclusions>
- <exclusion>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- </exclusion>
+ <exclusion>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -50,14 +50,19 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/application-preprocessor/src/test/java/com/yahoo/application/preprocessor/ApplicationPreprocessorTest.java b/application-preprocessor/src/test/java/com/yahoo/application/preprocessor/ApplicationPreprocessorTest.java
index 5039b05b393..0e5d8fb2784 100644
--- a/application-preprocessor/src/test/java/com/yahoo/application/preprocessor/ApplicationPreprocessorTest.java
+++ b/application-preprocessor/src/test/java/com/yahoo/application/preprocessor/ApplicationPreprocessorTest.java
@@ -1,9 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.preprocessor;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
@@ -14,17 +13,26 @@ import java.util.Optional;
public class ApplicationPreprocessorTest {
- @Rule
- public TemporaryFolder outputDir = new TemporaryFolder();
+ @TempDir
+ public File outputDir;
// Basic test just to check that instantiation and run() works. Unit testing is in config-application-package
@Test
- public void basic() throws ParserConfigurationException, TransformerException, SAXException, IOException {
+ void basic() throws ParserConfigurationException, TransformerException, SAXException, IOException {
ApplicationPreprocessor preprocessor = new ApplicationPreprocessor(new File("src/test/resources/simple"),
- Optional.of(outputDir.newFolder()),
- Optional.empty(),
- Optional.empty());
+ Optional.of(newFolder(outputDir, "basic")),
+ Optional.empty(),
+ Optional.empty());
preprocessor.run();
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
diff --git a/application/pom.xml b/application/pom.xml
index 51448502d1d..34bf1b56c0d 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -60,11 +60,6 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
<!-- All dependencies that should be visible in test classpath, but not compile classpath,
for user projects must be added in compile scope here.
@@ -127,6 +122,20 @@
<artifactId>testutil</artifactId>
<version>${project.version}</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- START JETTY embedded jars -->
@@ -172,6 +181,16 @@
<artifactId>jetty-servlets</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- END JETTY embedded jars -->
</dependencies>
diff --git a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
index 800c30ac8b8..503f11ca0d7 100644
--- a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
+++ b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
@@ -2,13 +2,12 @@
package com.yahoo.application;
import com.yahoo.io.IOUtils;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.nio.file.Files;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Tony Vaagenes
@@ -16,55 +15,53 @@ import static org.junit.Assert.assertTrue;
*/
public class ApplicationBuilderTest {
@Test
- public void query_profile_types_can_be_added() throws Exception {
+ void query_profile_types_can_be_added() throws Exception {
withApplicationBuilder(builder -> {
builder.queryProfileType("MyProfileType", "<query-profile-type id=\"MyProfileType\">" + //
- "<field name=\"age\" type=\"integer\" />" + //
- "<field name=\"profession\" type=\"string\" />" + //
- "<field name=\"user\" type=\"query-profile:MyUserProfile\" />" + //
- "</query-profile-type>");
+ "<field name=\"age\" type=\"integer\" />" + //
+ "<field name=\"profession\" type=\"string\" />" + //
+ "<field name=\"user\" type=\"query-profile:MyUserProfile\" />" + //
+ "</query-profile-type>");
assertTrue(Files.exists(builder.getPath().resolve("search/query-profiles/types/MyProfileType.xml")));
});
}
@Test
- public void query_profile_can_be_added() throws Exception {
+ void query_profile_can_be_added() throws Exception {
withApplicationBuilder(builder -> {
builder.queryProfile("MyProfile",
- "<query-profile id=\"MyProfile\">" +
- "<field name=\"message\">Hello world!</field>" +
- "</query-profile>");
+ "<query-profile id=\"MyProfile\">" +
+ "<field name=\"message\">Hello world!</field>" +
+ "</query-profile>");
assertTrue(Files.exists(builder.getPath().resolve("search/query-profiles/MyProfile.xml")));
});
}
@Test
- public void rank_expression_can_be_added() throws Exception {
+ void rank_expression_can_be_added() throws Exception {
withApplicationBuilder(builder -> {
builder.rankExpression("myExpression", "content");
assertTrue(Files.exists(builder.getPath().resolve("schemas/myExpression.expression")));
});
}
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
+ // application unreferenced inside try
@Test
- @SuppressWarnings("try") // application unreferenced inside try
- public void builder_cannot_be_reused() throws Exception {
- expectedException.expect(RuntimeException.class);
- expectedException.expectMessage("build method");
+ @SuppressWarnings("try")
+ void builder_cannot_be_reused() throws Exception {
+ Throwable exception = assertThrows(RuntimeException.class, () -> {
- ApplicationBuilder builder = new ApplicationBuilder();
- builder.servicesXml("<container version=\"1.0\" />");
- try (Application application = builder.build()) {
- // do nothing
- }
+ ApplicationBuilder builder = new ApplicationBuilder();
+ builder.servicesXml("<container version=\"1.0\" />");
+ try (Application application = builder.build()) {
+ // do nothing
+ }
- builder.servicesXml(""); // should fail
+ builder.servicesXml(""); // should fail
+ });
+ assertTrue(exception.getMessage().contains("build method")); // should fail
}
private interface TestCase {
diff --git a/application/src/test/java/com/yahoo/application/ApplicationTest.java b/application/src/test/java/com/yahoo/application/ApplicationTest.java
index 1b542b4ac98..5b4a68756f0 100644
--- a/application/src/test/java/com/yahoo/application/ApplicationTest.java
+++ b/application/src/test/java/com/yahoo/application/ApplicationTest.java
@@ -21,7 +21,7 @@ import com.yahoo.search.handler.SearchHandler;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.File;
@@ -33,10 +33,11 @@ import java.nio.charset.StandardCharsets;
import java.util.Map;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bratseth
@@ -45,28 +46,28 @@ import static org.junit.Assert.fail;
public class ApplicationTest {
@Test
- public void minimal_application_can_be_constructed() {
+ void minimal_application_can_be_constructed() {
try (Application application = Application.fromServicesXml("<container version=\"1.0\"/>", Networking.disable)) {
- Application unused = application;
+ Application unused = application;
}
}
/** Tests that an application with search chains referencing a content cluster can be constructed. */
@Test
- public void container_and_referenced_content() {
+ void container_and_referenced_content() {
try (Application application =
- Application.fromApplicationPackage(new File("src/test/app-packages/withcontent"), Networking.disable)) {
+ Application.fromApplicationPackage(new File("src/test/app-packages/withcontent"), Networking.disable)) {
Result result = application.getJDisc("default").search().process(new ComponentSpecification("default"),
- new Query("?query=substring:foobar&timeout=20000"));
+ new Query("?query=substring:foobar&timeout=20000"));
assertEquals("WEAKAND(100) (AND substring:fo substring:oo substring:ob substring:ba substring:ar)",
- result.hits().get("hasQuery").getQuery().getModel().getQueryTree().toString());
+ result.hits().get("hasQuery").getQuery().getModel().getQueryTree().toString());
}
}
@Test
- public void application_with_query_profile_sets_up_query_profile_registry() {
+ void application_with_query_profile_sets_up_query_profile_registry() {
try (Application application =
- Application.fromApplicationPackage(new File("src/test/app-packages/withqueryprofile"), Networking.disable)) {
+ Application.fromApplicationPackage(new File("src/test/app-packages/withqueryprofile"), Networking.disable)) {
Query query = new Query(HttpRequest.createTestRequest("?query=substring:foobar&timeout=20000", com.yahoo.jdisc.http.HttpRequest.Method.GET), application.getCompiledQueryProfileRegistry().findQueryProfile("default"));
Result result = application.getJDisc("default").search().process(new ComponentSpecification("default"), query);
@@ -82,7 +83,7 @@ public class ApplicationTest {
}
@Test
- public void empty_container() throws Exception {
+ void empty_container() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container())))) {
try {
app.process(new DocumentRemove(null));
@@ -108,7 +109,7 @@ public class ApplicationTest {
}
@Test
- public void config() throws Exception {
+ void config() throws Exception {
try (
ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.documentProcessor("docproc", "default", MockDocproc.class)
@@ -122,7 +123,7 @@ public class ApplicationTest {
.mymap("key2", "value2")
.mymapstruct("key1", new MockApplicationConfig.Mymapstruct.Builder().id("mapid1").value("mapvalue1"))
.mymapstruct("key2", new MockApplicationConfig.Mymapstruct.Builder().id("mapid2").value("mapvalue2")))))))
- ) {
+ ) {
MockDocproc docproc = (MockDocproc) app.getComponentById("docproc@default");
assertNotNull(docproc);
@@ -162,11 +163,11 @@ public class ApplicationTest {
}
@Test
- public void handler() throws Exception {
+ void handler() throws Exception {
try (
ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.handler("http://*/", MockHttpHandler.class))))
- ) {
+ ) {
RequestHandler handler = app.getRequestHandlerById(MockHttpHandler.class.getName());
assertNotNull(handler);
@@ -191,13 +192,13 @@ public class ApplicationTest {
}
}
- @Test
// TODO: Creates access log
- public void renderer() throws Exception {
+ @Test
+ void renderer() throws Exception {
try (
ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.renderer("mock", MockRenderer.class))))
- ) {
+ ) {
Request request = new Request("http://localhost:" + getDefaults().vespaWebServicePort() + "/search/?format=mock");
Response response = app.handleRequest(request);
@@ -208,36 +209,36 @@ public class ApplicationTest {
}
@Test
- public void search_default() throws Exception {
+ void search_default() throws Exception {
try (
ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.searcher(MockSearcher.class))))
- ) {
+ ) {
Result result = app.search(new Query("?query=foo&timeout=20000"));
assertEquals(1, result.hits().size());
}
}
@Test
- public void search() throws Exception {
+ void search() throws Exception {
try (
ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.searcher("foo", MockSearcher.class))))
- ) {
+ ) {
Result result = app.search("foo", new Query("?query=foo&timeout=20000"));
assertEquals(1, result.hits().size());
}
}
@Test
- public void document_type() throws Exception {
+ void document_type() throws Exception {
try (
Application app = Application.fromBuilder(new Application.Builder()
.documentType("test", new String(this.getClass().getResourceAsStream("/test.sd").readAllBytes(), StandardCharsets.UTF_8))
.container("default", new Application.Builder.Container()
- .documentProcessor(MockDocproc.class)
- .config(new MockApplicationConfig(new MockApplicationConfig.Builder().mystruct(new MockApplicationConfig.Mystruct.Builder().id("foo").value("bar"))))))
- ) {
+ .documentProcessor(MockDocproc.class)
+ .config(new MockApplicationConfig(new MockApplicationConfig.Builder().mystruct(new MockApplicationConfig.Mystruct.Builder().id("foo").value("bar"))))))
+ ) {
Map<String, DocumentType> typeMap = app.getJDisc("jdisc").documentProcessing().getDocumentTypes();
assertNotNull(typeMap);
assertTrue(typeMap.containsKey("test"));
@@ -245,7 +246,7 @@ public class ApplicationTest {
}
@Test
- public void get_search_handler() throws Exception {
+ void get_search_handler() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container().search(true))))) {
SearchHandler searchHandler = (SearchHandler) app.getRequestHandlerById("com.yahoo.search.handler.SearchHandler");
assertNotNull(searchHandler);
@@ -253,7 +254,7 @@ public class ApplicationTest {
}
@Test
- public void component() throws Exception {
+ void component() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.component(MockSearcher.class))))) {
Component c = app.getComponentById(MockSearcher.class.getName());
@@ -262,7 +263,7 @@ public class ApplicationTest {
}
@Test
- public void component_with_config() throws Exception {
+ void component_with_config() throws Exception {
MockApplicationConfig config = new MockApplicationConfig(new MockApplicationConfig.Builder().mystruct(new MockApplicationConfig.Mystruct.Builder().id("foo").value("bar")));
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.component("foo", MockDocproc.class, config))))) {
@@ -272,7 +273,7 @@ public class ApplicationTest {
}
@Test
- public void file_distribution() {
+ void file_distribution() {
try (Application application = Application.fromApplicationPackage(new File("src/test/app-packages/filedistribution/"), Networking.disable)) {
// Deployment succeeded
Application unused = application;
@@ -280,7 +281,7 @@ public class ApplicationTest {
}
@Test
- public void server() throws Exception {
+ void server() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container()
.server("foo", MockServer.class)))
)) {
@@ -291,7 +292,7 @@ public class ApplicationTest {
}
@Test
- public void query_profile() throws Exception {
+ void query_profile() throws Exception {
try (Application app = Application.fromBuilder(new Application.Builder()
.queryProfile("default", "<query-profile id=\"default\">\n" +
"<field name=\"defaultage\">7d</field>\n" +
@@ -302,25 +303,27 @@ public class ApplicationTest {
.rankExpression("re", "commonfirstphase(globalstaticrank)")
.documentType("test", new String(this.getClass().getResourceAsStream("/test.sd").readAllBytes(), StandardCharsets.UTF_8))
.container("default", new Application.Builder.Container()
- .search(true)
+ .search(true)
))) {
Application unused = app;
}
}
- @Test(expected = ConnectException.class)
- public void http_interface_is_off_when_networking_is_disabled() throws Exception {
- int httpPort = getFreePort();
- try (Application application = Application.fromServicesXml(servicesXmlWithServer(httpPort), Networking.disable)) {
- HttpClient client = new org.apache.http.impl.client.DefaultHttpClient();
- int statusCode = client.execute(new HttpGet("http://localhost:" + httpPort)).getStatusLine().getStatusCode();
- fail("Networking.disable is specified, but the network interface is enabled! Got status code: " + statusCode);
- Application unused = application;
- }
+ @Test
+ void http_interface_is_off_when_networking_is_disabled() throws Exception {
+ assertThrows(ConnectException.class, () -> {
+ int httpPort = getFreePort();
+ try (Application application = Application.fromServicesXml(servicesXmlWithServer(httpPort), Networking.disable)) {
+ HttpClient client = new org.apache.http.impl.client.DefaultHttpClient();
+ int statusCode = client.execute(new HttpGet("http://localhost:" + httpPort)).getStatusLine().getStatusCode();
+ fail("Networking.disable is specified, but the network interface is enabled! Got status code: " + statusCode);
+ Application unused = application;
+ }
+ });
}
@Test
- public void http_interface_is_on_when_networking_is_enabled() throws Exception {
+ void http_interface_is_on_when_networking_is_enabled() throws Exception {
int httpPort = getFreePort();
try (Application application = Application.fromServicesXml(servicesXmlWithServer(httpPort), Networking.enable)) {
HttpClient client = new org.apache.http.impl.client.DefaultHttpClient();
@@ -338,7 +341,7 @@ public class ApplicationTest {
}
@Test
- public void athenz_in_deployment_xml() {
+ void athenz_in_deployment_xml() {
try (Application application = Application.fromApplicationPackage(new File("src/test/app-packages/athenz-in-deployment-xml/"), Networking.disable)) {
// Deployment succeeded
Application unused = application;
@@ -360,7 +363,7 @@ public class ApplicationTest {
}
@Test
- public void application_with_access_control_can_be_constructed() {
+ void application_with_access_control_can_be_constructed() {
try (Application application = Application.fromServicesXml(servicesXmlWithAccessControl(), Networking.disable)) {
Application unused = application;
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java b/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
index 7c786d35fab..7dad204a8ce 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
@@ -13,12 +13,13 @@ import com.yahoo.document.Document;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.processing.execution.chain.ChainRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -47,16 +48,16 @@ public class ContainerDocprocTest {
return xml;
}
- @Before
+ @BeforeEach
public void resetContainer() {
Container.resetInstance();
}
@Test
- public void requireThatBasicDocumentProcessingWorks() throws Exception {
+ void requireThatBasicDocumentProcessingWorks() throws Exception {
try (Application app = new ApplicationBuilder()
- .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
- .documentType("music", DOCUMENT).build()) {
+ .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
+ .documentType("music", DOCUMENT).build()) {
JDisc container = app.getJDisc("container");
DocumentProcessing docProc = container.documentProcessing();
@@ -84,11 +85,11 @@ public class ContainerDocprocTest {
}
@Test
- public void requireThatLaterDocumentProcessingWorks() throws Exception {
+ void requireThatLaterDocumentProcessingWorks() throws Exception {
try (Application app = new ApplicationBuilder()
- .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
- .networking(Networking.disable)
- .documentType("music", DOCUMENT).build()) {
+ .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
+ .networking(Networking.disable)
+ .documentType("music", DOCUMENT).build()) {
JDisc container = app.getJDisc("container");
DocumentProcessing docProc = container.documentProcessing();
DocumentType type = docProc.getDocumentTypes().get("music");
@@ -118,35 +119,44 @@ public class ContainerDocprocTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void requireThatUnknownChainThrows() {
- try (JDisc container = JDisc.fromServicesXml(
- getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
- Networking.disable)) {
- container.documentProcessing().process(ComponentSpecification.fromString("unknown"),
- new com.yahoo.docproc.Processing());
- }
+ @Test
+ void requireThatUnknownChainThrows() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml(
+ getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
+ Networking.disable)) {
+ container.documentProcessing().process(ComponentSpecification.fromString("unknown"),
+ new com.yahoo.docproc.Processing());
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatProcessingFails() {
- try (JDisc container = JDisc.fromServicesXml(
- getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
- Networking.disable)) {
- container.processing();
- }
+ @Test
+ void requireThatProcessingFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml(
+ getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
+ Networking.disable)) {
+ container.processing();
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatSearchFails() {
- try (JDisc container = JDisc.fromServicesXml(
- getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
- Networking.disable)) {
- container.search();
- }
+ @Test
+ void requireThatSearchFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml(
+ getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
+ Networking.disable)) {
+ container.search();
+ }
+
+ });
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java b/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java
index f76008b4e02..656660f7580 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java
@@ -9,16 +9,16 @@ import com.yahoo.application.container.handler.Response;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.test.json.JsonTestHelper;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.net.URLEncoder;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* Verify that we can create a JDisc (and hence Application) instance capable of doing model evaluation
@@ -27,22 +27,23 @@ import static org.junit.Assume.assumeTrue;
*/
public class ContainerModelEvaluationTest {
+ // This should ideally work but may not be worth the effort
@Test
- @Ignore // This should ideally work but may not be worth the effort
- public void testCreateJDiscInstanceWithModelEvaluation() {
+ @Disabled
+ void testCreateJDiscInstanceWithModelEvaluation() {
try (JDisc jdisc =
- JDisc.fromPath(new File("src/test/app-packages/model-evaluation").toPath(),
- Networking.disable)) {
+ JDisc.fromPath(new File("src/test/app-packages/model-evaluation").toPath(),
+ Networking.disable)) {
assertLoadedModels(jdisc);
}
}
@Test
- public void testCreateApplicationInstanceWithModelEvaluation() {
+ void testCreateApplicationInstanceWithModelEvaluation() {
assumeTrue(OnnxEvaluator.isRuntimeAvailable());
try (Application application =
- Application.fromApplicationPackage(new File("src/test/app-packages/model-evaluation"),
- Networking.disable)) {
+ Application.fromApplicationPackage(new File("src/test/app-packages/model-evaluation"),
+ Networking.disable)) {
assertLoadedModels(application.getJDisc("default"));
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
index e5019d6b54f..b10d62e72e0 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
@@ -7,13 +7,14 @@ import com.yahoo.component.ComponentSpecification;
import com.yahoo.container.Container;
import com.yahoo.processing.Request;
import com.yahoo.processing.Response;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -36,13 +37,13 @@ public class ContainerProcessingTest {
return xml;
}
- @Before
+ @BeforeEach
public void resetContainer() {
Container.resetInstance();
}
@Test
- public void requireThatBasicProcessingWorks() {
+ void requireThatBasicProcessingWorks() {
try (JDisc container = getContainerWithRot13()) {
Processing processing = container.processing();
@@ -55,10 +56,10 @@ public class ContainerProcessingTest {
}
@Test
- public void requireThatBasicProcessingDoesNotTruncateBigResponse() {
- int SIZE = 50*1000;
+ void requireThatBasicProcessingDoesNotTruncateBigResponse() {
+ int SIZE = 50 * 1000;
StringBuilder foo = new StringBuilder();
- for (int j = 0 ; j < SIZE ; j++) {
+ for (int j = 0; j < SIZE; j++) {
foo.append('b');
}
@@ -69,13 +70,13 @@ public class ContainerProcessingTest {
container.handleRequest(
new com.yahoo.application.container.handler.Request("http://foo/processing/?chain=foo&title=" + foo.toString()));
- assertEquals(SIZE+26, response.getBody().length);
+ assertEquals(SIZE + 26, response.getBody().length);
}
}
}
@Test
- public void processing_and_rendering_works() throws Exception {
+ void processing_and_rendering_works() throws Exception {
try (JDisc container = getContainerWithRot13()) {
Processing processing = container.processing();
@@ -90,27 +91,36 @@ public class ContainerProcessingTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void requireThatUnknownChainThrows() {
- try (JDisc container = getContainerWithRot13()) {
- container.processing().process(ComponentSpecification.fromString("unknown"), new Request());
- }
+ @Test
+ void requireThatUnknownChainThrows() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ try (JDisc container = getContainerWithRot13()) {
+ container.processing().process(ComponentSpecification.fromString("unknown"), new Request());
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatDocprocFails() {
- try (JDisc container = getContainerWithRot13()) {
- container.documentProcessing();
- }
+ @Test
+ void requireThatDocprocFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = getContainerWithRot13()) {
+ container.documentProcessing();
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatSearchFails() {
- try (JDisc container = getContainerWithRot13()) {
- container.search();
- }
+ @Test
+ void requireThatSearchFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = getContainerWithRot13()) {
+ container.search();
+ }
+
+ });
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java b/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
index 911d57a7d6e..24cae99b5ab 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
@@ -11,12 +11,13 @@ import com.yahoo.application.container.handlers.HeaderEchoRequestHandler;
import com.yahoo.application.container.handlers.ThrowingInWriteRequestHandler;
import com.yahoo.application.container.handlers.WriteException;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.charset.CharacterCodingException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -37,7 +38,7 @@ public class ContainerRequestTest {
}
@Test
- public void requireThatRequestBodyWorks() throws CharacterCodingException {
+ void requireThatRequestBodyWorks() throws CharacterCodingException {
String DATA = "we have no bananas today";
Request req = new Request("http://banana/echo", DATA.getBytes(Utf8.getCharset()));
@@ -50,7 +51,7 @@ public class ContainerRequestTest {
}
@Test
- public void requireThatCustomRequestHeadersWork() {
+ void requireThatCustomRequestHeadersWork() {
Request req = new Request("http://banana/echo");
req.getHeaders().add("X-Foo", "Bar");
@@ -62,26 +63,31 @@ public class ContainerRequestTest {
}
}
- @Test(expected = WriteException.class)
- public void requireThatRequestHandlerThatThrowsInWriteWorks() {
- String DATA = "we have no bananas today";
- Request req = new Request("http://banana/throwwrite", DATA.getBytes(Utf8.getCharset()));
+ @Test
+ void requireThatRequestHandlerThatThrowsInWriteWorks() {
+ assertThrows(WriteException.class, () -> {
+ String DATA = "we have no bananas today";
+ Request req = new Request("http://banana/throwwrite", DATA.getBytes(Utf8.getCharset()));
- try (JDisc container = JDisc.fromServicesXml(getXML(ThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/throwwrite"), Networking.disable)) {
- Response response = container.handleRequest(req);
- req.toString();
- }
+ try (JDisc container = JDisc.fromServicesXml(getXML(ThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/throwwrite"), Networking.disable)) {
+ Response response = container.handleRequest(req);
+ req.toString();
+ }
+ });
}
- @Test(expected = DelayedWriteException.class)
- public void requireThatRequestHandlerThatThrowsDelayedInWriteWorks() {
- String DATA = "we have no bananas today";
- Request req = new Request("http://banana/delayedthrowwrite", DATA.getBytes(Utf8.getCharset()));
+ @Test
+ void requireThatRequestHandlerThatThrowsDelayedInWriteWorks() {
+ assertThrows(DelayedWriteException.class, () -> {
+ String DATA = "we have no bananas today";
+ Request req = new Request("http://banana/delayedthrowwrite", DATA.getBytes(Utf8.getCharset()));
- try (JDisc container = JDisc.fromServicesXml(getXML(DelayedThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/delayedthrowwrite"), Networking.disable)) {
- Response response = container.handleRequest(req);
- req.toString();
- }
+ try (JDisc container = JDisc.fromServicesXml(getXML(DelayedThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/delayedthrowwrite"), Networking.disable)) {
+ Response response = container.handleRequest(req);
+ req.toString();
+ }
+
+ });
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java b/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
index e1e520bccc9..465bdef87a3 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
@@ -6,12 +6,13 @@ import com.yahoo.application.container.searchers.AddHitSearcher;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author gjoranv
@@ -20,7 +21,7 @@ import static org.junit.Assert.assertTrue;
public class ContainerSchemaTest {
@Test
- public void processing_and_rendering_works() throws Exception {
+ void processing_and_rendering_works() throws Exception {
final String searcherId = AddHitSearcher.class.getName();
try (JDisc container = containerWithSearch(searcherId)) {
@@ -32,7 +33,7 @@ public class ContainerSchemaTest {
}
@Test
- public void searching_works() {
+ void searching_works() {
final String searcherId = AddHitSearcher.class.getName();
try (JDisc container = containerWithSearch(searcherId)) {
@@ -54,11 +55,14 @@ public class ContainerSchemaTest {
"</container>", Networking.disable);
}
- @Test(expected = UnsupportedOperationException.class)
- public void retrieving_search_from_container_without_search_is_illegal() {
- try (JDisc container = JDisc.fromServicesXml("<container version=\"1.0\" />", Networking.disable)) {
- container.search(); // throws
- }
+ @Test
+ void retrieving_search_from_container_without_search_is_illegal() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml("<container version=\"1.0\" />", Networking.disable)) {
+ container.search(); // throws
+ }
+
+ });
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerTest.java b/application/src/test/java/com/yahoo/application/container/ContainerTest.java
index fda8e0c597a..31e0b71d186 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerTest.java
@@ -10,17 +10,17 @@ import com.yahoo.application.container.handlers.TestHandler;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.nio.charset.CharacterCodingException;
import java.nio.file.FileSystems;
import static com.yahoo.application.container.JDisc.fromServicesXml;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Tony Vaagenes
@@ -30,7 +30,7 @@ import static org.junit.Assert.fail;
public class ContainerTest {
@Test
- public void container_can_be_used_as_top_level_element() {
+ void container_can_be_used_as_top_level_element() {
try (JDisc container = fromServicesXml("<container version=\"1.0\">" + //
"<search />" + //
"</container>", Networking.disable)) {
@@ -39,7 +39,7 @@ public class ContainerTest {
}
@Test
- public void container_id_can_be_set() {
+ void container_id_can_be_set() {
try (JDisc container = fromServicesXml("<container version=\"1.0\" id=\"my-service-id\">" + //
"<search />" + //
"</container>", Networking.disable)) {
@@ -48,7 +48,7 @@ public class ContainerTest {
}
@Test
- public void container_can_be_embedded_in_services_tag() {
+ void container_can_be_embedded_in_services_tag() {
try (JDisc container = fromServicesXml("<services>" + //
"<container version=\"1.0\" id=\"my-service-id\">" + //
"<search />" + //
@@ -58,9 +58,10 @@ public class ContainerTest {
}
}
+ // container is unused inside the try block
@Test
- @SuppressWarnings("try") // container is unused inside the try block
- public void multiple_container_elements_gives_exception() {
+ @SuppressWarnings("try")
+ void multiple_container_elements_gives_exception() {
try (JDisc container = fromServicesXml("<services>" + //
"<container version=\"1.0\" id=\"id1\" />" + //
"<container version=\"1.0\" />" + //
@@ -72,7 +73,7 @@ public class ContainerTest {
}
@Test
- public void handleRequest_yields_response_from_correct_request_handler() {
+ void handleRequest_yields_response_from_correct_request_handler() {
final String handlerClass = TestHandler.class.getName();
try (JDisc container = fromServicesXml("<container version=\"1.0\">" + //
"<handler id=\"test-handler\" class=\"" + handlerClass + "\">" + //
@@ -89,7 +90,7 @@ public class ContainerTest {
}
@Test
- public void load_searcher_from_bundle() {
+ void load_searcher_from_bundle() {
try (JDisc container = JDisc.fromPath(FileSystems.getDefault().getPath("src/test/app-packages/searcher-app"),
Networking.disable)) {
Result result = container.search().process(ComponentSpecification.fromString("default"),
@@ -99,7 +100,7 @@ public class ContainerTest {
}
@Test
- public void document_types_can_be_accessed() throws Exception {
+ void document_types_can_be_accessed() throws Exception {
try (Application application = new ApplicationBuilder().documentType("example", EXAMPLE_DOCUMENT)
.servicesXml(CONTAINER_WITH_DOCUMENT_PROCESSING).build()) {
JDisc container = application.getJDisc("container");
@@ -109,7 +110,7 @@ public class ContainerTest {
}
@Test
- public void annotation_types_can_be_accessed() throws Exception {
+ void annotation_types_can_be_accessed() throws Exception {
try (Application application = new ApplicationBuilder().documentType("example", "search example {\n" + //
" " + EXAMPLE_DOCUMENT + "\n" + //
" annotation exampleAnnotation {}\n" + //
@@ -121,9 +122,9 @@ public class ContainerTest {
}
}
- @Ignore // Enable this when static state has been removed.
+ @Disabled // Enable this when static state has been removed.
@Test
- public void multiple_containers_can_be_run_in_parallel() throws Exception {
+ void multiple_containers_can_be_run_in_parallel() throws Exception {
try (JDisc jdisc1 = jdiscWithHttp(); JDisc jdisc2 = jdiscWithHttp()) {
sendRequest(jdisc1);
sendRequest(jdisc2);
diff --git a/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java b/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java
index d88d69f247e..19d5176c108 100644
--- a/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java
+++ b/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.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.application.container.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -12,12 +12,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -27,7 +28,7 @@ import static org.junit.Assert.fail;
public class HeadersTestCase {
@Test
- public void requireThatSizeWorksAsExpected() {
+ void requireThatSizeWorksAsExpected() {
Headers headers = new Headers();
assertEquals(0, headers.size());
headers.add("foo", "bar");
@@ -43,7 +44,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatIsEmptyWorksAsExpected() {
+ void requireThatIsEmptyWorksAsExpected() {
Headers headers = new Headers();
assertTrue(headers.isEmpty());
headers.add("foo", "bar");
@@ -53,7 +54,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsKeyWorksAsExpected() {
+ void requireThatContainsKeyWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.containsKey("foo"));
assertFalse(headers.containsKey("FOO"));
@@ -63,7 +64,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsValueWorksAsExpected() {
+ void requireThatContainsValueWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.containsValue(Arrays.asList("bar")));
headers.add("foo", "bar");
@@ -71,7 +72,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsWorksAsExpected() {
+ void requireThatContainsWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.contains("foo", "bar"));
assertFalse(headers.contains("FOO", "bar"));
@@ -85,7 +86,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsIgnoreCaseWorksAsExpected() {
+ void requireThatContainsIgnoreCaseWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.containsIgnoreCase("foo", "bar"));
assertFalse(headers.containsIgnoreCase("FOO", "bar"));
@@ -99,7 +100,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatAddStringWorksAsExpected() {
+ void requireThatAddStringWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.add("foo", "bar");
@@ -109,7 +110,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatAddListWorksAsExpected() {
+ void requireThatAddListWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.add("foo", Arrays.asList("bar"));
@@ -119,7 +120,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatAddAllWorksAsExpected() {
+ void requireThatAddAllWorksAsExpected() {
Headers headers = new Headers();
headers.add("foo", "bar");
headers.add("bar", "baz");
@@ -136,7 +137,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatPutStringWorksAsExpected() {
+ void requireThatPutStringWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.put("foo", "bar");
@@ -146,7 +147,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatPutListWorksAsExpected() {
+ void requireThatPutListWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.put("foo", Arrays.asList("bar"));
@@ -156,7 +157,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatPutAllWorksAsExpected() {
+ void requireThatPutAllWorksAsExpected() {
Headers headers = new Headers();
headers.add("foo", "bar");
headers.add("bar", "baz");
@@ -173,7 +174,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatRemoveWorksAsExpected() {
+ void requireThatRemoveWorksAsExpected() {
Headers headers = new Headers();
headers.put("foo", Arrays.asList("bar", "baz"));
assertEquals(Arrays.asList("bar", "baz"), headers.get("foo"));
@@ -183,7 +184,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatRemoveStringWorksAsExpected() {
+ void requireThatRemoveStringWorksAsExpected() {
Headers headers = new Headers();
headers.put("foo", Arrays.asList("bar", "baz"));
assertEquals(Arrays.asList("bar", "baz"), headers.get("foo"));
@@ -196,7 +197,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatClearWorksAsExpected() {
+ void requireThatClearWorksAsExpected() {
Headers headers = new Headers();
headers.add("foo", "bar");
headers.add("bar", "baz");
@@ -208,7 +209,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatGetWorksAsExpected() {
+ void requireThatGetWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.add("foo", "bar");
@@ -216,7 +217,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatGetFirstWorksAsExpected() {
+ void requireThatGetFirstWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.getFirst("foo"));
headers.add("foo", Arrays.asList("bar", "baz"));
@@ -224,7 +225,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatIsTrueWorksAsExpected() {
+ void requireThatIsTrueWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.isTrue("foo"));
headers.put("foo", Arrays.asList("true"));
@@ -242,7 +243,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatKeySetWorksAsExpected() {
+ void requireThatKeySetWorksAsExpected() {
Headers headers = new Headers();
assertEquals(Collections.<Set<String>>emptySet(), headers.keySet());
headers.add("foo", "bar");
@@ -252,7 +253,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatValuesWorksAsExpected() {
+ void requireThatValuesWorksAsExpected() {
Headers headers = new Headers();
assertTrue(headers.values().isEmpty());
headers.add("foo", "bar");
@@ -268,7 +269,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntrySetWorksAsExpected() {
+ void requireThatEntrySetWorksAsExpected() {
Headers headers = new Headers();
assertEquals(Collections.emptySet(), headers.entrySet());
headers.put("foo", Arrays.asList("bar", "baz"));
@@ -282,7 +283,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntriesWorksAsExpected() {
+ void requireThatEntriesWorksAsExpected() {
Headers headers = new Headers();
assertEquals(Collections.emptyList(), headers.entries());
headers.put("foo", Arrays.asList("bar", "baz"));
@@ -301,7 +302,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntryIsUnmodifiable() {
+ void requireThatEntryIsUnmodifiable() {
Headers headers = new Headers();
headers.put("foo", "bar");
Map.Entry<String, String> entry = headers.entries().get(0);
@@ -314,7 +315,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntriesAreUnmodifiable() {
+ void requireThatEntriesAreUnmodifiable() {
Headers headers = new Headers();
headers.put("foo", "bar");
List<Map.Entry<String, String>> entries = headers.entries();
@@ -333,25 +334,25 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEqualsWorksAsExpected() {
+ void requireThatEqualsWorksAsExpected() {
Headers lhs = new Headers();
Headers rhs = new Headers();
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
lhs.add("foo", "bar");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.add("foo", "bar");
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatHashCodeWorksAsExpected() {
+ void requireThatHashCodeWorksAsExpected() {
Headers lhs = new Headers();
Headers rhs = new Headers();
- assertTrue(lhs.hashCode() == rhs.hashCode());
+ assertEquals(lhs.hashCode(), rhs.hashCode());
lhs.add("foo", "bar");
assertTrue(lhs.hashCode() != rhs.hashCode());
rhs.add("foo", "bar");
- assertTrue(lhs.hashCode() == rhs.hashCode());
+ assertEquals(lhs.hashCode(), rhs.hashCode());
}
private static class MyEntry implements Map.Entry<String, String> {
diff --git a/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java b/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
index edd2acb630d..b0971c141d6 100644
--- a/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
+++ b/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.container.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author Einar M R Rosenvinge
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertNotNull;
public class ResponseTestCase {
@Test
- public void requireThatCharsetParsingWorks() {
+ void requireThatCharsetParsingWorks() {
assertEquals("utf-8", Response.charset("text/foobar").toString().toLowerCase());
assertEquals("utf-8", Response.charset("adsf").toString().toLowerCase());
assertEquals("utf-8", Response.charset("").toString().toLowerCase());
@@ -26,7 +26,7 @@ public class ResponseTestCase {
}
@Test
- public void testDefaultResponseBody() {
+ void testDefaultResponseBody() {
Response res1 = new Response();
Response res2 = new Response(new byte[0]);
diff --git a/bundle-plugin-test/integration-test/pom.xml b/bundle-plugin-test/integration-test/pom.xml
index a97d30fbaec..7384bf3aea6 100644
--- a/bundle-plugin-test/integration-test/pom.xml
+++ b/bundle-plugin-test/integration-test/pom.xml
@@ -29,13 +29,18 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
diff --git a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java
index faa33542f5c..2e3a3204ef5 100644
--- a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java
+++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/BundleTest.java
@@ -2,8 +2,8 @@
package com.yahoo.container.plugin;
import com.yahoo.vespa.config.VespaVersion;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -18,9 +18,9 @@ import java.util.jar.Manifest;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Verifies the bundle jar file built and its manifest.
@@ -38,7 +38,7 @@ public class BundleTest {
private JarFile jarFile;
private Attributes mainAttributes;
- @Before
+ @BeforeEach
public void setup() {
try {
File componentJar = findBundleJar("main");
@@ -60,7 +60,7 @@ public class BundleTest {
}
@Test
- public void require_that_bundle_version_is_added_to_manifest() {
+ void require_that_bundle_version_is_added_to_manifest() {
String bundleVersion = mainAttributes.getValue("Bundle-Version");
// Because of snapshot builds, we can only verify the major version.
@@ -69,12 +69,12 @@ public class BundleTest {
}
@Test
- public void require_that_bundle_symbolic_name_matches_pom_artifactId() {
+ void require_that_bundle_symbolic_name_matches_pom_artifactId() {
assertEquals("main", mainAttributes.getValue("Bundle-SymbolicName"));
}
@Test
- public void require_that_manifest_contains_inferred_imports() {
+ void require_that_manifest_contains_inferred_imports() {
String importPackage = mainAttributes.getValue("Import-Package");
// From SimpleSearcher
@@ -87,35 +87,35 @@ public class BundleTest {
}
@Test
- public void require_that_manifest_contains_manual_imports() {
+ void require_that_manifest_contains_manual_imports() {
String importPackage = mainAttributes.getValue("Import-Package");
assertTrue(importPackage.contains("manualImport.withoutVersion"));
assertTrue(importPackage.contains("manualImport.withVersion;version=\"12.3.4\""));
- for (int i=1; i<=2; ++i)
+ for (int i = 1; i <= 2; ++i)
assertTrue(importPackage.contains("multiple.packages.with.the.same.version" + i + ";version=\"[1,2)\""));
}
@Test
- public void require_that_manifest_contains_exports() {
+ void require_that_manifest_contains_exports() {
String exportPackage = mainAttributes.getValue("Export-Package");
assertTrue(exportPackage.contains("com.yahoo.test;version=1.2.3.RELEASE"));
}
- @Test
// TODO: use another jar than jrt, which now pulls in a lot of dependencies that pollute the manifest of the
// generated bundle. (It's compile scoped in pom.xml to be added to the bundle-cp.)
- public void require_that_manifest_contains_bundle_class_path() {
+ @Test
+ void require_that_manifest_contains_bundle_class_path() {
String bundleClassPath = mainAttributes.getValue("Bundle-ClassPath");
assertTrue(bundleClassPath.contains(".,"));
Pattern jrtPattern = Pattern.compile("dependencies/jrt" + snapshotOrVersionOrNone);
- assertTrue("Bundle class path did not contain jrt.", jrtPattern.matcher(bundleClassPath).find());
+ assertTrue(jrtPattern.matcher(bundleClassPath).find(), "Bundle class path did not contain jrt.");
}
@Test
- public void require_that_component_jar_file_contains_compile_artifacts() {
+ void require_that_component_jar_file_contains_compile_artifacts() {
String depJrt = "dependencies/jrt";
Pattern jrtPattern = Pattern.compile(depJrt + snapshotOrVersionOrNone);
ZipEntry jrtEntry = null;
@@ -130,12 +130,12 @@ public class BundleTest {
}
}
}
- assertNotNull("Component jar file did not contain jrt dependency.", jrtEntry);
+ assertNotNull(jrtEntry, "Component jar file did not contain jrt dependency.");
}
@Test
- public void require_that_web_inf_url_is_propagated_to_the_manifest() {
+ void require_that_web_inf_url_is_propagated_to_the_manifest() {
String webInfUrl = mainAttributes.getValue("WebInfUrl");
assertTrue(webInfUrl.contains("/WEB-INF/web.xml"));
}
diff --git a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java
index f99f1583324..67a191f1f94 100644
--- a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java
+++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/container/plugin/ExportPackageVersionTest.java
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.plugin;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -10,8 +10,8 @@ import java.util.jar.Attributes;
import java.util.jar.JarFile;
import static com.yahoo.container.plugin.BundleTest.findBundleJar;
-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;
/**
* Verifies that the 'useArtifactVersionForExportPackages' setting for the bundle-plugin works as intended.
@@ -23,7 +23,7 @@ public class ExportPackageVersionTest {
private static Attributes mainAttributes;
private static String bundleVersion;
- @BeforeClass
+ @BeforeAll
public static void setup() {
try {
File componentJar = findBundleJar("artifact-version-for-exports");
@@ -36,7 +36,7 @@ public class ExportPackageVersionTest {
}
@Test
- public void artifact_version_without_qualifier_is_used_as_export_version() {
+ void artifact_version_without_qualifier_is_used_as_export_version() {
// Bundle-Version is artifact version without qualifier
String expectedExport = "ai.vespa.noversion;version=" + bundleVersion;
@@ -48,13 +48,13 @@ public class ExportPackageVersionTest {
}
@Test
- public void explicit_version_in_ExportPackage_annotation_overrides_artifact_version() {
+ void explicit_version_in_ExportPackage_annotation_overrides_artifact_version() {
String exportPackage = mainAttributes.getValue("Export-Package");
assertTrue(exportPackage.contains("ai.vespa.explicitversion;version=2.4.6.RELEASE"));
}
@Test
- public void artifact_version_of_dependency_is_used_as_export_version_for_package_in_compile_scoped_dependency() {
+ void artifact_version_of_dependency_is_used_as_export_version_for_package_in_compile_scoped_dependency() {
String exportPackage = mainAttributes.getValue("Export-Package");
// TODO: This test should have checked for a fixed version of the dependency bundle, different than the main bundle version.
@@ -63,7 +63,7 @@ public class ExportPackageVersionTest {
}
@Test
- public void explicit_version_in_ExportPackage_annotation_overrides_artifact_version_of_compile_scoped_dependency() {
+ void explicit_version_in_ExportPackage_annotation_overrides_artifact_version_of_compile_scoped_dependency() {
String exportPackage = mainAttributes.getValue("Export-Package");
assertTrue(exportPackage.contains("ai.vespa.explicitversion_dep;version=3.6.9.RELEASE"));
}
diff --git a/bundle-plugin/pom.xml b/bundle-plugin/pom.xml
index be5d2d59de2..4911f88b61a 100644
--- a/bundle-plugin/pom.xml
+++ b/bundle-plugin/pom.xml
@@ -33,6 +33,16 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
</dependency>
@@ -51,11 +61,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java
index 62ecd780d7e..97c2bf02d9b 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java
@@ -3,17 +3,17 @@ package com.yahoo.container.plugin.bundle;
import com.yahoo.container.plugin.osgi.ExportPackages;
import com.yahoo.container.plugin.osgi.ExportPackages.Export;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Tony Vaagenes
@@ -37,29 +37,29 @@ public class AnalyzeBundleTest {
}
@Test
- public void require_that_non_osgi_bundles_are_ignored() {
+ void require_that_non_osgi_bundles_are_ignored() {
assertFalse(exportsByPackageName.containsKey("com.yahoo.sample.exported.package.ignored"));
}
@Test
- public void require_that_exports_are_retrieved_from_manifest_in_jars() {
+ void require_that_exports_are_retrieved_from_manifest_in_jars() {
assertEquals(1, exportsByPackageName.keySet().size());
assertTrue(exportsByPackageName.containsKey("com.yahoo.sample.exported.package"));
}
@Test
- public void exported_class_names_can_be_retrieved() {
+ void exported_class_names_can_be_retrieved() {
assertEquals(ExportPackages.packageNames(exports), exports.get(0).getPackageNames().stream().collect(Collectors.toSet()));
}
@Test
- public void require_that_invalid_exports_throws_exception() {
+ void require_that_invalid_exports_throws_exception() {
try {
AnalyzeBundle.exportedPackages(jarFile("errorExport.jar"));
fail();
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("Invalid manifest in bundle 'src/test/resources/jar/errorExport.jar'"));
- assertTrue(e.getCause().getMessage(), e.getCause().getMessage().startsWith("Failed parsing Export-Package"));
+ assertTrue(e.getCause().getMessage().startsWith("Failed parsing Export-Package"), e.getCause().getMessage());
}
}
}
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java
index f9f56a31b20..8f78363dab5 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.java
@@ -17,7 +17,7 @@ import com.yahoo.container.plugin.classanalysis.sampleclasses.MethodAnnotation;
import com.yahoo.container.plugin.classanalysis.sampleclasses.MethodInvocation;
import com.yahoo.osgi.annotation.ExportPackage;
import com.yahoo.osgi.annotation.Version;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.security.auth.login.LoginException;
import java.awt.Image;
@@ -29,10 +29,10 @@ import java.util.Optional;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.analyzeClass;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.classFile;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.name;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests that analysis of class files works.
@@ -43,23 +43,23 @@ import static org.junit.Assert.fail;
public class AnalyzeClassTest {
@Test
- public void full_class_name_is_returned() {
+ void full_class_name_is_returned() {
assertEquals(name(Base.class), analyzeClass(Base.class).getName());
}
@Test
- public void base_class_is_included() {
+ void base_class_is_included() {
assertTrue(analyzeClass(Derived.class).getReferencedClasses().contains(name(Base.class)));
}
@Test
- public void implemented_interfaces_are_included() {
+ void implemented_interfaces_are_included() {
assertTrue(analyzeClass(Base.class).getReferencedClasses().containsAll(
List.of(name(Interface1.class), name(Interface2.class))));
}
@Test
- public void interface_can_be_analyzed() {
+ void interface_can_be_analyzed() {
ClassFileMetaData classMetaData = analyzeClass(Interface1.class);
assertEquals(name(Interface1.class), classMetaData.getName());
@@ -67,77 +67,77 @@ public class AnalyzeClassTest {
}
@Test
- public void return_type_is_included() {
+ void return_type_is_included() {
assertTrue(analyzeClass(Interface1.class).getReferencedClasses().contains(name(Image.class)));
}
@Test
- public void parameters_are_included() {
+ void parameters_are_included() {
assertTrue(analyzeClass(Interface1.class).getReferencedClasses().contains(name(Kernel.class)));
}
@Test
- public void exceptions_are_included() {
+ void exceptions_are_included() {
assertTrue(analyzeClass(Interface1.class).getReferencedClasses().contains(name(ImagingOpException.class)));
}
@Test
- public void basic_types_ignored() {
+ void basic_types_ignored() {
List.of("int", "float").forEach(type ->
assertFalse(analyzeClass(Interface1.class).getReferencedClasses().contains(type)));
}
@Test
- public void arrays_of_basic_types_ignored() {
+ void arrays_of_basic_types_ignored() {
List.of("int[]", "int[][]").forEach(type ->
assertFalse(analyzeClass(Interface1.class).getReferencedClasses().contains(type)));
}
@Test
- public void instance_field_types_are_included() {
+ void instance_field_types_are_included() {
assertTrue(analyzeClass(Fields.class).getReferencedClasses().contains(name(String.class)));
}
@Test
- public void static_field_types_are_included() {
+ void static_field_types_are_included() {
assertTrue(analyzeClass(Fields.class).getReferencedClasses().contains(name(java.util.List.class)));
}
@Test
- public void field_annotation_is_included() {
+ void field_annotation_is_included() {
assertTrue(analyzeClass(Fields.class).getReferencedClasses().contains(name(DummyAnnotation.class)));
}
@Test
- public void class_annotation_is_included() {
+ void class_annotation_is_included() {
assertTrue(analyzeClass(ClassAnnotation.class).getReferencedClasses().contains(name(DummyAnnotation.class)));
}
@Test
- public void invisible_annotation_not_included() {
+ void invisible_annotation_not_included() {
assertFalse(analyzeClass(InvisibleAnnotation.class).getReferencedClasses().contains(name(InvisibleDummyAnnotation.class)));
}
@Test
- public void method_annotation_is_included() {
+ void method_annotation_is_included() {
assertTrue(analyzeClass(MethodAnnotation.class).getReferencedClasses().contains(name(DummyAnnotation.class)));
}
@Test
- public void export_package_annotations_are_ignored() {
+ void export_package_annotations_are_ignored() {
List.of(ExportPackage.class, Version.class).forEach(type ->
assertFalse(Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.package-info"))
.getReferencedClasses().contains(type)));
}
@Test
- public void export_annotations_are_processed() {
+ void export_annotations_are_processed() {
assertEquals(Optional.of(new ExportPackageAnnotation(3, 1, 4, "TEST_QUALIFIER-2")),
Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.package-info")).getExportPackage());
}
@Test
- public void export_annotations_are_validated() {
+ void export_annotations_are_validated() {
try {
Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.invalid.package-info"));
@@ -150,38 +150,38 @@ public class AnalyzeClassTest {
}
@Test
- public void catch_clauses_are_included() {
+ void catch_clauses_are_included() {
assertTrue(Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.CatchException"))
.getReferencedClasses().contains(name(LoginException.class)));
}
@Test
- public void class_references_are_included() {
+ void class_references_are_included() {
assertTrue(Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.ClassReference"))
.getReferencedClasses().contains(name(Interface1.class)));
}
@Test
- public void return_type_of_method_invocations_are_included() {
+ void return_type_of_method_invocations_are_included() {
assertTrue(analyzeClass(MethodInvocation.class).getReferencedClasses().contains(name(Image.class)));
}
@Test
- public void attributes_are_included() {
+ void attributes_are_included() {
//Uses com/coremedia/iso/Utf8.class from com.googlecode.mp4parser:isoparser:1.0-RC-1
assertTrue(Analyze.analyzeClass(classFile("class/Utf8")).getReferencedClasses()
.contains("org.aspectj.weaver.MethodDeclarationLineNumber"));
}
@Test
- public void switch_statements_are_analyzed() {
+ void switch_statements_are_analyzed() {
var referencedClasses = analyzeClass(SwitchStatement.class).getReferencedClasses();
assertTrue(referencedClasses.contains(name(ImmutableList.class)));
assertTrue(referencedClasses.contains(name(IllegalArgumentException.class)));
}
@Test
- public void records_are_analyzed() {
+ void records_are_analyzed() {
var referencedClasses = analyzeClass(RecordWithOverride.class).getReferencedClasses();
assertTrue(referencedClasses.containsAll(List.of(
name(java.util.List.class),
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.java
index 0076869eaa5..2b2e83fb024 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.java
@@ -9,15 +9,15 @@ import com.yahoo.container.plugin.classanalysis.sampleclasses.Fields;
import com.yahoo.container.plugin.classanalysis.sampleclasses.Interface1;
import com.yahoo.container.plugin.classanalysis.sampleclasses.Interface3;
import com.yahoo.container.plugin.classanalysis.sampleclasses.Methods;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.PrintStream;
import java.util.List;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.analyzeClass;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.name;
-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;
/**
* Tests that classes used in method bodies are included in the imports list.
@@ -27,52 +27,52 @@ import static org.junit.Assert.assertTrue;
public class AnalyzeMethodBodyTest {
@Test
- public void class_of_locals_are_included() {
+ void class_of_locals_are_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(Base.class)));
}
@Test
- public void class_of_locals_in_static_method_are_included() {
+ void class_of_locals_in_static_method_are_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(Derived.class)));
}
@Test
- public void field_references_are_included() {
+ void field_references_are_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().containsAll(List.of(name(java.util.List.class), name(Fields.class))));
}
@Test
- public void class_owning_field_is_included() {
+ void class_owning_field_is_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(System.class)));
}
@Test
- public void class_containing_method_is_included() {
+ void class_containing_method_is_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(PrintStream.class)));
}
@Test
- public void element_of_new_multidimensional_array_is_included() {
+ void element_of_new_multidimensional_array_is_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(Interface1.class)));
}
@Test
- public void basic_arrays_are_not_included() {
+ void basic_arrays_are_not_included() {
assertFalse(analyzeClass(Methods.class).getReferencedClasses().contains("int[]"));
}
@Test
- public void container_generic_parameters_are_included() {
+ void container_generic_parameters_are_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(Dummy.class)));
}
@Test
- public void functional_interface_usage_is_included() {
+ void functional_interface_usage_is_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(Interface3.class)));
}
@Test
- public void class_owning_method_handler_is_included() {
+ void class_owning_method_handler_is_included() {
assertTrue(analyzeClass(Methods.class).getReferencedClasses().contains(name(ClassWithMethod.class)));
}
}
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java
index 31abe785cbe..002959959ec 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.plugin.classanalysis;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author gjoranv
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals;
public class PackageTallyTest {
@Test
- public void referenced_packages_missing_from_available_packages_are_detected() {
+ void referenced_packages_missing_from_available_packages_are_detected() {
PackageTally tally = new PackageTally(Map.of(), Set.of("p1", "java.util", "com.yahoo.api.annotations", "missing"));
Set<String> missingPackages = tally.referencedPackagesMissingFrom(Set.of("p1"));
assertEquals(Set.of("missing"), missingPackages);
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/mojo/GenerateSourcesMojoTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/mojo/GenerateSourcesMojoTest.java
index 3b75d9dcb7d..4edc9c3712d 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/mojo/GenerateSourcesMojoTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/mojo/GenerateSourcesMojoTest.java
@@ -2,10 +2,10 @@
package com.yahoo.container.plugin.mojo;
import org.apache.maven.plugin.MojoExecutionException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* @author Simon Thoresen Hult
@@ -13,10 +13,10 @@ import static org.junit.Assume.assumeNotNull;
public class GenerateSourcesMojoTest {
@Test
- public void requireThatDefaultConfigGenVersionIsLoadedFromBuildProperties() throws MojoExecutionException {
+ void requireThatDefaultConfigGenVersionIsLoadedFromBuildProperties() throws MojoExecutionException {
String expected = System.getProperty("expectedDefaultConfigGenVersion");
System.out.println("expectedDefaultConfigGenVersion = " + expected);
- assumeNotNull(expected);
+ assumeTrue(expected != null);
String actual = GenerateSourcesMojo.loadDefaultConfigGenVersion();
System.out.println("defaultConfigGenVersion = " + actual);
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ExportPackageParserTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ExportPackageParserTest.java
index 2c9b32a325f..de5c0f2be9d 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ExportPackageParserTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ExportPackageParserTest.java
@@ -3,13 +3,13 @@ package com.yahoo.container.plugin.osgi;
import com.yahoo.container.plugin.osgi.ExportPackages.Export;
import com.yahoo.container.plugin.osgi.ExportPackages.Parameter;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Tony Vaagenes
@@ -19,7 +19,7 @@ public class ExportPackageParserTest {
private final Parameter versionParameter = new Parameter("version", "1.2.3.sample");
@Test
- public void require_that_package_is_parsed_correctly() {
+ void require_that_package_is_parsed_correctly() {
List<Export> exports = ExportPackageParser.parseExports("sample.exported.package");
assertEquals(1, exports.size());
@@ -28,7 +28,7 @@ public class ExportPackageParserTest {
}
@Test
- public void require_that_version_is_parsed_correctly() {
+ void require_that_version_is_parsed_correctly() {
List<Export> exports = ExportPackageParser.parseExports("com.yahoo.sample.exported.package;version=\"1.2.3.sample\"");
assertEquals(1, exports.size());
@@ -38,7 +38,7 @@ public class ExportPackageParserTest {
}
@Test
- public void require_that_multiple_packages_with_same_parameters_is_parsed_correctly() {
+ void require_that_multiple_packages_with_same_parameters_is_parsed_correctly() {
List<Export> exports = ExportPackageParser.parseExports("exported.package1;exported.package2;version=\"1.2.3.sample\"");
assertEquals(1, exports.size());
@@ -48,7 +48,7 @@ public class ExportPackageParserTest {
}
@Test
- public void require_that_spaces_between_separators_are_allowed() {
+ void require_that_spaces_between_separators_are_allowed() {
List<Export> exports = ExportPackageParser.parseExports("exported.package1 , exported.package2 ; version = \"1.2.3.sample\" ");
assertEquals(2, exports.size());
@@ -61,7 +61,7 @@ public class ExportPackageParserTest {
@SuppressWarnings("unchecked")
@Test
- public void require_that_multiple_parameters_for_a_package_is_parsed_correctly() {
+ void require_that_multiple_parameters_for_a_package_is_parsed_correctly() {
List<Export> exports = ExportPackageParser.parseExports("exported.package;version=\"1.2.3.sample\";param2=true");
assertEquals(1, exports.size());
@@ -70,7 +70,7 @@ public class ExportPackageParserTest {
}
@Test
- public void require_that_multiple_exports_are_parsed_correctly() {
+ void require_that_multiple_exports_are_parsed_correctly() {
List<Export> exports = ExportPackageParser.parseExports("exported.package1,exported.package2");
assertEquals(2, exports.size());
Export export = exports.get(0);
@@ -100,9 +100,9 @@ public class ExportPackageParserTest {
}
// TODO: MAVEN_OPTS are not propagated by the maven-surefire-plugin. Either try to fix the underlying problem or set -Xss in plugin config.
- @Ignore // Frequently causes StackOverflowError
+ @Disabled // Frequently causes StackOverflowError
@Test
- public void require_that_long_string_literals_do_not_cause_stack_overflow_error() {
+ void require_that_long_string_literals_do_not_cause_stack_overflow_error() {
//From jersey-server-1.13.jar
String exportHeader = "com.sun.jersey.server.impl.wadl;uses:=\"com.sun.jersey.api.model,com.sun.resea"
+ "rch.ws.wadl,com.sun.jersey.api.wadl.config,com.sun.jersey.server.wadl,com.sun."
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
index 29f2be838a1..aa74746bfff 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
@@ -4,9 +4,7 @@ package com.yahoo.container.plugin.osgi;
import com.yahoo.container.plugin.osgi.ExportPackages.Export;
import com.yahoo.container.plugin.osgi.ExportPackages.Parameter;
import com.yahoo.container.plugin.osgi.ImportPackages.Import;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashSet;
@@ -15,8 +13,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Tony Vaagenes
@@ -34,37 +33,37 @@ public class ImportPackageTest {
}
@Test
- public void require_that_non_implemented_import_with_matching_export_is_included() {
+ void require_that_non_implemented_import_with_matching_export_is_included() {
Set<Import> imports = calculateImports(referencedPackages, Set.of(), exports);
assertEquals(1, imports.stream().filter(imp -> imp.packageName().equals(PACKAGE_NAME) && imp.version().isEmpty()).count());
}
@Test
- public void require_that_non_implemented_import_without_matching_export_is_excluded() {
+ void require_that_non_implemented_import_without_matching_export_is_excluded() {
Set<Import> imports = calculateImports(referencedPackages, Set.of(), Map.of());
assertTrue(imports.isEmpty());
}
@Test
- public void require_that_implemented_import_with_matching_export_is_excluded() {
+ void require_that_implemented_import_with_matching_export_is_excluded() {
Set<Import> imports = calculateImports(referencedPackages, referencedPackages, exports);
assertTrue(imports.isEmpty());
}
@Test
- public void require_that_version_is_included() {
+ void require_that_version_is_included() {
Set<Import> imports = calculateImports(referencedPackages, Set.of(), exportsWithVersion);
assertEquals(1, imports.stream().filter(imp -> imp.packageName().equals(PACKAGE_NAME) && imp.version().equals("1.3")).count());
}
@Test
- public void require_that_all_versions_up_to_the_next_major_version_is_in_range() {
+ void require_that_all_versions_up_to_the_next_major_version_is_in_range() {
assertEquals("[1.2,2)", new Import("foo", Optional.of("1.2")).importVersionRange().get());
}
// TODO: Detecting guava packages should be based on bundle-symbolicName, not package name.
@Test
- public void require_that_for_guava_all_future_major_versions_are_in_range() {
+ void require_that_for_guava_all_future_major_versions_are_in_range() {
Optional<String> rangeWithInfiniteUpperLimit = Optional.of("[18.1," + ImportPackages.INFINITE_VERSION + ")");
assertEquals(rangeWithInfiniteUpperLimit, new Import("com.google.common", Optional.of("18.1")).importVersionRange());
assertEquals(rangeWithInfiniteUpperLimit, new Import("com.google.common.foo", Optional.of("18.1")).importVersionRange());
@@ -72,32 +71,29 @@ public class ImportPackageTest {
}
@Test
- public void require_that_none_version_gives_non_version_range() {
+ void require_that_none_version_gives_non_version_range() {
assertTrue(new Import("foo", Optional.empty()).importVersionRange().isEmpty());
}
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void require_that_exception_is_thrown_when_major_component_is_non_numeric() {
- expectedException.expect(IllegalArgumentException.class);
- new Import("foo", Optional.of("1notValid.2"));
+ void require_that_exception_is_thrown_when_major_component_is_non_numeric() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new Import("foo", Optional.of("1notValid.2"));
+ });
}
@Test
- public void require_that_osgi_import_supports_missing_version() {
+ void require_that_osgi_import_supports_missing_version() {
assertEquals("com.yahoo.exported", new Import("com.yahoo.exported", Optional.empty()).asOsgiImport());
}
@Test
- public void require_that_osgi_import_version_range_includes_all_versions_from_the_current_up_to_the_next_major_version() {
+ void require_that_osgi_import_version_range_includes_all_versions_from_the_current_up_to_the_next_major_version() {
assertEquals("com.yahoo.exported;version=\"[1.2,2)\"", new Import("com.yahoo.exported", Optional.of("1.2")).asOsgiImport());
}
@Test
- public void require_that_osgi_import_version_range_ignores_qualifier() {
+ void require_that_osgi_import_version_range_ignores_qualifier() {
assertEquals("com.yahoo.exported;version=\"[1.2.3,2)\"", new Import("com.yahoo.exported", Optional.of("1.2.3.qualifier")).asOsgiImport());
}
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/util/TestBundleDependencyScopeTranslatorTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/util/TestBundleDependencyScopeTranslatorTest.java
index ada2f8d208a..d20bbe0e073 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/util/TestBundleDependencyScopeTranslatorTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/util/TestBundleDependencyScopeTranslatorTest.java
@@ -5,7 +5,7 @@ package com.yahoo.container.plugin.util;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -14,7 +14,7 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bjorncs
@@ -24,7 +24,7 @@ public class TestBundleDependencyScopeTranslatorTest {
private static final String GROUP_ID = "com.test";
@Test
- public void test_dependencies_are_translated_to_compile_scope_by_default() {
+ void test_dependencies_are_translated_to_compile_scope_by_default() {
Set<Artifact> artifacts = new TreeSet<>();
Artifact a = createArtifact(artifacts, "a", "test", List.of());
Artifact aa = createArtifact(artifacts, "a-a", "test", List.of("a"));
@@ -40,7 +40,7 @@ public class TestBundleDependencyScopeTranslatorTest {
}
@Test
- public void non_test_scope_dependencies_keep_original_scope() {
+ void non_test_scope_dependencies_keep_original_scope() {
Set<Artifact> artifacts = new TreeSet<>();
Artifact a = createArtifact(artifacts, "a", "provided", List.of());
Artifact aa = createArtifact(artifacts, "a-a", "provided", List.of("a"));
@@ -61,14 +61,14 @@ public class TestBundleDependencyScopeTranslatorTest {
}
@Test
- public void ordering_in_config_string_determines_translation() {
+ void ordering_in_config_string_determines_translation() {
Set<Artifact> artifacts = new TreeSet<>();
Artifact a = createArtifact(artifacts, "a", "test", List.of());
Artifact aa = createArtifact(artifacts, "a-a", "test", List.of("a"));
{
String configString =
"com.test:a-a:runtime," +
- "com.test:a:test,";
+ "com.test:a:test,";
TestBundleDependencyScopeTranslator translator = TestBundleDependencyScopeTranslator.from(artifacts, configString);
assertScope(translator, a, "test");
assertScope(translator, aa, "runtime");
@@ -76,7 +76,7 @@ public class TestBundleDependencyScopeTranslatorTest {
{
String configString =
"com.test:a:test," +
- "com.test:a-a:runtime";
+ "com.test:a-a:runtime";
TestBundleDependencyScopeTranslator translator = TestBundleDependencyScopeTranslator.from(artifacts, configString);
assertScope(translator, a, "test");
assertScope(translator, aa, "test");
@@ -84,7 +84,7 @@ public class TestBundleDependencyScopeTranslatorTest {
}
@Test
- public void transitive_non_test_dependencies_of_test_dependencies_keep_original_scope() {
+ void transitive_non_test_dependencies_of_test_dependencies_keep_original_scope() {
Set<Artifact> artifacts = new TreeSet<>();
Artifact a = createArtifact(artifacts, "a", "test", List.of());
Artifact aa = createArtifact(artifacts, "a-a", "test", List.of("a"));
@@ -108,7 +108,7 @@ public class TestBundleDependencyScopeTranslatorTest {
}
@Test
- public void different_classifiers_are_handled_separately() {
+ void different_classifiers_are_handled_separately() {
Set<Artifact> artifacts = new TreeSet<>();
Artifact a = createArtifact(artifacts, "a", "test", List.of());
Artifact ab = createArtifact(artifacts, "a-b", "provided", List.of("a"));
diff --git a/clustercontroller-apps/pom.xml b/clustercontroller-apps/pom.xml
index fa0f5c064ad..8a3fa2da811 100644
--- a/clustercontroller-apps/pom.xml
+++ b/clustercontroller-apps/pom.xml
@@ -13,21 +13,16 @@
<packaging>container-plugin</packaging>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>container-dev</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- </exclusion>
- </exclusions>
+ <exclusions>
+ <exclusion>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
@@ -58,6 +53,16 @@
<artifactId>jettison</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java
index dda18fc3396..7c5913774c3 100644
--- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java
+++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java
@@ -6,19 +6,19 @@ import com.yahoo.cloud.config.ZookeepersConfig;
import com.yahoo.jdisc.Metric;
import com.yahoo.vespa.config.content.FleetcontrollerConfig;
import com.yahoo.vespa.config.content.StorDistributionConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class ClusterControllerClusterConfigurerTest {
@Test
- public void testSimple() throws Exception {
+ void testSimple() throws Exception {
ClusterController controller = new ClusterController();
StorDistributionConfig.Builder distributionConfig = new StorDistributionConfig.Builder();
StorDistributionConfig.Group.Builder group = new StorDistributionConfig.Group.Builder();
@@ -45,13 +45,17 @@ public class ClusterControllerClusterConfigurerTest {
zookeepersConfig.zookeeperserverlist("foo");
Metric metric = new Metric() {
@Override
- public void set(String s, Number number, Context context) {}
+ public void set(String s, Number number, Context context) {
+ }
@Override
- public void add(String s, Number number, Context context) {}
+ public void add(String s, Number number, Context context) {
+ }
@Override
- public Context createContext(Map<String, ?> stringMap) { return null; }
+ public Context createContext(Map<String, ?> stringMap) {
+ return null;
+ }
};
- // Used in standalone mode to get config without a cluster controller instance
+ // Used in standalone mode to get config without a cluster controller instance
ClusterControllerClusterConfigurer configurer = new ClusterControllerClusterConfigurer(
null,
new StorDistributionConfig(distributionConfig),
@@ -68,7 +72,7 @@ public class ClusterControllerClusterConfigurerTest {
assertEquals(0.7, configurer.getOptions().clusterFeedBlockLimit.get("bar"), 0.01);
assertEquals(0.05, configurer.getOptions().clusterFeedBlockNoiseLevel, 0.001);
- try{
+ try {
zookeepersConfig.zookeeperserverlist("");
new ClusterControllerClusterConfigurer(
controller,
diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java
index 2c33f781737..cfda92b472d 100644
--- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java
+++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java
@@ -5,17 +5,17 @@ import com.yahoo.jdisc.Metric;
import com.yahoo.vdslib.distribution.ConfiguredNode;
import com.yahoo.vespa.clustercontroller.core.FleetController;
import com.yahoo.vespa.clustercontroller.core.FleetControllerOptions;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Doesn't really test cluster controller, but runs some lines of code.
@@ -34,7 +34,7 @@ public class ClusterControllerTest {
public Context createContext(Map<String, ?> stringMap) { return null; }
};
- @Before
+ @BeforeEach
public void setUp() {
options = new FleetControllerOptions("storage", Set.of(new ConfiguredNode(0, false)));
options.zooKeeperServerAddress = null;
@@ -43,7 +43,7 @@ public class ClusterControllerTest {
}
@Test
- public void testSimple() throws Exception {
+ void testSimple() throws Exception {
ClusterController cc = new ClusterController();
cc.setOptions(options, metric);
cc.setOptions(options, metric);
@@ -57,7 +57,7 @@ public class ClusterControllerTest {
}
@Test
- public void testShutdownException() throws Exception {
+ void testShutdownException() throws Exception {
ClusterController cc = new ClusterController() {
void shutdownController(FleetController controller) throws Exception {
throw new Exception("Foo");
diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StateRestApiV2HandlerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StateRestApiV2HandlerTest.java
index bf759e3dc76..7146d95e7ba 100644
--- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StateRestApiV2HandlerTest.java
+++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StateRestApiV2HandlerTest.java
@@ -3,17 +3,17 @@ package com.yahoo.vespa.clustercontroller.apps.clustercontroller;
import com.yahoo.cloud.config.ClusterInfoConfig;
import com.yahoo.vespa.clustercontroller.core.restapiv2.ClusterControllerStateRestAPI;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.TreeMap;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class StateRestApiV2HandlerTest {
@Test
- public void testNoMatchingSockets() {
+ void testNoMatchingSockets() {
ClusterController controller = new ClusterController();
ClusterInfoConfig config = new ClusterInfoConfig(
new ClusterInfoConfig.Builder().clusterId("cluster-id").nodeCount(1));
@@ -22,7 +22,7 @@ public class StateRestApiV2HandlerTest {
}
@Test
- public void testMappingOfIndexToClusterControllers() {
+ void testMappingOfIndexToClusterControllers() {
ClusterInfoConfig.Builder builder = new ClusterInfoConfig.Builder()
.clusterId("cluster-id")
.nodeCount(1)
diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StatusHandlerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StatusHandlerTest.java
index 7a204aa791d..d4eb84677dc 100644
--- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StatusHandlerTest.java
+++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/StatusHandlerTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.apps.clustercontroller;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class StatusHandlerTest {
@Test
- public void testSimple() {
+ void testSimple() {
ClusterController controller = new ClusterController();
StatusHandler handler = new StatusHandler(controller, StatusHandler.testContext());
}
diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscHttpRequestHandlerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscHttpRequestHandlerTest.java
index 6a27228feab..19a5a2a60f9 100644
--- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscHttpRequestHandlerTest.java
+++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscHttpRequestHandlerTest.java
@@ -2,15 +2,15 @@
package com.yahoo.vespa.clustercontroller.apputil.communication.http;
import com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-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;
/**
* The handler is mostly tested through the apache tests, using it as endpoint here..
@@ -20,7 +20,7 @@ public class JDiscHttpRequestHandlerTest {
private ThreadPoolExecutor executor;
- @Before
+ @BeforeEach
public void setUp() {
executor = new ThreadPoolExecutor(10, 100, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000));
}
@@ -30,8 +30,8 @@ public class JDiscHttpRequestHandlerTest {
}
@Test
- public void testInvalidMethod() throws Exception {
- try{
+ void testInvalidMethod() throws Exception {
+ try {
HttpRequest request = new HttpRequest();
JDiscHttpRequestHandler.setOperation(request, com.yahoo.jdisc.http.HttpRequest.Method.CONNECT);
fail("Control should not reach here");
@@ -41,7 +41,7 @@ public class JDiscHttpRequestHandlerTest {
}
@Test
- public void testNothingButAddCoverage() throws Exception {
+ void testNothingButAddCoverage() throws Exception {
new JDiscHttpRequestHandler.EmptyCompletionHandler().failed(null);
}
}
diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscMetricWrapperTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscMetricWrapperTest.java
index e7c8301cfca..a62437d1a8f 100644
--- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscMetricWrapperTest.java
+++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apputil/communication/http/JDiscMetricWrapperTest.java
@@ -2,12 +2,12 @@
package com.yahoo.vespa.clustercontroller.apputil.communication.http;
import com.yahoo.jdisc.Metric;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class JDiscMetricWrapperTest {
@@ -22,10 +22,10 @@ public class JDiscMetricWrapperTest {
++calls;
return new Context() {};
}
- };
+ }
@Test
- public void testSimple() {
+ void testSimple() {
MetricImpl impl1 = new MetricImpl();
MetricImpl impl2 = new MetricImpl();
JDiscMetricWrapper wrapper = new JDiscMetricWrapper(impl1);
diff --git a/clustercontroller-core/pom.xml b/clustercontroller-core/pom.xml
index 243b69bf1e2..dbd7e14a8f6 100644
--- a/clustercontroller-core/pom.xml
+++ b/clustercontroller-core/pom.xml
@@ -27,8 +27,8 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
@@ -38,13 +38,14 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -53,6 +54,16 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
</dependency>
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java
index dece8019e2c..b12f37e092d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -52,43 +52,43 @@ public class AggregatedStatsMergePendingCheckerTest {
}
@Test
- public void unknown_content_node_may_have_merges_pending() {
+ void unknown_content_node_may_have_merges_pending() {
Fixture f = Fixture.fromBucketsPending(1);
assertTrue(f.mayHaveMergesPending("default", 2));
}
@Test
- public void unknown_bucket_space_has_no_merges_pending() {
+ void unknown_bucket_space_has_no_merges_pending() {
Fixture f = Fixture.fromBucketsPending(1);
assertFalse(f.mayHaveMergesPending("global", 1));
}
@Test
- public void valid_bucket_space_stats_can_have_no_merges_pending() {
+ void valid_bucket_space_stats_can_have_no_merges_pending() {
Fixture f = Fixture.fromBucketsPending(0);
assertFalse(f.mayHaveMergesPending("default", 1));
}
@Test
- public void valid_bucket_space_stats_may_have_merges_pending() {
+ void valid_bucket_space_stats_may_have_merges_pending() {
Fixture f = Fixture.fromBucketsPending(1);
assertTrue(f.mayHaveMergesPending("default", 1));
}
@Test
- public void invalid_bucket_space_stats_may_have_merges_pending() {
+ void invalid_bucket_space_stats_may_have_merges_pending() {
Fixture f = Fixture.fromInvalidBucketStats();
assertTrue(f.mayHaveMergesPending("default", 1));
}
@Test
- public void cluster_without_updates_from_all_distributors_may_have_merges_pending() {
+ void cluster_without_updates_from_all_distributors_may_have_merges_pending() {
Fixture f = Fixture.fromIncompleteStats();
assertTrue(f.mayHaveMergesPending("default", 1));
}
@Test
- public void min_merge_completion_ratio_is_used_when_calculating_may_have_merges_pending() {
+ void min_merge_completion_ratio_is_used_when_calculating_may_have_merges_pending() {
// Completion ratio is (5-3)/5 = 0.4
assertTrue(Fixture.fromBucketsPending(3, 0.6).mayHaveMergesPending("default", 1));
// Completion ratio is (5-2)/5 = 0.6
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java
index f0b91102e8f..ec6255fd13b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java
@@ -10,8 +10,8 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabaseFactory;
import com.yahoo.vespa.clustercontroller.utils.util.NoMetricReporter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashSet;
@@ -22,10 +22,10 @@ import java.util.Set;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.mapOf;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.setOf;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.usage;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.createResourceUsageJson;
-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;
public class ClusterFeedBlockTest extends FleetControllerTest {
@@ -36,7 +36,7 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
private FleetController ctrl;
private DummyCommunicator communicator;
- @Before
+ @BeforeEach
public void setUp() {
supervisor = new Supervisor(new Transport());
}
@@ -107,7 +107,7 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
}
@Test
- public void cluster_feed_can_be_blocked_and_unblocked_by_single_node() throws Exception {
+ void cluster_feed_can_be_blocked_and_unblocked_by_single_node() throws Exception {
initialize(createOptions(mapOf(usage("cheese", 0.7), usage("wine", 0.4))));
assertFalse(ctrl.getClusterStateBundle().clusterFeedIsBlocked());
@@ -127,7 +127,7 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
}
@Test
- public void cluster_feed_block_state_is_recomputed_when_options_are_updated() throws Exception {
+ void cluster_feed_block_state_is_recomputed_when_options_are_updated() throws Exception {
initialize(createOptions(mapOf(usage("cheese", 0.7), usage("wine", 0.4))));
assertFalse(ctrl.getClusterStateBundle().clusterFeedIsBlocked());
@@ -142,7 +142,7 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
}
@Test
- public void cluster_feed_block_state_is_recomputed_when_resource_block_set_differs() throws Exception {
+ void cluster_feed_block_state_is_recomputed_when_resource_block_set_differs() throws Exception {
initialize(createOptions(mapOf(usage("cheese", 0.7), usage("wine", 0.4))));
assertFalse(ctrl.getClusterStateBundle().clusterFeedIsBlocked());
@@ -155,12 +155,12 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
bundle = ctrl.getClusterStateBundle();
assertTrue(bundle.clusterFeedIsBlocked());
assertEquals("cheese on node 1 [unknown hostname] (0.800 > 0.700), " +
- "wine on node 1 [unknown hostname] (0.500 > 0.400)",
- bundle.getFeedBlock().get().getDescription());
+ "wine on node 1 [unknown hostname] (0.500 > 0.400)",
+ bundle.getFeedBlock().get().getDescription());
}
@Test
- public void cluster_feed_block_state_is_not_recomputed_when_only_resource_usage_levels_differ() throws Exception {
+ void cluster_feed_block_state_is_not_recomputed_when_only_resource_usage_levels_differ() throws Exception {
initialize(createOptions(mapOf(usage("cheese", 0.7), usage("wine", 0.4))));
assertFalse(ctrl.getClusterStateBundle().clusterFeedIsBlocked());
@@ -177,7 +177,7 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
}
@Test
- public void cluster_feed_block_state_is_recomputed_when_usage_enters_hysteresis_range() throws Exception {
+ void cluster_feed_block_state_is_recomputed_when_usage_enters_hysteresis_range() throws Exception {
initialize(createOptions(mapOf(usage("cheese", 0.7), usage("wine", 0.4)), 0.1));
assertFalse(ctrl.getClusterStateBundle().clusterFeedIsBlocked());
@@ -193,22 +193,22 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
// is not discovered here. Still correct in terms of what resources are blocked or not, but
// the description is not up to date here.
assertEquals("cheese on node 1 [unknown hostname] (0.750 > 0.700)",
- bundle.getFeedBlock().get().getDescription());
+ bundle.getFeedBlock().get().getDescription());
// Trigger an explicit recompute by adding a separate resource exhaustion
reportResourceUsageFromNode(1, setOf(usage("cheese", 0.67), usage("wine", 0.5)));
bundle = ctrl.getClusterStateBundle();
assertTrue(bundle.clusterFeedIsBlocked());
assertEquals("cheese on node 1 [unknown hostname] (0.670 > 0.600), " +
- "wine on node 1 [unknown hostname] (0.500 > 0.400)", // Not under hysteresis
- bundle.getFeedBlock().get().getDescription());
+ "wine on node 1 [unknown hostname] (0.500 > 0.400)", // Not under hysteresis
+ bundle.getFeedBlock().get().getDescription());
// Wine usage drops beyond hysteresis range, should be unblocked immediately.
reportResourceUsageFromNode(1, setOf(usage("cheese", 0.61), usage("wine", 0.2)));
bundle = ctrl.getClusterStateBundle();
assertTrue(bundle.clusterFeedIsBlocked());
assertEquals("cheese on node 1 [unknown hostname] (0.610 > 0.600)",
- bundle.getFeedBlock().get().getDescription());
+ bundle.getFeedBlock().get().getDescription());
// Cheese now drops below hysteresis range, should be unblocked as well.
reportResourceUsageFromNode(1, setOf(usage("cheese", 0.59), usage("wine", 0.2)));
@@ -217,7 +217,7 @@ public class ClusterFeedBlockTest extends FleetControllerTest {
}
@Test
- public void unavailable_nodes_are_not_considered_when_computing_feed_blocked_state() throws Exception {
+ void unavailable_nodes_are_not_considered_when_computing_feed_blocked_state() throws Exception {
initialize(createOptions(mapOf(usage("cheese", 0.7), usage("wine", 0.4)), 0.1));
assertFalse(ctrl.getClusterStateBundle().clusterFeedIsBlocked());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java
index d12541687f0..17c461a487b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java
@@ -6,7 +6,7 @@ import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
import java.util.function.Function;
@@ -15,9 +15,7 @@ import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.exhaustion;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.setOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
-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.*;
public class ClusterStateBundleTest {
@@ -67,7 +65,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void builder_creates_baseline_state_and_derived_state_per_space() {
+ void builder_creates_baseline_state_and_derived_state_per_space() {
ClusterStateBundle bundle = createTestBundle();
assertThat(bundle.getBaselineClusterState(), equalTo(stateOf("distributor:2 storage:2")));
assertThat(bundle.getDerivedBucketSpaceStates().size(), equalTo(3));
@@ -77,7 +75,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void version_clone_sets_version_for_all_spaces() {
+ void version_clone_sets_version_for_all_spaces() {
ClusterStateBundle bundle = createTestBundle().clonedWithVersionSet(123);
assertThat(bundle.getBaselineClusterState(), equalTo(stateOf("version:123 distributor:2 storage:2")));
assertThat(bundle.getDerivedBucketSpaceStates().size(), equalTo(3));
@@ -87,13 +85,13 @@ public class ClusterStateBundleTest {
}
@Test
- public void same_bundle_instance_considered_similar() {
+ void same_bundle_instance_considered_similar() {
ClusterStateBundle bundle = createTestBundle();
assertTrue(bundle.similarTo(bundle));
}
@Test
- public void similarity_test_considers_all_bucket_spaces() {
+ void similarity_test_considers_all_bucket_spaces() {
ClusterStateBundle bundle = createTestBundle(false);
ClusterStateBundle unchangedBundle = createTestBundle(false);
@@ -106,7 +104,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void similarity_test_considers_cluster_feed_block_state() {
+ void similarity_test_considers_cluster_feed_block_state() {
var nonBlockingBundle = createTestBundle(false);
var blockingBundle = createTestBundleWithFeedBlock("foo");
var blockingBundleWithOtherDesc = createTestBundleWithFeedBlock("bar");
@@ -119,7 +117,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void similarity_test_considers_cluster_feed_block_concrete_exhaustion_set() {
+ void similarity_test_considers_cluster_feed_block_concrete_exhaustion_set() {
var blockingBundleNoSet = createTestBundleWithFeedBlock("foo");
var blockingBundleWithSet = createTestBundleWithFeedBlock("bar", setOf(exhaustion(1, "beer"), exhaustion(1, "wine")));
var blockingBundleWithOtherSet = createTestBundleWithFeedBlock("bar", setOf(exhaustion(1, "beer"), exhaustion(1, "soda")));
@@ -132,7 +130,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void feed_block_state_is_available() {
+ void feed_block_state_is_available() {
var nonBlockingBundle = createTestBundle(false);
var blockingBundle = createTestBundleWithFeedBlock("foo");
@@ -147,14 +145,14 @@ public class ClusterStateBundleTest {
}
@Test
- public void toString_without_bucket_space_states_prints_only_baseline_state() {
+ void toString_without_bucket_space_states_prints_only_baseline_state() {
ClusterStateBundle bundle = ClusterStateBundle.ofBaselineOnly(
annotatedStateOf("distributor:2 storage:2"));
assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2')"));
}
@Test
- public void toString_includes_all_bucket_space_states() {
+ void toString_includes_all_bucket_space_states() {
ClusterStateBundle bundle = createTestBundle();
assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " +
"default 'distributor:2 storage:2 .0.s:d', " +
@@ -163,7 +161,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void toString_with_feed_blocked_includes_description() {
+ void toString_with_feed_blocked_includes_description() {
var blockingBundle = createTestBundleWithFeedBlock("bear sleeping on server rack");
assertThat(blockingBundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " +
"default 'distributor:2 storage:2', " +
@@ -173,19 +171,19 @@ public class ClusterStateBundleTest {
}
@Test
- public void toString_without_derived_states_specifies_deferred_activation_iff_set() {
+ void toString_without_derived_states_specifies_deferred_activation_iff_set() {
var bundle = ClusterStateBundle.ofBaselineOnly(annotatedStateOf("distributor:2 storage:2"), null, true);
assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2' (deferred activation))"));
}
@Test
- public void toString_without_derived_states_does_not_specify_deferred_activation_iff_not_set() {
+ void toString_without_derived_states_does_not_specify_deferred_activation_iff_not_set() {
var bundle = ClusterStateBundle.ofBaselineOnly(annotatedStateOf("distributor:2 storage:2"), null, false);
assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2')"));
}
@Test
- public void toString_with_derived_states_specifies_deferred_activation_iff_set() {
+ void toString_with_derived_states_specifies_deferred_activation_iff_set() {
var bundle = createTestBundleBuilder(true).deferredActivation(true).deriveAndBuild();
assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " +
"default 'distributor:2 storage:2 .0.s:d', " +
@@ -194,7 +192,7 @@ public class ClusterStateBundleTest {
}
@Test
- public void toString_with_derived_states_does_not_specify_deferred_activation_iff_not_set() {
+ void toString_with_derived_states_does_not_specify_deferred_activation_iff_not_set() {
var bundle = createTestBundleBuilder(true).deferredActivation(false).deriveAndBuild();
assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " +
"default 'distributor:2 storage:2 .0.s:d', " +
@@ -203,25 +201,25 @@ public class ClusterStateBundleTest {
}
@Test
- public void deferred_activation_is_disabled_by_default() {
+ void deferred_activation_is_disabled_by_default() {
ClusterStateBundle bundle = createTestBundle();
assertFalse(bundle.deferredActivation());
}
@Test
- public void can_build_bundle_with_deferred_activation_enabled() {
+ void can_build_bundle_with_deferred_activation_enabled() {
var bundle = createTestBundleBuilder(false).deferredActivation(true).deriveAndBuild();
assertTrue(bundle.deferredActivation());
}
@Test
- public void can_build_bundle_with_deferred_activation_disabled() {
+ void can_build_bundle_with_deferred_activation_disabled() {
var bundle = createTestBundleBuilder(false).deferredActivation(false).deriveAndBuild();
assertFalse(bundle.deferredActivation());
}
@Test
- public void simple_bundle_without_derived_states_propagates_deferred_activation_flag() {
+ void simple_bundle_without_derived_states_propagates_deferred_activation_flag() {
var bundle = ClusterStateBundle
.builder(annotatedStateOf("distributor:2 storage:2"))
.deferredActivation(true) // defaults to false
@@ -230,22 +228,23 @@ public class ClusterStateBundleTest {
}
@Test
- public void cloning_preserves_false_deferred_activation_flag() {
+ void cloning_preserves_false_deferred_activation_flag() {
var bundle = createTestBundleBuilder(true).deferredActivation(false).deriveAndBuild();
var derived = bundle.cloneWithMapper(Function.identity());
assertEquals(bundle, derived);
}
@Test
- public void cloning_preserves_true_deferred_activation_flag() {
+ void cloning_preserves_true_deferred_activation_flag() {
var bundle = createTestBundleBuilder(true).deferredActivation(true).deriveAndBuild();
var derived = bundle.cloneWithMapper(Function.identity());
assertEquals(bundle, derived);
}
@Test
- public void cloning_preserves_feed_block_state() {
- var bundle = createTestBundleWithFeedBlock("foo");;
+ void cloning_preserves_feed_block_state() {
+ var bundle = createTestBundleWithFeedBlock("foo");
+ ;
var derived = bundle.cloneWithMapper(Function.identity());
assertEquals(bundle, derived);
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java
index f857bfcee89..78911c414a2 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java
@@ -6,7 +6,7 @@ import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Optional;
import java.util.Set;
@@ -30,7 +30,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_with_all_nodes_reported_down_has_state_down() {
+ void cluster_with_all_nodes_reported_down_has_state_down() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(6).markEntireClusterDown();
final AnnotatedClusterState state = generateFromFixtureWithDefaultParams(fixture);
@@ -41,7 +41,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_with_all_nodes_up_state_correct_distributor_and_storage_count() {
+ void cluster_with_all_nodes_up_state_correct_distributor_and_storage_count() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(6).bringEntireClusterUp();
final AnnotatedClusterState state = generateFromFixtureWithDefaultParams(fixture);
@@ -49,7 +49,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void distributor_reported_states_reflected_in_generated_state() {
+ void distributor_reported_states_reflected_in_generated_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(9)
.bringEntireClusterUp()
.reportDistributorNodeState(2, State.DOWN)
@@ -61,7 +61,7 @@ public class ClusterStateGeneratorTest {
// NOTE: initializing state tested separately since it involves init progress state info
@Test
- public void storage_reported_states_reflected_in_generated_state() {
+ void storage_reported_states_reflected_in_generated_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(9)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.DOWN)
@@ -72,7 +72,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void worse_distributor_wanted_state_overrides_reported_state() {
+ void worse_distributor_wanted_state_overrides_reported_state() {
// Maintenance mode is illegal for distributors and therefore not tested
final ClusterFixture fixture = ClusterFixture.forFlatCluster(7)
.bringEntireClusterUp()
@@ -85,7 +85,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void worse_storage_wanted_state_overrides_reported_state() {
+ void worse_storage_wanted_state_overrides_reported_state() {
// Does not test all maintenance mode overrides; see maintenance_mode_overrides_reported_state
// for that.
final ClusterFixture fixture = ClusterFixture.forFlatCluster(7)
@@ -100,7 +100,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void better_distributor_wanted_state_does_not_override_reported_state() {
+ void better_distributor_wanted_state_does_not_override_reported_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(7)
.bringEntireClusterUp()
.reportDistributorNodeState(0, State.DOWN)
@@ -111,7 +111,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void better_storage_wanted_state_does_not_override_reported_state() {
+ void better_storage_wanted_state_does_not_override_reported_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(7)
.bringEntireClusterUp()
.reportStorageNodeState(1, State.DOWN)
@@ -130,7 +130,7 @@ public class ClusterStateGeneratorTest {
* directly from Maintenance -> Up.
*/
@Test
- public void retired_node_in_init_state_is_set_to_maintenance() {
+ void retired_node_in_init_state_is_set_to_maintenance() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(1, State.INITIALIZING)
@@ -152,7 +152,7 @@ public class ClusterStateGeneratorTest {
* value and triggering on a sufficiently low value.
*/
@Test
- public void storage_node_in_init_mode_while_listing_buckets_is_marked_down() {
+ void storage_node_in_init_mode_while_listing_buckets_is_marked_down() {
final NodeState initWhileListingBuckets = new NodeState(NodeType.STORAGE, State.INITIALIZING);
initWhileListingBuckets.setInitProgress(0.0f);
@@ -169,7 +169,7 @@ public class ClusterStateGeneratorTest {
* is set to Maintenance.
*/
@Test
- public void implicit_down_while_listing_buckets_does_not_override_wanted_state() {
+ void implicit_down_while_listing_buckets_does_not_override_wanted_state() {
final NodeState initWhileListingBuckets = new NodeState(NodeType.STORAGE, State.INITIALIZING);
initWhileListingBuckets.setInitProgress(0.0f);
@@ -183,7 +183,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void distributor_nodes_in_init_mode_are_not_mapped_to_down() {
+ void distributor_nodes_in_init_mode_are_not_mapped_to_down() {
final NodeState initWhileListingBuckets = new NodeState(NodeType.DISTRIBUTOR, State.INITIALIZING);
initWhileListingBuckets.setInitProgress(0.0f);
@@ -199,7 +199,7 @@ public class ClusterStateGeneratorTest {
* Maintenance mode overrides all reported states, even Down.
*/
@Test
- public void maintenance_mode_wanted_state_overrides_reported_state() {
+ void maintenance_mode_wanted_state_overrides_reported_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(7)
.bringEntireClusterUp()
.proposeStorageNodeWantedState(0, State.MAINTENANCE)
@@ -215,7 +215,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void wanted_state_description_carries_over_to_generated_state() {
+ void wanted_state_description_carries_over_to_generated_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(7)
.bringEntireClusterUp()
.proposeStorageNodeWantedState(1, State.MAINTENANCE, "foo")
@@ -230,7 +230,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void config_retired_mode_is_reflected_in_generated_state() {
+ void config_retired_mode_is_reflected_in_generated_state() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(5)
.markNodeAsConfigRetired(2)
.bringEntireClusterUp();
@@ -241,7 +241,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void config_retired_mode_is_overridden_by_worse_wanted_state() {
+ void config_retired_mode_is_overridden_by_worse_wanted_state() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(5)
.markNodeAsConfigRetired(2)
.markNodeAsConfigRetired(3)
@@ -279,17 +279,17 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void reported_down_node_within_transition_time_has_maintenance_generated_state() {
+ void reported_down_node_within_transition_time_has_maintenance_generated_state() {
do_test_change_within_node_transition_time_window_generates_maintenance(State.DOWN);
}
@Test
- public void reported_stopping_node_within_transition_time_has_maintenance_generated_state() {
+ void reported_stopping_node_within_transition_time_has_maintenance_generated_state() {
do_test_change_within_node_transition_time_window_generates_maintenance(State.STOPPING);
}
@Test
- public void reported_node_down_after_transition_time_has_down_generated_state() {
+ void reported_node_down_after_transition_time_has_down_generated_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams()
.currentTimeInMilllis(11_000)
@@ -306,7 +306,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void distributor_nodes_are_not_implicitly_transitioned_to_maintenance_mode() {
+ void distributor_nodes_are_not_implicitly_transitioned_to_maintenance_mode() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams()
.currentTimeInMilllis(10_000)
@@ -323,7 +323,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void transient_maintenance_mode_does_not_override_wanted_down_state() {
+ void transient_maintenance_mode_does_not_override_wanted_down_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams()
.currentTimeInMilllis(10_000)
@@ -340,7 +340,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void reported_down_retired_node_within_transition_time_transitions_to_maintenance() {
+ void reported_down_retired_node_within_transition_time_transitions_to_maintenance() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams()
.currentTimeInMilllis(10_000)
@@ -356,7 +356,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void crash_count_exceeding_limit_marks_node_as_down() {
+ void crash_count_exceeding_limit_marks_node_as_down() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams().maxPrematureCrashes(10);
@@ -368,7 +368,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void crash_count_not_exceeding_limit_does_not_mark_node_as_down() {
+ void crash_count_not_exceeding_limit_does_not_mark_node_as_down() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams().maxPrematureCrashes(10);
@@ -380,7 +380,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void exceeded_crash_count_does_not_override_wanted_maintenance_state() {
+ void exceeded_crash_count_does_not_override_wanted_maintenance_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5)
.bringEntireClusterUp()
.proposeStorageNodeWantedState(1, State.MAINTENANCE);
@@ -395,7 +395,7 @@ public class ClusterStateGeneratorTest {
// Stopping -> Down is expected and does not indicate an unstable node.
@Test
- public void transition_from_controlled_stop_to_down_does_not_add_to_crash_counter() {
+ void transition_from_controlled_stop_to_down_does_not_add_to_crash_counter() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(2)
.bringEntireClusterUp()
.reportStorageNodeState(1, State.STOPPING, "controlled shutdown") // urgh, string matching logic
@@ -405,7 +405,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void non_observed_storage_node_start_timestamp_is_included_in_state() {
+ void non_observed_storage_node_start_timestamp_is_included_in_state() {
final NodeState nodeState = new NodeState(NodeType.STORAGE, State.UP);
// A reported state timestamp that is not yet marked as observed in the NodeInfo
// for the same node is considered not observed by other nodes and must therefore
@@ -421,7 +421,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void non_observed_distributor_start_timestamp_is_included_in_state() {
+ void non_observed_distributor_start_timestamp_is_included_in_state() {
final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, State.UP);
nodeState.setStartTimestamp(6000);
@@ -434,7 +434,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void fully_observed_storage_node_timestamp_not_included_in_state() {
+ void fully_observed_storage_node_timestamp_not_included_in_state() {
final NodeState nodeState = new NodeState(NodeType.STORAGE, State.UP);
nodeState.setStartTimestamp(5000);
@@ -450,7 +450,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void fully_observed_distributor_timestamp_not_included_in_state() {
+ void fully_observed_distributor_timestamp_not_included_in_state() {
final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, State.UP);
nodeState.setStartTimestamp(6000);
@@ -466,7 +466,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_down_if_less_than_min_count_of_storage_nodes_available() {
+ void cluster_down_if_less_than_min_count_of_storage_nodes_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.DOWN)
@@ -479,7 +479,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_not_down_if_more_than_min_count_of_storage_nodes_are_available() {
+ void cluster_not_down_if_more_than_min_count_of_storage_nodes_are_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.DOWN);
@@ -491,7 +491,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_down_if_less_than_min_count_of_distributors_available() {
+ void cluster_down_if_less_than_min_count_of_distributors_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportDistributorNodeState(0, State.DOWN)
@@ -504,7 +504,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_not_down_if_more_than_min_count_of_distributors_are_available() {
+ void cluster_not_down_if_more_than_min_count_of_distributors_are_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportDistributorNodeState(0, State.DOWN);
@@ -516,7 +516,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void maintenance_mode_counted_as_down_for_cluster_availability() {
+ void maintenance_mode_counted_as_down_for_cluster_availability() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.DOWN)
@@ -528,7 +528,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void init_and_retired_counted_as_up_for_cluster_availability() {
+ void init_and_retired_counted_as_up_for_cluster_availability() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.INITIALIZING)
@@ -541,7 +541,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_down_if_less_than_min_ratio_of_storage_nodes_available() {
+ void cluster_down_if_less_than_min_ratio_of_storage_nodes_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.DOWN)
@@ -555,7 +555,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_not_down_if_more_than_min_ratio_of_storage_nodes_available() {
+ void cluster_not_down_if_more_than_min_ratio_of_storage_nodes_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.DOWN);
@@ -568,7 +568,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_down_if_less_than_min_ratio_of_distributors_available() {
+ void cluster_down_if_less_than_min_ratio_of_distributors_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportDistributorNodeState(0, State.DOWN)
@@ -582,7 +582,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void cluster_not_down_if_more_than_min_ratio_of_distributors_available() {
+ void cluster_not_down_if_more_than_min_ratio_of_distributors_available() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportDistributorNodeState(0, State.DOWN);
@@ -594,7 +594,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void group_nodes_are_marked_down_if_group_availability_too_low() {
+ void group_nodes_are_marked_down_if_group_availability_too_low() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(3))
.bringEntireClusterUp()
@@ -608,7 +608,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void group_nodes_are_not_marked_down_if_group_availability_sufficiently_high() {
+ void group_nodes_are_not_marked_down_if_group_availability_sufficiently_high() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(3))
.bringEntireClusterUp()
@@ -620,7 +620,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void implicitly_downed_group_nodes_receive_a_state_description() {
+ void implicitly_downed_group_nodes_receive_a_state_description() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(2).eachWithNodeCount(2))
.bringEntireClusterUp()
@@ -634,7 +634,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void implicitly_downed_group_nodes_are_annotated_with_group_reason() {
+ void implicitly_downed_group_nodes_are_annotated_with_group_reason() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(2).eachWithNodeCount(2))
.bringEntireClusterUp()
@@ -647,7 +647,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void maintenance_nodes_in_downed_group_are_not_affected() {
+ void maintenance_nodes_in_downed_group_are_not_affected() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(3))
.bringEntireClusterUp()
@@ -664,7 +664,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void group_nodes_are_marked_maintenance_if_group_availability_too_low_by_orchestrator() {
+ void group_nodes_are_marked_maintenance_if_group_availability_too_low_by_orchestrator() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(3))
.bringEntireClusterUp()
@@ -679,7 +679,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void group_nodes_are_not_marked_maintenance_if_group_availability_high_by_orchestrator() {
+ void group_nodes_are_not_marked_maintenance_if_group_availability_high_by_orchestrator() {
final ClusterFixture fixture = ClusterFixture
.forHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(3))
.bringEntireClusterUp()
@@ -698,7 +698,7 @@ public class ClusterStateGeneratorTest {
* and any buckets caught over this level would not be accessible in the data space.
*/
@Test
- public void distribution_bits_bounded_by_reported_min_bits_from_storage_node() {
+ void distribution_bits_bounded_by_reported_min_bits_from_storage_node() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(1, new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(7));
@@ -708,7 +708,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void distribution_bits_bounded_by_lowest_reporting_storage_node() {
+ void distribution_bits_bounded_by_lowest_reporting_storage_node() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(6))
@@ -719,7 +719,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void distribution_bits_bounded_by_config_parameter() {
+ void distribution_bits_bounded_by_config_parameter() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3).bringEntireClusterUp();
final ClusterStateGenerator.Params params = fixture.generatorParams().idealDistributionBits(12);
@@ -731,7 +731,7 @@ public class ClusterStateGeneratorTest {
// TODO We generally want to avoid distribution bit decreases if at all possible, since "collapsing"
// the top-level bucket space can cause data loss on timestamp collisions across super buckets.
@Test
- public void distribution_bit_not_influenced_by_nodes_down_or_in_maintenance() {
+ void distribution_bit_not_influenced_by_nodes_down_or_in_maintenance() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(7))
@@ -760,20 +760,20 @@ public class ClusterStateGeneratorTest {
* let e.g. a transition from 10 bits to 20 bits cause 10 interim full re-distributions.
*/
@Test
- public void published_distribution_bit_bound_by_low_watermark_when_nodes_report_less_than_config_bits() {
+ void published_distribution_bit_bound_by_low_watermark_when_nodes_report_less_than_config_bits() {
assertThat(do_test_distribution_bit_watermark(5, 5),
- equalTo("bits:5 distributor:3 storage:3"));
+ equalTo("bits:5 distributor:3 storage:3"));
assertThat(do_test_distribution_bit_watermark(5, 6),
- equalTo("bits:5 distributor:3 storage:3"));
+ equalTo("bits:5 distributor:3 storage:3"));
assertThat(do_test_distribution_bit_watermark(5, 15),
- equalTo("bits:5 distributor:3 storage:3"));
+ equalTo("bits:5 distributor:3 storage:3"));
}
@Test
- public void published_state_jumps_to_configured_ideal_bits_when_all_nodes_report_it() {
+ void published_state_jumps_to_configured_ideal_bits_when_all_nodes_report_it() {
// Note: the rest of the mocked nodes always report 16 bits by default
assertThat(do_test_distribution_bit_watermark(5, 16),
- equalTo("distributor:3 storage:3")); // "bits:16" implied
+ equalTo("distributor:3 storage:3")); // "bits:16" implied
}
private String do_test_storage_node_with_no_init_progress(State wantedState) {
@@ -793,9 +793,9 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void storage_node_with_no_init_progress_within_timeout_is_marked_down() {
+ void storage_node_with_no_init_progress_within_timeout_is_marked_down() {
assertThat(do_test_storage_node_with_no_init_progress(State.UP),
- equalTo("distributor:3 storage:3 .0.s:d"));
+ equalTo("distributor:3 storage:3 .0.s:d"));
}
/**
@@ -803,9 +803,9 @@ public class ClusterStateGeneratorTest {
* as the wanted state.
*/
@Test
- public void maintenance_wanted_state_overrides_storage_node_with_no_init_progress() {
+ void maintenance_wanted_state_overrides_storage_node_with_no_init_progress() {
assertThat(do_test_storage_node_with_no_init_progress(State.MAINTENANCE),
- equalTo("distributor:3 storage:3 .0.s:m"));
+ equalTo("distributor:3 storage:3 .0.s:m"));
}
/**
@@ -816,7 +816,7 @@ public class ClusterStateGeneratorTest {
* their init stage and would otherwise pop in and out of the cluster state.
*/
@Test
- public void unstable_init_storage_node_has_init_state_substituted_by_down() {
+ void unstable_init_storage_node_has_init_state_substituted_by_down() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5)
.bringEntireClusterUp()
.reportStorageNodeState(0, State.INITIALIZING)
@@ -828,7 +828,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void storage_node_with_crashes_but_not_unstable_init_does_not_have_init_state_substituted_by_down() {
+ void storage_node_with_crashes_but_not_unstable_init_does_not_have_init_state_substituted_by_down() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5)
.bringEntireClusterUp()
.reportStorageNodeState(0, new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.5f));
@@ -846,7 +846,7 @@ public class ClusterStateGeneratorTest {
* potentially contributing additional instability to the cluster.
*/
@Test
- public void unstable_retired_node_should_be_marked_down() {
+ void unstable_retired_node_should_be_marked_down() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(5)
.bringEntireClusterUp()
.proposeStorageNodeWantedState(3, State.RETIRED);
@@ -860,7 +860,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void generator_params_can_inherit_values_from_controller_options() {
+ void generator_params_can_inherit_values_from_controller_options() {
FleetControllerOptions options = new FleetControllerOptions("foocluster", Set.of(new ConfiguredNode(0, false)));
options.maxPrematureCrashes = 1;
options.minStorageNodesUp = 2;
@@ -881,7 +881,7 @@ public class ClusterStateGeneratorTest {
}
@Test
- public void configured_zero_init_progress_time_disables_auto_init_to_down_feature() {
+ void configured_zero_init_progress_time_disables_auto_init_to_down_feature() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.bringEntireClusterUp()
.reportStorageNodeState(0, new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.5f));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java
index 1125c431cae..473007f6a7c 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java
@@ -4,11 +4,11 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.*;
import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
import com.yahoo.vespa.clustercontroller.core.hostinfo.StorageNodeStatsBridge;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
/**
@@ -25,7 +25,7 @@ public class ClusterStateViewTest {
}
@Test
- public void testWrongNodeType() {
+ void testWrongNodeType() {
when(nodeInfo.isDistributor()).thenReturn(false);
clusterStateView.handleUpdatedHostInfo(nodeInfo, createHostInfo("101"));
@@ -34,7 +34,7 @@ public class ClusterStateViewTest {
}
@Test
- public void testStateVersionMismatch() {
+ void testStateVersionMismatch() {
when(nodeInfo.isDistributor()).thenReturn(true);
when(clusterState.getVersion()).thenReturn(101);
@@ -44,7 +44,7 @@ public class ClusterStateViewTest {
}
@Test
- public void testFailToGetStats() {
+ void testFailToGetStats() {
when(nodeInfo.isDistributor()).thenReturn(true);
when(clusterState.getVersion()).thenReturn(101);
@@ -54,17 +54,17 @@ public class ClusterStateViewTest {
}
@Test
- public void testSuccessCase() {
+ void testSuccessCase() {
when(nodeInfo.isDistributor()).thenReturn(true);
HostInfo hostInfo = HostInfo.createHostInfo(
"{" +
- " \"cluster-state-version\": 101," +
- " \"distributor\": {\n" +
- " \"storage-nodes\": [\n" +
- " {\n" +
- " \"node-index\": 3\n" +
- " }\n" +
- " ]}}");
+ " \"cluster-state-version\": 101," +
+ " \"distributor\": {\n" +
+ " \"storage-nodes\": [\n" +
+ " {\n" +
+ " \"node-index\": 3\n" +
+ " }\n" +
+ " ]}}");
when(nodeInfo.getNodeIndex()).thenReturn(3);
@@ -76,7 +76,7 @@ public class ClusterStateViewTest {
}
@Test
- public void testIndicesOfUpNodes() {
+ void testIndicesOfUpNodes() {
when(clusterState.getNodeCount(NodeType.DISTRIBUTOR)).thenReturn(7);
NodeState nodeState = mock(NodeState.class);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
index 11c00414cb8..2b62915439f 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
@@ -2,13 +2,11 @@
package com.yahoo.vespa.clustercontroller.core;
import com.google.common.collect.Sets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
-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.*;
/**
* @author hakonhall
@@ -67,7 +65,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_handles_updates_to_single_distributor_and_content_node() {
+ void aggregator_handles_updates_to_single_distributor_and_content_node() {
Fixture f = new Fixture(distributorNodes(1), contentNodes(3));
ContentClusterStatsBuilder stats = new ContentClusterStatsBuilder()
.add(3, "default", 10, 1)
@@ -77,7 +75,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_handles_updates_to_multiple_distributors_and_content_nodes() {
+ void aggregator_handles_updates_to_multiple_distributors_and_content_nodes() {
Fixture f = new FourNodesFixture();
f.verify(new ContentClusterStatsBuilder()
@@ -88,7 +86,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_handles_multiple_updates_from_same_distributor() {
+ void aggregator_handles_multiple_updates_from_same_distributor() {
Fixture f = new Fixture(distributorNodes(1, 2), contentNodes(3));
f.update(1, new ContentClusterStatsBuilder().add(3, "default"));
@@ -111,7 +109,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_handles_more_content_nodes_that_distributors() {
+ void aggregator_handles_more_content_nodes_that_distributors() {
Fixture f = new Fixture(distributorNodes(1), contentNodes(3, 4));
ContentClusterStatsBuilder stats = new ContentClusterStatsBuilder()
.add(3, "default", 10, 1)
@@ -121,7 +119,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_ignores_updates_to_unknown_distributor() {
+ void aggregator_ignores_updates_to_unknown_distributor() {
Fixture f = new Fixture(distributorNodes(1), contentNodes(3));
final int downDistributorIndex = 2;
f.update(downDistributorIndex, new ContentClusterStatsBuilder()
@@ -130,7 +128,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_tracks_when_it_has_updates_from_all_distributors() {
+ void aggregator_tracks_when_it_has_updates_from_all_distributors() {
Fixture f = new Fixture(distributorNodes(1, 2), contentNodes(3));
assertFalse(f.hasUpdatesFromAllDistributors());
f.update(1, new ContentClusterStatsBuilder().add(3, "default"));
@@ -142,7 +140,7 @@ public class ClusterStatsAggregatorTest {
}
@Test
- public void aggregator_can_provide_aggregated_stats_per_distributor() {
+ void aggregator_can_provide_aggregated_stats_per_distributor() {
Fixture f = new FourNodesFixture();
f.verify(1, ContentNodeStatsBuilder.forNode(1)
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java
index ae237b3330e..b9e7714671c 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java
@@ -2,12 +2,12 @@
package com.yahoo.vespa.clustercontroller.core;
import com.google.common.collect.Sets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
-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;
public class ClusterStatsChangeTrackerTest {
@@ -74,39 +74,39 @@ public class ClusterStatsChangeTrackerTest {
}
@Test
- public void stats_have_not_changed_if_not_all_distributors_are_updated() {
+ void stats_have_not_changed_if_not_all_distributors_are_updated() {
Fixture f = Fixture.empty();
assertFalse(f.statsHaveChanged());
}
@Test
- public void stats_have_changed_if_in_sync_node_not_found_in_previous_stats() {
+ void stats_have_changed_if_in_sync_node_not_found_in_previous_stats() {
Fixture f = Fixture.fromStats(stats().inSync(0));
assertTrue(f.statsHaveChanged());
}
@Test
- public void stats_have_changed_if_buckets_pending_node_not_found_in_previous_stats() {
+ void stats_have_changed_if_buckets_pending_node_not_found_in_previous_stats() {
Fixture f = Fixture.fromStats(stats().bucketsPending(0));
assertTrue(f.statsHaveChanged());
}
@Test
- public void stats_have_changed_if_one_node_has_in_sync_to_buckets_pending_transition() {
+ void stats_have_changed_if_one_node_has_in_sync_to_buckets_pending_transition() {
Fixture f = Fixture.fromStats(stats().bucketsPending(0).inSync(1));
f.newAggregatedStats(stats().bucketsPending(0).bucketsPending(1));
assertTrue(f.statsHaveChanged());
}
@Test
- public void stats_have_changed_if_one_node_has_buckets_pending_to_in_sync_transition() {
+ void stats_have_changed_if_one_node_has_buckets_pending_to_in_sync_transition() {
Fixture f = Fixture.fromStats(stats().bucketsPending(0).bucketsPending(1));
f.newAggregatedStats(stats().bucketsPending(0).inSync(1));
assertTrue(f.statsHaveChanged());
}
@Test
- public void stats_have_not_changed_if_no_nodes_have_changed_state() {
+ void stats_have_not_changed_if_no_nodes_have_changed_state() {
Fixture f = Fixture.fromStats(stats().bucketsPending(0).bucketsPending(1));
f.newAggregatedStats(stats().bucketsPending(0).bucketsPending(1));
assertFalse(f.statsHaveChanged());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java
index ff1c5b0bb17..d43a3e13c6a 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java
@@ -7,8 +7,8 @@ import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRenderer;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONWriter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.StringWriter;
import java.io.Writer;
@@ -27,7 +27,7 @@ public class ContentClusterHtmlRendererTest {
private final TreeMap<Integer, NodeInfo> distributorNodeInfoByIndex = new TreeMap<>();
private String result;
- @Before
+ @BeforeEach
public void before() throws JSONException {
final ClusterStateBundle stateBundle = ClusterStateBundle.ofBaselineOnly(
AnnotatedClusterState.withoutAnnotations(
@@ -71,7 +71,7 @@ public class ContentClusterHtmlRendererTest {
}
@Test
- public void testVtagRendering() {
+ void testVtagRendering() {
// 9 distribution nodes should have green tag on release1.
assertThat(result.split("<td bgcolor=\"#c0ffc0\" align=\"right\"><nobr>release1</nobr></td>").length, is(10));
// 1 distribution node should have warning on release1bad.
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsTest.java
index 47d1970e4d6..d30de6f7954 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsTest.java
@@ -1,18 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.vespa.clustercontroller.core.ContentNodeStats.BucketSpaceStats;
-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.*;
public class ContentNodeStatsTest {
@Test
- public void bucket_space_stats_can_transition_from_valid_to_invalid() {
- BucketSpaceStats stats = BucketSpaceStats.of(5,1);
+ void bucket_space_stats_can_transition_from_valid_to_invalid() {
+ BucketSpaceStats stats = BucketSpaceStats.of(5, 1);
assertTrue(stats.valid());
stats.merge(BucketSpaceStats.invalid(), 1);
@@ -21,7 +19,7 @@ public class ContentNodeStatsTest {
}
@Test
- public void bucket_space_stats_can_transition_from_invalid_to_valid() {
+ void bucket_space_stats_can_transition_from_invalid_to_valid() {
BucketSpaceStats stats = BucketSpaceStats.invalid();
assertFalse(stats.valid());
@@ -33,7 +31,7 @@ public class ContentNodeStatsTest {
}
@Test
- public void bucket_space_stats_tracks_multiple_layers_of_invalid() {
+ void bucket_space_stats_tracks_multiple_layers_of_invalid() {
BucketSpaceStats stats = BucketSpaceStats.invalid();
stats.merge(BucketSpaceStats.invalid(), 1);
assertFalse(stats.valid());
@@ -52,19 +50,19 @@ public class ContentNodeStatsTest {
}
@Test
- public void invalid_bucket_space_stats_may_have_pending_buckets() {
+ void invalid_bucket_space_stats_may_have_pending_buckets() {
assertTrue(BucketSpaceStats.invalid().mayHaveBucketsPending(1.0));
}
@Test
- public void bucket_space_stats_without_buckets_total_use_buckets_pending_to_calculate_may_have_buckets_pending() {
+ void bucket_space_stats_without_buckets_total_use_buckets_pending_to_calculate_may_have_buckets_pending() {
assertTrue(BucketSpaceStats.of(0, 2).mayHaveBucketsPending(0.6));
assertTrue(BucketSpaceStats.of(0, 1).mayHaveBucketsPending(0.6));
assertFalse(BucketSpaceStats.of(0, 0).mayHaveBucketsPending(0.6));
}
@Test
- public void min_merge_completion_ratio_is_used_to_calculate_bucket_space_stats_may_have_buckets_pending() {
+ void min_merge_completion_ratio_is_used_to_calculate_bucket_space_stats_may_have_buckets_pending() {
assertTrue(BucketSpaceStats.of(5, 6).mayHaveBucketsPending(0.6));
assertTrue(BucketSpaceStats.of(5, 5).mayHaveBucketsPending(0.6));
assertTrue(BucketSpaceStats.of(5, 4).mayHaveBucketsPending(0.6));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java
index 1f7b9293960..4d8c7799c58 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java
@@ -10,9 +10,9 @@ import com.yahoo.vespa.clustercontroller.core.database.DatabaseFactory;
import com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeListener;
import com.yahoo.vespa.clustercontroller.core.listeners.SlobrokListener;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
@@ -20,8 +20,8 @@ import org.mockito.MockitoAnnotations;
import java.util.Map;
import java.util.TreeMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -89,18 +89,18 @@ public class DatabaseHandlerTest {
}
}
- @Before
+ @BeforeEach
public void setUp() {
openMock = MockitoAnnotations.openMocks(this);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
openMock.close();
}
@Test
- public void can_store_latest_cluster_state_bundle() throws Exception {
+ void can_store_latest_cluster_state_bundle() throws Exception {
Fixture f = new Fixture();
DatabaseHandler handler = f.createHandler();
handler.doNextZooKeeperTask(f.createMockContext()); // Database setup step
@@ -110,7 +110,7 @@ public class DatabaseHandlerTest {
}
@Test
- public void can_load_latest_cluster_state_bundle() throws Exception {
+ void can_load_latest_cluster_state_bundle() throws Exception {
Fixture f = new Fixture();
DatabaseHandler handler = f.createHandler();
handler.doNextZooKeeperTask(f.createMockContext()); // Database setup step
@@ -124,7 +124,7 @@ public class DatabaseHandlerTest {
// FIXME I don't like the semantics of this, but it mirrors the legacy behavior for the
// rest of the DB load operations exposed by the DatabaseHandler.
@Test
- public void empty_bundle_is_returned_if_no_db_connection() throws Exception {
+ void empty_bundle_is_returned_if_no_db_connection() throws Exception {
Fixture f = new Fixture();
DatabaseHandler handler = f.createHandler();
// Note: no DB setup step
@@ -134,7 +134,7 @@ public class DatabaseHandlerTest {
}
@Test
- public void save_wanted_state_of_configured_nodes() throws Exception {
+ void save_wanted_state_of_configured_nodes() throws Exception {
var fixture = new Fixture();
DatabaseHandler handler = fixture.createHandler();
DatabaseHandler.DatabaseContext databaseContext = fixture.createMockContext();
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java
index 2ff48e00d0f..dc297e7a549 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java
@@ -12,22 +12,21 @@ import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Logger;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DatabaseTest extends FleetControllerTest {
private static final Logger log = Logger.getLogger(DatabaseTest.class.getName());
@Test
- public void testWantedStatesInZooKeeper() throws Exception {
+ void testWantedStatesInZooKeeper() throws Exception {
startingTest("DatabaseTest::testWantedStatesInZooKeeper");
FleetControllerOptions options = defaultOptions("mycluster");
options.zooKeeperServerAddress = "127.0.0.1";
@@ -81,7 +80,7 @@ public class DatabaseTest extends FleetControllerTest {
}
@Test
- public void testWantedStateOfUnknownNode() throws Exception {
+ void testWantedStateOfUnknownNode() throws Exception {
startingTest("DatabaseTest::testWantedStatesOfUnknownNode");
FleetControllerOptions options = defaultOptions("mycluster");
options.minRatioOfDistributorNodesUp = 0;
@@ -124,7 +123,7 @@ public class DatabaseTest extends FleetControllerTest {
assertWantedStates(wantedStates);
stopFleetController();
- for (int i=6; i<nodes.size(); ++i) nodes.get(i).disconnect();
+ for (int i = 6; i < nodes.size(); ++i) nodes.get(i).disconnect();
startFleetController();
waitForState("version:\\d+ distributor:3 storage:7 .1.s:m .3.s:d .4.s:d .5.s:d .6.s:m");
@@ -132,14 +131,14 @@ public class DatabaseTest extends FleetControllerTest {
setWantedState(new Node(NodeType.STORAGE, 6), new NodeState(NodeType.STORAGE, State.UP), wantedStates);
waitForState("version:\\d+ distributor:3 storage:3 .1.s:m");
- for (int i=6; i<nodes.size(); ++i) nodes.get(i).connect();
+ for (int i = 6; i < nodes.size(); ++i) nodes.get(i).connect();
waitForState("version:\\d+ distributor:10 .8.s:d storage:10 .1.s:m .7.s:r .8.s:d");
assertWantedStates(wantedStates);
}
private void assertWantedStates(Map<Node, NodeState> wantedStates) {
for (DummyVdsNode node : nodes) {
- assertEquals(node.getNode().toString(), wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()));
+ assertEquals(wantedStates.get(node.getNode()), fleetController.getWantedNodeState(node.getNode()), node.getNode().toString());
}
}
@@ -156,8 +155,8 @@ public class DatabaseTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage/cluster.mycluster/" + n.getType().toString() + "/" + n.getIndex()));
req.parameters().add(new StringValue(ns.serialize(true)));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("s"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("s"), req.toString());
wantedStates.put(n, ns);
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java
index e9d3a9cf83e..d3b0addbb13 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java
@@ -6,12 +6,12 @@ import com.yahoo.vdslib.state.ClusterState;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
-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;
public class DistributionBitCountTest extends FleetControllerTest {
@@ -37,7 +37,7 @@ public class DistributionBitCountTest extends FleetControllerTest {
* Test that then altering config to increased bit count, that a new system state is not sent out (and not altered) if a storagenode needs it to be no further split.
*/
@Test
- public void testDistributionBitCountConfigIncrease() throws Exception {
+ void testDistributionBitCountConfigIncrease() throws Exception {
setUpSystem("DistributionBitCountTest::testDistributionBitCountConfigIncrease");
options.distributionBits = 20;
fleetController.updateOptions(options);
@@ -53,7 +53,7 @@ public class DistributionBitCountTest extends FleetControllerTest {
* Test that then altering config to decrease bit count, that a new system state is sent out with that bit count.
*/
@Test
- public void testDistributionBitCountConfigDecrease() throws Exception {
+ void testDistributionBitCountConfigDecrease() throws Exception {
setUpSystem("DistributionBitCountTest::testDistributionBitCountConfigDecrease");
options.distributionBits = 12;
fleetController.updateOptions(options);
@@ -69,7 +69,7 @@ public class DistributionBitCountTest extends FleetControllerTest {
* node now being lowest, the fleetcontroller adjusts to use that bit in system state.
*/
@Test
- public void testStorageNodeReportingHigherBitCount() throws Exception {
+ void testStorageNodeReportingHigherBitCount() throws Exception {
setUpSystem("DistributionBitCountTest::testStorageNodeReportingHigherBitCount");
nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(11));
@@ -78,12 +78,11 @@ public class DistributionBitCountTest extends FleetControllerTest {
ClusterState startState = waitForState("version:\\d+ bits:11 distributor:10 storage:10");
nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(12));
- assertEquals(startState + "->" + fleetController.getSystemState(),
- startState.getVersion(), fleetController.getSystemState().getVersion());
+ assertEquals(startState.getVersion(), fleetController.getSystemState().getVersion(), startState + "->" + fleetController.getSystemState());
for (int i = 0; i < 10; ++i) {
// nodes is array of [distr.0, stor.0, distr.1, stor.1, ...] and we just want the storage nodes
- nodes.get(i*2 + 1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(17));
+ nodes.get(i * 2 + 1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(17));
}
assertEquals(startState.getVersion() + 1, waitForState("version:\\d+ bits:17 distributor:10 storage:10").getVersion());
}
@@ -93,7 +92,7 @@ public class DistributionBitCountTest extends FleetControllerTest {
* Test that then storage node report lower bit count, and then becomes the smallest, the fleetcontroller adjusts to use that bit in system state.
*/
@Test
- public void testStorageNodeReportingLowerBitCount() throws Exception {
+ void testStorageNodeReportingLowerBitCount() throws Exception {
setUpSystem("DistributionBitCountTest::testStorageNodeReportingLowerBitCount");
nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(13));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java
index 48d6ccbf655..8b07c216774 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java
@@ -18,7 +18,7 @@ import static org.hamcrest.CoreMatchers.hasItem;
import static com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode;
import static com.yahoo.vespa.clustercontroller.core.ClusterFixture.distributorNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
@@ -124,7 +124,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void single_storage_node_state_transition_emits_altered_node_state_event() {
+ void single_storage_node_state_transition_emits_altered_node_state_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("distributor:3 storage:3 .0.s:d");
@@ -138,7 +138,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void single_distributor_node_state_transition_emits_altered_node_state_event() {
+ void single_distributor_node_state_transition_emits_altered_node_state_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("distributor:3 .1.s:d storage:3");
@@ -152,7 +152,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void node_state_change_event_is_tagged_with_given_time() {
+ void node_state_change_event_is_tagged_with_given_time() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("distributor:3 storage:3 .0.s:d")
@@ -164,7 +164,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void multiple_node_state_transitions_emit_multiple_node_state_events() {
+ void multiple_node_state_transitions_emit_multiple_node_state_events() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3 .1.s:d")
.clusterStateAfter("distributor:3 .2.s:d storage:3 .0.s:r");
@@ -183,7 +183,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void no_emitted_node_state_event_when_node_state_not_changed() {
+ void no_emitted_node_state_event_when_node_state_not_changed() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("distributor:3 storage:3");
@@ -193,7 +193,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void node_down_edge_with_group_down_reason_has_separate_event_emitted() {
+ void node_down_edge_with_group_down_reason_has_separate_event_emitted() {
// We sneakily use a flat cluster here but still use a 'group down' reason. Differ doesn't currently care.
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
@@ -213,7 +213,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void group_down_to_group_down_does_not_emit_new_event() {
+ void group_down_to_group_down_does_not_emit_new_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3 .1.s:d")
.clusterStateAfter("distributor:3 storage:3 .1.s:m")
@@ -229,7 +229,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void group_down_to_clear_reason_emits_group_up_event() {
+ void group_down_to_clear_reason_emits_group_up_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3 .2.s:d")
.clusterStateAfter("distributor:3 storage:3")
@@ -247,7 +247,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void cluster_up_edge_emits_sufficient_node_availability_event() {
+ void cluster_up_edge_emits_sufficient_node_availability_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("cluster:d distributor:3 storage:3")
.clusterStateAfter("distributor:3 storage:3");
@@ -259,7 +259,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void cluster_down_event_without_reason_annotation_emits_generic_down_event() {
+ void cluster_down_event_without_reason_annotation_emits_generic_down_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3");
@@ -271,7 +271,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void cluster_event_is_tagged_with_given_time() {
+ void cluster_event_is_tagged_with_given_time() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3")
@@ -283,7 +283,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void no_event_emitted_for_cluster_down_to_down_edge() {
+ void no_event_emitted_for_cluster_down_to_down_edge() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("cluster:d distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3");
@@ -293,7 +293,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void too_few_storage_nodes_cluster_down_reason_emits_corresponding_event() {
+ void too_few_storage_nodes_cluster_down_reason_emits_corresponding_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3")
@@ -307,7 +307,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void too_few_distributor_nodes_cluster_down_reason_emits_corresponding_event() {
+ void too_few_distributor_nodes_cluster_down_reason_emits_corresponding_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3")
@@ -320,7 +320,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void too_low_storage_node_ratio_cluster_down_reason_emits_corresponding_event() {
+ void too_low_storage_node_ratio_cluster_down_reason_emits_corresponding_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3")
@@ -333,7 +333,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void too_low_distributor_node_ratio_cluster_down_reason_emits_corresponding_event() {
+ void too_low_distributor_node_ratio_cluster_down_reason_emits_corresponding_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.clusterStateAfter("cluster:d distributor:3 storage:3")
@@ -346,7 +346,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void may_have_merges_pending_up_edge_event_emitted_if_derived_bucket_space_state_differs_from_baseline() {
+ void may_have_merges_pending_up_edge_event_emitted_if_derived_bucket_space_state_differs_from_baseline() {
EventFixture f = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.derivedClusterStateBefore("default", "distributor:3 storage:3")
@@ -367,7 +367,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void may_have_merges_pending_down_edge_event_emitted_if_derived_bucket_space_state_differs_from_baseline() {
+ void may_have_merges_pending_down_edge_event_emitted_if_derived_bucket_space_state_differs_from_baseline() {
EventFixture f = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.derivedClusterStateBefore("default", "distributor:3 storage:3 .1.s:m")
@@ -388,7 +388,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void both_baseline_and_derived_bucket_space_state_events_are_emitted() {
+ void both_baseline_and_derived_bucket_space_state_events_are_emitted() {
EventFixture f = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.derivedClusterStateBefore("default", "distributor:3 storage:3")
@@ -408,7 +408,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void derived_bucket_space_state_events_are_not_emitted_if_similar_to_baseline() {
+ void derived_bucket_space_state_events_are_not_emitted_if_similar_to_baseline() {
EventFixture f = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.derivedClusterStateBefore("default", "distributor:3 storage:3")
@@ -426,7 +426,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void storage_node_passed_maintenance_grace_period_emits_event() {
+ void storage_node_passed_maintenance_grace_period_emits_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3 .0.s:m")
.clusterStateAfter("distributor:3 storage:3 .0.s:d")
@@ -443,7 +443,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void storage_node_maintenance_grace_period_event_only_emitted_on_maintenance_to_down_edge() {
+ void storage_node_maintenance_grace_period_event_only_emitted_on_maintenance_to_down_edge() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3 .0.s:u")
.clusterStateAfter("distributor:3 storage:3 .0.s:d")
@@ -457,7 +457,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void feed_block_engage_edge_emits_cluster_event() {
+ void feed_block_engage_edge_emits_cluster_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.feedBlockBefore(null)
@@ -471,7 +471,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void feed_block_disengage_edge_emits_cluster_event() {
+ void feed_block_disengage_edge_emits_cluster_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.feedBlockBefore(ClusterStateBundle.FeedBlock.blockedWithDescription("we're closed"))
@@ -484,7 +484,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void feed_block_engaged_to_engaged_edge_does_not_emit_new_cluster_event() {
+ void feed_block_engaged_to_engaged_edge_does_not_emit_new_cluster_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.feedBlockBefore(ClusterStateBundle.FeedBlock.blockedWithDescription("we're closed"))
@@ -496,7 +496,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void feed_block_engage_edge_with_node_exhaustion_info_emits_cluster_and_node_events() {
+ void feed_block_engage_edge_with_node_exhaustion_info_emits_cluster_and_node_events() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.feedBlockBefore(null)
@@ -515,7 +515,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void added_exhaustion_in_feed_block_resource_set_emits_node_event() {
+ void added_exhaustion_in_feed_block_resource_set_emits_node_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.feedBlockBefore(ClusterStateBundle.FeedBlock.blockedWith(
@@ -533,7 +533,7 @@ public class EventDiffCalculatorTest {
}
@Test
- public void removed_exhaustion_in_feed_block_resource_set_emits_node_event() {
+ void removed_exhaustion_in_feed_block_resource_set_emits_node_event() {
final EventFixture fixture = EventFixture.createForNodes(3)
.clusterStateBefore("distributor:3 storage:3")
.feedBlockBefore(ClusterStateBundle.FeedBlock.blockedWith(
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java
index afbc50124e2..eee0cb41eeb 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java
@@ -3,19 +3,22 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
import java.util.logging.Level;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
public class EventLogTest {
private final MetricUpdater metricUpdater = mock(MetricUpdater.class);
private final NodeEvent nodeEvent = mock(NodeEvent.class);
@@ -33,7 +36,7 @@ public class EventLogTest {
}
@Test
- public void testMetric() {
+ void testMetric() {
initialize(metricUpdater);
eventLog.addNodeOnlyEvent(nodeEvent, Level.INFO);
@@ -43,7 +46,7 @@ public class EventLogTest {
}
@Test
- public void testNullMetricReporter() {
+ void testNullMetricReporter() {
initialize(null);
eventLog.addNodeOnlyEvent(nodeEvent, Level.INFO);
@@ -52,7 +55,7 @@ public class EventLogTest {
}
@Test
- public void testNoEventsDoNotThrowException() {
+ void testNoEventsDoNotThrowException() {
initialize(metricUpdater);
StringBuilder builder = new StringBuilder();
Node nonExistantNode = new Node(NodeType.DISTRIBUTOR, 0);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerContextImplTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerContextImplTest.java
index 450975076bb..96ce050f33b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerContextImplTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerContextImplTest.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.clustercontroller.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -9,7 +9,7 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hakonhall
@@ -20,7 +20,7 @@ public class FleetControllerContextImplTest {
private final FleetControllerContextImpl context = new FleetControllerContextImpl(id);
@Test
- public void verify() {
+ void verify() {
context.log(logger, Level.INFO, "A %s message", "log");
assertEquals(1, logger.records.size());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java
index a5eeb69e126..5e4b62e0462 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java
@@ -27,11 +27,10 @@ import com.yahoo.vespa.clustercontroller.core.testutils.WaitCondition;
import com.yahoo.vespa.clustercontroller.core.testutils.WaitTask;
import com.yahoo.vespa.clustercontroller.core.testutils.Waiter;
import com.yahoo.vespa.clustercontroller.utils.util.NoMetricReporter;
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.TestWatcher;
import java.util.ArrayList;
import java.util.Arrays;
@@ -49,11 +48,12 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Håkon Humberset
*/
+@ExtendWith(FleetControllerTest.CleanupZookeeperLogsOnSuccess.class)
public abstract class FleetControllerTest implements Waiter {
private static final Logger log = Logger.getLogger(FleetControllerTest.class.getName());
@@ -96,30 +96,31 @@ public abstract class FleetControllerTest implements Waiter {
public boolean shouldInform(double v) { return false; }
}
- protected class CleanupZookeeperLogsOnSuccess extends TestWatcher {
+ public static class CleanupZookeeperLogsOnSuccess implements TestWatcher {
+
+ public CleanupZookeeperLogsOnSuccess() {}
+
@Override
- protected void failed(Throwable e, Description description) {
+ public void testFailed(ExtensionContext context, Throwable cause) {
System.err.println("TEST FAILED - NOT cleaning up zookeeper directory");
- shutdownZooKeeper(false);
+ shutdownZooKeeper(context, false);
}
@Override
- protected void succeeded(Description description) {
+ public void testSuccessful(ExtensionContext context) {
System.err.println("TEST SUCCEEDED - cleaning up zookeeper directory");
- shutdownZooKeeper(true);
+ shutdownZooKeeper(context, true);
}
- private void shutdownZooKeeper(boolean cleanupZooKeeperDir) {
- if (zooKeeperServer != null) {
- zooKeeperServer.shutdown(cleanupZooKeeperDir);
- zooKeeperServer = null;
+ private void shutdownZooKeeper(ExtensionContext ctx, boolean cleanupZooKeeperDir) {
+ FleetControllerTest test = (FleetControllerTest) ctx.getTestInstance().orElseThrow();
+ if (test.zooKeeperServer != null) {
+ test.zooKeeperServer.shutdown(cleanupZooKeeperDir);
+ test.zooKeeperServer = null;
}
}
}
- @Rule
- public TestRule cleanupZookeeperLogsOnSuccess = new CleanupZookeeperLogsOnSuccess();
-
protected void startingTest(String name) {
System.err.println("STARTING TEST: " + name);
testName = name;
@@ -330,7 +331,7 @@ public abstract class FleetControllerTest implements Waiter {
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
tearDownSystem();
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java
index e6c5c31010f..7f6684e595d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class GroupAutoTakedownLiveConfigTest extends FleetControllerTest {
@@ -53,14 +53,14 @@ public class GroupAutoTakedownLiveConfigTest extends FleetControllerTest {
}
@Test
- public void bootstrap_min_ratio_option_is_propagated_to_group_availability_logic() throws Exception {
+ void bootstrap_min_ratio_option_is_propagated_to_group_availability_logic() throws Exception {
setUp3x3ClusterWithMinNodeRatio(0.67);
takeDownContentNode(0);
waitForStateExcludingNodeSubset("version:\\d+ distributor:9 storage:9 .0.s:d .1.s:d .2.s:d", asIntSet(0));
}
@Test
- public void min_ratio_live_reconfig_immediately_takes_effect() throws Exception {
+ void min_ratio_live_reconfig_immediately_takes_effect() throws Exception {
// Initially, arbitrarily many nodes may be down in a group.
setUp3x3ClusterWithMinNodeRatio(0.0);
takeDownContentNode(3);
@@ -75,7 +75,7 @@ public class GroupAutoTakedownLiveConfigTest extends FleetControllerTest {
}
@Test
- public void live_distribution_config_changes_trigger_cluster_state_change() throws Exception {
+ void live_distribution_config_changes_trigger_cluster_state_change() throws Exception {
setUp3x3ClusterWithMinNodeRatio(0.65);
takeDownContentNode(6);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
index 1d4b2a73560..f0c8503fed9 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
@@ -8,7 +8,7 @@ import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeListener;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.List;
@@ -19,7 +19,7 @@ import static com.yahoo.vespa.clustercontroller.core.matchers.NodeEventWithDescr
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.AllOf.allOf;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -71,17 +71,17 @@ public class GroupAutoTakedownTest {
* not apply to a flat structure.
*/
@Test
- public void config_does_not_apply_to_flat_hierarchy_clusters() {
+ void config_does_not_apply_to_flat_hierarchy_clusters() {
ClusterFixture fixture = createFixtureForAllUpFlatCluster(5, 0.99);
assertEquals("distributor:5 storage:5", fixture.generatedClusterState());
assertEquals("distributor:5 storage:5 .1.s:d",
- stateAfterStorageTransition(fixture, 1, State.DOWN));
+ stateAfterStorageTransition(fixture, 1, State.DOWN));
}
@Test
- public void group_node_down_edge_implicitly_marks_down_rest_of_nodes_in_group() {
+ void group_node_down_edge_implicitly_marks_down_rest_of_nodes_in_group() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
@@ -89,28 +89,28 @@ public class GroupAutoTakedownTest {
// Same group as node 4
assertEquals("distributor:6 storage:4",
- stateAfterStorageTransition(fixture, 5, State.DOWN));
+ stateAfterStorageTransition(fixture, 5, State.DOWN));
// Same group as node 1
assertEquals("distributor:6 storage:4 .0.s:d .1.s:d",
- stateAfterStorageTransition(fixture, 0, State.DOWN));
+ stateAfterStorageTransition(fixture, 0, State.DOWN));
}
@Test
- public void restored_group_node_availability_takes_group_back_up_automatically() {
+ void restored_group_node_availability_takes_group_back_up_automatically() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
// Group #2 -> down
assertEquals("distributor:6 storage:4",
- stateAfterStorageTransition(fixture, 5, State.DOWN));
+ stateAfterStorageTransition(fixture, 5, State.DOWN));
// Group #2 -> back up again
assertEquals("distributor:6 storage:6",
- stateAfterStorageTransition(fixture, 5, State.UP));
+ stateAfterStorageTransition(fixture, 5, State.UP));
}
@Test
- public void no_op_for_downed_nodes_in_already_downed_group() {
+ void no_op_for_downed_nodes_in_already_downed_group() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
@@ -123,7 +123,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void verbose_node_state_description_updated_for_implicitly_downed_nodes() {
+ void verbose_node_state_description_updated_for_implicitly_downed_nodes() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.75);
@@ -131,15 +131,15 @@ public class GroupAutoTakedownTest {
// Node 8 is taken down by the fixture and gets a fixture-assigned message that
// we should _not_ lose/overwrite.
assertEquals("distributor:9 storage:9 .6.s:d " +
- ".6.m:group\\x20node\\x20availability\\x20below\\x20configured\\x20threshold " +
- ".7.s:d " +
- ".7.m:group\\x20node\\x20availability\\x20below\\x20configured\\x20threshold " +
- ".8.s:d .8.m:mockdesc",
- verboseStateAfterStorageTransition(fixture, 8, State.DOWN));
+ ".6.m:group\\x20node\\x20availability\\x20below\\x20configured\\x20threshold " +
+ ".7.s:d " +
+ ".7.m:group\\x20node\\x20availability\\x20below\\x20configured\\x20threshold " +
+ ".8.s:d .8.m:mockdesc",
+ verboseStateAfterStorageTransition(fixture, 8, State.DOWN));
}
@Test
- public void legacy_cluster_wide_availabilty_ratio_is_computed_after_group_takedowns() {
+ void legacy_cluster_wide_availabilty_ratio_is_computed_after_group_takedowns() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
fixture.setMinNodesUp(5, 5, 0.51, 0.51);
@@ -152,7 +152,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void maintenance_wanted_state_not_overwritten() {
+ void maintenance_wanted_state_not_overwritten() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.99);
@@ -166,7 +166,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void transient_maintenance_mode_on_down_edge_does_not_take_down_group() {
+ void transient_maintenance_mode_on_down_edge_does_not_take_down_group() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.99);
fixture.enableTransientMaintenanceModeOnDown(1000);
@@ -190,7 +190,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void taking_down_node_adds_node_specific_event() {
+ void taking_down_node_adds_node_specific_event() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
@@ -205,7 +205,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void bringing_node_back_up_adds_node_specific_event() {
+ void bringing_node_back_up_adds_node_specific_event() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
@@ -223,7 +223,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void wanted_state_retired_implicitly_down_node_is_transitioned_to_retired_mode_immediately() {
+ void wanted_state_retired_implicitly_down_node_is_transitioned_to_retired_mode_immediately() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.99);
@@ -237,7 +237,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void downed_config_retired_node_transitions_back_to_retired_on_up_edge() {
+ void downed_config_retired_node_transitions_back_to_retired_on_up_edge() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.49);
@@ -252,14 +252,15 @@ public class GroupAutoTakedownTest {
nodes.add(new ConfiguredNode(5, true));
// TODO this should ideally also set the retired flag in the distribution
// config, but only the ConfiguredNodes are actually looked at currently.
- fixture.cluster.setNodes(nodes, new NodeListener() {});
+ fixture.cluster.setNodes(nodes, new NodeListener() {
+ });
assertEquals("distributor:6 storage:6 .4.s:d .5.s:r",
stateAfterStorageTransition(fixture, 5, State.UP));
}
@Test
- public void init_progress_is_preserved_across_group_down_up_edge() {
+ void init_progress_is_preserved_across_group_down_up_edge() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
@@ -277,7 +278,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void down_wanted_state_is_preserved_across_group_down_up_edge() {
+ void down_wanted_state_is_preserved_across_group_down_up_edge() {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.60);
@@ -294,7 +295,7 @@ public class GroupAutoTakedownTest {
}
@Test
- public void previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge() throws Exception {
+ void previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge() throws Exception {
ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
index a5357e0a639..d176455f4c0 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.ClusterState;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.text.ParseException;
import java.util.Collections;
@@ -49,7 +49,7 @@ public class GroupAvailabilityCalculatorTest {
private static Set<Integer> emptySet() { return indices(); }
@Test
- public void flat_cluster_does_not_implicitly_take_down_nodes() {
+ void flat_cluster_does_not_implicitly_take_down_nodes() {
GroupAvailabilityCalculator calc = calcForFlatCluster(5, 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -58,7 +58,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void group_node_down_edge_implicitly_marks_down_rest_of_nodes_in_group() {
+ void group_node_down_edge_implicitly_marks_down_rest_of_nodes_in_group() {
// 3 groups of 2 nodes, take down node #4 (1st node in last group). Since we require
// at least 51% of group capacity to be available, implicitly take down the last group
// entirely.
@@ -72,7 +72,7 @@ public class GroupAvailabilityCalculatorTest {
// Setting 50% as min ratio in a group with 2 nodes should let group be up if
// one node goes down.
@Test
- public void min_ratio_per_group_is_closed_interval() {
+ void min_ratio_per_group_is_closed_interval() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.50);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -80,7 +80,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void retired_node_is_counted_as_down() {
+ void retired_node_is_counted_as_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -88,7 +88,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void initializing_node_not_counted_as_down() {
+ void initializing_node_not_counted_as_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -96,7 +96,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void maintenance_node_not_counted_as_down() {
+ void maintenance_node_not_counted_as_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -104,7 +104,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void existing_maintenance_node_not_implicitly_downed_when_group_taken_down() {
+ void existing_maintenance_node_not_implicitly_downed_when_group_taken_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -112,7 +112,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void existing_retired_node_not_implicitly_downed_when_group_taken_down() {
+ void existing_retired_node_not_implicitly_downed_when_group_taken_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(3), 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -120,7 +120,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void down_to_down_edge_keeps_group_down() {
+ void down_to_down_edge_keeps_group_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(2).eachWithNodeCount(4), 0.76);
@@ -135,7 +135,7 @@ public class GroupAvailabilityCalculatorTest {
// causing "storage:6 .5.s:d" to be reduced to "storage:5". This still implies a
// node is down according to the distribution config and must be handled as such.
@Test
- public void implicitly_downed_node_at_state_end_is_counted_as_explicitly_down() {
+ void implicitly_downed_node_at_state_end_is_counted_as_explicitly_down() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.99);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -143,7 +143,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void non_uniform_group_sizes_are_supported() {
+ void non_uniform_group_sizes_are_supported() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroupNodes(1, 2, 3, 4), 0.67);
@@ -167,7 +167,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void min_ratio_of_zero_never_takes_down_groups_implicitly() {
+ void min_ratio_of_zero_never_takes_down_groups_implicitly() {
GroupAvailabilityCalculator calc = calcForHierarchicCluster(
DistributionBuilder.withGroups(2).eachWithNodeCount(4), 0.0);
assertThat(calc.nodesThatShouldBeDown(clusterState(
@@ -184,7 +184,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void one_safe_maintenance_node_does_not_take_down_group() {
+ void one_safe_maintenance_node_does_not_take_down_group() {
// 2 groups of 5 nodes each. Set node #5 safely in maintenance (1st node in last group).
// Since the minimum number of nodes that can safely be set to maintenance before taking
// the whole group down is 2, the whole group should NOT be taken down.
@@ -204,7 +204,7 @@ public class GroupAvailabilityCalculatorTest {
}
@Test
- public void two_safe_maintenance_nodes_takes_down_group() {
+ void two_safe_maintenance_nodes_takes_down_group() {
// 2 groups of 5 nodes each. Set nodes #5 and #6 safely in maintenance (1st and 2nd nodes
// in last group, respectively). Since the minimum number of nodes that can safely be set to
// maintenance before taking the whole group down is 2, the whole group should be taken down.
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
index 418400b3fff..b6bd6a3bf75 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.Group;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class LeafGroupsTest {
@Test
- public void rootGroupCountedAsLeafWhenNoChildren() {
+ void rootGroupCountedAsLeafWhenNoChildren() {
Group g = new Group(0, "donkeykong");
List<Group> leaves = LeafGroups.enumerateFrom(g);
@@ -25,7 +25,7 @@ public class LeafGroupsTest {
}
@Test
- public void singleLeafIsEnumerated() throws Exception {
+ void singleLeafIsEnumerated() throws Exception {
Group g = new Group(0, "donkeykong", dummyDistribution());
Group child = new Group(1, "mario");
g.addSubGroup(child);
@@ -36,7 +36,7 @@ public class LeafGroupsTest {
}
@Test
- public void singleLeafIsEnumeratedInNestedCase() throws Exception {
+ void singleLeafIsEnumeratedInNestedCase() throws Exception {
Group g = new Group(0, "donkeykong", dummyDistribution());
Group child = new Group(1, "mario", dummyDistribution());
child.addSubGroup(new Group(2, "toad"));
@@ -48,7 +48,7 @@ public class LeafGroupsTest {
}
@Test
- public void multipleLeafGroupsAreEnumerated() throws Exception {
+ void multipleLeafGroupsAreEnumerated() throws Exception {
Group g = new Group(0, "donkeykong", dummyDistribution());
Group child = new Group(1, "mario", dummyDistribution());
child.addSubGroup(new Group(2, "toad"));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
index 2f79ad3fa95..6a05cc78508 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
@@ -3,7 +3,7 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.document.FixedBucketSpaces;
import com.yahoo.vdslib.state.ClusterState;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
@@ -53,7 +53,7 @@ public class MaintenanceWhenPendingGlobalMergesTest {
}
@Test
- public void no_nodes_set_to_maintenance_in_global_bucket_space_state() {
+ void no_nodes_set_to_maintenance_in_global_bucket_space_state() {
Fixture f = new Fixture();
when(f.mockPendingChecker.mayHaveMergesPending(eq(globalSpace()), anyInt())).thenReturn(true); // False returned by default otherwise
AnnotatedClusterState derived = f.deriver.derivedFrom(stateFromString("distributor:2 storage:2"), globalSpace());
@@ -61,7 +61,7 @@ public class MaintenanceWhenPendingGlobalMergesTest {
}
@Test
- public void content_nodes_with_global_merge_pending_set_to_maintenance_in_default_space_state() {
+ void content_nodes_with_global_merge_pending_set_to_maintenance_in_default_space_state() {
Fixture f = new Fixture();
when(f.mockPendingChecker.mayHaveMergesPending(globalSpace(), 1)).thenReturn(true);
when(f.mockPendingChecker.mayHaveMergesPending(globalSpace(), 3)).thenReturn(true);
@@ -71,14 +71,14 @@ public class MaintenanceWhenPendingGlobalMergesTest {
}
@Test
- public void no_nodes_set_to_maintenance_when_no_merges_pending() {
+ void no_nodes_set_to_maintenance_when_no_merges_pending() {
Fixture f = new Fixture();
AnnotatedClusterState derived = f.deriver.derivedFrom(stateFromString("distributor:5 storage:5"), defaultSpace());
assertThat(derived, equalTo(stateFromString("distributor:5 storage:5")));
}
@Test
- public void default_space_merges_do_not_count_towards_maintenance() {
+ void default_space_merges_do_not_count_towards_maintenance() {
Fixture f = new Fixture();
when(f.mockPendingChecker.mayHaveMergesPending(eq(defaultSpace()), anyInt())).thenReturn(true);
AnnotatedClusterState derived = f.deriver.derivedFrom(stateFromString("distributor:2 storage:2"), defaultSpace());
@@ -86,7 +86,7 @@ public class MaintenanceWhenPendingGlobalMergesTest {
}
@Test
- public void nodes_only_set_to_maintenance_when_marked_up_init_or_retiring() {
+ void nodes_only_set_to_maintenance_when_marked_up_init_or_retiring() {
Fixture f = new Fixture();
when(f.mockPendingChecker.mayHaveMergesPending(eq(globalSpace()), anyInt())).thenReturn(true);
AnnotatedClusterState derived = f.deriver.derivedFrom(stateFromString("distributor:5 storage:5 .1.s:m .2.s:r .3.s:i .4.s:d"), defaultSpace());
@@ -96,7 +96,7 @@ public class MaintenanceWhenPendingGlobalMergesTest {
}
@Test
- public void node_state_reasons_are_used_as_baseline_in_default_bucket_space_state() {
+ void node_state_reasons_are_used_as_baseline_in_default_bucket_space_state() {
Fixture f = new Fixture();
when(f.mockPendingChecker.mayHaveMergesPending(globalSpace(), 1)).thenReturn(true);
when(f.mockPendingChecker.mayHaveMergesPending(globalSpace(), 3)).thenReturn(true);
@@ -108,7 +108,7 @@ public class MaintenanceWhenPendingGlobalMergesTest {
}
@Test
- public void node_with_pending_merges_only_set_to_maintenance_if_eligible() {
+ void node_with_pending_merges_only_set_to_maintenance_if_eligible() {
Fixture f = new Fixture();
Arrays.asList(1, 2, 3).forEach(idx -> when(f.mockPendingChecker.mayHaveMergesPending(globalSpace(), idx)).thenReturn(true));
Arrays.asList(1, 2, 4).forEach(idx -> when(f.mockTransitionConstraint.maintenanceTransitionAllowed(idx)).thenReturn(false));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java
index 257bb54047c..ae7ffd248d6 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java
@@ -12,10 +12,9 @@ import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.status.StatusHandler;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.ExtendWith;
import java.util.ArrayList;
import java.util.List;
@@ -24,10 +23,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+@ExtendWith(FleetControllerTest.CleanupZookeeperLogsOnSuccess.class)
+@Timeout(120)
public class MasterElectionTest extends FleetControllerTest {
private static final Logger log = Logger.getLogger(MasterElectionTest.class.getName());
@@ -35,12 +36,6 @@ public class MasterElectionTest extends FleetControllerTest {
private Supervisor supervisor;
private final List<FleetController> fleetControllers = new ArrayList<>();
- @Rule
- public TestRule cleanupZookeeperLogsOnSuccess = new CleanupZookeeperLogsOnSuccess();
-
- @Rule
- public Timeout globalTimeout = Timeout.seconds(120);
-
private static int defaultZkSessionTimeoutInMillis() { return 30_000; }
protected void setUpFleetController(int count, boolean useFakeTimer, FleetControllerOptions options) throws Exception {
@@ -116,7 +111,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void testMasterElection() throws Exception {
+ void testMasterElection() throws Exception {
startingTest("MasterElectionTest::testMasterElection");
log.log(Level.INFO, "STARTING TEST: MasterElectionTest::testMasterElection()");
FleetControllerOptions options = defaultOptions("mycluster");
@@ -135,7 +130,7 @@ public class MasterElectionTest extends FleetControllerTest {
// Too few for there to be a master at this point
for (int i = 0; i < fleetControllers.size(); ++i) {
if (fleetControllers.get(i).isRunning()) waitForCompleteCycle(i);
- assertFalse("Fleet controller " + i, fleetControllers.get(i).isMaster());
+ assertFalse(fleetControllers.get(i).isMaster(), "Fleet controller " + i);
}
StatusHandler.ContainerStatusPageServer statusPageServer = new StatusHandler.ContainerStatusPageServer();
@@ -222,7 +217,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void testClusterStateVersionIncreasesAcrossMasterElections() throws Exception {
+ void testClusterStateVersionIncreasesAcrossMasterElections() throws Exception {
startingTest("MasterElectionTest::testClusterStateVersionIncreasesAcrossMasterElections");
FleetControllerOptions options = defaultOptions("mycluster");
options.masterZooKeeperCooldownPeriod = 1;
@@ -243,7 +238,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void testVotingCorrectnessInFaceOfZKDisconnect() throws Exception {
+ void testVotingCorrectnessInFaceOfZKDisconnect() throws Exception {
startingTest("MasterElectionTest::testVotingCorrectnessInFaceOfZKDisconnect");
FleetControllerOptions options = defaultOptions("mycluster");
// "Magic" port value is in range allocated to module for testing.
@@ -264,7 +259,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void testZooKeeperUnavailable() throws Exception {
+ void testZooKeeperUnavailable() throws Exception {
startingTest("MasterElectionTest::testZooKeeperUnavailable");
FleetControllerOptions options = defaultOptions("mycluster");
options.masterZooKeeperCooldownPeriod = 100;
@@ -279,7 +274,7 @@ public class MasterElectionTest extends FleetControllerTest {
// No one can be master if server is unavailable
log.log(Level.INFO, "Checking master status");
for (int i = 0; i < fleetControllers.size(); ++i) {
- assertFalse("Index " + i, fleetControllers.get(i).isMaster());
+ assertFalse(fleetControllers.get(i).isMaster(), "Index " + i);
}
zooKeeperServer = new ZooKeeperTestServer();
@@ -295,7 +290,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void testMasterZooKeeperCooldown() throws Exception {
+ void testMasterZooKeeperCooldown() throws Exception {
startingTest("MasterElectionTest::testMasterZooKeeperCooldown");
FleetControllerOptions options = defaultOptions("mycluster");
options.masterZooKeeperCooldownPeriod = 3600 * 1000; // An hour
@@ -343,7 +338,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void testGetMaster() throws Exception {
+ void testGetMaster() throws Exception {
startingTest("MasterElectionTest::testGetMaster");
FleetControllerOptions options = defaultOptions("mycluster");
options.masterZooKeeperCooldownPeriod = 3600 * 1000; // An hour
@@ -364,33 +359,33 @@ public class MasterElectionTest extends FleetControllerTest {
Request req = new Request("getMaster");
- for (int nodeIndex = 0; nodeIndex<3; ++nodeIndex) {
+ for (int nodeIndex = 0; nodeIndex < 3; ++nodeIndex) {
for (int retry = 0; retry < FleetControllerTest.timeoutS * 10; ++retry) {
req = new Request("getMaster");
connections.get(nodeIndex).invokeSync(req, FleetControllerTest.timeoutS);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
if (req.returnValues().get(0).asInt32() == 0 &&
- req.returnValues().get(1).asString().equals("All 3 nodes agree that 0 is current master.")) {
+ req.returnValues().get(1).asString().equals("All 3 nodes agree that 0 is current master.")) {
break;
}
}
- assertEquals(req.toString(), 0, req.returnValues().get(0).asInt32());
- assertEquals(req.toString(), "All 3 nodes agree that 0 is current master.", req.returnValues().get(1).asString());
+ assertEquals(0, req.returnValues().get(0).asInt32(), req.toString());
+ assertEquals("All 3 nodes agree that 0 is current master.", req.returnValues().get(1).asString(), req.toString());
}
log.log(Level.INFO, "SHUTTING DOWN FLEET CONTROLLER 0");
fleetControllers.get(0).shutdown();
- // Wait until fc 1 & 2 votes for node 1
+ // Wait until fc 1 & 2 votes for node 1
waitForCompleteCycle(1);
waitForCompleteCycle(2);
- // 5 minutes is not long enough period to wait before letting this node be master.
+ // 5 minutes is not long enough period to wait before letting this node be master.
timer.advanceTime(300 * 1000); // 5 minutes
- int[] remainingNodes = { 1, 2 };
+ int[] remainingNodes = {1, 2};
waitForMasterReason(
"2 of 3 nodes agree 1 should be master, but old master cooldown period of 3600000 ms has not passed yet. To ensure it has got time to realize it is no longer master before we elect a new one, currently there is no master.",
-1, connections, remainingNodes);
- // Verify that fc 1 is not master, and the correct reasons for why not
+ // Verify that fc 1 is not master, and the correct reasons for why not
assertFalse(fleetControllers.get(1).isMaster());
// But after an hour it should become one.
@@ -399,31 +394,31 @@ public class MasterElectionTest extends FleetControllerTest {
req = new Request("getMaster");
connections.get(0).invokeSync(req, FleetControllerTest.timeoutS);
- assertEquals(req.toString(), 104, req.errorCode());
- assertEquals(req.toString(), "Connection error", req.errorMessage());
+ assertEquals(104, req.errorCode(), req.toString());
+ assertEquals("Connection error", req.errorMessage(), req.toString());
- for (int i=0; i<FleetControllerTest.timeoutS * 10; ++i) {
+ for (int i = 0; i < FleetControllerTest.timeoutS * 10; ++i) {
req = new Request("getMaster");
connections.get(1).invokeSync(req, FleetControllerTest.timeoutS);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
if (req.returnValues().get(0).asInt32() != -1) break;
- // We may have bad timing causing node not to have realized it is master yet
+ // We may have bad timing causing node not to have realized it is master yet
}
- assertEquals(req.toString(), 1, req.returnValues().get(0).asInt32());
- assertEquals(req.toString(), "2 of 3 nodes agree 1 is master.", req.returnValues().get(1).asString());
+ assertEquals(1, req.returnValues().get(0).asInt32(), req.toString());
+ assertEquals("2 of 3 nodes agree 1 is master.", req.returnValues().get(1).asString(), req.toString());
- for (int i=0; i<FleetControllerTest.timeoutS * 10; ++i) {
+ for (int i = 0; i < FleetControllerTest.timeoutS * 10; ++i) {
req = new Request("getMaster");
connections.get(2).invokeSync(req, FleetControllerTest.timeoutS);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
if (req.returnValues().get(0).asInt32() != -1) break;
}
- assertEquals(req.toString(), 1, req.returnValues().get(0).asInt32());
- assertEquals(req.toString(), "2 of 3 nodes agree 1 is master.", req.returnValues().get(1).asString());
+ assertEquals(1, req.returnValues().get(0).asInt32(), req.toString());
+ assertEquals("2 of 3 nodes agree 1 is master.", req.returnValues().get(1).asString(), req.toString());
}
@Test
- public void testReconfigure() throws Exception {
+ void testReconfigure() throws Exception {
startingTest("MasterElectionTest::testReconfigure");
FleetControllerOptions options = defaultOptions("mycluster");
options.masterZooKeeperCooldownPeriod = 1;
@@ -431,7 +426,7 @@ public class MasterElectionTest extends FleetControllerTest {
waitForMaster(0);
FleetControllerOptions newOptions = options.clone();
- for (int i=0; i<fleetControllers.size(); ++i) {
+ for (int i = 0; i < fleetControllers.size(); ++i) {
FleetControllerOptions nodeOptions = adjustConfig(newOptions, i, fleetControllers.size());
fleetControllers.get(i).updateOptions(nodeOptions);
}
@@ -448,7 +443,7 @@ public class MasterElectionTest extends FleetControllerTest {
* risk rolling back the version number in the face of a reelection.
*/
@Test
- public void cluster_state_version_written_to_zookeeper_even_with_empty_send_set() throws Exception {
+ void cluster_state_version_written_to_zookeeper_even_with_empty_send_set() throws Exception {
startingTest("MasterElectionTest::cluster_state_version_written_to_zookeeper_even_with_empty_send_set");
FleetControllerOptions options = defaultOptions("mycluster");
options.masterZooKeeperCooldownPeriod = 1;
@@ -474,7 +469,7 @@ public class MasterElectionTest extends FleetControllerTest {
n.disconnectImmediately();
waitForCompleteCycle(0);
});
- setWantedState(this.nodes.get(2*10 - 1), State.MAINTENANCE, "bar");
+ setWantedState(this.nodes.get(2 * 10 - 1), State.MAINTENANCE, "bar");
waitForCompleteCycle(0);
// This receives the version number of the highest _working_ cluster state, with
@@ -494,7 +489,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void previously_published_state_is_taken_into_account_for_default_space_when_controller_bootstraps() throws Exception {
+ void previously_published_state_is_taken_into_account_for_default_space_when_controller_bootstraps() throws Exception {
startingTest("MasterElectionTest::previously_published_state_is_taken_into_account_for_default_space_when_controller_bootstraps");
FleetControllerOptions options = defaultOptions("mycluster");
options.clusterHasGlobalDocumentTypes = true;
@@ -537,7 +532,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
@Test
- public void default_space_nodes_not_marked_as_maintenance_when_cluster_has_no_global_document_types() throws Exception {
+ void default_space_nodes_not_marked_as_maintenance_when_cluster_has_no_global_document_types() throws Exception {
startingTest("MasterElectionTest::default_space_nodes_not_marked_as_maintenance_when_cluster_has_no_global_document_types");
FleetControllerOptions options = defaultOptions("mycluster");
options.clusterHasGlobalDocumentTypes = false;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MetricReporterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MetricReporterTest.java
index 4cd2fcdfbd5..a6defaee7fe 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MetricReporterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MetricReporterTest.java
@@ -4,7 +4,7 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.ClusterState;
import com.yahoo.vespa.clustercontroller.core.matchers.HasMetricContext;
import com.yahoo.vespa.clustercontroller.utils.util.MetricReporter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
@@ -57,7 +57,7 @@ public class MetricReporterTest {
}
@Test
- public void metrics_are_emitted_for_different_node_state_counts() {
+ void metrics_are_emitted_for_different_node_state_counts() {
Fixture f = new Fixture();
f.metricUpdater.updateClusterStateMetrics(f.clusterFixture.cluster(),
ClusterState.stateFromString("distributor:10 .1.s:d storage:9 .1.s:d .2.s:m .4.s:d"),
@@ -90,28 +90,28 @@ public class MetricReporterTest {
}
@Test
- public void metrics_are_emitted_for_partial_node_availability_ratio() {
+ void metrics_are_emitted_for_partial_node_availability_ratio() {
// Only Up, Init, Retired and Maintenance are counted as available states
doTestRatiosInState("distributor:10 .1.s:d storage:9 .1.s:d .2.s:m .4.s:r .5.s:i .6.s:s", 0.9, 0.7);
}
@Test
- public void metrics_are_emitted_for_full_node_availability_ratio() {
+ void metrics_are_emitted_for_full_node_availability_ratio() {
doTestRatiosInState("distributor:10 storage:10", 1.0, 1.0);
}
@Test
- public void metrics_are_emitted_for_zero_node_availability_ratio() {
+ void metrics_are_emitted_for_zero_node_availability_ratio() {
doTestRatiosInState("cluster:d", 0.0, 0.0);
}
@Test
- public void maintenance_mode_is_counted_as_available() {
+ void maintenance_mode_is_counted_as_available() {
doTestRatiosInState("distributor:10 storage:10 .0.s:m", 1.0, 1.0);
}
@Test
- public void metrics_are_emitted_for_resource_usage() {
+ void metrics_are_emitted_for_resource_usage() {
Fixture f = new Fixture();
f.metricUpdater.updateClusterStateMetrics(f.clusterFixture.cluster(),
ClusterState.stateFromString("distributor:10 storage:10"),
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java
index bd1ffac089c..62a49ecf969 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java
@@ -1,13 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class NoZooKeeperTest extends FleetControllerTest {
@Test
- public void testWantedStatesInZooKeeper() throws Exception {
+ void testWantedStatesInZooKeeper() throws Exception {
startingTest("NoZooKeeperTest::testWantedStatesInZooKeeper");
FleetControllerOptions options = defaultOptions("mycluster");
options.zooKeeperServerAddress = null;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeInfoTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeInfoTest.java
index 129c70d1d29..4b068d107bf 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeInfoTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeInfoTest.java
@@ -4,16 +4,14 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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.*;
public class NodeInfoTest {
@Test
- public void unstable_init_flag_is_initially_clear() {
+ void unstable_init_flag_is_initially_clear() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(3);
final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
assertFalse(nodeInfo.recentlyObservedUnstableDuringInit());
@@ -26,7 +24,7 @@ public class NodeInfoTest {
}
@Test
- public void down_edge_during_init_state_marks_as_unstable_init() {
+ void down_edge_during_init_state_marks_as_unstable_init() {
ClusterFixture fixture = fixtureWithNodeMarkedAsUnstableInit(1);
final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
@@ -34,7 +32,7 @@ public class NodeInfoTest {
}
@Test
- public void stopping_edge_during_init_does_not_mark_as_unstable_init() {
+ void stopping_edge_during_init_does_not_mark_as_unstable_init() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(3).reportStorageNodeState(0, State.INITIALIZING);
fixture.reportStorageNodeState(0, State.STOPPING);
final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 0));
@@ -48,7 +46,7 @@ public class NodeInfoTest {
* from haunting a now stable node.
*/
@Test
- public void zeroing_crash_count_resets_unstable_init_flag() {
+ void zeroing_crash_count_resets_unstable_init_flag() {
ClusterFixture fixture = fixtureWithNodeMarkedAsUnstableInit(1);
final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
@@ -61,7 +59,7 @@ public class NodeInfoTest {
* further instabilities and should not clear the unstable init flag.
*/
@Test
- public void non_zero_crash_count_update_does_not_reset_unstable_init_flag() {
+ void non_zero_crash_count_update_does_not_reset_unstable_init_flag() {
ClusterFixture fixture = fixtureWithNodeMarkedAsUnstableInit(1);
final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
@@ -70,7 +68,7 @@ public class NodeInfoTest {
}
@Test
- public void non_zero_crash_count_does_not_implicitly_set_unstable_init_flag() {
+ void non_zero_crash_count_does_not_implicitly_set_unstable_init_flag() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(3);
final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
@@ -79,7 +77,7 @@ public class NodeInfoTest {
}
@Test
- public void down_wanted_state_overrides_config_retired_state() {
+ void down_wanted_state_overrides_config_retired_state() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.markNodeAsConfigRetired(1)
.proposeStorageNodeWantedState(1, State.DOWN);
@@ -89,7 +87,7 @@ public class NodeInfoTest {
}
@Test
- public void maintenance_wanted_state_overrides_config_retired_state() {
+ void maintenance_wanted_state_overrides_config_retired_state() {
ClusterFixture fixture = ClusterFixture.forFlatCluster(3)
.markNodeAsConfigRetired(1)
.proposeStorageNodeWantedState(1, State.MAINTENANCE);
@@ -99,7 +97,7 @@ public class NodeInfoTest {
}
@Test
- public void retired_state_overrides_default_up_wanted_state() {
+ void retired_state_overrides_default_up_wanted_state() {
final ClusterFixture fixture = ClusterFixture.forFlatCluster(3).markNodeAsConfigRetired(1);
NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java
index ea539cc13e0..69ddf8e2c02 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java
@@ -2,12 +2,12 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
import java.util.TreeSet;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class NodeSlobrokConfigurationMembershipTest extends FleetControllerTest {
@@ -32,13 +32,13 @@ public class NodeSlobrokConfigurationMembershipTest extends FleetControllerTest
}
@Test
- public void testSlobrokNodeOutsideConfiguredIndexSetIsNotIncludedInCluster() throws Exception {
+ void testSlobrokNodeOutsideConfiguredIndexSetIsNotIncludedInCluster() throws Exception {
setUpClusterWithForeignNode(nodeIndices, foreignNode);
waitForStateExcludingNodeSubset("version:\\d+ distributor:4 storage:4", asIntSet(foreignNode));
}
@Test
- public void testNodeSetReconfigurationForcesFreshSlobrokFetch() throws Exception {
+ void testNodeSetReconfigurationForcesFreshSlobrokFetch() throws Exception {
setUpClusterWithForeignNode(nodeIndices, foreignNode);
waitForStateExcludingNodeSubset("version:\\d+ distributor:4 storage:4", asIntSet(foreignNode));
@@ -53,7 +53,7 @@ public class NodeSlobrokConfigurationMembershipTest extends FleetControllerTest
}
@Test
- public void test_removed_retired_node_is_not_included_in_state() throws Exception {
+ void test_removed_retired_node_is_not_included_in_state() throws Exception {
final Set<ConfiguredNode> configuredNodes = asConfiguredNodes(nodeIndices);
FleetControllerOptions options = optionsForConfiguredNodes(configuredNodes);
setUpFleetController(true, options);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
index 87e102c67c1..6af852aa3ed 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
@@ -13,17 +13,14 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest;
import com.yahoo.vespa.config.content.StorDistributionConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -107,7 +104,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeForce() {
+ void testCanUpgradeForce() {
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(createCluster(createNodes(1)));
NodeState newState = new NodeState(NodeType.STORAGE, State.INITIALIZING);
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(
@@ -118,7 +115,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testDeniedInMoratorium() {
+ void testDeniedInMoratorium() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = new NodeStateChangeChecker(
requiredRedundancy, noopVisiting, cluster.clusterInfo(), true);
@@ -131,7 +128,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testUnknownStorageNode() {
+ void testUnknownStorageNode() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = new NodeStateChangeChecker(
requiredRedundancy, noopVisiting, cluster.clusterInfo(), false);
@@ -144,7 +141,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testSafeMaintenanceDisallowedWhenOtherStorageNodeInFlatClusterIsSuspended() {
+ void testSafeMaintenanceDisallowedWhenOtherStorageNodeInFlatClusterIsSuspended() {
// Nodes 0-3, storage node 0 being in maintenance with "Orchestrator" description.
ContentCluster cluster = createCluster(createNodes(4));
cluster.clusterInfo().getStorageNodeInfo(0).setWantedState(new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Orchestrator"));
@@ -164,7 +161,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testSafeMaintenanceDisallowedWhenOtherDistributorInFlatClusterIsSuspended() {
+ void testSafeMaintenanceDisallowedWhenOtherDistributorInFlatClusterIsSuspended() {
// Nodes 0-3, storage node 0 being in maintenance with "Orchestrator" description.
ContentCluster cluster = createCluster(createNodes(4));
cluster.clusterInfo().getDistributorNodeInfo(0)
@@ -185,7 +182,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testSafeMaintenanceDisallowedWhenDistributorInGroupIsDown() {
+ void testSafeMaintenanceDisallowedWhenDistributorInGroupIsDown() {
// Nodes 0-3, distributor 0 being in maintenance with "Orchestrator" description.
// 2 groups: nodes 0-1 is group 0, 2-3 is group 1.
ContentCluster cluster = createCluster(createNodes(4));
@@ -214,13 +211,13 @@ public class NodeStateChangeCheckerTest {
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(
new Node(NodeType.STORAGE, 1), clusterStateWith0InMaintenance,
SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
- assertFalse(result.getReason(), result.settingWantedStateIsAllowed());
+ assertFalse(result.settingWantedStateIsAllowed(), result.getReason());
assertEquals("Another distributor wants state DOWN: 0", result.getReason());
}
}
@Test
- public void testSafeMaintenanceWhenOtherStorageNodeInGroupIsSuspended() {
+ void testSafeMaintenanceWhenOtherStorageNodeInGroupIsSuspended() {
// Nodes 0-3, storage node 0 being in maintenance with "Orchestrator" description.
// 2 groups: nodes 0-1 is group 0, 2-3 is group 1.
ContentCluster cluster = createCluster(createNodes(4));
@@ -249,7 +246,7 @@ public class NodeStateChangeCheckerTest {
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(
new Node(NodeType.STORAGE, 1), clusterStateWith0InMaintenance,
SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
- assertTrue(result.getReason(), result.settingWantedStateIsAllowed());
+ assertTrue(result.settingWantedStateIsAllowed(), result.getReason());
assertFalse(result.wantedStateAlreadySet());
}
}
@@ -295,7 +292,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testSafeSetStateDistributors() {
+ void testSafeSetStateDistributors() {
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(createCluster(createNodes(1)));
NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(
nodeDistributor, defaultAllUpClusterState(), SetUnitStateRequest.Condition.SAFE,
@@ -306,7 +303,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeSafeMissingStorage() {
+ void testCanUpgradeSafeMissingStorage() {
// Create a content cluster with 4 nodes, and storage node with index 3 down.
ContentCluster cluster = createCluster(createNodes(4));
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 5, 6)));
@@ -327,14 +324,14 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeStorageSafeYes() {
+ void testCanUpgradeStorageSafeYes() {
NodeStateChangeChecker.Result result = transitionToMaintenanceWithNoStorageNodesDown();
assertTrue(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
}
@Test
- public void testSetUpFailsIfReportedIsDown() {
+ void testSetUpFailsIfReportedIsDown() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
// Not setting nodes up -> all are down
@@ -349,7 +346,7 @@ public class NodeStateChangeCheckerTest {
// A node may be reported as Up but have a generated state of Down if it's part of
// nodes taken down implicitly due to a group having too low node availability.
@Test
- public void testSetUpSucceedsIfReportedIsUpButGeneratedIsDown() {
+ void testSetUpSucceedsIfReportedIsUpButGeneratedIsDown() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
@@ -367,7 +364,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanSetUpEvenIfOldWantedStateIsDown() {
+ void testCanSetUpEvenIfOldWantedStateIsDown() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 3, 6)));
@@ -380,7 +377,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeStorageSafeNo() {
+ void testCanUpgradeStorageSafeNo() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 3, 6)));
@@ -395,7 +392,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeIfMissingMinReplicationFactor() {
+ void testCanUpgradeIfMissingMinReplicationFactor() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 3, 6)));
@@ -408,7 +405,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeIfStorageNodeMissingFromNodeInfo() {
+ void testCanUpgradeIfStorageNodeMissingFromNodeInfo() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
String hostInfo = "{\n" +
@@ -432,7 +429,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testMissingDistributorState() {
+ void testMissingDistributorState() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
cluster.clusterInfo().getStorageNodeInfo(1).setReportedState(new NodeState(NodeType.STORAGE, State.UP), 0);
@@ -460,20 +457,20 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testSettingUpWhenUpCausesAlreadySet() {
+ void testSettingUpWhenUpCausesAlreadySet() {
NodeStateChangeChecker.Result result = transitionToSameState(State.UP, "foo", "bar");
assertTrue(result.wantedStateAlreadySet());
}
@Test
- public void testSettingAlreadySetState() {
+ void testSettingAlreadySetState() {
NodeStateChangeChecker.Result result = transitionToSameState("foo", "foo");
assertFalse(result.settingWantedStateIsAllowed());
assertTrue(result.wantedStateAlreadySet());
}
@Test
- public void testDifferentDescriptionImpliesDenied() {
+ void testDifferentDescriptionImpliesDenied() {
NodeStateChangeChecker.Result result = transitionToSameState("foo", "bar");
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
@@ -526,28 +523,28 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testCanUpgradeWhenAllUp() {
+ void testCanUpgradeWhenAllUp() {
NodeStateChangeChecker.Result result = transitionToMaintenanceWithNoStorageNodesDown();
assertTrue(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
}
@Test
- public void testCanUpgradeWhenAllUpOrRetired() {
+ void testCanUpgradeWhenAllUpOrRetired() {
NodeStateChangeChecker.Result result = transitionToMaintenanceWithNoStorageNodesDown();
assertTrue(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
}
@Test
- public void testCanUpgradeWhenStorageIsDown() {
+ void testCanUpgradeWhenStorageIsDown() {
NodeStateChangeChecker.Result result = transitionToMaintenanceWithOneStorageNodeDown(nodeStorage.getIndex());
assertTrue(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
}
@Test
- public void testCannotUpgradeWhenOtherStorageIsDown() {
+ void testCannotUpgradeWhenOtherStorageIsDown() {
int otherIndex = 2;
// If this fails, just set otherIndex to some other valid index.
assertNotEquals(nodeStorage.getIndex(), otherIndex);
@@ -559,7 +556,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testNodeRatioRequirementConsidersGeneratedNodeStates() {
+ void testNodeRatioRequirementConsidersGeneratedNodeStates() {
ContentCluster cluster = createCluster(createNodes(4));
NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
@@ -581,7 +578,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testDownDisallowedByNonRetiredState() {
+ void testDownDisallowedByNonRetiredState() {
NodeStateChangeChecker.Result result = evaluateDownTransition(
defaultAllUpClusterState(),
State.UP,
@@ -593,7 +590,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testDownDisallowedByBuckets() {
+ void testDownDisallowedByBuckets() {
NodeStateChangeChecker.Result result = evaluateDownTransition(
retiredClusterStateSuffix(),
State.UP,
@@ -605,7 +602,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testDownDisallowedByReportedState() {
+ void testDownDisallowedByReportedState() {
NodeStateChangeChecker.Result result = evaluateDownTransition(
retiredClusterStateSuffix(),
State.INITIALIZING,
@@ -617,7 +614,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testDownDisallowedByVersionMismatch() {
+ void testDownDisallowedByVersionMismatch() {
NodeStateChangeChecker.Result result = evaluateDownTransition(
retiredClusterStateSuffix(),
State.UP,
@@ -630,7 +627,7 @@ public class NodeStateChangeCheckerTest {
}
@Test
- public void testAllowedToSetDown() {
+ void testAllowedToSetDown() {
NodeStateChangeChecker.Result result = evaluateDownTransition(
retiredClusterStateSuffix(),
State.UP,
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceExhaustionCalculatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceExhaustionCalculatorTest.java
index e136ddfa72d..24945d0d261 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceExhaustionCalculatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceExhaustionCalculatorTest.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.State;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.createFixtureWithReportedUsages;
@@ -11,27 +11,24 @@ import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.forNode;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.mapOf;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.setOf;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.usage;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class ResourceExhaustionCalculatorTest {
@Test
- public void no_feed_block_returned_when_no_resources_lower_than_limit() {
+ void no_feed_block_returned_when_no_resources_lower_than_limit() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.49), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNull(feedBlock);
}
@Test
- public void feed_block_returned_when_single_resource_beyond_limit() {
+ void feed_block_returned_when_single_resource_beyond_limit() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
assertTrue(feedBlock.blockFeedInCluster());
@@ -39,10 +36,10 @@ public class ResourceExhaustionCalculatorTest {
}
@Test
- public void feed_block_description_can_contain_optional_name_component() {
+ void feed_block_description_can_contain_optional_name_component() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", "a-fancy-disk", 0.51), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
assertTrue(feedBlock.blockFeedInCluster());
@@ -50,80 +47,80 @@ public class ResourceExhaustionCalculatorTest {
}
@Test
- public void missing_or_malformed_rpc_addresses_are_emitted_as_unknown_hostnames() {
+ void missing_or_malformed_rpc_addresses_are_emitted_as_unknown_hostnames() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.4), usage("memory", 0.85)));
+ forNode(2, usage("disk", 0.4), usage("memory", 0.85)));
cf.cluster().getNodeInfo(storageNode(1)).setRpcAddress(null);
cf.cluster().getNodeInfo(storageNode(2)).setRpcAddress("max mekker");
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
assertTrue(feedBlock.blockFeedInCluster());
assertEquals("disk on node 1 [unknown hostname] (0.510 > 0.500), " +
- "memory on node 2 [unknown hostname] (0.850 > 0.800)", feedBlock.getDescription());
+ "memory on node 2 [unknown hostname] (0.850 > 0.800)", feedBlock.getDescription());
}
@Test
- public void feed_block_returned_when_multiple_resources_beyond_limit() {
+ void feed_block_returned_when_multiple_resources_beyond_limit() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.4), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.85)),
- forNode(2, usage("disk", 0.45), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.45), usage("memory", 0.6)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
assertTrue(feedBlock.blockFeedInCluster());
assertEquals("disk on node 1 [storage.1.local] (0.510 > 0.400), " +
- "memory on node 1 [storage.1.local] (0.850 > 0.800), " +
- "disk on node 2 [storage.2.local] (0.450 > 0.400)",
- feedBlock.getDescription());
+ "memory on node 1 [storage.1.local] (0.850 > 0.800), " +
+ "disk on node 2 [storage.2.local] (0.450 > 0.400)",
+ feedBlock.getDescription());
}
@Test
- public void feed_block_description_is_bounded_in_number_of_described_resources() {
+ void feed_block_description_is_bounded_in_number_of_described_resources() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.4), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.85)),
- forNode(2, usage("disk", 0.45), usage("memory", 0.6)),
- forNode(3, usage("disk", 0.6), usage("memory", 0.9)));
+ forNode(2, usage("disk", 0.45), usage("memory", 0.6)),
+ forNode(3, usage("disk", 0.6), usage("memory", 0.9)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
assertTrue(feedBlock.blockFeedInCluster());
assertEquals("disk on node 1 [storage.1.local] (0.510 > 0.400), " +
- "memory on node 1 [storage.1.local] (0.850 > 0.800), " +
- "disk on node 2 [storage.2.local] (0.450 > 0.400) (... and 2 more)",
- feedBlock.getDescription());
+ "memory on node 1 [storage.1.local] (0.850 > 0.800), " +
+ "disk on node 2 [storage.2.local] (0.450 > 0.400) (... and 2 more)",
+ feedBlock.getDescription());
}
@Test
- public void no_feed_block_returned_when_feed_block_disabled() {
+ void no_feed_block_returned_when_feed_block_disabled() {
var calc = new ResourceExhaustionCalculator(false, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.4), usage("memory", 0.6)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNull(feedBlock);
}
@Test
- public void retain_node_feed_block_status_when_within_hysteresis_window_limit_crossed_edge_case() {
+ void retain_node_feed_block_status_when_within_hysteresis_window_limit_crossed_edge_case() {
var curFeedBlock = ClusterStateBundle.FeedBlock.blockedWith("foo", setOf(exhaustion(1, "memory", 0.51)));
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.5)), curFeedBlock, 0.1);
// Node 1 goes from 0.51 to 0.49, crossing the 0.5 threshold. Should still be blocked.
// Node 2 is at 0.49 but was not previously blocked and should not be blocked now either.
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.3), usage("memory", 0.49)),
- forNode(2, usage("disk", 0.3), usage("memory", 0.49)));
+ forNode(2, usage("disk", 0.3), usage("memory", 0.49)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
// TODO should we not change the limits themselves? Explicit mention of hysteresis state?
assertEquals("memory on node 1 [storage.1.local] (0.490 > 0.400)",
- feedBlock.getDescription());
+ feedBlock.getDescription());
}
@Test
- public void retain_node_feed_block_status_when_within_hysteresis_window_under_limit_edge_case() {
+ void retain_node_feed_block_status_when_within_hysteresis_window_under_limit_edge_case() {
var curFeedBlock = ClusterStateBundle.FeedBlock.blockedWith("foo", setOf(exhaustion(1, "memory", 0.49)));
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.5)), curFeedBlock, 0.1);
// Node 1 goes from 0.49 to 0.48, NOT crossing the 0.5 threshold. Should still be blocked.
// Node 2 is at 0.49 but was not previously blocked and should not be blocked now either.
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.3), usage("memory", 0.48)),
- forNode(2, usage("disk", 0.3), usage("memory", 0.49)));
+ forNode(2, usage("disk", 0.3), usage("memory", 0.49)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNotNull(feedBlock);
assertEquals("memory on node 1 [storage.1.local] (0.480 > 0.400)",
@@ -131,22 +128,22 @@ public class ResourceExhaustionCalculatorTest {
}
@Test
- public void retained_node_feed_block_cleared_once_hysteresis_threshold_is_passed() {
+ void retained_node_feed_block_cleared_once_hysteresis_threshold_is_passed() {
var curFeedBlock = ClusterStateBundle.FeedBlock.blockedWith("foo", setOf(exhaustion(1, "memory", 0.48)));
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.5)), curFeedBlock, 0.1);
// Node 1 goes from 0.48 to 0.39. Should be unblocked
// Node 2 is at 0.49 but was not previously blocked and should not be blocked now either.
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.3), usage("memory", 0.39)),
- forNode(2, usage("disk", 0.3), usage("memory", 0.49)));
+ forNode(2, usage("disk", 0.3), usage("memory", 0.49)));
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
assertNull(feedBlock);
}
@Test
- public void node_must_be_available_in_reported_state_to_trigger_feed_block() {
+ void node_must_be_available_in_reported_state_to_trigger_feed_block() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.6), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.6), usage("memory", 0.6)));
cf.reportStorageNodeState(1, State.DOWN);
cf.reportStorageNodeState(2, State.DOWN);
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
@@ -154,10 +151,10 @@ public class ResourceExhaustionCalculatorTest {
}
@Test
- public void node_must_be_available_in_wanted_state_to_trigger_feed_block() {
+ void node_must_be_available_in_wanted_state_to_trigger_feed_block() {
var calc = new ResourceExhaustionCalculator(true, mapOf(usage("disk", 0.5), usage("memory", 0.8)));
var cf = createFixtureWithReportedUsages(forNode(1, usage("disk", 0.51), usage("memory", 0.79)),
- forNode(2, usage("disk", 0.6), usage("memory", 0.6)));
+ forNode(2, usage("disk", 0.6), usage("memory", 0.6)));
cf.proposeStorageNodeWantedState(1, State.DOWN);
cf.proposeStorageNodeWantedState(2, State.MAINTENANCE);
var feedBlock = calc.inferContentClusterFeedBlockOrNull(cf.cluster().getNodeInfos());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStatsTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStatsTest.java
index 2eeaf7658ff..fddd5b52aa2 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStatsTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStatsTest.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.clustercontroller.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Collections;
@@ -13,15 +13,14 @@ import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.exhaustion;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.forNode;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.setOf;
import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.usage;
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ResourceUsageStatsTest {
private final double DELTA = 0.00001;
@Test
- public void disk_and_memory_utilization_is_max_among_all_content_nodes() {
+ void disk_and_memory_utilization_is_max_among_all_content_nodes() {
var stats = ResourceUsageStats.calculateFrom(createNodeInfo(
forNode(1, usage("disk", 0.3), usage("memory", 0.6)),
forNode(2, usage("disk", 0.4), usage("memory", 0.5))),
@@ -34,7 +33,7 @@ public class ResourceUsageStatsTest {
}
@Test
- public void disk_and_memory_utilization_is_zero_if_no_samples_are_available() {
+ void disk_and_memory_utilization_is_zero_if_no_samples_are_available() {
var stats = ResourceUsageStats.calculateFrom(createNodeInfo(
forNode(1), forNode(2)),
createFeedBlockLimits(0.8, 0.9),
@@ -46,20 +45,20 @@ public class ResourceUsageStatsTest {
}
@Test
- public void nodes_above_limit_is_zero_without_feed_block_status() {
+ void nodes_above_limit_is_zero_without_feed_block_status() {
var stats = ResourceUsageStats.calculateFrom(Collections.emptyList(), Collections.emptyMap(), Optional.empty());
assertEquals(0, stats.getNodesAboveLimit());
}
@Test
- public void nodes_above_limit_is_equal_to_node_resource_exhaustions() {
+ void nodes_above_limit_is_equal_to_node_resource_exhaustions() {
var stats = ResourceUsageStats.calculateFrom(Collections.emptyList(), Collections.emptyMap(),
createFeedBlock(exhaustion(1, "disk"), exhaustion(2, "memory")));
assertEquals(2, stats.getNodesAboveLimit());
}
@Test
- public void nodes_above_limit_counts_each_node_only_once() {
+ void nodes_above_limit_counts_each_node_only_once() {
var stats = ResourceUsageStats.calculateFrom(Collections.emptyList(), Collections.emptyMap(),
createFeedBlock(exhaustion(1, "disk"), exhaustion(1, "memory")));
assertEquals(1, stats.getNodesAboveLimit());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java
index fee1d33725c..41d7465b602 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java
@@ -20,7 +20,7 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.rpc.RpcServer;
import com.yahoo.vespa.clustercontroller.core.testutils.LogFormatter;
import com.yahoo.vespa.clustercontroller.core.testutils.WaitCondition;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -30,10 +30,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author humbe
@@ -52,7 +49,7 @@ public class RpcServerTest extends FleetControllerTest {
}
@Test
- public void testRebinding() throws Exception {
+ void testRebinding() throws Exception {
startingTest("RpcServerTest::testRebinding");
Slobrok slobrok = new Slobrok();
String[] slobrokConnectionSpecs = new String[1];
@@ -81,17 +78,18 @@ public class RpcServerTest extends FleetControllerTest {
* similar things, so strange if it should be from them too though. Maybe last test there.
*/
@Test
- public void testFailOccasionallyAndIgnoreToSeeIfOtherTestsThenWork() {
- try{
+ void testFailOccasionallyAndIgnoreToSeeIfOtherTestsThenWork() {
+ try {
startingTest("RpcServerTest::testFailOccasionallyAndIgnoreToSeeIfOtherTestsThenWork");
setUpFleetController(true, defaultOptions("mycluster"));
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ }
}
@Test
- public void testGetSystemState() throws Exception {
+ void testGetSystemState() throws Exception {
LogFormatter.initializeLogging();
startingTest("RpcServerTest::testGetSystemState");
FleetControllerOptions options = defaultOptions("mycluster");
@@ -131,12 +129,12 @@ public class RpcServerTest extends FleetControllerTest {
Request req = new Request("getSystemState");
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ss"), req.toString());
String systemState = req.returnValues().get(1).asString();
ClusterState retrievedClusterState = new ClusterState(systemState);
- assertEquals(systemState, State.DOWN, retrievedClusterState.getNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getState());
- assertTrue(systemState, retrievedClusterState.getNodeState(new Node(NodeType.STORAGE, 9)).getState().oneOf("md"));
+ assertEquals(State.DOWN, retrievedClusterState.getNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getState(), systemState);
+ assertTrue(retrievedClusterState.getNodeState(new Node(NodeType.STORAGE, 9)).getState().oneOf("md"), systemState);
}
private void setWantedNodeState(State newState, NodeType nodeType, int nodeIndex) {
@@ -154,12 +152,12 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage/cluster.mycluster/" + node.getType().toString() + "/" + node.getIndex()));
req.parameters().add(new StringValue(newNodeState.serialize(true)));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("s"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("s"), req.toString());
}
@Test
- public void testGetNodeState() throws Exception {
+ void testGetNodeState() throws Exception {
startingTest("RpcServerTest::testGetNodeState");
Set<ConfiguredNode> configuredNodes = new TreeSet<>();
for (int i = 0; i < 10; i++)
@@ -199,19 +197,19 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(0));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(0).asString()).getState());
NodeState reported = NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(1).asString());
- assertTrue(req.returnValues().get(1).asString(), reported.getState().oneOf("d-"));
+ assertTrue(reported.getState().oneOf("d-"), req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
req = new Request("getNodeState");
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(2));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(0).asString()).getState());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(2).asString()).getState());
@@ -220,8 +218,8 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(4));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals("", req.returnValues().get(0).asString());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
@@ -230,16 +228,16 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(15));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
+ assertEquals(ErrorCode.METHOD_FAILED, req.errorCode(), req.toString());
assertEquals("No node distributor.15 exists in cluster mycluster", req.errorMessage());
- assertFalse(req.toString(), req.checkReturnTypes("ssss"));
+ assertFalse(req.checkReturnTypes("ssss"), req.toString());
req = new Request("getNodeState");
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(1));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals("s:i i:0.2", req.returnValues().get(0).asString());
assertEquals("s:i i:0.2", req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
@@ -248,19 +246,19 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(2));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals(State.DOWN, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(0).asString()).getState());
reported = NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(1).asString());
- assertTrue(req.returnValues().get(1).asString(), reported.getState().oneOf("d-"));
+ assertTrue(reported.getState().oneOf("d-"), req.returnValues().get(1).asString());
assertEquals(State.RETIRED, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(2).asString()).getState());
req = new Request("getNodeState");
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(5));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals("", req.returnValues().get(0).asString());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
@@ -269,15 +267,15 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(7));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("ssss"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("ssss"), req.toString());
assertEquals(State.MAINTENANCE, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(0).asString()).getState());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals(State.MAINTENANCE, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(2).asString()).getState());
}
@Test
- public void testGetNodeStateWithConfiguredRetired() throws Exception {
+ void testGetNodeStateWithConfiguredRetired() throws Exception {
startingTest("RpcServerTest::testGetNodeStateWithConfiguredRetired");
List<ConfiguredNode> configuredNodes = new ArrayList<>();
for (int i = 0; i < 4; i++)
@@ -311,7 +309,7 @@ public class RpcServerTest extends FleetControllerTest {
}
@Test
- public void testGetNodeStateWithConfigurationChangeToRetiredWhileNodeDown() throws Exception {
+ void testGetNodeStateWithConfigurationChangeToRetiredWhileNodeDown() throws Exception {
startingTest("RpcServerTest::testGetNodeStateWithConfigurationChangeToRetiredWhileNodeDown");
{ // Configuration: 5 nodes, all normal
@@ -392,7 +390,7 @@ public class RpcServerTest extends FleetControllerTest {
}
@Test
- public void testGetNodeStateWithConfigurationChangeToRetired() throws Exception {
+ void testGetNodeStateWithConfigurationChangeToRetired() throws Exception {
startingTest("RpcServerTest::testGetNodeStateWithConfigurationChangeToRetired");
{ // Configuration: 5 nodes, all normal
@@ -450,27 +448,27 @@ public class RpcServerTest extends FleetControllerTest {
{ // Configuration change: Remove the previously retired nodes
/*
- TODO: Verify current result: version:23 distributor:7 .0.s:d .1.s:d .2.s:d .3.s:d .4.s:d storage:7 .0.s:m .1.s:m .2.s:m .3.s:m .4.s:m
- TODO: Make this work without stopping/disconnecting (see StateChangeHandler.setNodes
- Set<ConfiguredNode> configuredNodes = new TreeSet<>();
- configuredNodes.add(new ConfiguredNode(5, false));
- configuredNodes.add(new ConfiguredNode(6, false));
- FleetControllerOptions options = new FleetControllerOptions("mycluster", configuredNodes);
- options.slobrokConnectionSpecs = this.options.slobrokConnectionSpecs;
- this.options.maxInitProgressTimeMs = 30000;
- this.options.stableStateTimePeriod = 60000;
- fleetController.updateOptions(options, 0);
- for (int i = 0; i < 5*2; i++) {
- nodes.get(i).disconnectSlobrok();
- nodes.get(i).disconnect();
- }
- waitForState("version:\\d+ distributor:7 storage:7 .0.s:d .1.s:d .2.s:d .3.s:d .4.s:d");
- */
+ TODO: Verify current result: version:23 distributor:7 .0.s:d .1.s:d .2.s:d .3.s:d .4.s:d storage:7 .0.s:m .1.s:m .2.s:m .3.s:m .4.s:m
+ TODO: Make this work without stopping/disconnecting (see StateChangeHandler.setNodes
+ Set<ConfiguredNode> configuredNodes = new TreeSet<>();
+ configuredNodes.add(new ConfiguredNode(5, false));
+ configuredNodes.add(new ConfiguredNode(6, false));
+ FleetControllerOptions options = new FleetControllerOptions("mycluster", configuredNodes);
+ options.slobrokConnectionSpecs = this.options.slobrokConnectionSpecs;
+ this.options.maxInitProgressTimeMs = 30000;
+ this.options.stableStateTimePeriod = 60000;
+ fleetController.updateOptions(options, 0);
+ for (int i = 0; i < 5*2; i++) {
+ nodes.get(i).disconnectSlobrok();
+ nodes.get(i).disconnect();
+ }
+ waitForState("version:\\d+ distributor:7 storage:7 .0.s:d .1.s:d .2.s:d .3.s:d .4.s:d");
+ */
}
}
@Test
- public void testSetNodeState() throws Exception {
+ void testSetNodeState() throws Exception {
startingTest("RpcServerTest::testSetNodeState");
Set<Integer> nodeIndexes = new TreeSet<>(List.of(4, 6, 9, 10, 14, 16, 21, 22, 23, 25));
Set<ConfiguredNode> configuredNodes = nodeIndexes.stream().map(i -> new ConfiguredNode(i, false)).collect(Collectors.toSet());
@@ -489,8 +487,8 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/14"));
req.parameters().add(new StringValue("s:r"));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("s"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("s"), req.toString());
waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r .*");
@@ -498,8 +496,8 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/16"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("s"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
+ assertTrue(req.checkReturnTypes("s"), req.toString());
waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
nodes.get(5 * 2 + 1).disconnect();
@@ -517,7 +515,7 @@ public class RpcServerTest extends FleetControllerTest {
}
@Test
- public void testSetNodeStateOutOfRange() throws Exception {
+ void testSetNodeStateOutOfRange() throws Exception {
startingTest("RpcServerTest::testSetNodeStateOutOfRange");
FleetControllerOptions options = defaultOptions("mycluster");
options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(2, 10)));
@@ -534,27 +532,27 @@ public class RpcServerTest extends FleetControllerTest {
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/10"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
- assertEquals(req.toString(), "Cannot set wanted state of node storage.10. Index does not correspond to a configured node.", req.errorMessage());
+ assertEquals(ErrorCode.METHOD_FAILED, req.errorCode(), req.toString());
+ assertEquals("Cannot set wanted state of node storage.10. Index does not correspond to a configured node.", req.errorMessage(), req.toString());
req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/distributor/10"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
- assertEquals(req.toString(), "Cannot set wanted state of node distributor.10. Index does not correspond to a configured node.", req.errorMessage());
+ assertEquals(ErrorCode.METHOD_FAILED, req.errorCode(), req.toString());
+ assertEquals("Cannot set wanted state of node distributor.10. Index does not correspond to a configured node.", req.errorMessage(), req.toString());
req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/9"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.toString());
waitForState("version:\\d+ distributor:10 storage:10 .9.s:m");
}
@Test
- public void testGetMaster() throws Exception {
+ void testGetMaster() throws Exception {
startingTest("RpcServerTest::testGetMaster");
FleetControllerOptions options = defaultOptions("mycluster");
options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(2, 10)));
@@ -569,14 +567,14 @@ public class RpcServerTest extends FleetControllerTest {
Request req = new Request("getMaster");
connection.invokeSync(req, timeoutS);
- assertEquals(req.toString(), 0, req.returnValues().get(0).asInt32());
- assertEquals(req.toString(), "All 1 nodes agree that 0 is current master.", req.returnValues().get(1).asString());
+ assertEquals(0, req.returnValues().get(0).asInt32(), req.toString());
+ assertEquals("All 1 nodes agree that 0 is current master.", req.returnValues().get(1).asString(), req.toString());
// Note that this feature is tested better in MasterElectionTest.testGetMaster as it has multiple fleetcontrollers
}
@Test
- public void testGetNodeList() throws Exception {
+ void testGetNodeList() throws Exception {
startingTest("RpcServerTest::testGetNodeList");
setUpFleetController(true, defaultOptions("mycluster", 5));
final int nodeCount = 5;
@@ -596,8 +594,8 @@ public class RpcServerTest extends FleetControllerTest {
for (int j = 0; j <= nodeCount; ++j) {
Request req = new Request("getNodeList");
connection.invokeSync(req, timeoutS);
- assertEquals(req.errorMessage(), ErrorCode.NONE, req.errorCode());
- assertTrue(req.toString(), req.checkReturnTypes("SS"));
+ assertEquals(ErrorCode.NONE, req.errorCode(), req.errorMessage());
+ assertTrue(req.checkReturnTypes("SS"), req.toString());
String[] slobrok = req.returnValues().get(0).asStringArray().clone();
String[] rpc = req.returnValues().get(1).asStringArray().clone();
@@ -610,7 +608,7 @@ public class RpcServerTest extends FleetControllerTest {
if (i < nodeCount && !"".equals(rpc[i])) {
continue;
}
- assertEquals(slobrok[i], "", rpc[i]);
+ assertEquals("", rpc[i], slobrok[i]);
continue;
}
assertNotEquals("", rpc[i]);
@@ -618,7 +616,7 @@ public class RpcServerTest extends FleetControllerTest {
req2.parameters().add(new StringValue("unknown"));
Target connection2 = supervisor.connect(new Spec(rpc[i]));
connection2.invokeSync(req2, timeoutS);
- assertEquals(req2.toString(), ErrorCode.NONE, req.errorCode());
+ assertEquals(ErrorCode.NONE, req.errorCode(), req2.toString());
}
break;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
index d61cd1271b6..df0b873e25b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
@@ -4,7 +4,7 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.State;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -28,13 +28,13 @@ public class RpcVersionAutoDowngradeTest extends FleetControllerTest {
}
@Test
- public void cluster_state_rpc_version_is_auto_downgraded_and_retried_for_older_nodes() throws Exception {
+ void cluster_state_rpc_version_is_auto_downgraded_and_retried_for_older_nodes() throws Exception {
setUpFakeCluster(2); // HEAD is at v4
waitForState("version:\\d+ distributor:10 storage:10");
}
@Test
- public void implicit_activation_for_nodes_that_return_not_found_for_version_activation_rpc() throws Exception {
+ void implicit_activation_for_nodes_that_return_not_found_for_version_activation_rpc() throws Exception {
setUpFakeCluster(3); // HEAD is at v4
waitForState("version:\\d+ distributor:10 storage:10");
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java
index 47ba7e1cb77..b59c90f4955 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java
@@ -3,9 +3,10 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.jrt.slobrok.server.Slobrok;
import java.util.logging.Level;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.logging.Logger;
@@ -14,7 +15,7 @@ public class SlobrokTest extends FleetControllerTest {
private static final Logger log = Logger.getLogger(SlobrokTest.class.getName());
@Test
- public void testSingleSlobrokRestart() throws Exception {
+ void testSingleSlobrokRestart() throws Exception {
startingTest("SlobrokTest::testSingleSlobrokRestart");
FleetControllerOptions options = defaultOptions("mycluster");
options.nodeStateRequestTimeoutMS = 60 * 60 * 1000;
@@ -26,13 +27,13 @@ public class SlobrokTest extends FleetControllerTest {
int version = fleetController.getSystemState().getVersion();
int slobrokPort = slobrok.port();
- // Test that we survive some slobrok instability without changing system state.
- for (int j=0; j<4; ++j) {
+ // Test that we survive some slobrok instability without changing system state.
+ for (int j = 0; j < 4; ++j) {
log.log(Level.INFO, "Mirror updateForDistributor count is " + fleetController.getSlobrokMirrorUpdates());
- log.log(Level.INFO, "STOPPING SLOBROK SERVER (" + (j+1) + "/4)");
+ log.log(Level.INFO, "STOPPING SLOBROK SERVER (" + (j + 1) + "/4)");
slobrok.stop();
- for (int i=0; i<10; ++i) {
- // Force one node to at least notice that the slobrok server is gone
+ for (int i = 0; i < 10; ++i) {
+ // Force one node to at least notice that the slobrok server is gone
if (i == 5) {
log.log(Level.INFO, "Forcing one node to initate a resend: " + nodes.get(3));
nodes.get(3).replyToPendingNodeStateRequests();
@@ -40,9 +41,9 @@ public class SlobrokTest extends FleetControllerTest {
waitForCompleteCycle();
timer.advanceTime(100);
}
- log.log(Level.INFO, "STARTING SLOBROK SERVER AGAIN (" + (j+1) + "/4)");
+ log.log(Level.INFO, "STARTING SLOBROK SERVER AGAIN (" + (j + 1) + "/4)");
slobrok = new Slobrok(slobrokPort);
- // May take up to 30 seconds for slobrok clients to re-register. Trigger retry.
+ // May take up to 30 seconds for slobrok clients to re-register. Trigger retry.
for (DummyVdsNode node : nodes) {
node.disconnectSlobrok();
node.registerSlobrok();
@@ -56,19 +57,19 @@ public class SlobrokTest extends FleetControllerTest {
if (clusterAvailable()) break;
timer.advanceTime(1000);
waitForCompleteCycle();
- try{
+ try {
Thread.sleep(10);
- } catch (InterruptedException e) { /* ignore */ }
+ } catch (InterruptedException e) { /* ignore */
+ }
}
assertClusterAvailable();
}
- assertEquals("Cluster state was affected, although it should not have been.",
- version, fleetController.getSystemState().getVersion());
+ assertEquals(version, fleetController.getSystemState().getVersion(), "Cluster state was affected, although it should not have been.");
}
@Test
- public void testNodeTooLongOutOfSlobrok() throws Exception {
+ void testNodeTooLongOutOfSlobrok() throws Exception {
startingTest("SlobrokTest::testNodeTooLongOutOfSlobrok");
FleetControllerOptions options = defaultOptions("mycluster");
options.maxSlobrokDisconnectGracePeriod = 60 * 1000;
@@ -81,13 +82,16 @@ public class SlobrokTest extends FleetControllerTest {
nodes.get(0).disconnectSlobrok();
log.log(Level.INFO, "DISCONNECTED NODE FROM SLOBROK. SHOULD BE IN COOLDOWN PERIOD");
fleetController.waitForNodesInSlobrok(9, 10, timeoutMS);
- synchronized (timer) {
+ synchronized(timer) {
nodes.get(0).sendGetNodeStateReply(0);
}
// Give system a little time to possible faultily removing node not in slobrok
timer.advanceTime(1000);
- try{ Thread.sleep(10); } catch (InterruptedException e) { /* ignore */ }
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) { /* ignore */
+ }
assertEquals(version, fleetController.getSystemState().getVersion());
log.log(Level.INFO, "JUMPING TIME. NODE SHOULD BE MARKED DOWN");
// At this point the fleetcontroller might not have noticed that the node is out of slobrok yet.
@@ -108,8 +112,8 @@ public class SlobrokTest extends FleetControllerTest {
private void assertClusterAvailable() {
ContentCluster cluster = fleetController.getCluster();
for (NodeInfo info : cluster.getNodeInfos()) {
- assertEquals("Node " + info + " connection attempts.", 0, info.getConnectionAttemptCount());
- assertTrue("Node " + info + " has no last request time.", info.getLatestNodeStateRequestTime() != 0);
+ assertEquals(0, info.getConnectionAttemptCount(), "Node " + info + " connection attempts.");
+ assertTrue(info.getLatestNodeStateRequestTime() != 0, "Node " + info + " has no last request time.");
}
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java
index 699a35a190c..2bea95ab8c5 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java
@@ -12,8 +12,8 @@ import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeListener;
import com.yahoo.vespa.clustercontroller.core.mocks.TestEventLog;
import com.yahoo.vespa.clustercontroller.core.testutils.LogFormatter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.LinkedList;
@@ -21,8 +21,8 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Logger;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class StateChangeHandlerTest {
@@ -76,7 +76,7 @@ public class StateChangeHandlerTest {
private TestNodeListener nodeStateUpdateListener;
private final ClusterStateGenerator.Params params = new ClusterStateGenerator.Params();
- @Before
+ @BeforeEach
public void setUp() {
LogFormatter.initializeLogging();
}
@@ -125,7 +125,7 @@ public class StateChangeHandlerTest {
log.info("Marking " + node + " out of slobrok");
cluster.getNodeInfo(node).markRpcAddressOutdated(clock);
nodeStateChangeHandler.handleMissingNode(stateBefore, cluster.getNodeInfo(node), nodeStateUpdateListener);
- assertTrue(eventLog.toString(), eventLog.toString().contains("Node is no longer in slobrok"));
+ assertTrue(eventLog.toString().contains("Node is no longer in slobrok"), eventLog.toString());
eventLog.clear();
}
@@ -159,16 +159,16 @@ public class StateChangeHandlerTest {
}
@Test
- public void testUnstableNodeInSlobrok() {
+ void testUnstableNodeInSlobrok() {
initialize(new Config());
startWithStableStateClusterWithNodesUp();
Node node = new Node(NodeType.STORAGE, 0);
- for (int j=0; j<3; ++j) {
+ for (int j = 0; j < 3; ++j) {
log.info("Iteration " + j);
assertEquals(0, cluster.getNodeInfo(node).getPrematureCrashCount());
assertEquals(State.UP, cluster.getNodeInfo(node).getWantedState().getState());
assertEquals(State.UP, currentClusterState().getNodeState(node).getState());
- for (int k=0; k<config.maxPrematureCrashes; ++k) {
+ for (int k = 0; k < config.maxPrematureCrashes; ++k) {
log.info("Premature iteration " + k);
markNodeOutOfSlobrok(node);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java
index 5a33414c955..7c61423ac2b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java
@@ -13,8 +13,8 @@ import com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabaseFactory;
import com.yahoo.vespa.clustercontroller.core.testutils.StateWaiter;
import com.yahoo.vespa.clustercontroller.utils.util.NoMetricReporter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.util.ArrayList;
@@ -25,9 +25,7 @@ import java.util.logging.Logger;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
-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.*;
public class StateChangeTest extends FleetControllerTest {
@@ -37,7 +35,7 @@ public class StateChangeTest extends FleetControllerTest {
private DummyCommunicator communicator;
private EventLog eventLog;
- @Before
+ @BeforeEach
public void setUp() {
supervisor = new Supervisor(new Transport());
}
@@ -101,7 +99,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testNormalStartup() throws Exception {
+ void testNormalStartup() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxInitProgressTime = 50000;
@@ -115,7 +113,7 @@ public class StateChangeTest extends FleetControllerTest {
communicator.setNodeState(new Node(NodeType.DISTRIBUTOR, j), new NodeState(NodeType.DISTRIBUTOR, State.INITIALIZING).setInitProgress(0.0f), "");
}
- for (int i=0; i<100; i += 10) {
+ for (int i = 0; i < 100; i += 10) {
timer.advanceTime(options.maxInitProgressTime / 20);
ctrl.tick();
for (int j = 0; j < 10; ++j) {
@@ -129,9 +127,9 @@ public class StateChangeTest extends FleetControllerTest {
// Regular init progress does not update the cluster state until the node is done initializing (or goes down,
// whichever comes first).
assertEquals("version:6 distributor:10 .0.s:i .0.i:0.0 .1.s:i .1.i:0.0 .2.s:i .2.i:0.0 .3.s:i .3.i:0.0 " +
- ".4.s:i .4.i:0.0 .5.s:i .5.i:0.0 .6.s:i .6.i:0.0 .7.s:i .7.i:0.0 .8.s:i .8.i:0.0 " +
- ".9.s:i .9.i:0.0 storage:10 .0.s:i .0.i:0.1 .1.s:i .1.i:0.1 .2.s:i .2.i:0.1 .3.s:i .3.i:0.1 " +
- ".4.s:i .4.i:0.1 .5.s:i .5.i:0.1 .6.s:i .6.i:0.1 .7.s:i .7.i:0.1 .8.s:i .8.i:0.1 .9.s:i .9.i:0.1",
+ ".4.s:i .4.i:0.0 .5.s:i .5.i:0.0 .6.s:i .6.i:0.0 .7.s:i .7.i:0.0 .8.s:i .8.i:0.0 " +
+ ".9.s:i .9.i:0.0 storage:10 .0.s:i .0.i:0.1 .1.s:i .1.i:0.1 .2.s:i .2.i:0.1 .3.s:i .3.i:0.1 " +
+ ".4.s:i .4.i:0.1 .5.s:i .5.i:0.1 .6.s:i .6.i:0.1 .7.s:i .7.i:0.1 .8.s:i .8.i:0.1 .9.s:i .9.i:0.1",
ctrl.consolidatedClusterState().toString());
timer.advanceTime(options.maxInitProgressTime / 20);
@@ -155,25 +153,25 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.DISTRIBUTOR, 0),
"Event: distributor.0: Now reporting state U\n" +
- "Event: distributor.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: distributor.0: Now reporting state I, i 0.00\n" +
- "Event: distributor.0: Altered node state in cluster state from 'U' to 'I, i 0.00'\n" +
- "Event: distributor.0: Now reporting state U\n" +
- "Event: distributor.0: Altered node state in cluster state from 'I, i 0.00' to 'U'\n");
+ "Event: distributor.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: distributor.0: Now reporting state I, i 0.00\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'U' to 'I, i 0.00'\n" +
+ "Event: distributor.0: Now reporting state U\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'I, i 0.00' to 'U'\n");
verifyNodeEvents(new Node(NodeType.STORAGE, 0),
"Event: storage.0: Now reporting state U\n" +
- "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.0: Now reporting state I, i 0.00 (ls)\n" +
- "Event: storage.0: Altered node state in cluster state from 'U' to 'D'\n" +
- "Event: storage.0: Now reporting state I, i 0.100 (read)\n" +
- "Event: storage.0: Altered node state in cluster state from 'D' to 'I, i 0.100 (read)'\n" +
- "Event: storage.0: Now reporting state U\n" +
- "Event: storage.0: Altered node state in cluster state from 'I, i 0.100 (read)' to 'U'\n");
+ "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.0: Now reporting state I, i 0.00 (ls)\n" +
+ "Event: storage.0: Altered node state in cluster state from 'U' to 'D'\n" +
+ "Event: storage.0: Now reporting state I, i 0.100 (read)\n" +
+ "Event: storage.0: Altered node state in cluster state from 'D' to 'I, i 0.100 (read)'\n" +
+ "Event: storage.0: Now reporting state U\n" +
+ "Event: storage.0: Altered node state in cluster state from 'I, i 0.100 (read)' to 'U'\n");
}
@Test
- public void testNodeGoingDownAndUp() throws Exception {
+ void testNodeGoingDownAndUp() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.nodeStateRequestTimeoutMS = 60 * 60 * 1000;
options.minTimeBetweenNewSystemStates = 0;
@@ -191,7 +189,7 @@ public class StateChangeTest extends FleetControllerTest {
ctrl.tick();
String desc = ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getDescription();
- assertTrue(desc, desc.contains("Closed at other end"));
+ assertTrue(desc.contains("Closed at other end"), desc);
assertEquals("version:4 distributor:10 .0.s:d storage:10", ctrl.getSystemState().toString());
@@ -208,7 +206,7 @@ public class StateChangeTest extends FleetControllerTest {
assert(!ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).hasDescription());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.contains("Closed at other end"));
+ assertTrue(desc.contains("Closed at other end"), desc);
timer.advanceTime(options.maxTransitionTime.get(NodeType.STORAGE) + 1);
@@ -217,7 +215,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:6 distributor:10 .0.t:12345678 storage:10 .0.s:d", ctrl.getSystemState().toString());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.contains("Closed at other end"));
+ assertTrue(desc.contains("Closed at other end"), desc);
timer.advanceTime(1000);
@@ -233,24 +231,24 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.DISTRIBUTOR, 0),
"Event: distributor.0: Now reporting state U\n" +
- "Event: distributor.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: distributor.0: Failed to get node state: D: Closed at other end\n" +
- "Event: distributor.0: Stopped or possibly crashed after 0 ms, which is before stable state time period. Premature crash count is now 1.\n" +
- "Event: distributor.0: Altered node state in cluster state from 'U' to 'D: Closed at other end'\n" +
- "Event: distributor.0: Now reporting state U, t 12345678\n" +
- "Event: distributor.0: Altered node state in cluster state from 'D: Closed at other end' to 'U, t 12345678'\n" +
- "Event: distributor.0: Altered node state in cluster state from 'U, t 12345678' to 'U'\n");
+ "Event: distributor.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: distributor.0: Failed to get node state: D: Closed at other end\n" +
+ "Event: distributor.0: Stopped or possibly crashed after 0 ms, which is before stable state time period. Premature crash count is now 1.\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'U' to 'D: Closed at other end'\n" +
+ "Event: distributor.0: Now reporting state U, t 12345678\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'D: Closed at other end' to 'U, t 12345678'\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'U, t 12345678' to 'U'\n");
verifyNodeEvents(new Node(NodeType.STORAGE, 0),
"Event: storage.0: Now reporting state U\n" +
- "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.0: Failed to get node state: D: Closed at other end\n" +
- "Event: storage.0: Stopped or possibly crashed after 1000 ms, which is before stable state time period. Premature crash count is now 1.\n" +
- "Event: storage.0: Altered node state in cluster state from 'U' to 'M: Closed at other end'\n" +
- "Event: storage.0: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
- "Event: storage.0: Altered node state in cluster state from 'M: Closed at other end' to 'D: Closed at other end'\n" +
- "Event: storage.0: Now reporting state U, t 12345679\n" +
- "Event: storage.0: Altered node state in cluster state from 'D: Closed at other end' to 'U, t 12345679'\n");
+ "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.0: Failed to get node state: D: Closed at other end\n" +
+ "Event: storage.0: Stopped or possibly crashed after 1000 ms, which is before stable state time period. Premature crash count is now 1.\n" +
+ "Event: storage.0: Altered node state in cluster state from 'U' to 'M: Closed at other end'\n" +
+ "Event: storage.0: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
+ "Event: storage.0: Altered node state in cluster state from 'M: Closed at other end' to 'D: Closed at other end'\n" +
+ "Event: storage.0: Now reporting state U, t 12345679\n" +
+ "Event: storage.0: Altered node state in cluster state from 'D: Closed at other end' to 'U, t 12345679'\n");
assertEquals(1, ctrl.getCluster().getNodeInfo(new Node(NodeType.DISTRIBUTOR, 0)).getPrematureCrashCount());
assertEquals(1, ctrl.getCluster().getNodeInfo(new Node(NodeType.STORAGE, 0)).getPrematureCrashCount());
@@ -262,7 +260,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testNodeGoingDownAndUpNotifying() throws Exception {
+ void testNodeGoingDownAndUpNotifying() throws Exception {
// Same test as above, but node manages to notify why it is going down first.
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.nodeStateRequestTimeoutMS = 60 * 60 * 1000;
@@ -272,15 +270,15 @@ public class StateChangeTest extends FleetControllerTest {
ctrl.tick();
- tick((int)options.stableStateTimePeriod + 1);
+ tick((int) options.stableStateTimePeriod + 1);
communicator.setNodeState(new Node(NodeType.DISTRIBUTOR, 0), State.DOWN, "controlled shutdown");
ctrl.tick();
String desc = ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getDescription();
- assertTrue(desc, desc.contains("Received signal 15 (SIGTERM - Termination signal)")
- || desc.contains("controlled shutdown"));
+ assertTrue(desc.contains("Received signal 15 (SIGTERM - Termination signal)")
+ || desc.contains("controlled shutdown"), desc);
tick(1000);
@@ -293,15 +291,15 @@ public class StateChangeTest extends FleetControllerTest {
assert(!ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).hasDescription());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.contains("Received signal 15 (SIGTERM - Termination signal)")
- || desc.contains("controlled shutdown"));
+ assertTrue(desc.contains("Received signal 15 (SIGTERM - Termination signal)")
+ || desc.contains("controlled shutdown"), desc);
tick(options.maxTransitionTime.get(NodeType.STORAGE) + 1);
assertEquals("version:6 distributor:10 storage:10 .0.s:d", ctrl.getSystemState().toString());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.contains("Received signal 15 (SIGTERM - Termination signal)")
- || desc.contains("controlled shutdown"));
+ assertTrue(desc.contains("Received signal 15 (SIGTERM - Termination signal)")
+ || desc.contains("controlled shutdown"), desc);
communicator.setNodeState(new Node(NodeType.STORAGE, 0), State.UP, "");
@@ -315,26 +313,26 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.DISTRIBUTOR, 0),
"Event: distributor.0: Now reporting state U\n" +
- "Event: distributor.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: distributor.0: Failed to get node state: D: controlled shutdown\n" +
- "Event: distributor.0: Altered node state in cluster state from 'U' to 'D: controlled shutdown'\n" +
- "Event: distributor.0: Now reporting state U\n" +
- "Event: distributor.0: Altered node state in cluster state from 'D: controlled shutdown' to 'U'\n");
+ "Event: distributor.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: distributor.0: Failed to get node state: D: controlled shutdown\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'U' to 'D: controlled shutdown'\n" +
+ "Event: distributor.0: Now reporting state U\n" +
+ "Event: distributor.0: Altered node state in cluster state from 'D: controlled shutdown' to 'U'\n");
verifyNodeEvents(new Node(NodeType.STORAGE, 0),
"Event: storage.0: Now reporting state U\n" +
- "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.0: Failed to get node state: D: controlled shutdown\n" +
- "Event: storage.0: Altered node state in cluster state from 'U' to 'M: controlled shutdown'\n" +
- "Event: storage.0: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
- "Event: storage.0: Altered node state in cluster state from 'M: controlled shutdown' to 'D: controlled shutdown'\n" +
- "Event: storage.0: Now reporting state U\n" +
- "Event: storage.0: Altered node state in cluster state from 'D: controlled shutdown' to 'U'\n");
+ "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.0: Failed to get node state: D: controlled shutdown\n" +
+ "Event: storage.0: Altered node state in cluster state from 'U' to 'M: controlled shutdown'\n" +
+ "Event: storage.0: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
+ "Event: storage.0: Altered node state in cluster state from 'M: controlled shutdown' to 'D: controlled shutdown'\n" +
+ "Event: storage.0: Now reporting state U\n" +
+ "Event: storage.0: Altered node state in cluster state from 'D: controlled shutdown' to 'U'\n");
}
@Test
- public void testNodeGoingDownAndUpFast() throws Exception {
+ void testNodeGoingDownAndUpFast() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxSlobrokDisconnectGracePeriod = 60 * 1000;
@@ -370,12 +368,12 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.STORAGE, 0),
"Event: storage.0: Now reporting state U\n" +
- "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.0: Node is no longer in slobrok, but we still have a pending state request.\n");
+ "Event: storage.0: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.0: Node is no longer in slobrok, but we still have a pending state request.\n");
}
@Test
- public void testMaintenanceWhileNormalStorageNodeRestart() throws Exception {
+ void testMaintenanceWhileNormalStorageNodeRestart() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxSlobrokDisconnectGracePeriod = 60 * 1000;
@@ -388,7 +386,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:4 distributor:10 storage:10 .6.s:m", ctrl.getSystemState().toString());
NodeState ns = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 6));
- assertTrue(ns.toString(), ns.getDescription().contains("Connection error: Closed at other end"));
+ assertTrue(ns.getDescription().contains("Connection error: Closed at other end"), ns.toString());
tick(1000);
@@ -417,19 +415,19 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.STORAGE, 6),
"Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
- "Event: storage.6: Stopped or possibly crashed after 0 ms, which is before stable state time period. Premature crash count is now 1.\n" +
- "Event: storage.6: Altered node state in cluster state from 'U' to 'M: Connection error: Closed at other end'\n" +
- "Event: storage.6: Now reporting state I, i 0.00 (ls)\n" +
- "Event: storage.6: Now reporting state I, i 0.600 (read)\n" +
- "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'I, i 0.600 (read)'\n" +
- "Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'I, i 0.600 (read)' to 'U'\n");
+ "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
+ "Event: storage.6: Stopped or possibly crashed after 0 ms, which is before stable state time period. Premature crash count is now 1.\n" +
+ "Event: storage.6: Altered node state in cluster state from 'U' to 'M: Connection error: Closed at other end'\n" +
+ "Event: storage.6: Now reporting state I, i 0.00 (ls)\n" +
+ "Event: storage.6: Now reporting state I, i 0.600 (read)\n" +
+ "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'I, i 0.600 (read)'\n" +
+ "Event: storage.6: Now reporting state U\n" +
+ "Event: storage.6: Altered node state in cluster state from 'I, i 0.600 (read)' to 'U'\n");
}
@Test
- public void testMaintenanceWithoutInitIfRetired() throws Exception {
+ void testMaintenanceWithoutInitIfRetired() throws Exception {
List<ConfiguredNode> nodes = new ArrayList<>();
for (int i = 0; i < 10; i++) {
boolean retired = (i == 6);
@@ -448,7 +446,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:4 distributor:10 storage:10 .6.s:m", ctrl.getSystemState().toString());
NodeState ns = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 6));
- assertTrue(ns.toString(), ns.getDescription().contains("Connection error: Closed at other end"));
+ assertTrue(ns.getDescription().contains("Connection error: Closed at other end"), ns.toString());
tick(1000);
@@ -477,18 +475,18 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.STORAGE, 6),
"Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'R'\n" +
- "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
- "Event: storage.6: Stopped or possibly crashed after 0 ms, which is before stable state time period. Premature crash count is now 1.\n" +
- "Event: storage.6: Altered node state in cluster state from 'R' to 'M: Connection error: Closed at other end'\n" +
- "Event: storage.6: Now reporting state I, i 0.00 (ls)\n" +
- "Event: storage.6: Now reporting state I, i 0.600 (read)\n" +
- "Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'R'\n");
+ "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'R'\n" +
+ "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
+ "Event: storage.6: Stopped or possibly crashed after 0 ms, which is before stable state time period. Premature crash count is now 1.\n" +
+ "Event: storage.6: Altered node state in cluster state from 'R' to 'M: Connection error: Closed at other end'\n" +
+ "Event: storage.6: Now reporting state I, i 0.00 (ls)\n" +
+ "Event: storage.6: Now reporting state I, i 0.600 (read)\n" +
+ "Event: storage.6: Now reporting state U\n" +
+ "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'R'\n");
}
@Test
- public void testMaintenanceToDownIfPastTransitionTimeAndRetired() throws Exception {
+ void testMaintenanceToDownIfPastTransitionTimeAndRetired() throws Exception {
List<ConfiguredNode> nodes = new ArrayList<>();
for (int i = 0; i < 10; i++) {
boolean retired = (i == 6);
@@ -516,7 +514,7 @@ public class StateChangeTest extends FleetControllerTest {
// Test that a node that has been down for a long time (above steady state period), actually alters cluster state to
// tell that it is initializing, rather than being ignored as a just restarted/unstable node should be.
@Test
- public void testDownNodeInitializing() throws Exception {
+ void testDownNodeInitializing() throws Exception {
// Actually report initializing state if node has been down steadily for a while
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxTransitionTime.put(NodeType.STORAGE, 5000);
@@ -566,20 +564,20 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.STORAGE, 6),
"Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
- "Event: storage.6: Altered node state in cluster state from 'U' to 'M: Connection error: Closed at other end'\n" +
- "Event: storage.6: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
- "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'D: Connection error: Closed at other end'\n" +
- "Event: storage.6: Now reporting state I, i 0.00100 (ls)\n" +
- "Event: storage.6: Now reporting state I, i 0.100 (read)\n" +
- "Event: storage.6: Altered node state in cluster state from 'D: Connection error: Closed at other end' to 'I, i 0.100 (read)'\n" +
- "Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'I, i 0.100 (read)' to 'U'\n");
+ "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
+ "Event: storage.6: Altered node state in cluster state from 'U' to 'M: Connection error: Closed at other end'\n" +
+ "Event: storage.6: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
+ "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'D: Connection error: Closed at other end'\n" +
+ "Event: storage.6: Now reporting state I, i 0.00100 (ls)\n" +
+ "Event: storage.6: Now reporting state I, i 0.100 (read)\n" +
+ "Event: storage.6: Altered node state in cluster state from 'D: Connection error: Closed at other end' to 'I, i 0.100 (read)'\n" +
+ "Event: storage.6: Now reporting state U\n" +
+ "Event: storage.6: Altered node state in cluster state from 'I, i 0.100 (read)' to 'U'\n");
}
@Test
- public void testNodeInitializationStalled() throws Exception {
+ void testNodeInitializationStalled() throws Exception {
// Node should eventually be marked down, and not become initializing next time, but stay down until up
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxTransitionTime.put(NodeType.STORAGE, 5000);
@@ -647,31 +645,31 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.STORAGE, 6),
"Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
- "Event: storage.6: Altered node state in cluster state from 'U' to 'M: Connection error: Closed at other end'\n" +
- "Event: storage.6: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
- "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'D: Connection error: Closed at other end'\n" +
- "Event: storage.6: Now reporting state I, i 0.100 (read)\n" +
- "Event: storage.6: Altered node state in cluster state from 'D: Connection error: Closed at other end' to 'I, i 0.100 (read)'\n" +
- "Event: storage.6: 5001 milliseconds without initialize progress. Marking node down. Premature crash count is now 1.\n" +
- "Event: storage.6: Altered node state in cluster state from 'I, i 0.100 (read)' to 'D'\n" +
- "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
- "Event: storage.6: Now reporting state I, i 0.00 (ls)\n" +
- "Event: storage.6: Now reporting state I, i 0.100 (read)\n" +
- "Event: storage.6: Now reporting state U\n" +
- "Event: storage.6: Altered node state in cluster state from 'D' to 'U'\n");
+ "Event: storage.6: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
+ "Event: storage.6: Altered node state in cluster state from 'U' to 'M: Connection error: Closed at other end'\n" +
+ "Event: storage.6: Exceeded implicit maintenance mode grace period of 5000 milliseconds. Marking node down.\n" +
+ "Event: storage.6: Altered node state in cluster state from 'M: Connection error: Closed at other end' to 'D: Connection error: Closed at other end'\n" +
+ "Event: storage.6: Now reporting state I, i 0.100 (read)\n" +
+ "Event: storage.6: Altered node state in cluster state from 'D: Connection error: Closed at other end' to 'I, i 0.100 (read)'\n" +
+ "Event: storage.6: 5001 milliseconds without initialize progress. Marking node down. Premature crash count is now 1.\n" +
+ "Event: storage.6: Altered node state in cluster state from 'I, i 0.100 (read)' to 'D'\n" +
+ "Event: storage.6: Failed to get node state: D: Connection error: Closed at other end\n" +
+ "Event: storage.6: Now reporting state I, i 0.00 (ls)\n" +
+ "Event: storage.6: Now reporting state I, i 0.100 (read)\n" +
+ "Event: storage.6: Now reporting state U\n" +
+ "Event: storage.6: Altered node state in cluster state from 'D' to 'U'\n");
}
@Test
- public void testBackwardsInitializationProgress() throws Exception {
+ void testBackwardsInitializationProgress() throws Exception {
// Same as stalled. Mark down, keep down until up
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxTransitionTime.put(NodeType.STORAGE, 5000);
options.maxInitProgressTime = 5000;
options.stableStateTimePeriod = 1000000;
- // Set long so we dont time out RPC requests and mark nodes down due to advancing time to get in steady state
+ // Set long so we dont time out RPC requests and mark nodes down due to advancing time to get in steady state
options.nodeStateRequestTimeoutMS = (int) options.stableStateTimePeriod * 2;
initialize(options);
@@ -708,7 +706,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testNodeGoingDownWhileInitializing() throws Exception {
+ void testNodeGoingDownWhileInitializing() throws Exception {
// Same as stalled. Mark down, keep down until up
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxTransitionTime.put(NodeType.STORAGE, 5000);
@@ -766,7 +764,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testContinuousCrashRightAfterInit() throws Exception {
+ void testContinuousCrashRightAfterInit() throws Exception {
startingTest("StateChangeTest::testContinuousCrashRightAfterInit");
// If node does this too many times, take it out of service
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
@@ -820,7 +818,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testClusterStateMinNodes() throws Exception {
+ void testClusterStateMinNodes() throws Exception {
startingTest("StateChangeTest::testClusterStateMinNodes");
// If node does this too many times, take it out of service
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
@@ -875,7 +873,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testClusterStateMinFactor() throws Exception {
+ void testClusterStateMinFactor() throws Exception {
startingTest("StateChangeTest::testClusterStateMinFactor");
// If node does this too many times, take it out of service
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
@@ -942,21 +940,21 @@ public class StateChangeTest extends FleetControllerTest {
for (ClusterState state : states) {
debugString.append(state.toString()).append("\n");
}
- assertEquals(debugString.toString(), expectedMessageCount(node), states.size());
+ assertEquals(expectedMessageCount(node), states.size(), debugString.toString());
}
}
abstract int expectedMessageCount(final DummyVdsNode node);
}
@Test
- public void testNoSystemStateBeforeInitialTimePeriod() throws Exception {
+ void testNoSystemStateBeforeInitialTimePeriod() throws Exception {
startingTest("StateChangeTest::testNoSystemStateBeforeInitialTimePeriod()");
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.minTimeBeforeFirstSystemStateBroadcast = 3 * 60 * 1000;
setUpSystem(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions(), true);
// Leave one node down to avoid sending cluster state due to having seen all node states.
- for (int i=0; i<nodes.size(); ++i) {
+ for (int i = 0; i < nodes.size(); ++i) {
if (i != 3) {
nodes.get(i).connect();
}
@@ -971,7 +969,10 @@ public class StateChangeTest extends FleetControllerTest {
waiter.waitForState("^distributor:10 (\\.\\d+\\.t:\\d+ )*storage:10 (\\.\\d+\\.t:\\d+ )*.1.s:d( \\.\\d+\\.t:\\d+)*", timeoutMS);
waitForCompleteCycle();
new StateMessageChecker(nodes) {
- @Override int expectedMessageCount(final DummyVdsNode node) { return 0; }
+ @Override
+ int expectedMessageCount(final DummyVdsNode node) {
+ return 0;
+ }
};
// Pass time and see that the nodes get state
@@ -982,7 +983,8 @@ public class StateChangeTest extends FleetControllerTest {
fleetController.waitForNodesHavingSystemStateVersionEqualToOrAbove(version, 19, timeoutMS);
new StateMessageChecker(nodes) {
- @Override int expectedMessageCount(final DummyVdsNode node) {
+ @Override
+ int expectedMessageCount(final DummyVdsNode node) {
return node.getNode().equals(new Node(NodeType.STORAGE, 1)) ? 0 : 2;
}
};
@@ -990,7 +992,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testSystemStateSentWhenNodesReplied() throws Exception {
+ void testSystemStateSentWhenNodesReplied() throws Exception {
startingTest("StateChangeTest::testSystemStateSentWhenNodesReplied()");
final FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.minTimeBeforeFirstSystemStateBroadcast = 300 * 60 * 1000;
@@ -1019,12 +1021,15 @@ public class StateChangeTest extends FleetControllerTest {
// The last two versions of the cluster state should be seen (all nodes up,
// zero out timestate)
new StateMessageChecker(nodes) {
- @Override int expectedMessageCount(final DummyVdsNode node) { return 2; }
+ @Override
+ int expectedMessageCount(final DummyVdsNode node) {
+ return 2;
+ }
};
}
@Test
- public void testDontTagFailingSetSystemStateOk() throws Exception {
+ void testDontTagFailingSetSystemStateOk() throws Exception {
startingTest("StateChangeTest::testDontTagFailingSetSystemStateOk()");
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
setUpFleetController(true, options);
@@ -1055,7 +1060,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testAlteringDistributionSplitCount() throws Exception {
+ void testAlteringDistributionSplitCount() throws Exception {
startingTest("StateChangeTest::testAlteringDistributionSplitCount");
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.distributionBits = 17;
@@ -1102,7 +1107,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void testSetAllTimestampsAfterDowntime() throws Exception {
+ void testSetAllTimestampsAfterDowntime() throws Exception {
startingTest("StateChangeTest::testSetAllTimestampsAfterDowntime");
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
setUpFleetController(true, options);
@@ -1135,24 +1140,24 @@ public class StateChangeTest extends FleetControllerTest {
for (ConfiguredNode i : options.nodes) {
Node nodeId = new Node(NodeType.STORAGE, i.index());
long ts = lastState.getNodeState(nodeId).getStartTimestamp();
- assertTrue(nodeId + "\n" + stateHistory + "\nWas " + ts + " should be " + fleetController.getCluster().getNodeInfo(nodeId).getStartTimestamp(), ts > 0);
+ assertTrue(ts > 0, nodeId + "\n" + stateHistory + "\nWas " + ts + " should be " + fleetController.getCluster().getNodeInfo(nodeId).getStartTimestamp());
}
} else {
for (ConfiguredNode i : options.nodes) {
Node nodeId = new Node(NodeType.STORAGE, i.index());
- assertEquals(nodeId.toString(), 0, lastState.getNodeState(nodeId).getStartTimestamp());
+ assertEquals(0, lastState.getNodeState(nodeId).getStartTimestamp(), nodeId.toString());
}
}
for (ConfiguredNode i : options.nodes) {
Node nodeId = new Node(NodeType.DISTRIBUTOR, i.index());
- assertEquals(nodeId.toString(), 0, lastState.getNodeState(nodeId).getStartTimestamp());
+ assertEquals(0, lastState.getNodeState(nodeId).getStartTimestamp(), nodeId.toString());
}
}
}
@Test
- public void consolidated_cluster_state_reflects_node_changes_when_cluster_is_down() throws Exception {
+ void consolidated_cluster_state_reflects_node_changes_when_cluster_is_down() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxTransitionTime.put(NodeType.STORAGE, 0);
options.minStorageNodesUp = 10;
@@ -1166,7 +1171,7 @@ public class StateChangeTest extends FleetControllerTest {
ctrl.tick();
assertThat(ctrl.consolidatedClusterState().toString(),
- equalTo("version:4 cluster:d distributor:10 storage:10 .2.s:d"));
+ equalTo("version:4 cluster:d distributor:10 storage:10 .2.s:d"));
// After this point, any further node changes while the cluster is still down won't be published.
// This is because cluster state similarity checks are short-circuited if both are Down, as no other parts
@@ -1179,14 +1184,14 @@ public class StateChangeTest extends FleetControllerTest {
// NOTE: _same_ version, different node state content. Overall cluster down-state is still the same.
assertThat(ctrl.consolidatedClusterState().toString(),
- equalTo("version:4 cluster:d distributor:10 storage:10 .2.s:d .5.s:d"));
+ equalTo("version:4 cluster:d distributor:10 storage:10 .2.s:d .5.s:d"));
}
// Related to the above test, watchTimer invocations must receive the _current_ state and not the
// published state. Failure to ensure this would cause events to be fired non-stop, as the effect
// of previous timer invocations (with subsequent state generation) would not be visible.
@Test
- public void timer_events_during_cluster_down_observe_most_recent_node_changes() throws Exception {
+ void timer_events_during_cluster_down_observe_most_recent_node_changes() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
options.maxTransitionTime.put(NodeType.STORAGE, 1000);
options.minStorageNodesUp = 10;
@@ -1210,10 +1215,10 @@ public class StateChangeTest extends FleetControllerTest {
verifyNodeEvents(new Node(NodeType.STORAGE, 2),
"Event: storage.2: Now reporting state U\n" +
- "Event: storage.2: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
- "Event: storage.2: Failed to get node state: D: foo\n" +
- "Event: storage.2: Stopped or possibly crashed after 500 ms, which is before stable state time period. Premature crash count is now 1.\n" +
- "Event: storage.2: Altered node state in cluster state from 'U' to 'M: foo'\n");
+ "Event: storage.2: Altered node state in cluster state from 'D: Node not seen in slobrok.' to 'U'\n" +
+ "Event: storage.2: Failed to get node state: D: foo\n" +
+ "Event: storage.2: Stopped or possibly crashed after 500 ms, which is before stable state time period. Premature crash count is now 1.\n" +
+ "Event: storage.2: Altered node state in cluster state from 'U' to 'M: foo'\n");
// Note: even though max transition time has passed, events are now emitted only on cluster state
// publish edges. These are currently suppressed when the cluster state is down, as all cluster down
// states are considered similar to other cluster down states. This is not necessarily optimal, but
@@ -1221,7 +1226,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void do_not_emit_multiple_events_when_node_state_does_not_match_versioned_state() throws Exception {
+ void do_not_emit_multiple_events_when_node_state_does_not_match_versioned_state() throws Exception {
FleetControllerOptions options = defaultOptions("mycluster", createNodes(10));
initialize(options);
@@ -1418,7 +1423,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void synchronous_remote_task_is_completed_when_state_is_acked_by_cluster() throws Exception {
+ void synchronous_remote_task_is_completed_when_state_is_acked_by_cluster() throws Exception {
RemoteTaskFixture fixture = createDefaultFixture();
MockTask task = fixture.scheduleVersionDependentTaskWithSideEffects();
@@ -1437,7 +1442,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void failing_task_is_immediately_completed() throws Exception {
+ void failing_task_is_immediately_completed() throws Exception {
RemoteTaskFixture fixture = createDefaultFixture();
MockTask task = fixture.scheduleFailingVersionDependentTaskWithSideEffects();
@@ -1446,7 +1451,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void no_op_synchronous_remote_task_can_complete_immediately_if_current_state_already_acked() throws Exception {
+ void no_op_synchronous_remote_task_can_complete_immediately_if_current_state_already_acked() throws Exception {
RemoteTaskFixture fixture = createFixtureWith(optionsWithZeroTransitionTime());
fixture.markStorageNodeDown(0);
MockTask task = fixture.scheduleNoOpVersionDependentTask(); // Tries to set node 0 into Down; already in that state
@@ -1459,7 +1464,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void no_op_synchronous_remote_task_waits_until_current_state_is_acked() throws Exception {
+ void no_op_synchronous_remote_task_waits_until_current_state_is_acked() throws Exception {
RemoteTaskFixture fixture = createFixtureWith(optionsWithZeroTransitionTime());
communicator.setShouldDeferDistributorClusterStateAcks(true);
@@ -1483,7 +1488,7 @@ public class StateChangeTest extends FleetControllerTest {
// tasks running in such a context as if they were no-ops. I.e. we only require
// the cluster down-state to have been published.
@Test
- public void immediately_complete_sync_remote_task_when_cluster_is_down() throws Exception {
+ void immediately_complete_sync_remote_task_when_cluster_is_down() throws Exception {
RemoteTaskFixture fixture = createFixtureWith(optionsAllowingZeroNodesDown());
// Controller options require 10/10 nodes up, so take one down to trigger a cluster Down edge.
fixture.markStorageNodeDown(1);
@@ -1497,7 +1502,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void multiple_tasks_may_be_scheduled_and_answered_at_the_same_time() throws Exception {
+ void multiple_tasks_may_be_scheduled_and_answered_at_the_same_time() throws Exception {
RemoteTaskFixture fixture = createDefaultFixture();
communicator.setShouldDeferDistributorClusterStateAcks(true);
@@ -1515,7 +1520,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void synchronous_task_immediately_failed_when_leadership_lost() throws Exception {
+ void synchronous_task_immediately_failed_when_leadership_lost() throws Exception {
FleetControllerOptions options = optionsWithZeroTransitionTime();
options.fleetControllerCount = 3;
RemoteTaskFixture fixture = createFixtureWith(options);
@@ -1540,7 +1545,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void cluster_state_ack_is_not_dependent_on_state_send_grace_period() throws Exception {
+ void cluster_state_ack_is_not_dependent_on_state_send_grace_period() throws Exception {
FleetControllerOptions options = defaultOptions();
options.minTimeBetweenNewSystemStates = 10_000;
RemoteTaskFixture fixture = createFixtureWith(options);
@@ -1560,7 +1565,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void synchronous_task_immediately_answered_when_not_leader() throws Exception {
+ void synchronous_task_immediately_answered_when_not_leader() throws Exception {
FleetControllerOptions options = optionsWithZeroTransitionTime();
options.fleetControllerCount = 3;
RemoteTaskFixture fixture = createFixtureWith(options);
@@ -1575,7 +1580,7 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void task_not_completed_within_deadline_is_failed_with_deadline_exceeded_error() throws Exception {
+ void task_not_completed_within_deadline_is_failed_with_deadline_exceeded_error() throws Exception {
FleetControllerOptions options = defaultOptions();
options.setMaxDeferredTaskVersionWaitTime(Duration.ofSeconds(60));
RemoteTaskFixture fixture = createFixtureWith(options);
@@ -1624,14 +1629,14 @@ public class StateChangeTest extends FleetControllerTest {
}
@Test
- public void task_not_completed_within_deadline_lists_nodes_not_converged_in_error_message() throws Exception {
+ void task_not_completed_within_deadline_lists_nodes_not_converged_in_error_message() throws Exception {
doTestTaskDeadlineExceeded(false, "the following nodes have not converged to " +
"at least version 4: distributor.0, distributor.1, distributor.2, distributor.3, " +
"distributor.4, distributor.5, distributor.6, distributor.7, distributor.8, distributor.9");
}
@Test
- public void task_not_completed_within_deadline_with_deferred_activation_checks_activation_version() throws Exception {
+ void task_not_completed_within_deadline_with_deferred_activation_checks_activation_version() throws Exception {
doTestTaskDeadlineExceeded(true, "the following nodes have not converged to " +
"at least version 4: distributor.0, distributor.1, distributor.2, distributor.3, " +
"distributor.4, distributor.5, distributor.6, distributor.7, distributor.8, distributor.9 " +
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java
index 041f4e4052d..892aefbb865 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java
@@ -2,12 +2,12 @@
package com.yahoo.vespa.clustercontroller.core;
import java.util.logging.Level;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class StateGatherTest extends FleetControllerTest {
@@ -24,7 +24,7 @@ public class StateGatherTest extends FleetControllerTest {
}
@Test
- public void testAlwaysHavePendingGetNodeStateRequestTowardsNodes() throws Exception {
+ void testAlwaysHavePendingGetNodeStateRequestTowardsNodes() throws Exception {
Logger.getLogger(NodeStateGatherer.class.getName()).setLevel(Level.FINEST);
startingTest("StateGatherTest::testOverlappingGetNodeStateRequests");
FleetControllerOptions options = defaultOptions("mycluster");
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
index 2361a5cefd8..0e3c3c6d4b3 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
@@ -7,13 +7,11 @@ import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-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.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -40,7 +38,7 @@ public class StateVersionTrackerTest {
}
@Test
- public void version_is_incremented_when_new_state_is_applied() {
+ void version_is_incremented_when_new_state_is_applied() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(100);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2"), 123);
@@ -49,33 +47,33 @@ public class StateVersionTrackerTest {
}
@Test
- public void version_is_1_upon_construction() {
+ void version_is_1_upon_construction() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
assertEquals(1, versionTracker.getCurrentVersion());
}
@Test
- public void set_current_version_caps_lowest_version_to_1() {
+ void set_current_version_caps_lowest_version_to_1() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(0);
assertEquals(1, versionTracker.getCurrentVersion());
}
@Test
- public void new_version_from_zk_predicate_initially_false() {
+ void new_version_from_zk_predicate_initially_false() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
assertFalse(versionTracker.hasReceivedNewVersionFromZooKeeper());
}
@Test
- public void new_version_from_zk_predicate_true_after_setting_zk_version() {
+ void new_version_from_zk_predicate_true_after_setting_zk_version() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(5);
assertTrue(versionTracker.hasReceivedNewVersionFromZooKeeper());
}
@Test
- public void new_version_from_zk_predicate_false_after_applying_higher_version() {
+ void new_version_from_zk_predicate_false_after_applying_higher_version() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(5);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2"), 123);
@@ -83,14 +81,14 @@ public class StateVersionTrackerTest {
}
@Test
- public void exposed_states_are_empty_upon_construction() {
+ void exposed_states_are_empty_upon_construction() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
assertTrue(versionTracker.getVersionedClusterState().toString().isEmpty());
assertTrue(versionTracker.getAnnotatedVersionedClusterState().getClusterState().toString().isEmpty());
}
@Test
- public void diff_from_initial_state_implies_changed_state() {
+ void diff_from_initial_state_implies_changed_state() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.updateLatestCandidateStateBundle(stateBundleWithoutAnnotations("cluster:d"));
assertTrue(versionTracker.candidateChangedEnoughFromCurrentToWarrantPublish());
@@ -104,48 +102,48 @@ public class StateVersionTrackerTest {
}
@Test
- public void version_mismatch_not_counted_as_changed_state() {
+ void version_mismatch_not_counted_as_changed_state() {
assertFalse(stateChangedBetween("distributor:2 storage:2", "distributor:2 storage:2"));
}
@Test
- public void different_distributor_node_count_implies_changed_state() {
+ void different_distributor_node_count_implies_changed_state() {
assertTrue(stateChangedBetween("distributor:2 storage:2", "distributor:3 storage:2"));
assertTrue(stateChangedBetween("distributor:3 storage:2", "distributor:2 storage:2"));
}
@Test
- public void different_storage_node_count_implies_changed_state() {
+ void different_storage_node_count_implies_changed_state() {
assertTrue(stateChangedBetween("distributor:2 storage:2", "distributor:2 storage:3"));
assertTrue(stateChangedBetween("distributor:2 storage:3", "distributor:2 storage:2"));
}
@Test
- public void different_distributor_node_state_implies_changed_state() {
+ void different_distributor_node_state_implies_changed_state() {
assertTrue(stateChangedBetween("distributor:2 storage:2", "distributor:2 .0.s:d storage:2"));
assertTrue(stateChangedBetween("distributor:2 .0.s:d storage:2", "distributor:2 storage:2"));
}
@Test
- public void different_storage_node_state_implies_changed_state() {
+ void different_storage_node_state_implies_changed_state() {
assertTrue(stateChangedBetween("distributor:2 storage:2", "distributor:2 storage:2 .0.s:d"));
assertTrue(stateChangedBetween("distributor:2 storage:2 .0.s:d", "distributor:2 storage:2"));
}
@Test
- public void init_progress_change_not_counted_as_changed_state() {
+ void init_progress_change_not_counted_as_changed_state() {
assertFalse(stateChangedBetween("distributor:2 storage:2 .0.s:i .0.i:0.5",
- "distributor:2 storage:2 .0.s:i .0.i:0.6"));
+ "distributor:2 storage:2 .0.s:i .0.i:0.6"));
}
@Test
- public void lowest_observed_distribution_bit_is_initially_16() {
+ void lowest_observed_distribution_bit_is_initially_16() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
assertEquals(16, versionTracker.getLowestObservedDistributionBits());
}
@Test
- public void lowest_observed_distribution_bit_is_tracked_across_states() {
+ void lowest_observed_distribution_bit_is_tracked_across_states() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
updateAndPromote(versionTracker, stateWithoutAnnotations("bits:15 distributor:2 storage:2"), 100);
assertEquals(15, versionTracker.getLowestObservedDistributionBits());
@@ -161,7 +159,7 @@ public class StateVersionTrackerTest {
// min used bits. The former is derived from the latter, but the latter is not visible in the
// published state (but _is_ visible in the internal ClusterState structures).
@Test
- public void per_node_min_bits_changes_are_not_considered_different() {
+ void per_node_min_bits_changes_are_not_considered_different() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
final AnnotatedClusterState stateWithMinBits = stateWithoutAnnotations("distributor:2 storage:2");
stateWithMinBits.getClusterState().setNodeState(
@@ -173,7 +171,7 @@ public class StateVersionTrackerTest {
}
@Test
- public void state_history_is_initially_empty() {
+ void state_history_is_initially_empty() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
assertTrue(versionTracker.getClusterStateHistory().isEmpty());
}
@@ -188,9 +186,9 @@ public class StateVersionTrackerTest {
}
@Test
- public void applying_state_adds_to_cluster_state_history() {
+ void applying_state_adds_to_cluster_state_history() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
- updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2") ,100);
+ updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2"), 100);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:3 storage:3"), 200);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:4 storage:4"), 300);
@@ -204,11 +202,11 @@ public class StateVersionTrackerTest {
}
@Test
- public void old_states_pruned_when_state_history_limit_reached() {
+ void old_states_pruned_when_state_history_limit_reached() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setMaxHistoryEntryCount(2);
- updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2") ,100);
+ updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2"), 100);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:3 storage:3"), 200);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:4 storage:4"), 300);
@@ -227,7 +225,7 @@ public class StateVersionTrackerTest {
}
@Test
- public void can_get_latest_non_published_candidate_state() {
+ void can_get_latest_non_published_candidate_state() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
AnnotatedClusterState candidate = stateWithoutAnnotations("distributor:2 storage:2");
@@ -258,7 +256,7 @@ public class StateVersionTrackerTest {
}
@Test
- public void version_change_check_takes_derived_states_into_account() {
+ void version_change_check_takes_derived_states_into_account() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.updateLatestCandidateStateBundle(baselineBundle(false));
versionTracker.promoteCandidateToVersionedState(1234);
@@ -273,7 +271,7 @@ public class StateVersionTrackerTest {
}
@Test
- public void buckets_pending_state_is_tracked_between_cluster_states() {
+ void buckets_pending_state_is_tracked_between_cluster_states() {
final StateVersionTracker tracker = createWithMockedMetrics();
final NodeInfo distributorNode = mock(DistributorNodeInfo.class);
when(distributorNode.isDistributor()).thenReturn(true);
@@ -307,7 +305,7 @@ public class StateVersionTrackerTest {
}
@Test
- public void setting_zookeeper_retrieved_bundle_sets_current_versioned_state_and_resets_candidate_state() {
+ void setting_zookeeper_retrieved_bundle_sets_current_versioned_state_and_resets_candidate_state() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(100);
versionTracker.updateLatestCandidateStateBundle(
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java
index 1832f1132ac..0a193766df3 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java
@@ -8,13 +8,13 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.listeners.SlobrokListener;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeListener;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.util.stream.Stream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -85,7 +85,7 @@ public class SystemStateBroadcasterTest {
}
@Test
- public void always_publish_baseline_cluster_state() {
+ void always_publish_baseline_cluster_state() {
Fixture f = new Fixture();
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("version:3 distributor:2 storage:2");
ClusterFixture cf = ClusterFixture.forFlatCluster(2).bringEntireClusterUp().assignDummyRpcAddresses();
@@ -95,7 +95,7 @@ public class SystemStateBroadcasterTest {
}
@Test
- public void non_observed_startup_timestamps_are_published_per_node_for_baseline_state() {
+ void non_observed_startup_timestamps_are_published_per_node_for_baseline_state() {
Fixture f = new Fixture();
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("version:3 distributor:2 storage:2");
ClusterFixture cf = ClusterFixture.forFlatCluster(2).bringEntireClusterUp().assignDummyRpcAddresses();
@@ -112,7 +112,7 @@ public class SystemStateBroadcasterTest {
}
@Test
- public void bucket_space_states_are_published_verbatim_when_no_additional_timestamps_needed() {
+ void bucket_space_states_are_published_verbatim_when_no_additional_timestamps_needed() {
Fixture f = new Fixture();
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("version:3 distributor:2 storage:2",
StateMapping.of("default", "version:3 distributor:2 storage:2 .0.s:d"),
@@ -125,7 +125,7 @@ public class SystemStateBroadcasterTest {
}
@Test
- public void non_observed_startup_timestamps_are_published_per_bucket_space_state() {
+ void non_observed_startup_timestamps_are_published_per_bucket_space_state() {
Fixture f = new Fixture();
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("version:3 distributor:2 storage:2",
StateMapping.of("default", "version:3 distributor:2 storage:2 .0.s:d"),
@@ -146,7 +146,7 @@ public class SystemStateBroadcasterTest {
}
@Test
- public void state_not_broadcast_if_version_not_tagged_as_written_to_zookeeper() {
+ void state_not_broadcast_if_version_not_tagged_as_written_to_zookeeper() {
Fixture f = new Fixture();
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("version:100 distributor:2 storage:2");
ClusterFixture cf = ClusterFixture.forFlatCluster(2).bringEntireClusterUp().assignDummyRpcAddresses();
@@ -159,7 +159,7 @@ public class SystemStateBroadcasterTest {
}
@Test
- public void state_is_broadcast_if_version_is_tagged_as_written_to_zookeeper() {
+ void state_is_broadcast_if_version_is_tagged_as_written_to_zookeeper() {
Fixture f = new Fixture();
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("version:100 distributor:2 storage:2");
ClusterFixture cf = ClusterFixture.forFlatCluster(2).bringEntireClusterUp().assignDummyRpcAddresses();
@@ -262,9 +262,10 @@ public class SystemStateBroadcasterTest {
}
}
+ // Type erasure of Waiter in mocked argument capture
@Test
- @SuppressWarnings("unchecked") // Type erasure of Waiter in mocked argument capture
- public void activation_not_sent_before_all_distributors_have_acked_state_bundle() {
+ @SuppressWarnings("unchecked")
+ void activation_not_sent_before_all_distributors_have_acked_state_bundle() {
var f = StateActivationFixture.withTwoPhaseEnabled();
var cf = f.cf;
@@ -292,9 +293,10 @@ public class SystemStateBroadcasterTest {
assertNull(f.broadcaster.getLastClusterStateBundleConverged());
}
+ // Type erasure of Waiter in mocked argument capture
@Test
- @SuppressWarnings("unchecked") // Type erasure of Waiter in mocked argument capture
- public void state_bundle_not_considered_converged_until_activation_acked_by_all_distributors() {
+ @SuppressWarnings("unchecked")
+ void state_bundle_not_considered_converged_until_activation_acked_by_all_distributors() {
var f = StateActivationFixture.withTwoPhaseEnabled();
var cf = f.cf;
@@ -309,22 +311,23 @@ public class SystemStateBroadcasterTest {
});
respondToActivateClusterStateVersion(cf.cluster.getNodeInfo(Node.ofDistributor(0)),
- f.stateBundle, d0ActivateWaiter.getValue());
+ f.stateBundle, d0ActivateWaiter.getValue());
f.simulateBroadcastTick(cf, 123);
assertNull(f.broadcaster.getLastClusterStateBundleConverged()); // Not yet converged
respondToActivateClusterStateVersion(cf.cluster.getNodeInfo(Node.ofDistributor(1)),
- f.stateBundle, d1ActivateWaiter.getValue());
+ f.stateBundle, d1ActivateWaiter.getValue());
f.simulateBroadcastTick(cf, 123);
// Finally, all distributors have ACKed the version! State is marked as converged.
assertEquals(f.stateBundle, f.broadcaster.getLastClusterStateBundleConverged());
}
+ // Type erasure of Waiter in mocked argument capture
@Test
- @SuppressWarnings("unchecked") // Type erasure of Waiter in mocked argument capture
- public void activation_not_sent_if_deferred_activation_is_disabled_in_state_bundle() {
+ @SuppressWarnings("unchecked")
+ void activation_not_sent_if_deferred_activation_is_disabled_in_state_bundle() {
var f = StateActivationFixture.withTwoPhaseDisabled();
var cf = f.cf;
@@ -339,9 +342,10 @@ public class SystemStateBroadcasterTest {
});
}
+ // Type erasure of Waiter in mocked argument capture
@Test
- @SuppressWarnings("unchecked") // Type erasure of Waiter in mocked argument capture
- public void activation_convergence_considers_actual_version_returned_from_node() {
+ @SuppressWarnings("unchecked")
+ void activation_convergence_considers_actual_version_returned_from_node() {
var f = StateActivationFixture.withTwoPhaseEnabled();
var cf = f.cf;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraintTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraintTest.java
index 6257a10064a..5471a6ff4be 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraintTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraintTest.java
@@ -2,10 +2,10 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.ClusterState;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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;
public class UpEdgeMaintenanceTransitionConstraintTest {
@@ -19,27 +19,27 @@ public class UpEdgeMaintenanceTransitionConstraintTest {
}
@Test
- public void transition_allowed_when_previous_state_is_down() {
+ void transition_allowed_when_previous_state_is_down() {
assertTrue(nodeMayTransitionToMaintenanceInState(1, "distributor:5 storage:5 .1.s:d"));
}
@Test
- public void transition_allowed_when_previous_state_is_maintenance() {
+ void transition_allowed_when_previous_state_is_maintenance() {
assertTrue(nodeMayTransitionToMaintenanceInState(1, "distributor:5 storage:5 .1.s:m"));
}
@Test
- public void transition_not_allowed_when_previous_state_is_up() {
+ void transition_not_allowed_when_previous_state_is_up() {
assertFalse(nodeMayTransitionToMaintenanceInState(0, "distributor:5 storage:5"));
}
@Test
- public void transition_not_allowed_when_previous_state_is_initializing() {
+ void transition_not_allowed_when_previous_state_is_initializing() {
assertFalse(nodeMayTransitionToMaintenanceInState(0, "distributor:5 storage:5 .0.s:i"));
}
@Test
- public void transition_not_allowed_when_previous_state_is_retired() {
+ void transition_not_allowed_when_previous_state_is_retired() {
assertFalse(nodeMayTransitionToMaintenanceInState(0, "distributor:5 storage:5 .0.s:r"));
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java
index a58f75dba02..7bbae78dbab 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java
@@ -2,13 +2,14 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.State;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class WantedStateTest extends FleetControllerTest {
@Test
- public void testSettingStorageNodeMaintenanceAndBack() throws Exception {
+ void testSettingStorageNodeMaintenanceAndBack() throws Exception {
startingTest("WantedStateTest::testSettingStorageNodeMaintenanceAndBack()");
setUpFleetController(true, defaultOptions("mycluster"));
setUpVdsNodes(true, new DummyVdsNodeOptions());
@@ -22,7 +23,7 @@ public class WantedStateTest extends FleetControllerTest {
}
@Test
- public void testOverridingWantedStateOtherReason() throws Exception {
+ void testOverridingWantedStateOtherReason() throws Exception {
startingTest("WantedStateTest::testOverridingWantedStateOtherReason()");
setUpFleetController(true, defaultOptions("mycluster"));
setUpVdsNodes(true, new DummyVdsNodeOptions());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
index 1ce7586adea..79c03a67698 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
@@ -4,22 +4,16 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vespa.clustercontroller.core.database.CasWriteFailed;
import com.yahoo.vespa.clustercontroller.core.database.Database;
import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabase;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.time.Duration;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
public class ZooKeeperDatabaseTest {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private static class Fixture implements AutoCloseable {
final ZooKeeperTestServer zkServer;
ClusterFixture clusterFixture;
@@ -58,7 +52,7 @@ public class ZooKeeperDatabaseTest {
}
@Test
- public void can_store_and_load_cluster_state_bundle_from_database() throws Exception {
+ void can_store_and_load_cluster_state_bundle_from_database() throws Exception {
try (Fixture f = new Fixture()) {
f.createDatabase();
f.db().retrieveLastPublishedStateBundle(); // Must be called once prior to prime last known znode version
@@ -77,27 +71,29 @@ public class ZooKeeperDatabaseTest {
}
@Test
- public void storing_cluster_state_bundle_with_mismatching_expected_znode_version_throws_exception() throws Exception {
- expectedException.expect(CasWriteFailed.class);
- expectedException.expectMessage("version mismatch in cluster state bundle znode (expected -2)");
- try (Fixture f = new Fixture()) {
- f.createDatabase();
- f.db().storeLastPublishedStateBundle(dummyBundle());
- }
+ void storing_cluster_state_bundle_with_mismatching_expected_znode_version_throws_exception() throws Exception {
+ Throwable exception = assertThrows(CasWriteFailed.class, () -> {
+ try (Fixture f = new Fixture()) {
+ f.createDatabase();
+ f.db().storeLastPublishedStateBundle(dummyBundle());
+ }
+ });
+ assertTrue(exception.getMessage().contains("version mismatch in cluster state bundle znode (expected -2)"));
}
@Test
- public void storing_cluster_state_version_with_mismatching_expected_znode_version_throws_exception() throws Exception {
- expectedException.expect(CasWriteFailed.class);
- expectedException.expectMessage("version mismatch in cluster state version znode (expected -2)");
- try (Fixture f = new Fixture()) {
- f.createDatabase();
- f.db().storeLatestSystemStateVersion(12345);
- }
+ void storing_cluster_state_version_with_mismatching_expected_znode_version_throws_exception() throws Exception {
+ Throwable exception = assertThrows(CasWriteFailed.class, () -> {
+ try (Fixture f = new Fixture()) {
+ f.createDatabase();
+ f.db().storeLatestSystemStateVersion(12345);
+ }
+ });
+ assertTrue(exception.getMessage().contains("version mismatch in cluster state version znode (expected -2)"));
}
@Test
- public void empty_state_bundle_is_returned_if_no_bundle_already_stored_in_database() throws Exception {
+ void empty_state_bundle_is_returned_if_no_bundle_already_stored_in_database() throws Exception {
try (Fixture f = new Fixture()) {
f.createDatabase();
ClusterStateBundle bundleReceived = f.db().retrieveLastPublishedStateBundle();
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
index b5ad82b6b0c..3c9fd069e14 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.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.clustercontroller.core.hostinfo;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -13,10 +13,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class HostInfoTest {
@@ -29,7 +26,7 @@ public class HostInfoTest {
}
@Test
- public void testEmptyJson() {
+ void testEmptyJson() {
HostInfo hostInfo = HostInfo.createHostInfo("{}");
assertNull(hostInfo.getVtag().getVersionOrNull());
assertTrue(hostInfo.getDistributor().getStorageNodes().isEmpty());
@@ -39,13 +36,13 @@ public class HostInfoTest {
}
@Test
- public void testExtendedJson() throws IOException {
+ void testExtendedJson() throws IOException {
HostInfo hostInfo = HostInfo.createHostInfo(readDataFile("host_info.json"));
assertEquals("5.32.76", hostInfo.getVtag().getVersionOrNull());
}
@Test
- public void testFullSet() throws IOException {
+ void testFullSet() throws IOException {
HostInfo hostInfo = HostInfo.createHostInfo(readDataFile("host_info.json"));
List<StorageNode> storageNodeList = hostInfo.getDistributor().getStorageNodes();
assertEquals(2, storageNodeList.size());
@@ -59,8 +56,8 @@ public class HostInfoTest {
assertEquals(123, hostInfo.getClusterStateVersionOrNull().intValue());
assertEquals(Optional.of(129L), hostInfo.getMetrics()
- .getValueAt("vds.datastored.bucket_space.buckets_total", Map.of("bucketSpace", "default"))
- .map(Metrics.Value::getLast));
+ .getValueAt("vds.datastored.bucket_space.buckets_total", Map.of("bucketSpace", "default"))
+ .map(Metrics.Value::getLast));
assertEquals(Optional.of(0L),
hostInfo.getMetrics()
.getValueAt("vds.datastored.bucket_space.buckets_total", Map.of("bucketSpace", "global"))
@@ -75,7 +72,7 @@ public class HostInfoTest {
}
@Test
- public void testSpeed() throws Exception {
+ void testSpeed() throws Exception {
String json = readDataFile("slow_host_info.json");
long start = 0;
@@ -92,7 +89,7 @@ public class HostInfoTest {
}
@Test
- public void testSharedFile() throws Exception {
+ void testSharedFile() throws Exception {
String json = readDataFile("distributor.json");
HostInfo hostInfo = HostInfo.createHostInfo(json);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/StorageNodeStatsBridgeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/StorageNodeStatsBridgeTest.java
index cb99dfe38e3..0eb25ab5cd4 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/StorageNodeStatsBridgeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/StorageNodeStatsBridgeTest.java
@@ -3,7 +3,7 @@ package com.yahoo.vespa.clustercontroller.core.hostinfo;
import com.yahoo.vespa.clustercontroller.core.ContentNodeStats;
import com.yahoo.vespa.clustercontroller.core.ContentClusterStats;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -14,7 +14,7 @@ import java.util.Iterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author hakonhall
@@ -29,7 +29,7 @@ public class StorageNodeStatsBridgeTest {
}
@Test
- public void testContentNodeStats() throws IOException {
+ void testContentNodeStats() throws IOException {
String data = getJsonString();
HostInfo hostInfo = HostInfo.createHostInfo(data);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java
index 84116674afa..8e49703c94b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java
@@ -2,67 +2,68 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ClusterListTest extends StateRestApiTest {
@Test
- public void testClusterList() throws Exception {
+ void testClusterList() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("", 0));
String expected =
"{\"cluster\": {\n" +
- " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
- " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
- "}}";
+ " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
+ " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveClusterList() throws Exception {
+ void testRecursiveClusterList() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("", 1));
String expected =
"{\"cluster\": {\n" +
- " \"books\": {\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
- " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:4 storage:4\",\n" +
- " \"bucket-spaces\": [\n" +
- " {\n" +
- " \"name\": \"default\",\n" +
- " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"global\",\n" +
- " \"state\": \"distributor:4 storage:4\"\n" +
- " }\n" +
- " ]\n" +
- " }}\n" +
- " },\n" +
- " \"music\": {\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\"},\n" +
- " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\"}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
- " \"bucket-spaces\": []\n" +
- " }}\n" +
- " }\n" +
- "}}";
+ " \"books\": {\n" +
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
+ " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:4 storage:4\",\n" +
+ " \"bucket-spaces\": [\n" +
+ " {\n" +
+ " \"name\": \"default\",\n" +
+ " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"global\",\n" +
+ " \"state\": \"distributor:4 storage:4\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }}\n" +
+ " },\n" +
+ " \"music\": {\n" +
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\"},\n" +
+ " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\"}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
+ " \"bucket-spaces\": []\n" +
+ " }}\n" +
+ " }\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java
index 2efb731c88c..ab9c92a6d9e 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java
@@ -2,74 +2,74 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ClusterTest extends StateRestApiTest {
@Test
- public void testCluster() throws Exception {
+ void testCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("books", 0));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
- " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:4 storage:4\",\n" +
- " \"bucket-spaces\": [\n" +
- " {\n" +
- " \"name\": \"default\",\n" +
- " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"global\",\n" +
- " \"state\": \"distributor:4 storage:4\"\n" +
- " }\n" +
- " ]\n" +
- " }}\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
+ " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:4 storage:4\",\n" +
+ " \"bucket-spaces\": [\n" +
+ " {\n" +
+ " \"name\": \"default\",\n" +
+ " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"global\",\n" +
+ " \"state\": \"distributor:4 storage:4\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }}\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveCluster() throws Exception {
+ void testRecursiveCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music", 1));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\"},\n" +
- " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/2\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/3\"},\n" +
- " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/5\"},\n" +
- " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/7\"}\n" +
- " }},\n" +
- " \"distributor\": {\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
- " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
- " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
- " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
- " }}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
- " \"bucket-spaces\": []\n" +
- " }}\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"node\": {\n" +
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\"},\n" +
+ " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/2\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/3\"},\n" +
+ " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/5\"},\n" +
+ " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/7\"}\n" +
+ " }},\n" +
+ " \"distributor\": {\"node\": {\n" +
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
+ " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
+ " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
+ " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
+ " }}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
+ " \"bucket-spaces\": []\n" +
+ " }}\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java
index 38fab2f5c54..52c46215e50 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java
@@ -8,99 +8,99 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.ContentCluster;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class NodeTest extends StateRestApiTest {
@Test
- public void testDistributor() throws Exception {
+ void testDistributor() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/distributor/1", 0));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testStorage() throws Exception {
+ void testStorage() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 0));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " },\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveNode() throws Exception {
+ void testRecursiveNode() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 1));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " },\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testNodeNotSeenInSlobrok() throws Exception {
+ void testNodeNotSeenInSlobrok() throws Exception {
setUp(true);
ContentCluster old = music.context.cluster;
music.context.cluster = new ContentCluster(old.getName(), old.getConfiguredNodes().values(), old.getDistribution());
@@ -110,22 +110,22 @@ public class NodeTest extends StateRestApiTest {
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 0));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"Not seen\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"Node not seen in slobrok.\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"Not seen\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"Node not seen in slobrok.\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
index d85cf95defc..15aeded2d37 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
@@ -5,19 +5,17 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.OtherMasterEx
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
public class NotMasterTest extends StateRestApiTest {
@Test
- public void testUnknownMaster() throws Exception {
+ void testUnknownMaster() throws Exception {
setUp(true);
music.fleetControllerMaster = null;
- // Non-recursive cluster list works, as it doesn't touches into fleetcontrollers
+ // Non-recursive cluster list works, as it doesn't touches into fleetcontrollers
{
UnitResponse response = restAPI.getState(new StateRequest("", 0));
String expected =
@@ -27,49 +25,49 @@ public class NotMasterTest extends StateRestApiTest {
"}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
- // Recursive cluster list does not work
- try{
+ // Recursive cluster list does not work
+ try {
restAPI.getState(new StateRequest("", 1));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- // Other requests does not work either
- try{
+ // Other requests does not work either
+ try {
restAPI.getState(new StateRequest("music", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1/0", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1")
- .setNewState("user", "down", "test"));
+ .setNewState("user", "down", "test"));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
}
@Test
- public void testKnownOtherMaster() throws Exception {
+ void testKnownOtherMaster() throws Exception {
setUp(true);
ccSockets.put(1, new ClusterControllerStateRestAPI.Socket("otherhost", getDefaults().vespaWebServicePort()));
music.fleetControllerMaster = 1;
@@ -78,59 +76,59 @@ public class NotMasterTest extends StateRestApiTest {
UnitResponse response = restAPI.getState(new StateRequest("", 0));
String expected =
"{\"cluster\": {\n" +
- " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
- " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
- "}}";
+ " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
+ " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
// Recursive cluster list does not work
- try{
+ try {
restAPI.getState(new StateRequest("", 1));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
// Other requests does not work either
- try{
+ try {
restAPI.getState(new StateRequest("music", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1/0", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1")
.setNewState("user", "down", "test"));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
index ec60adf16d3..65acea02d34 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
@@ -3,47 +3,47 @@ package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class PartitionTest extends StateRestApiTest {
@Test
- public void testPartition() throws Exception {
+ void testPartition() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1/0", 0));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveCluster() throws Exception {
+ void testRecursiveCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1/0", 1));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
index ec8e7855db6..adbf24bc4d1 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
@@ -2,22 +2,21 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
public class RequestTest {
@Test
- public void testGetResultBeforeCompletion() {
+ void testGetResultBeforeCompletion() {
Request<String> r = new Request<>(Request.MasterState.MUST_BE_MASTER) {
@Override
public String calculateResult(Context context) {
return "foo";
}
};
- try{
+ try {
r.getResult();
fail();
} catch (InternalFailure e) {
@@ -25,7 +24,7 @@ public class RequestTest {
fail();
}
r.notifyCompleted();
- try{
+ try {
r.getResult();
fail();
} catch (InternalFailure e) {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
index f2aa00ea13e..2e5b610a039 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
@@ -2,119 +2,119 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServiceTest extends StateRestApiTest {
@Test
- public void testService() throws Exception {
+ void testService() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/distributor", 0));
String expected =
"{\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
- " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
- " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
- " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
- "}}";
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
+ " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
+ " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
+ " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveCluster() throws Exception {
+ void testRecursiveCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/distributor", 1));
String expected =
"{\"node\": {\n" +
- " \"1\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"2\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g1\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"Node not seen in slobrok.\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"3\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"5\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"7\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}}";
+ " \"1\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"2\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g1\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"Node not seen in slobrok.\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"3\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"5\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"7\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
index 685ad3f0b43..1b52194b270 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
@@ -18,9 +18,7 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStat
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.time.Clock;
import java.time.Duration;
@@ -32,11 +30,7 @@ import java.util.regex.Pattern;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
@@ -44,10 +38,6 @@ import static org.mockito.Mockito.when;
public class SetNodeStateTest extends StateRestApiTest {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
public static class SetUnitStateRequestImpl extends StateRequest implements SetUnitStateRequest {
private final Map<String, UnitState> newStates = new LinkedHashMap<>();
private Condition condition = Condition.FORCE;
@@ -176,7 +166,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testSimple() throws Exception {
+ void testSimple() throws Exception {
setUp(true);
verifyStateSet("down", "testing");
verifyStateSet("up", "foo");
@@ -186,14 +176,14 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testSetNodesForCluster() throws Exception {
+ void testSetNodesForCluster() throws Exception {
setUp(true);
verifyClusterSet("maintenance", "prepare for maintenance");
verifyClusterSet("up", "and we're back online");
}
@Test
- public void testShouldNotModifyDistributorSafe() throws Exception {
+ void testShouldNotModifyDistributorSafe() throws Exception {
setUp(false);
SetResponse setResponse = restAPI.setUnitState(new SetUnitStateRequestImpl("music/distributor/1")
.setNewState("user", "up", "whatever reason.")
@@ -204,7 +194,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testShouldModifyStorageSafeOk() throws Exception {
+ void testShouldModifyStorageSafeOk() throws Exception {
setUp(false);
SetResponse setResponse = restAPI.setUnitState(new SetUnitStateRequestImpl("music/storage/2")
.setNewState("user", "maintenance", "whatever reason.")
@@ -214,7 +204,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testShouldModifyStorageSafeBlocked() throws Exception {
+ void testShouldModifyStorageSafeBlocked() throws Exception {
// Sets up 2 groups: [0, 2, 4] and [1, 3, 5]
setUpMusicGroup(6, "");
@@ -254,7 +244,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void settingSafeMaintenanceWhenNodeDown() throws Exception {
+ void settingSafeMaintenanceWhenNodeDown() throws Exception {
// Sets up 2 groups: [0, 2, 4] and [1, 3, 5], with 1 being down
setUpMusicGroup(6, " .1.s:d");
assertUnitState(1, "generated", State.DOWN, "");
@@ -289,7 +279,7 @@ public class SetNodeStateTest extends StateRestApiTest {
UnitResponse response = restAPI.getState(new StateRequest(path, 0));
Response.NodeResponse nodeResponse = (Response.NodeResponse) response;
UnitState unitState = nodeResponse.getStatePerType().get(type);
- assertNotNull("No such type " + type + " at path " + path, unitState);
+ assertNotNull(unitState, "No such type " + type + " at path " + path);
assertEquals(state.toString().toLowerCase(), unitState.getId());
assertEquals(reason, unitState.getReason());
}
@@ -326,19 +316,18 @@ public class SetNodeStateTest extends StateRestApiTest {
Matcher matcher = Pattern.compile(reasonRegex).matcher(setResponse.getReason());
String errorMessage = "Expected reason to match '" + reasonRegex + "', but got: " + setResponse.getReason() + "'";
- assertTrue(errorMessage, matcher.find());
+ assertTrue(matcher.find(), errorMessage);
int alreadyMaintainedIndex = Integer.parseInt(matcher.group(1));
// Example: Say index 1 is in maintenance, and we try to set 2 in maintenance. This should
// NOT be allowed, since 2 is in a different group than 1.
- assertEquals("Tried to set " + index + " in maintenance, but got: " + setResponse.getReason(),
- index % 2, (alreadyMaintainedIndex + 1) % 2);
+ assertEquals(index % 2, (alreadyMaintainedIndex + 1) % 2, "Tried to set " + index + " in maintenance, but got: " + setResponse.getReason());
assertThat(setResponse.getWasModified(), is(false));
}
@Test
- public void testSetWantedStateOnNodeNotInSlobrok() throws Exception {
+ void testSetWantedStateOnNodeNotInSlobrok() throws Exception {
// Node 2 in cluster music does not have a valid NodeInfo due to passing true to setUp
setUp(true);
restAPI.setUnitState(new SetUnitStateRequestImpl("music/distributor/2").setNewState("user", "down", "borked node"));
@@ -348,73 +337,73 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testWrongUnit() throws Exception {
+ void testWrongUnit() throws Exception {
setUp(true);
String wrongUnitMessage = "State can only be set at cluster or node level";
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"").setNewState("user", "down", "testing"));
fail();
} catch (OperationNotSupportedForUnitException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
+ assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage());
}
// ... setting at cluster-level is allowed
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor").setNewState("user", "down", "testing"));
fail();
} catch (OperationNotSupportedForUnitException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
+ assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage());
}
// ... setting at node-level is allowed
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/0").setNewState("user", "down", "testing"));
fail();
} catch (OperationNotSupportedForUnitException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
+ assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage());
}
}
@Test
- public void testInvalidUnit() throws Exception {
+ void testInvalidUnit() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"foo").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/content").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/bah").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/10").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/0/1").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/bar").setNewState("user", "down", "testing"));
fail();
@@ -423,71 +412,71 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testSettingInvalidStateType() throws Exception {
+ void testSettingInvalidStateType() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("foo", "down", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No new user state given"));
+ assertTrue(e.getMessage().contains("No new user state given"), e.getMessage());
}
}
@Test
- public void testSafeIsInvalidForSetNodesStatesForCluster() throws Exception {
+ void testSafeIsInvalidForSetNodesStatesForCluster() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl("music")
.setNewState("user", "maintenance", "example reason")
.setCondition(SetUnitStateRequest.Condition.SAFE));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(
- "Setting all nodes in a cluster to a state is only supported with FORCE"));
+ assertTrue(e.getMessage().contains(
+ "Setting all nodes in a cluster to a state is only supported with FORCE"), e.getMessage());
}
}
@Test
- public void testSettingWrongStateType() throws Exception {
+ void testSettingWrongStateType() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("generated", "down", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No new user state given"));
+ assertTrue(e.getMessage().contains("No new user state given"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("unit", "down", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No new user state given"));
+ assertTrue(e.getMessage().contains("No new user state given"), e.getMessage());
}
}
@Test
- public void testInvalidState() throws Exception {
+ void testInvalidState() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "initializing", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Invalid user state"));
+ assertTrue(e.getMessage().contains("Invalid user state"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "stopping", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Invalid user state"));
+ assertTrue(e.getMessage().contains("Invalid user state"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "foo", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Invalid user state"));
+ assertTrue(e.getMessage().contains("Invalid user state"), e.getMessage());
}
}
@Test
- public void testOverwriteReason() throws Exception {
+ void testOverwriteReason() throws Exception {
setUp(true);
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "down", "testing"));
@@ -508,19 +497,19 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void set_node_state_requests_are_by_default_tagged_as_having_version_ack_dependency() {
+ void set_node_state_requests_are_by_default_tagged_as_having_version_ack_dependency() {
SetNodeStateRequest request = createDummySetNodeStateRequest();
assertTrue(request.hasVersionAckDependency());
}
@Test
- public void set_node_state_requests_not_initially_marked_as_failed() {
+ void set_node_state_requests_not_initially_marked_as_failed() {
SetNodeStateRequest request = createDummySetNodeStateRequest();
assertFalse(request.isFailed());
}
@Test
- public void set_node_state_requests_may_override_version_ack_dependency() {
+ void set_node_state_requests_may_override_version_ack_dependency() {
SetNodeStateRequest request = new SetNodeStateRequest(createDummyId(), new SetUnitStateRequestImpl("music/storage/1")
.setNewState("user", "maintenance", "whatever reason.")
.setResponseWait(SetUnitStateRequest.ResponseWait.NO_WAIT));
@@ -531,40 +520,42 @@ public class SetNodeStateTest extends StateRestApiTest {
// important to test (and expected to happen) for requests that have dependencies on cluster
// state version publishing.
@Test
- public void leadership_loss_fails_set_node_state_request() throws Exception {
- expectedException.expectMessage("Leadership lost before request could complete");
- expectedException.expect(UnknownMasterException.class);
+ void leadership_loss_fails_set_node_state_request() throws Exception {
+ Throwable exception = assertThrows(UnknownMasterException.class, () -> {
- SetNodeStateRequest request = createDummySetNodeStateRequest();
- request.handleFailure(RemoteClusterControllerTask.Failure.of(RemoteClusterControllerTask.FailureCondition.LEADERSHIP_LOST));
- request.getResult();
+ SetNodeStateRequest request = createDummySetNodeStateRequest();
+ request.handleFailure(RemoteClusterControllerTask.Failure.of(RemoteClusterControllerTask.FailureCondition.LEADERSHIP_LOST));
+ request.getResult();
+ });
+ assertTrue(exception.getMessage().contains("Leadership lost before request could complete"));
}
@Test
- public void leadership_loss_marks_request_as_failed_for_early_out_response() {
+ void leadership_loss_marks_request_as_failed_for_early_out_response() {
SetNodeStateRequest request = createDummySetNodeStateRequest();
request.handleFailure(RemoteClusterControllerTask.Failure.of(RemoteClusterControllerTask.FailureCondition.LEADERSHIP_LOST));
assertTrue(request.isFailed());
}
@Test
- public void deadline_exceeded_fails_set_node_state_request() throws Exception {
- expectedException.expectMessage("Task exceeded its version wait deadline: gremlins in the computer");
- expectedException.expect(DeadlineExceededException.class);
+ void deadline_exceeded_fails_set_node_state_request() throws Exception {
+ Throwable exception = assertThrows(DeadlineExceededException.class, () -> {
- SetNodeStateRequest request = createDummySetNodeStateRequest();
- request.handleFailure(RemoteClusterControllerTask.Failure.of(
- RemoteClusterControllerTask.FailureCondition.DEADLINE_EXCEEDED, "gremlins in the computer"));
- request.getResult();
+ SetNodeStateRequest request = createDummySetNodeStateRequest();
+ request.handleFailure(RemoteClusterControllerTask.Failure.of(
+ RemoteClusterControllerTask.FailureCondition.DEADLINE_EXCEEDED, "gremlins in the computer"));
+ request.getResult();
+ });
+ assertTrue(exception.getMessage().contains("Task exceeded its version wait deadline: gremlins in the computer"));
}
@Test
- public void no_fail_if_modified() throws StateRestApiException {
+ void no_fail_if_modified() throws StateRestApiException {
assertFalse(isFailed(true));
}
@Test
- public void fail_if_not_modified() throws StateRestApiException {
+ void fail_if_not_modified() throws StateRestApiException {
assertTrue(isFailed(false));
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
index 9f14b2e71d2..1bd17b11755 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
@@ -15,8 +15,8 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiE
import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -43,13 +43,13 @@ public class SetNodeStateRequestTest {
private boolean inMasterMoratorium = false;
private boolean probe = false;
- @Before
+ @BeforeEach
public void setUp() {
newStates.put("user", unitState);
}
@Test
- public void testUpToMaintenance() throws StateRestApiException {
+ void testUpToMaintenance() throws StateRestApiException {
testSetStateRequest(
"maintenance",
State.UP, State.UP,
@@ -58,7 +58,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testProbingDoesntChangeState() throws StateRestApiException {
+ void testProbingDoesntChangeState() throws StateRestApiException {
probe = true;
testSetStateRequest(
"maintenance",
@@ -68,7 +68,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testUpToDown() throws StateRestApiException {
+ void testUpToDown() throws StateRestApiException {
testSetStateRequest(
"down",
State.UP, State.UP,
@@ -77,7 +77,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testMaintenanceToUp() throws StateRestApiException {
+ void testMaintenanceToUp() throws StateRestApiException {
testSetStateRequest(
"up",
State.MAINTENANCE, State.DOWN,
@@ -86,7 +86,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testDownToUp() throws StateRestApiException {
+ void testDownToUp() throws StateRestApiException {
testSetStateRequest(
"up",
State.DOWN, State.DOWN,
@@ -95,7 +95,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testOnlyStorageInMaintenaceToMaintenance() throws StateRestApiException {
+ void testOnlyStorageInMaintenaceToMaintenance() throws StateRestApiException {
testSetStateRequest(
"maintenance",
State.MAINTENANCE, State.UP,
@@ -104,7 +104,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testNoOpMaintenaceToMaintenance() throws StateRestApiException {
+ void testNoOpMaintenaceToMaintenance() throws StateRestApiException {
testSetStateRequest(
"maintenance",
State.MAINTENANCE, State.DOWN,
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java
index ca9e81b6bc4..809979620c2 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java
@@ -21,7 +21,7 @@ import com.yahoo.vespa.clustercontroller.core.FleetControllerOptions;
import com.yahoo.vespa.clustercontroller.core.NodeInfo;
import com.yahoo.vespa.clustercontroller.core.SetClusterStateRequest;
import com.yahoo.vespa.clustercontroller.core.Timer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.HashSet;
@@ -33,7 +33,7 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.eq;
@@ -51,7 +51,7 @@ public class RPCCommunicatorTest {
private static final int ROUNDTRIP_LATENCY_SECONDS = 2000;
@Test
- public void testGenerateNodeStateRequestTimeoutMs() {
+ void testGenerateNodeStateRequestTimeoutMs() {
final RPCCommunicator communicator = new RPCCommunicator(
RPCCommunicator.createRealSupervisor(),
null /* Timer */,
@@ -74,11 +74,11 @@ public class RPCCommunicatorTest {
assertThat(min, is(not(max)));
assertTrue(min >= NODE_STATE_REQUEST_TIMEOUT_INTERVAL_START_PERCENTAGE *
NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS / 100);
- assertTrue(uniqueTimeoutValues.size()> TEST_ITERATIONS/2);
+ assertTrue(uniqueTimeoutValues.size() > TEST_ITERATIONS / 2);
}
@Test
- public void testGenerateNodeStateRequestTimeoutMsWithUpdates() {
+ void testGenerateNodeStateRequestTimeoutMsWithUpdates() {
final RPCCommunicator communicator = new RPCCommunicator(RPCCommunicator.createRealSupervisor(), null /* Timer */, INDEX, 1, 1, 100, 0);
FleetControllerOptions fleetControllerOptions = new FleetControllerOptions(null /*clustername*/, Set.of(new ConfiguredNode(0, false)));
fleetControllerOptions.nodeStateRequestTimeoutEarliestPercentage = 100;
@@ -90,7 +90,7 @@ public class RPCCommunicatorTest {
}
@Test
- public void testRoundtripLatency() {
+ void testRoundtripLatency() {
final Timer timer = new FakeTimer();
final RPCCommunicator communicator = new RPCCommunicator(
RPCCommunicator.createRealSupervisor(),
@@ -111,7 +111,7 @@ public class RPCCommunicatorTest {
communicator.getNodeState(nodeInfo, null);
Mockito.verify(target).invokeAsync(
any(),
- eq(ROUNDTRIP_LATENCY_SECONDS + NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS/1000.0),
+ eq(ROUNDTRIP_LATENCY_SECONDS + NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS / 1000.0),
any());
}
@@ -146,7 +146,7 @@ public class RPCCommunicatorTest {
}
@Test
- public void setSystemState_v3_sends_distribution_states_rpc() {
+ void setSystemState_v3_sends_distribution_states_rpc() {
var f = new Fixture<SetClusterStateRequest>();
var cf = ClusterFixture.forFlatCluster(3).bringEntireClusterUp().assignDummyRpcAddresses();
var sentBundle = ClusterStateBundleUtil.makeBundle("distributor:3 storage:3");
@@ -162,7 +162,7 @@ public class RPCCommunicatorTest {
}
@Test
- public void set_distribution_states_v3_rpc_auto_downgrades_to_v2_on_unknown_method_error() {
+ void set_distribution_states_v3_rpc_auto_downgrades_to_v2_on_unknown_method_error() {
var f = new Fixture<SetClusterStateRequest>();
var cf = ClusterFixture.forFlatCluster(3).bringEntireClusterUp().assignDummyRpcAddresses();
var sentBundle = ClusterStateBundleUtil.makeBundle("version:123 distributor:3 storage:3");
@@ -188,7 +188,7 @@ public class RPCCommunicatorTest {
}
@Test
- public void activateClusterStateVersion_sends_version_activation_rpc() {
+ void activateClusterStateVersion_sends_version_activation_rpc() {
var f = new Fixture<ActivateClusterStateVersionRequest>();
var cf = ClusterFixture.forFlatCluster(3).bringEntireClusterUp().assignDummyRpcAddresses();
f.communicator.activateClusterStateVersion(12345, cf.cluster().getNodeInfo(Node.ofDistributor(1)), f.mockWaiter);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java
index 3d3347acb2d..7564fb40d46 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java
@@ -4,7 +4,7 @@ package com.yahoo.vespa.clustercontroller.core.rpc;
import com.yahoo.vespa.clustercontroller.core.ClusterStateBundle;
import com.yahoo.vespa.clustercontroller.core.ClusterStateBundleUtil;
import com.yahoo.vespa.clustercontroller.core.StateMapping;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
@@ -25,13 +25,13 @@ public class SlimeClusterStateBundleCodecTest {
}
@Test
- public void baseline_only_bundle_can_be_round_trip_encoded() {
+ void baseline_only_bundle_can_be_round_trip_encoded() {
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("distributor:2 storage:2");
assertThat(roundtripEncode(stateBundle), equalTo(stateBundle));
}
@Test
- public void multi_space_state_bundle_can_be_round_trip_encoded() {
+ void multi_space_state_bundle_can_be_round_trip_encoded() {
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("distributor:2 storage:2",
StateMapping.of("default", "distributor:2 storage:2 .0.s:d"),
StateMapping.of("upsidedown", "distributor:2 .0.s:d storage:2"));
@@ -49,7 +49,7 @@ public class SlimeClusterStateBundleCodecTest {
}
@Test
- public void encoded_cluster_states_can_be_compressed() {
+ void encoded_cluster_states_can_be_compressed() {
ClusterStateBundle stateBundle = makeCompressableBundle();
SlimeClusterStateBundleCodec codec = new SlimeClusterStateBundleCodec();
@@ -60,20 +60,20 @@ public class SlimeClusterStateBundleCodecTest {
}
@Test
- public void uncompressed_enveloped_bundle_can_be_roundtrip_encoded() {
+ void uncompressed_enveloped_bundle_can_be_roundtrip_encoded() {
// Insufficient length and too much entropy to be compressed
ClusterStateBundle stateBundle = ClusterStateBundleUtil.makeBundle("distributor:2 storage:3");
assertThat(roundtripEncodeWithEnvelope(stateBundle), equalTo(stateBundle));
}
@Test
- public void compressable_enveloped_bundle_can_be_roundtrip_encoded() {
+ void compressable_enveloped_bundle_can_be_roundtrip_encoded() {
ClusterStateBundle stateBundle = makeCompressableBundle();
assertThat(roundtripEncodeWithEnvelope(stateBundle), equalTo(stateBundle));
}
@Test
- public void can_roundtrip_encode_bundle_with_deferred_activation_enabled() {
+ void can_roundtrip_encode_bundle_with_deferred_activation_enabled() {
var stateBundle = ClusterStateBundleUtil.makeBundleBuilder("distributor:2 storage:2")
.deferredActivation(true)
.deriveAndBuild();
@@ -81,7 +81,7 @@ public class SlimeClusterStateBundleCodecTest {
}
@Test
- public void can_roundtrip_encode_bundle_with_deferred_activation_disabled() {
+ void can_roundtrip_encode_bundle_with_deferred_activation_disabled() {
var stateBundle = ClusterStateBundleUtil.makeBundleBuilder("distributor:2 storage:2")
.deferredActivation(false)
.deriveAndBuild();
@@ -89,7 +89,7 @@ public class SlimeClusterStateBundleCodecTest {
}
@Test
- public void can_roundtrip_encode_bundle_with_feed_block_state() {
+ void can_roundtrip_encode_bundle_with_feed_block_state() {
var stateBundle = ClusterStateBundleUtil.makeBundleBuilder("distributor:2 storage:2")
.feedBlock(ClusterStateBundle.FeedBlock.blockedWithDescription("more cake needed"))
.deriveAndBuild();
diff --git a/clustercontroller-utils/pom.xml b/clustercontroller-utils/pom.xml
index a1f0b1c21c2..0d8e30d3693 100644
--- a/clustercontroller-utils/pom.xml
+++ b/clustercontroller-utils/pom.xml
@@ -14,11 +14,6 @@
<packaging>container-plugin</packaging>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
</dependency>
@@ -35,6 +30,16 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java
index 7cea1adced6..739b8d4bf15 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java
@@ -1,19 +1,20 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.communication.async;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.LinkedList;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class AsyncTest {
@Test
- public void testListeners() {
+ void testListeners() {
AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test");
class Listener implements AsyncCallback<String> {
boolean called = false;
+
@Override
public void done(AsyncOperation<String> op) {
called = true;
@@ -40,7 +41,7 @@ public class AsyncTest {
}
@Test
- public void testMultipleResultSetters() {
+ void testMultipleResultSetters() {
{
AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test");
op.setResult("foo");
@@ -65,7 +66,7 @@ public class AsyncTest {
}
@Test
- public void testPartialResultOnFailure() {
+ void testPartialResultOnFailure() {
AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test");
op.setFailure(new Exception("bar"), "foo");
assertEquals("foo", op.getResult());
@@ -74,14 +75,16 @@ public class AsyncTest {
}
@Test
- public void testListenImpl() {
+ void testListenImpl() {
class ListenImpl extends AsyncOperationListenImpl<String> {
public ListenImpl(AsyncOperation<String> op) {
super(op);
}
- };
+ }
+ ;
class Listener implements AsyncCallback<String> {
int calls = 0;
+
@Override
public void done(AsyncOperation<String> op) {
++calls;
@@ -98,7 +101,7 @@ public class AsyncTest {
}
@Test
- public void testRedirectedOperation() {
+ void testRedirectedOperation() {
{
final AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test", "desc");
AsyncOperation<Integer> deleteRequest = new RedirectedAsyncOperation<String, Integer>(op) {
@@ -147,7 +150,7 @@ public class AsyncTest {
}
@Test
- public void testRedirectOnSuccessOperation() {
+ void testRedirectOnSuccessOperation() {
{
final AsyncOperationImpl<Integer> target = new AsyncOperationImpl<>("foo");
SuccessfulAsyncCallback<String, Integer> callback = new SuccessfulAsyncCallback<String, Integer>(target) {
@@ -243,17 +246,17 @@ public class AsyncTest {
}
@Test
- public void testStressCompletionAndRegisterToDetectRace() throws Exception {
+ void testStressCompletionAndRegisterToDetectRace() throws Exception {
int iterations = 1000;
Object monitor = new Object();
Completer completer = new Completer(monitor);
Listener listener = new Listener(monitor);
Thread t1 = new Thread(completer);
Thread t2 = new Thread(listener);
- try{
+ try {
t1.start();
t2.start();
- for (int i=0; i<iterations; ++i) {
+ for (int i = 0; i < iterations; ++i) {
AsyncOperationImpl<String> op = new AsyncOperationImpl<>("test");
synchronized (monitor) {
completer.op = op;
@@ -261,7 +264,10 @@ public class AsyncTest {
monitor.notifyAll();
}
while (completer.op != null || listener.op != null) {
- try{ Thread.sleep(0); } catch (InterruptedException e) {}
+ try {
+ Thread.sleep(0);
+ } catch (InterruptedException e) {
+ }
}
}
} finally {
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java
index 2583c3392c4..41328494f52 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java
@@ -1,11 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.communication.http;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class HttpRequestTest {
@@ -21,7 +19,7 @@ public class HttpRequestTest {
}
@Test
- public void testEquality() {
+ void testEquality() {
assertEquals(createRequest(), createRequest());
assertNotSame(createRequest(), createRequest().setHost("localhost"));
assertNotSame(createRequest(), createRequest().setPort(40));
@@ -31,16 +29,16 @@ public class HttpRequestTest {
}
@Test
- public void testVerifyComplete() {
+ void testVerifyComplete() {
// To be a complete request, an HTTP request must include:
// - A path
// - The HTTP operation type
- try{
+ try {
new HttpRequest().setPath("/foo").verifyComplete();
assertTrue(false);
} catch (IllegalStateException e) {
}
- try{
+ try {
new HttpRequest().setHttpOperation(HttpRequest.HttpOp.GET).verifyComplete();
assertTrue(false);
} catch (IllegalStateException e) {
@@ -49,7 +47,7 @@ public class HttpRequestTest {
}
@Test
- public void testMerge() {
+ void testMerge() {
{
HttpRequest base = new HttpRequest()
.setHttpOperation(HttpRequest.HttpOp.POST)
@@ -92,25 +90,25 @@ public class HttpRequestTest {
}
@Test
- public void testNonExistingHeader() {
+ void testNonExistingHeader() {
assertEquals("foo", new HttpRequest().getHeader("asd", "foo"));
assertEquals("foo", new HttpRequest().addHttpHeader("bar", "foo").getHeader("asd", "foo"));
}
@Test
- public void testOption() {
+ void testOption() {
assertEquals("bar", new HttpRequest().addUrlOption("foo", "bar").getOption("foo", "foo"));
assertEquals("foo", new HttpRequest().getOption("asd", "foo"));
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("GET? http://localhost:8080/",
- new HttpRequest()
- .setScheme("http")
- .setHost("localhost")
- .setPort(8080)
- .toString(true));
+ new HttpRequest()
+ .setScheme("http")
+ .setHost("localhost")
+ .setPort(8080)
+ .toString(true));
assertEquals("POST http://localhost/",
new HttpRequest()
.setScheme("http")
@@ -127,7 +125,7 @@ public class HttpRequestTest {
}
@Test
- public void testNothingButGetCoverage() {
+ void testNothingButGetCoverage() {
assertEquals(false, new HttpRequest().equals(new Object()));
new HttpRequest().getHeaders();
new HttpRequest().setUrlOptions(new HttpRequest().getUrlOptions());
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java
index 59fd4521efb..3a08d735a4e 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java
@@ -1,14 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.communication.http;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class HttpResultTest {
@Test
- public void testSuccess() {
+ void testSuccess() {
assertEquals(false, new HttpResult().setHttpCode(199, "foo").isSuccess());
assertEquals(true, new HttpResult().setHttpCode(200, "foo").isSuccess());
assertEquals(true, new HttpResult().setHttpCode(299, "foo").isSuccess());
@@ -16,7 +16,7 @@ public class HttpResultTest {
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("HTTP 200/OK", new HttpResult().setContent("Foo").toString());
assertEquals("HTTP 200/OK\n\nFoo", new HttpResult().setContent("Foo").toString(true));
assertEquals("HTTP 200/OK", new HttpResult().toString(true));
@@ -24,7 +24,7 @@ public class HttpResultTest {
}
@Test
- public void testNothingButGetCoverage() {
+ void testNothingButGetCoverage() {
new HttpResult().getHeaders();
}
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java
index 2e8f9ea9b58..19fc27669af 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java
@@ -3,31 +3,31 @@ package com.yahoo.vespa.clustercontroller.utils.communication.http;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JsonHttpResultTest {
@Test
- public void testCopyConstructor() {
+ void testCopyConstructor() {
assertEquals("{}", new JsonHttpResult(new HttpResult()).getJson().toString());
}
@Test
- public void testOutput() {
+ void testOutput() {
assertEquals("HTTP 200/OK\n"
- + "\n"
- + "JSON: {\"foo\": 3}",
- new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : 3 }")).toString(true));
+ + "\n"
+ + "JSON: {\"foo\": 3}",
+ new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : 3 }")).toString(true));
assertEquals("HTTP 200/OK\n"
- + "\n"
- + "{ \"foo\" : }",
+ + "\n"
+ + "{ \"foo\" : }",
new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : }")).toString(true));
}
@Test
- public void testNonJsonOutput() {
+ void testNonJsonOutput() {
JsonHttpResult result = new JsonHttpResult();
result.setContent("Foo");
StringBuilder sb = new StringBuilder();
@@ -36,7 +36,7 @@ public class JsonHttpResultTest {
}
@Test
- public void testInvalidJsonOutput() {
+ void testInvalidJsonOutput() {
JsonHttpResult result = new JsonHttpResult();
result.setJson(new JSONObject() {
@Override
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java
index 2c9d9296aae..52b632c6eb8 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.communication.http.writer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpWriterTest {
@@ -19,34 +19,34 @@ public class HttpWriterTest {
+ "</html>\n";
@Test
- public void testStructure() {
+ void testStructure() {
HttpWriter writer = new HttpWriter();
String header = defaultHeader.replace(defaultTitle, "Untitled page");
assertEquals(header + defaultFooter, writer.toString());
}
@Test
- public void testTitle() {
+ void testTitle() {
HttpWriter writer = new HttpWriter().addTitle(defaultTitle);
assertEquals(defaultHeader + defaultFooter, writer.toString());
}
@Test
- public void testParagraph() {
+ void testParagraph() {
String paragraph = "This is a paragraph";
String paragraph2 = "More text";
HttpWriter writer = new HttpWriter().addTitle(defaultTitle).write(paragraph).write(paragraph2);
String content = " <p>\n"
- + " " + paragraph + "\n"
- + " </p>\n"
- + " <p>\n"
- + " " + paragraph2 + "\n"
- + " </p>\n";
+ + " " + paragraph + "\n"
+ + " </p>\n"
+ + " <p>\n"
+ + " " + paragraph2 + "\n"
+ + " </p>\n";
assertEquals(defaultHeader + content + defaultFooter, writer.toString());
}
@Test
- public void testLink() {
+ void testLink() {
String name = "My link";
String link = "/foo/bar?hmm";
HttpWriter writer = new HttpWriter().addTitle(defaultTitle).writeLink(name, link);
@@ -55,15 +55,15 @@ public class HttpWriterTest {
}
@Test
- public void testErrors() {
- try{
+ void testErrors() {
+ try {
HttpWriter writer = new HttpWriter().addTitle(defaultTitle);
writer.toString();
writer.write("foo");
assertTrue(false);
} catch (IllegalStateException e) {
}
- try{
+ try {
new HttpWriter().write("foo").addTitle("bar");
assertTrue(false);
} catch (IllegalStateException e) {
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java
index 0f6e9e235dc..d0378dd9065 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java
@@ -9,12 +9,11 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.*;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.server.RestApiHandler;
import com.yahoo.vespa.clustercontroller.utils.test.TestTransport;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class StateRestAPITest {
@@ -60,96 +59,96 @@ public class StateRestAPITest {
AsyncOperation<HttpResult> op = testTransport.getClient().execute(request);
AsyncUtils.waitFor(op);
if (!op.isSuccess()) { // Don't call getCause() unless it fails
- assertTrue(op.getCause().toString(), op.isSuccess());
+ assertTrue(op.isSuccess(), op.getCause().toString());
}
assertTrue(op.getResult() != null);
return op.getResult();
}
private JSONObject executeOkJsonRequest(HttpRequest request) {
HttpResult result = execute(request);
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
return (JSONObject) result.getContent();
}
@Test
- public void testTopLevelList() throws Exception {
+ void testTopLevelList() throws Exception {
setupDummyStateApi();
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"cluster\": {\n"
- + " \"foo\": {\"link\": \"\\/cluster\\/v2\\/foo\"},\n"
- + " \"bar\": {\"link\": \"\\/cluster\\/v2\\/bar\"}\n"
- + "}}";
+ + " \"foo\": {\"link\": \"\\/cluster\\/v2\\/foo\"},\n"
+ + " \"bar\": {\"link\": \"\\/cluster\\/v2\\/bar\"}\n"
+ + "}}";
assertEquals(expected, ((JSONObject) result.getContent()).toString(2));
}
@Test
- public void testClusterState() throws Exception {
+ void testClusterState() throws Exception {
setupDummyStateApi();
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo"));
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"node\": {\n"
- + " \"1\": {\"link\": \"\\/cluster\\/v2\\/foo\\/1\"},\n"
- + " \"3\": {\"link\": \"\\/cluster\\/v2\\/foo\\/3\"}\n"
- + "}}";
+ + " \"1\": {\"link\": \"\\/cluster\\/v2\\/foo\\/1\"},\n"
+ + " \"3\": {\"link\": \"\\/cluster\\/v2\\/foo\\/3\"}\n"
+ + "}}";
assertEquals(expected, ((JSONObject) result.getContent()).toString(2));
}
@Test
- public void testNodeState() throws Exception {
+ void testNodeState() throws Exception {
setupDummyStateApi();
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3"));
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\n"
- + " \"attributes\": {\"group\": \"mygroup\"},\n"
- + " \"state\": {\"current\": {\n"
- + " \"state\": \"up\",\n"
- + " \"reason\": \"\"\n"
- + " }},\n"
- + " \"metrics\": {\"doc-count\": 8}\n"
- + "}";
+ + " \"attributes\": {\"group\": \"mygroup\"},\n"
+ + " \"state\": {\"current\": {\n"
+ + " \"state\": \"up\",\n"
+ + " \"reason\": \"\"\n"
+ + " }},\n"
+ + " \"metrics\": {\"doc-count\": 8}\n"
+ + "}";
assertEquals(expected, ((JSONObject) result.getContent()).toString(2));
}
@Test
- public void testRecursiveMode() throws Exception {
+ void testRecursiveMode() throws Exception {
setupDummyStateApi();
{
JSONObject json = executeOkJsonRequest(
new HttpRequest().setPath("/cluster/v2").addUrlOption("recursive", "true"));
String expected =
"{\"cluster\": {\n" +
- " \"foo\": {\"node\": {\n" +
- " \"1\": {\n" +
- " \"attributes\": {\"group\": \"mygroup\"},\n" +
- " \"state\": {\"current\": {\n" +
- " \"state\": \"initializing\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\"doc-count\": 5}\n" +
- " },\n" +
- " \"3\": {\n" +
- " \"attributes\": {\"group\": \"mygroup\"},\n" +
- " \"state\": {\"current\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\"doc-count\": 8}\n" +
- " }\n" +
- " }},\n" +
- " \"bar\": {\"node\": {\"2\": {\n" +
- " \"attributes\": {\"group\": \"mygroup\"},\n" +
- " \"state\": {\"current\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\"doc-count\": 0}\n" +
- " }}}\n" +
- "}}";
+ " \"foo\": {\"node\": {\n" +
+ " \"1\": {\n" +
+ " \"attributes\": {\"group\": \"mygroup\"},\n" +
+ " \"state\": {\"current\": {\n" +
+ " \"state\": \"initializing\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\"doc-count\": 5}\n" +
+ " },\n" +
+ " \"3\": {\n" +
+ " \"attributes\": {\"group\": \"mygroup\"},\n" +
+ " \"state\": {\"current\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\"doc-count\": 8}\n" +
+ " }\n" +
+ " }},\n" +
+ " \"bar\": {\"node\": {\"2\": {\n" +
+ " \"attributes\": {\"group\": \"mygroup\"},\n" +
+ " \"state\": {\"current\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\"doc-count\": 0}\n" +
+ " }}}\n" +
+ "}}";
assertEquals(expected, json.toString(2));
}
{
@@ -157,17 +156,17 @@ public class StateRestAPITest {
new HttpRequest().setPath("/cluster/v2").addUrlOption("recursive", "1"));
String expected =
"{\"cluster\": {\n" +
- " \"foo\": {\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/foo\\/1\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/foo\\/3\"}\n" +
- " }},\n" +
- " \"bar\": {\"node\": {\"2\": {\"link\": \"\\/cluster\\/v2\\/bar\\/2\"}}}\n" +
- "}}";
+ " \"foo\": {\"node\": {\n" +
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/foo\\/1\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/foo\\/3\"}\n" +
+ " }},\n" +
+ " \"bar\": {\"node\": {\"2\": {\"link\": \"\\/cluster\\/v2\\/bar\\/2\"}}}\n" +
+ "}}";
// Verify that the actual link does not contain backslash. It's just an artifact of
// jettison json output.
assertEquals("/cluster/v2/foo/1",
- json.getJSONObject("cluster").getJSONObject("foo").getJSONObject("node")
- .getJSONObject("1").getString("link"));
+ json.getJSONObject("cluster").getJSONObject("foo").getJSONObject("node")
+ .getJSONObject("1").getString("link"));
assertEquals(expected, json.toString(2));
}
{
@@ -175,23 +174,23 @@ public class StateRestAPITest {
new HttpRequest().setPath("/cluster/v2/foo").addUrlOption("recursive", "1"));
String expected =
"{\"node\": {\n" +
- " \"1\": {\n" +
- " \"attributes\": {\"group\": \"mygroup\"},\n" +
- " \"state\": {\"current\": {\n" +
- " \"state\": \"initializing\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\"doc-count\": 5}\n" +
- " },\n" +
- " \"3\": {\n" +
- " \"attributes\": {\"group\": \"mygroup\"},\n" +
- " \"state\": {\"current\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\"doc-count\": 8}\n" +
- " }\n" +
- "}}";
+ " \"1\": {\n" +
+ " \"attributes\": {\"group\": \"mygroup\"},\n" +
+ " \"state\": {\"current\": {\n" +
+ " \"state\": \"initializing\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\"doc-count\": 5}\n" +
+ " },\n" +
+ " \"3\": {\n" +
+ " \"attributes\": {\"group\": \"mygroup\"},\n" +
+ " \"state\": {\"current\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\"doc-count\": 8}\n" +
+ " }\n" +
+ "}}";
assertEquals(expected, json.toString(2));
}
{
@@ -199,9 +198,9 @@ public class StateRestAPITest {
new HttpRequest().setPath("/cluster/v2/foo").addUrlOption("recursive", "false"));
String expected =
"{\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/foo\\/1\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/foo\\/3\"}\n" +
- "}}";
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/foo\\/1\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/foo\\/3\"}\n" +
+ "}}";
assertEquals(expected, json.toString(2));
}
}
@@ -217,15 +216,15 @@ public class StateRestAPITest {
json.put("response-wait", responseWait.get());
}
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
StringBuilder print = new StringBuilder();
result.printContent(print);
return print.toString();
}
@Test
- public void testSetNodeState() throws Exception {
+ void testSetNodeState() throws Exception {
setupDummyStateApi();
{
JSONObject json = new JSONObject().put("state", new JSONObject()
@@ -233,8 +232,8 @@ public class StateRestAPITest {
.put("state", "retired")
.put("reason", "No reason")));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
}
{
JSONObject json = executeOkJsonRequest(new HttpRequest().setPath("/cluster/v2/foo/3"));
@@ -246,14 +245,14 @@ public class StateRestAPITest {
+ " }},\n"
+ " \"metrics\": {\"doc-count\": 8}\n"
+ "}";
- assertEquals(json.toString(2), expected, json.toString(2));
+ assertEquals(expected, json.toString(2), json.toString(2));
}
{
JSONObject json = new JSONObject().put("state", new JSONObject()
.put("current", new JSONObject()));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 200, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(200, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
}
{
JSONObject json = executeOkJsonRequest(new HttpRequest().setPath("/cluster/v2/foo/3"));
@@ -265,12 +264,12 @@ public class StateRestAPITest {
+ " }},\n"
+ " \"metrics\": {\"doc-count\": 8}\n"
+ "}";
- assertEquals(json.toString(2), expected, json.toString(2));
+ assertEquals(expected, json.toString(2), json.toString(2));
}
}
@Test
- public void set_node_state_response_wait_type_is_propagated_to_handler() throws Exception {
+ void set_node_state_response_wait_type_is_propagated_to_handler() throws Exception {
setupDummyStateApi();
{
String result = retireAndExpectHttp200Response(Optional.of("wait-until-cluster-acked"));
@@ -291,7 +290,7 @@ public class StateRestAPITest {
}
@Test
- public void set_node_state_response_wait_type_is_cluster_acked_by_default() throws Exception {
+ void set_node_state_response_wait_type_is_cluster_acked_by_default() throws Exception {
setupDummyStateApi();
String result = retireAndExpectHttp200Response(Optional.empty());
assertEquals(result,
@@ -302,92 +301,92 @@ public class StateRestAPITest {
}
@Test
- public void testMissingUnits() throws Exception {
+ void testMissingUnits() throws Exception {
setupDummyStateApi();
{
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/unknown"));
- assertEquals(result.toString(true), 404, result.getHttpReturnCode());
- assertEquals(result.toString(true), "No such resource 'unknown'.", result.getHttpReturnCodeDescription());
+ assertEquals(404, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("No such resource 'unknown'.", result.getHttpReturnCodeDescription(), result.toString(true));
String expected = "{\"message\":\"No such resource 'unknown'.\"}";
assertEquals(expected, result.getContent().toString());
}
{
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/1234"));
- assertEquals(result.toString(true), 404, result.getHttpReturnCode());
- assertEquals(result.toString(true), "No such resource 'foo/1234'.", result.getHttpReturnCodeDescription());
+ assertEquals(404, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("No such resource 'foo/1234'.", result.getHttpReturnCodeDescription(), result.toString(true));
String expected = "{\"message\":\"No such resource 'foo\\/1234'.\"}";
assertEquals(expected, result.getContent().toString());
}
}
@Test
- public void testUnknownMaster() throws Exception {
+ void testUnknownMaster() throws Exception {
setupDummyStateApi();
stateApi.induceException(new UnknownMasterException());
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 503, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Service Unavailable", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(503, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Service Unavailable", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"No known master cluster controller currently exists.\"}";
assertEquals(expected, result.getContent().toString());
- assertTrue(result.getHeader("Location") == null);
+ assertNull(result.getHeader("Location"));
}
@Test
- public void testOtherMaster() throws Exception {
+ void testOtherMaster() throws Exception {
setupDummyStateApi();
{
stateApi.induceException(new OtherMasterException("example.com", 80));
HttpResult result = execute(new HttpRequest().setScheme("https").setPath("/cluster/v2").addUrlOption(" %=?&", "&?%=").addUrlOption("foo", "bar"));
- assertEquals(result.toString(true), 307, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Temporary Redirect", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "https://example.com:80/cluster/v2?%20%25%3D%3F%26=%26%3F%25%3D&foo=bar", result.getHeader("Location"));
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(307, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Temporary Redirect", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("https://example.com:80/cluster/v2?%20%25%3D%3F%26=%26%3F%25%3D&foo=bar", result.getHeader("Location"), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Cluster controller not master. Use master at example.com:80.\"}";
assertEquals(expected, result.getContent().toString());
}
{
stateApi.induceException(new OtherMasterException("example.com", 80));
HttpResult result = execute(new HttpRequest().setScheme("http").setPath("/cluster/v2/foo"));
- assertEquals(result.toString(true), 307, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Temporary Redirect", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "http://example.com:80/cluster/v2/foo", result.getHeader("Location"));
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(307, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Temporary Redirect", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("http://example.com:80/cluster/v2/foo", result.getHeader("Location"), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Cluster controller not master. Use master at example.com:80.\"}";
assertEquals(expected, result.getContent().toString());
}
}
@Test
- public void testRuntimeException() throws Exception {
+ void testRuntimeException() throws Exception {
setupDummyStateApi();
stateApi.induceException(new RuntimeException("Moahaha"));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 500, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Failed to process request", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(500, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Failed to process request", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"java.lang.RuntimeException: Moahaha\"}";
assertEquals(expected, result.getContent().toString());
}
@Test
- public void testClientFailures() throws Exception {
+ void testClientFailures() throws Exception {
setupDummyStateApi();
{
stateApi.induceException(new InvalidContentException("Foo bar"));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Content of HTTP request had invalid data", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Content of HTTP request had invalid data", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Foo bar\"}";
assertEquals(expected, result.getContent().toString());
}
{
stateApi.induceException(new InvalidOptionValueException("foo", "bar", "Foo can not be bar"));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Option 'foo' have invalid value 'bar'", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Option 'foo' have invalid value 'bar'", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Option 'foo' have invalid value 'bar': Foo can not be bar\"}";
assertEquals(expected, result.getContent().toString());
}
@@ -396,94 +395,94 @@ public class StateRestAPITest {
path[0] = "foo";
stateApi.induceException(new OperationNotSupportedForUnitException(path, "Foo"));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 405, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Operation not supported for resource", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(405, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Operation not supported for resource", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"[foo]: Foo\"}";
assertEquals(expected, result.getContent().toString());
}
}
@Test
- public void testInternalFailure() throws Exception {
+ void testInternalFailure() throws Exception {
setupDummyStateApi();
{
stateApi.induceException(new InternalFailure("Foo"));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 500, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Failed to process request", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(500, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Failed to process request", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Internal failure. Should not happen: Foo\"}";
assertEquals(expected, result.getContent().toString());
}
}
@Test
- public void testInvalidRecursiveValues() throws Exception {
+ void testInvalidRecursiveValues() throws Exception {
setupDummyStateApi();
{
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2").addUrlOption("recursive", "-5"));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Option 'recursive' have invalid value '-5'", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Option 'recursive' have invalid value '-5'", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Option 'recursive' have invalid value '-5': Recursive option must be true, false, 0 or a positive integer\"}";
assertEquals(expected, result.getContent().toString());
}
{
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2").addUrlOption("recursive", "foo"));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Option 'recursive' have invalid value 'foo'", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Option 'recursive' have invalid value 'foo'", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"Option 'recursive' have invalid value 'foo': Recursive option must be true, false, 0 or a positive integer\"}";
assertEquals(expected, result.getContent().toString());
}
}
@Test
- public void testInvalidJsonInSetStateRequest() throws Exception {
+ void testInvalidJsonInSetStateRequest() throws Exception {
setupDummyStateApi();
{
JSONObject json = new JSONObject();
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Content of HTTP request had invalid data", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
- assertTrue(result.toString(true), result.getContent().toString().contains("Set state requests must contain a state object"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Content of HTTP request had invalid data", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
+ assertTrue(result.getContent().toString().contains("Set state requests must contain a state object"), result.toString(true));
}
{
JSONObject json = new JSONObject().put("state", 5);
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Content of HTTP request had invalid data", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
- assertTrue(result.toString(true), result.getContent().toString().contains("value of state is not a json object"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Content of HTTP request had invalid data", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
+ assertTrue(result.getContent().toString().contains("value of state is not a json object"), result.toString(true));
}
{
JSONObject json = new JSONObject().put("state", new JSONObject()
.put("current", 5));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Content of HTTP request had invalid data", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
- assertTrue(result.toString(true), result.getContent().toString().contains("value of state->current is not a json object"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Content of HTTP request had invalid data", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
+ assertTrue(result.getContent().toString().contains("value of state->current is not a json object"), result.toString(true));
}
{
JSONObject json = new JSONObject().put("state", new JSONObject()
.put("current", new JSONObject().put("state", 5)));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Content of HTTP request had invalid data", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
- assertTrue(result.toString(true), result.getContent().toString().contains("value of state->current->state is not a string"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Content of HTTP request had invalid data", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
+ assertTrue(result.getContent().toString().contains("value of state->current->state is not a string"), result.toString(true));
}
{
JSONObject json = new JSONObject().put("state", new JSONObject()
.put("current", new JSONObject().put("state", "down").put("reason", 5)));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Content of HTTP request had invalid data", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
- assertTrue(result.toString(true), result.getContent().toString().contains("value of state->current->reason is not a string"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Content of HTTP request had invalid data", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
+ assertTrue(result.getContent().toString().contains("value of state->current->reason is not a string"), result.toString(true));
}
{
String result = retireAndExpectHttp400Response("Non existing condition", "no-wait");
@@ -506,21 +505,21 @@ public class StateRestAPITest {
.put("condition", condition)
.put("response-wait", responseWait);
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
- assertEquals(result.toString(true), 400, result.getHttpReturnCode());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(400, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
StringBuilder print = new StringBuilder();
result.printContent(print);
return print.toString();
}
@Test
- public void testInvalidPathPrefix() throws Exception {
+ void testInvalidPathPrefix() throws Exception {
DummyBackend backend = new DummyBackend();
stateApi = new DummyStateApi(backend);
populateDummyBackend(backend);
testTransport = new TestTransport();
RestApiHandler handler = new RestApiHandler(stateApi);
- try{
+ try {
handler.setDefaultPathPrefix("cluster/v2");
assertTrue(false);
} catch (IllegalArgumentException e) {
@@ -528,14 +527,14 @@ public class StateRestAPITest {
}
@Test
- public void deadline_exceeded_exception_returns_http_504_error() throws Exception {
+ void deadline_exceeded_exception_returns_http_504_error() throws Exception {
setupDummyStateApi();
stateApi.induceException(new DeadlineExceededException("argh!"));
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
- assertEquals(result.toString(true), 504, result.getHttpReturnCode());
- assertEquals(result.toString(true), "Gateway Timeout", result.getHttpReturnCodeDescription());
- assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
+ assertEquals(504, result.getHttpReturnCode(), result.toString(true));
+ assertEquals("Gateway Timeout", result.getHttpReturnCodeDescription(), result.toString(true));
+ assertEquals("application/json", result.getHeader("Content-Type"), result.toString(true));
String expected = "{\"message\":\"argh!\"}";
assertEquals(expected, result.getContent().toString());
}
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/server/RestApiHandlerTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/server/RestApiHandlerTest.java
index 2826c70f40a..6363264ce3e 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/server/RestApiHandlerTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/server/RestApiHandlerTest.java
@@ -2,16 +2,16 @@
package com.yahoo.vespa.clustercontroller.utils.staterestapi.server;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InvalidContentException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class RestApiHandlerTest {
@Test
- public void testParsingOfTimeout() throws InvalidContentException {
+ void testParsingOfTimeout() throws InvalidContentException {
assertEquals(Optional.empty(), RestApiHandler.parseTimeout(null));
assertEquals(Optional.of(Duration.ofMillis(12500)), RestApiHandler.parseTimeout("12.5"));
assertEquals(Optional.of(Duration.ofMillis(0)), RestApiHandler.parseTimeout("-1"));
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/CertainlyCloneableTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/CertainlyCloneableTest.java
index f81c4ba7a96..e14562d42c0 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/CertainlyCloneableTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/CertainlyCloneableTest.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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;
public class CertainlyCloneableTest {
@@ -15,8 +15,8 @@ public class CertainlyCloneableTest {
}
@Test
- public void testSimple() {
- try{
+ void testSimple() {
+ try {
Foo f = new Foo();
f.clone();
fail("Control should not get here");
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/ClockTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/ClockTest.java
index ef338d35eb3..c791723615c 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/ClockTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/ClockTest.java
@@ -1,14 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClockTest {
@Test
- public void testNothingButGetCoverage() {
+ void testNothingButGetCoverage() {
long s = new Clock().getTimeInSecs();
long ms = new Clock().getTimeInMillis();
assertTrue(ms >= 1000 * s);
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/JSONObjectWrapperTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/JSONObjectWrapperTest.java
index a5f57510194..f09907e7fcd 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/JSONObjectWrapperTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/JSONObjectWrapperTest.java
@@ -1,16 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JSONObjectWrapperTest {
@Test
- public void testExceptionWrapping() {
+ void testExceptionWrapping() {
JSONObjectWrapper wrapper = new JSONObjectWrapper();
- try{
+ try {
wrapper.put(null, "foo");
} catch (NullPointerException e) {
assertEquals("Null key.", e.getMessage());
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/MetricReporterTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/MetricReporterTest.java
index b29de4c972c..33164aaf53e 100644
--- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/MetricReporterTest.java
+++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/util/MetricReporterTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.TreeMap;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class MetricReporterTest {
@@ -31,10 +31,10 @@ public class MetricReporterTest {
sb.append(" )\n");
return new Context() {};
}
- };
+ }
@Test
- public void testNoMetricReporter() {
+ void testNoMetricReporter() {
NoMetricReporter reporter = new NoMetricReporter();
reporter.add("foo", 3, null);
reporter.set("foo", 3, null);
@@ -42,7 +42,7 @@ public class MetricReporterTest {
}
@Test
- public void testPrefix() {
+ void testPrefix() {
MetricReporterMock mock = new MetricReporterMock();
ComponentMetricReporter c = new ComponentMetricReporter(mock, "prefix");
c.addDimension("urk", "fy");
@@ -50,14 +50,14 @@ public class MetricReporterTest {
c.set("bar", 1);
assertEquals(
"createContext( )\n" +
- "createContext( urk=fy )\n" +
- "add(prefixfoo, 2)\n" +
- "set(prefixbar, 1)\n", mock.sb.toString());
+ "createContext( urk=fy )\n" +
+ "add(prefixfoo, 2)\n" +
+ "set(prefixbar, 1)\n", mock.sb.toString());
}
@Test
- public void testWithContext() {
+ void testWithContext() {
MetricReporterMock mock = new MetricReporterMock();
ComponentMetricReporter c = new ComponentMetricReporter(mock, "prefix");
c.addDimension("urk", "fy");
@@ -67,27 +67,27 @@ public class MetricReporterTest {
c.set("bar", 1, c.createContext(myContext));
assertEquals(
"createContext( )\n" +
- "createContext( urk=fy )\n" +
- "createContext( myvar=3 urk=fy )\n" +
- "add(prefixfoo, 2)\n" +
- "createContext( myvar=3 urk=fy )\n" +
- "set(prefixbar, 1)\n", mock.sb.toString());
+ "createContext( urk=fy )\n" +
+ "createContext( myvar=3 urk=fy )\n" +
+ "add(prefixfoo, 2)\n" +
+ "createContext( myvar=3 urk=fy )\n" +
+ "set(prefixbar, 1)\n", mock.sb.toString());
}
@Test
- public void testDefaultContext() {
+ void testDefaultContext() {
MetricReporterMock mock = new MetricReporterMock();
ComponentMetricReporter c = new ComponentMetricReporter(mock, "prefix");
c.addDimension("urk", "fy");
c.add("foo", 2, c.createContext(null));
assertEquals(
"createContext( )\n" +
- "createContext( urk=fy )\n" +
- "add(prefixfoo, 2)\n", mock.sb.toString());
+ "createContext( urk=fy )\n" +
+ "add(prefixfoo, 2)\n", mock.sb.toString());
}
@Test
- public void testContextOverlap() {
+ void testContextOverlap() {
MetricReporterMock mock = new MetricReporterMock();
ComponentMetricReporter c = new ComponentMetricReporter(mock, "prefix");
c.addDimension("urk", "fy");
@@ -96,9 +96,9 @@ public class MetricReporterTest {
c.add("foo", 2, c.createContext(myContext));
assertEquals(
"createContext( )\n" +
- "createContext( urk=fy )\n" +
- "createContext( urk=yes )\n" +
- "add(prefixfoo, 2)\n", mock.sb.toString());
+ "createContext( urk=fy )\n" +
+ "createContext( urk=yes )\n" +
+ "add(prefixfoo, 2)\n", mock.sb.toString());
}
}
diff --git a/component/pom.xml b/component/pom.xml
index a4330957069..e8cee594066 100755
--- a/component/pom.xml
+++ b/component/pom.xml
@@ -16,11 +16,6 @@
<version>8-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>config-bundle</artifactId>
<version>${project.version}</version>
@@ -39,6 +34,16 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
diff --git a/component/src/test/java/com/yahoo/component/VersionCompatibilityTest.java b/component/src/test/java/com/yahoo/component/VersionCompatibilityTest.java
index c4f0e0f7439..45c94591b11 100644
--- a/component/src/test/java/com/yahoo/component/VersionCompatibilityTest.java
+++ b/component/src/test/java/com/yahoo/component/VersionCompatibilityTest.java
@@ -1,14 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.component;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Locale;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author jonmv
@@ -16,7 +16,7 @@ import static org.junit.Assert.fail;
public class VersionCompatibilityTest {
@Test
- public void testNoIncompatibilities() {
+ void testNoIncompatibilities() {
List<String> versions = List.of();
VersionCompatibility compatibility = VersionCompatibility.fromVersionList(versions);
assertTrue(compatibility.accept(new Version(0, 0, 0), new Version(0, 0, 0)));
@@ -26,36 +26,36 @@ public class VersionCompatibilityTest {
}
@Test
- public void testValidIncompatibilities() {
+ void testValidIncompatibilities() {
List<String> versions = List.of("1.2.*", "2", "3.*", "4.0.0", "4.0.1", "4.0.3", "4.1.0", "5");
VersionCompatibility compatibility = VersionCompatibility.fromVersionList(versions);
- assertTrue (compatibility.accept(new Version(0, 0, 0), new Version(0, 0, 0)));
- assertTrue (compatibility.accept(new Version(0, 0, 0), new Version(1, 1, 1)));
+ assertTrue(compatibility.accept(new Version(0, 0, 0), new Version(0, 0, 0)));
+ assertTrue(compatibility.accept(new Version(0, 0, 0), new Version(1, 1, 1)));
assertFalse(compatibility.accept(new Version(0, 0, 0), new Version(1, 2, 3)));
assertFalse(compatibility.accept(new Version(1, 1, 0), new Version(1, 2, 0)));
assertFalse(compatibility.accept(new Version(1, 2, 1), new Version(1, 2, 0)));
assertFalse(compatibility.accept(new Version(1, 1, 0), new Version(1, 3, 0)));
- assertTrue (compatibility.accept(new Version(1, 2, 3), new Version(1, 2, 3)));
- assertTrue (compatibility.accept(new Version(1, 3, 0), new Version(1, 9, 9)));
+ assertTrue(compatibility.accept(new Version(1, 2, 3), new Version(1, 2, 3)));
+ assertTrue(compatibility.accept(new Version(1, 3, 0), new Version(1, 9, 9)));
assertFalse(compatibility.accept(new Version(1, 3, 0), new Version(2, 0, 0)));
- assertTrue (compatibility.accept(new Version(2, 0, 0), new Version(2, 2, 2)));
+ assertTrue(compatibility.accept(new Version(2, 0, 0), new Version(2, 2, 2)));
assertFalse(compatibility.accept(new Version(2, 0, 0), new Version(3, 0, 0)));
- assertTrue (compatibility.accept(new Version(3, 0, 0), new Version(3, 0, 0)));
+ assertTrue(compatibility.accept(new Version(3, 0, 0), new Version(3, 0, 0)));
assertFalse(compatibility.accept(new Version(3, 0, 0), new Version(3, 1, 0)));
- assertTrue (compatibility.accept(new Version(3, 0, 0), new Version(3, 0, 1)));
+ assertTrue(compatibility.accept(new Version(3, 0, 0), new Version(3, 0, 1)));
assertFalse(compatibility.accept(new Version(3, 0, 0), new Version(4, 0, 0)));
assertFalse(compatibility.accept(new Version(4, 0, 0), new Version(4, 0, 1)));
- assertTrue (compatibility.accept(new Version(4, 0, 1), new Version(4, 0, 2)));
+ assertTrue(compatibility.accept(new Version(4, 0, 1), new Version(4, 0, 2)));
assertFalse(compatibility.accept(new Version(4, 0, 2), new Version(4, 0, 3)));
assertFalse(compatibility.accept(new Version(4, 0, 3), new Version(4, 1, 0)));
assertFalse(compatibility.accept(new Version(4, 1, 0), new Version(5, 0, 0)));
- assertTrue (compatibility.accept(new Version(5, 0, 0), new Version(6, 0, 0)));
+ assertTrue(compatibility.accept(new Version(5, 0, 0), new Version(6, 0, 0)));
assertFalse(compatibility.accept(new Version(0, 0, 0), new Version(2, 0, 0)));
assertFalse(compatibility.accept(new Version(0, 0, 0), new Version(6, 0, 0)));
}
@Test
- public void testIllegalIncompatibilities() {
+ void testIllegalIncompatibilities() {
assertThrows(List.of("1", "*"), IllegalArgumentException.class, "may not have siblings");
assertThrows(List.of("*", "*.*"), IllegalArgumentException.class, "may not have siblings");
assertThrows(List.of("*", "*"), IllegalArgumentException.class, "may not have siblings");
diff --git a/component/src/test/java/com/yahoo/component/VersionSpecificationTestCase.java b/component/src/test/java/com/yahoo/component/VersionSpecificationTestCase.java
index 7b419f0fc5d..cb4b07f1b33 100644
--- a/component/src/test/java/com/yahoo/component/VersionSpecificationTestCase.java
+++ b/component/src/test/java/com/yahoo/component/VersionSpecificationTestCase.java
@@ -1,11 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.component;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -13,74 +15,74 @@ import static org.junit.Assert.assertTrue;
public class VersionSpecificationTestCase {
@Test
- public void testPrimitiveCreation() {
- VersionSpecification version=new VersionSpecification(1,2,3,"qualifier");
- assertEquals(1, (int)version.getSpecifiedMajor());
- assertEquals(2, (int)version.getSpecifiedMinor());
- assertEquals(3, (int)version.getSpecifiedMicro());
- assertEquals("qualifier",version.getSpecifiedQualifier());
+ void testPrimitiveCreation() {
+ VersionSpecification version = new VersionSpecification(1, 2, 3, "qualifier");
+ assertEquals(1, (int) version.getSpecifiedMajor());
+ assertEquals(2, (int) version.getSpecifiedMinor());
+ assertEquals(3, (int) version.getSpecifiedMicro());
+ assertEquals("qualifier", version.getSpecifiedQualifier());
assertEquals(1, version.getMajor());
assertEquals(2, version.getMinor());
assertEquals(3, version.getMicro());
- assertEquals("qualifier",version.getQualifier());
+ assertEquals("qualifier", version.getQualifier());
}
@Test
- public void testUnderspecifiedPrimitiveCreation() {
- VersionSpecification version=new VersionSpecification(1);
- assertEquals(1,(int)version.getSpecifiedMajor());
- assertEquals(null,version.getSpecifiedMinor());
- assertEquals(null,version.getSpecifiedMicro());
- assertEquals(null,version.getSpecifiedQualifier());
+ void testUnderspecifiedPrimitiveCreation() {
+ VersionSpecification version = new VersionSpecification(1);
+ assertEquals(1, (int) version.getSpecifiedMajor());
+ assertNull(version.getSpecifiedMinor());
+ assertNull(version.getSpecifiedMicro());
+ assertNull(version.getSpecifiedQualifier());
assertEquals(1, version.getMajor());
assertEquals(0, version.getMinor());
assertEquals(0, version.getMicro());
- assertEquals("",version.getQualifier());
+ assertEquals("", version.getQualifier());
}
@Test
- public void testStringCreation() {
- VersionSpecification version=new VersionSpecification("1.2.3.qualifier");
- assertEquals(1,(int)version.getSpecifiedMajor());
- assertEquals(2,(int)version.getSpecifiedMinor());
- assertEquals(3,(int)version.getSpecifiedMicro());
- assertEquals("qualifier",version.getSpecifiedQualifier());
+ void testStringCreation() {
+ VersionSpecification version = new VersionSpecification("1.2.3.qualifier");
+ assertEquals(1, (int) version.getSpecifiedMajor());
+ assertEquals(2, (int) version.getSpecifiedMinor());
+ assertEquals(3, (int) version.getSpecifiedMicro());
+ assertEquals("qualifier", version.getSpecifiedQualifier());
}
@Test
- public void testUnderspecifiedStringCreation() {
- VersionSpecification version=new VersionSpecification("1");
- assertEquals(1,(int)version.getSpecifiedMajor());
- assertEquals(null,version.getSpecifiedMinor());
- assertEquals(null,version.getSpecifiedMicro());
- assertEquals(null,version.getSpecifiedQualifier());
+ void testUnderspecifiedStringCreation() {
+ VersionSpecification version = new VersionSpecification("1");
+ assertEquals(1, (int) version.getSpecifiedMajor());
+ assertNull(version.getSpecifiedMinor());
+ assertNull(version.getSpecifiedMicro());
+ assertNull(version.getSpecifiedQualifier());
assertEquals(1, version.getMajor());
assertEquals(0, version.getMinor());
assertEquals(0, version.getMicro());
- assertEquals("",version.getQualifier());
+ assertEquals("", version.getQualifier());
}
@Test
- public void testEquality() {
- assertEquals(new VersionSpecification(),VersionSpecification.emptyVersionSpecification);
- assertEquals(new VersionSpecification(),new VersionSpecification(""));
- assertEquals(new VersionSpecification(1),new VersionSpecification("1"));
- assertEquals(new VersionSpecification(1,2),new VersionSpecification("1.2"));
- assertEquals(new VersionSpecification(1,2,3),new VersionSpecification("1.2.3"));
- assertEquals(new VersionSpecification(1,2,3,"qualifier"),new VersionSpecification("1.2.3.qualifier"));
+ void testEquality() {
+ assertEquals(new VersionSpecification(), VersionSpecification.emptyVersionSpecification);
+ assertEquals(new VersionSpecification(), new VersionSpecification(""));
+ assertEquals(new VersionSpecification(1), new VersionSpecification("1"));
+ assertEquals(new VersionSpecification(1, 2), new VersionSpecification("1.2"));
+ assertEquals(new VersionSpecification(1, 2, 3), new VersionSpecification("1.2.3"));
+ assertEquals(new VersionSpecification(1, 2, 3, "qualifier"), new VersionSpecification("1.2.3.qualifier"));
}
@Test
- public void testToString() {
- assertEquals("",new VersionSpecification().toString());
- assertEquals("1",new VersionSpecification(1).toString());
- assertEquals("1.2",new VersionSpecification(1,2).toString());
- assertEquals("1.2.3",new VersionSpecification(1,2,3).toString());
- assertEquals("1.2.3.qualifier",new VersionSpecification(1,2,3,"qualifier").toString());
+ void testToString() {
+ assertEquals("", new VersionSpecification().toString());
+ assertEquals("1", new VersionSpecification(1).toString());
+ assertEquals("1.2", new VersionSpecification(1, 2).toString());
+ assertEquals("1.2.3", new VersionSpecification(1, 2, 3).toString());
+ assertEquals("1.2.3.qualifier", new VersionSpecification(1, 2, 3, "qualifier").toString());
}
@Test
- public void testMatches() {
+ void testMatches() {
assertTrue(new VersionSpecification("").matches(new Version("1")));
assertTrue(new VersionSpecification("1").matches(new Version("1")));
assertFalse(new VersionSpecification("1").matches(new Version("2")));
@@ -112,19 +114,19 @@ public class VersionSpecificationTestCase {
}
@Test
- public void testOrder() {
- assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.2.3"))==0);
- assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.2.4"))<0);
- assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.2.2"))>0);
+ void testOrder() {
+ assertEquals(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.2.3")), 0);
+ assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.2.4")) < 0);
+ assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.2.2")) > 0);
- assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("2"))<0);
- assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.3"))<0);
+ assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("2")) < 0);
+ assertTrue(new VersionSpecification("1.2.3").compareTo(new VersionSpecification("1.3")) < 0);
- assertTrue(new VersionSpecification("1.0.0").compareTo(new VersionSpecification("1"))==0);
+ assertEquals(new VersionSpecification("1.0.0").compareTo(new VersionSpecification("1")), 0);
}
@Test
- public void testValidIntersect() {
+ void testValidIntersect() {
VersionSpecification mostSpecific = new VersionSpecification(4, 2, 1);
VersionSpecification leastSpecific = new VersionSpecification(4, 2);
@@ -134,9 +136,11 @@ public class VersionSpecificationTestCase {
leastSpecific.intersect(mostSpecific));
}
- @Test(expected=RuntimeException.class)
- public void testInvalidIntersect() {
- new VersionSpecification(4, 1).intersect(
- new VersionSpecification(4, 2));
+ @Test
+ void testInvalidIntersect() {
+ assertThrows(RuntimeException.class, () -> {
+ new VersionSpecification(4, 1).intersect(
+ new VersionSpecification(4, 2));
+ });
}
}
diff --git a/component/src/test/java/com/yahoo/component/VersionTestCase.java b/component/src/test/java/com/yahoo/component/VersionTestCase.java
index f66bc245f85..96adb6ce38f 100644
--- a/component/src/test/java/com/yahoo/component/VersionTestCase.java
+++ b/component/src/test/java/com/yahoo/component/VersionTestCase.java
@@ -3,11 +3,11 @@ package com.yahoo.component;
import com.yahoo.text.Utf8Array;
import com.yahoo.text.Utf8String;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -15,111 +15,111 @@ import static org.junit.Assert.assertTrue;
public class VersionTestCase {
@Test
- public void testPrimitiveCreation() {
- Version version=new Version(1,2,3,"qualifier");
- assertEquals(1,version.getMajor());
- assertEquals(2,version.getMinor());
- assertEquals(3,version.getMicro());
- assertEquals("qualifier",version.getQualifier());
+ void testPrimitiveCreation() {
+ Version version = new Version(1, 2, 3, "qualifier");
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getMicro());
+ assertEquals("qualifier", version.getQualifier());
}
@Test
- public void testUnderspecifiedPrimitiveCreation() {
- Version version=new Version(1);
- assertEquals(1,version.getMajor());
- assertEquals(1,version.getMajor());
- assertEquals(0,version.getMinor());
- assertEquals(0,version.getMicro());
- assertEquals("",version.getQualifier());
+ void testUnderspecifiedPrimitiveCreation() {
+ Version version = new Version(1);
+ assertEquals(1, version.getMajor());
+ assertEquals(1, version.getMajor());
+ assertEquals(0, version.getMinor());
+ assertEquals(0, version.getMicro());
+ assertEquals("", version.getQualifier());
}
@Test
- public void testStringCreation() {
- Version version=new Version("1.2.3.qualifier");
- assertEquals(1,version.getMajor());
- assertEquals(2,version.getMinor());
- assertEquals(3,version.getMicro());
- assertEquals("qualifier",version.getQualifier());
+ void testStringCreation() {
+ Version version = new Version("1.2.3.qualifier");
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getMicro());
+ assertEquals("qualifier", version.getQualifier());
}
@Test
- public void testUtf8StringCreation() {
- Version version=new Version((Utf8Array)new Utf8String("1.2.3.qualifier"));
- assertEquals(1,version.getMajor());
- assertEquals(2,version.getMinor());
- assertEquals(3,version.getMicro());
- assertEquals("qualifier",version.getQualifier());
+ void testUtf8StringCreation() {
+ Version version = new Version((Utf8Array) new Utf8String("1.2.3.qualifier"));
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getMicro());
+ assertEquals("qualifier", version.getQualifier());
}
@Test
- public void testUnderspecifiedStringCreation() {
- Version version=new Version("1");
- assertEquals(1,version.getMajor());
- assertEquals(0,version.getMinor());
- assertEquals(0,version.getMicro());
- assertEquals("",version.getQualifier());
+ void testUnderspecifiedStringCreation() {
+ Version version = new Version("1");
+ assertEquals(1, version.getMajor());
+ assertEquals(0, version.getMinor());
+ assertEquals(0, version.getMicro());
+ assertEquals("", version.getQualifier());
}
@Test
- public void testEquality() {
- assertEquals(new Version(),Version.emptyVersion);
- assertEquals(new Version(),new Version(""));
- assertEquals(new Version(0,0,0),Version.emptyVersion);
- assertEquals(new Version(1),new Version("1"));
- assertEquals(new Version(1,2),new Version("1.2"));
- assertEquals(new Version(1,2,3),new Version("1.2.3"));
- assertEquals(new Version(1,2,3,"qualifier"),new Version("1.2.3.qualifier"));
+ void testEquality() {
+ assertEquals(new Version(), Version.emptyVersion);
+ assertEquals(new Version(), new Version(""));
+ assertEquals(new Version(0, 0, 0), Version.emptyVersion);
+ assertEquals(new Version(1), new Version("1"));
+ assertEquals(new Version(1, 2), new Version("1.2"));
+ assertEquals(new Version(1, 2, 3), new Version("1.2.3"));
+ assertEquals(new Version(1, 2, 3, "qualifier"), new Version("1.2.3.qualifier"));
}
@Test
- public void testToString() {
- assertEquals("",new Version().toString());
- assertEquals("1",new Version(1).toString());
- assertEquals("1.2",new Version(1,2).toString());
- assertEquals("1.2.3",new Version(1,2,3).toString());
- assertEquals("1.2.3.qualifier",new Version(1,2,3,"qualifier").toString());
+ void testToString() {
+ assertEquals("", new Version().toString());
+ assertEquals("1", new Version(1).toString());
+ assertEquals("1.2", new Version(1, 2).toString());
+ assertEquals("1.2.3", new Version(1, 2, 3).toString());
+ assertEquals("1.2.3.qualifier", new Version(1, 2, 3, "qualifier").toString());
}
@Test
- public void testToFullString() {
- assertEquals("0.0.0",new Version().toFullString());
- assertEquals("1.0.0",new Version(1).toFullString());
- assertEquals("1.2.0",new Version(1,2).toFullString());
- assertEquals("1.2.3",new Version(1,2,3).toFullString());
- assertEquals("1.2.3.qualifier",new Version(1,2,3,"qualifier").toFullString());
+ void testToFullString() {
+ assertEquals("0.0.0", new Version().toFullString());
+ assertEquals("1.0.0", new Version(1).toFullString());
+ assertEquals("1.2.0", new Version(1, 2).toFullString());
+ assertEquals("1.2.3", new Version(1, 2, 3).toFullString());
+ assertEquals("1.2.3.qualifier", new Version(1, 2, 3, "qualifier").toFullString());
}
@Test
- public void testOrder() {
- assertTrue(new Version("1.2.3").compareTo(new Version("1.2.3"))==0);
- assertTrue(new Version("1.2.3").compareTo(new Version("1.2.4"))<0);
- assertTrue(new Version("1.2.3").compareTo(new Version("1.2.3.foo"))<0);
- assertTrue(new Version("1.2.3").compareTo(new Version("1.2.2"))>0);
- assertTrue(new Version("1.2.3.foo").compareTo(new Version("1.2.3"))>0);
- assertTrue(new Version("1.2.3").compareTo(new Version("2"))<0);
- assertTrue(new Version("1.2.3").compareTo(new Version("1.3"))<0);
- assertTrue(new Version("1.0.0").compareTo(new Version("1"))==0);
+ void testOrder() {
+ assertEquals(new Version("1.2.3").compareTo(new Version("1.2.3")), 0);
+ assertTrue(new Version("1.2.3").compareTo(new Version("1.2.4")) < 0);
+ assertTrue(new Version("1.2.3").compareTo(new Version("1.2.3.foo")) < 0);
+ assertTrue(new Version("1.2.3").compareTo(new Version("1.2.2")) > 0);
+ assertTrue(new Version("1.2.3.foo").compareTo(new Version("1.2.3")) > 0);
+ assertTrue(new Version("1.2.3").compareTo(new Version("2")) < 0);
+ assertTrue(new Version("1.2.3").compareTo(new Version("1.3")) < 0);
+ assertEquals(new Version("1.0.0").compareTo(new Version("1")), 0);
}
-
+
@Test
- public void testIsBefore() {
+ void testIsBefore() {
assertFalse(new Version("1.2.3").isBefore(new Version("0.2.3")));
assertFalse(new Version("1.2.3").isBefore(new Version("1.1.3")));
assertFalse(new Version("1.2.3").isBefore(new Version("1.2.2")));
assertFalse(new Version("1.2.3").isBefore(new Version("1.2.3")));
assertFalse(new Version("1.2.3.foo").isBefore(new Version("1.2.3")));
- assertTrue( new Version("1.2.3").isBefore(new Version("1.2.4")));
- assertTrue( new Version("1.2.3").isBefore(new Version("1.3.3")));
- assertTrue( new Version("1.2.3").isBefore(new Version("2.2.3")));
- assertTrue( new Version("1.2.3").isBefore(new Version("1.2.3.foo")));
+ assertTrue(new Version("1.2.3").isBefore(new Version("1.2.4")));
+ assertTrue(new Version("1.2.3").isBefore(new Version("1.3.3")));
+ assertTrue(new Version("1.2.3").isBefore(new Version("2.2.3")));
+ assertTrue(new Version("1.2.3").isBefore(new Version("1.2.3.foo")));
}
@Test
- public void testIsAfter() {
- assertTrue( new Version("1.2.3").isAfter(new Version("0.2.3")));
- assertTrue( new Version("1.2.3").isAfter(new Version("1.1.3")));
- assertTrue( new Version("1.2.3").isAfter(new Version("1.2.2")));
- assertTrue( new Version("1.2.3.foo").isAfter(new Version("1.2.3")));
+ void testIsAfter() {
+ assertTrue(new Version("1.2.3").isAfter(new Version("0.2.3")));
+ assertTrue(new Version("1.2.3").isAfter(new Version("1.1.3")));
+ assertTrue(new Version("1.2.3").isAfter(new Version("1.2.2")));
+ assertTrue(new Version("1.2.3.foo").isAfter(new Version("1.2.3")));
assertFalse(new Version("1.2.3").isAfter(new Version("1.2.3")));
assertFalse(new Version("1.2.3").isAfter(new Version("1.2.4")));
assertFalse(new Version("1.2.3").isAfter(new Version("1.3.3")));
diff --git a/config-lib/pom.xml b/config-lib/pom.xml
index ea72afb568d..66603deeb38 100644
--- a/config-lib/pom.xml
+++ b/config-lib/pom.xml
@@ -17,11 +17,6 @@
<name>${project.artifactId}</name>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>annotations</artifactId>
<version>${project.version}</version>
@@ -33,6 +28,16 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java b/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java
index bfa2f747c1c..50d71ba50e9 100644
--- a/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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 Ulf Lilleengen
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue;
*/
public class BooleanNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
BooleanNode n = new BooleanNode();
assertTrue(n.doSetValue("true"));
assertTrue(n.doSetValue("TRUE"));
diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
index 613cfe1cced..f05baeff08c 100644
--- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
@@ -6,7 +6,7 @@ import com.yahoo.foo.StructtypesConfig;
import com.yahoo.test.FunctionTestConfig;
import com.yahoo.test.IntConfig;
import com.yahoo.test.RestartConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.lang.reflect.Field;
@@ -26,11 +26,11 @@ import static com.yahoo.test.FunctionTestConfig.RootStruct;
import static com.yahoo.test.FunctionTestConfig.MyStructMap;
import static com.yahoo.foo.MaptypesConfig.Innermap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author gjoranv
@@ -40,7 +40,7 @@ public class ConfigInstanceBuilderTest
{
@Test
- public void struct_values_can_be_set_without_declaring_a_new_struct_builder() {
+ void struct_values_can_be_set_without_declaring_a_new_struct_builder() {
var builder = new StructtypesConfig.Builder();
builder.simple
.name("myname")
@@ -52,7 +52,7 @@ public class ConfigInstanceBuilderTest
}
@Test
- public void leaf_map_setter_merges_maps() {
+ void leaf_map_setter_merges_maps() {
MaptypesConfig.Builder builder = new MaptypesConfig.Builder()
.intmap("one", 1);
@@ -66,10 +66,10 @@ public class ConfigInstanceBuilderTest
}
@Test
- public void inner_map_setter_merges_maps() {
+ void inner_map_setter_merges_maps() {
MaptypesConfig.Builder builder = new MaptypesConfig.Builder()
.innermap("one", new Innermap.Builder()
- .foo(1));
+ .foo(1));
Map<String, Innermap.Builder> newMap = new HashMap<>();
newMap.put("two", new Innermap.Builder().foo(2));
@@ -81,13 +81,13 @@ public class ConfigInstanceBuilderTest
}
@Test
- public void testVariableAccessWithBuilder() {
+ void testVariableAccessWithBuilder() {
FunctionTestConfig config = createVariableAccessConfigWithBuilder();
assertVariableAccessValues(config, ":parent:");
}
@Test
- public void require_that_unset_builder_fields_are_null() throws Exception {
+ void require_that_unset_builder_fields_are_null() throws Exception {
FunctionTestConfig.Builder builder = new FunctionTestConfig.Builder();
assertNull(getMember(builder, "bool_val"));
assertNull(getMember(builder, "bool_with_def"));
@@ -111,7 +111,7 @@ public class ConfigInstanceBuilderTest
}
@Test
- public void require_that_set_builder_fields_are_nonNull() throws Exception {
+ void require_that_set_builder_fields_are_nonNull() throws Exception {
FunctionTestConfig.Builder builder = createVariableAccessBuilder();
assertNotNull(getMember(builder, "bool_val"));
assertNotNull(getMember(builder, "bool_with_def"));
@@ -129,13 +129,13 @@ public class ConfigInstanceBuilderTest
assertNotNull(getMember(builder, "refwithdef"));
assertNotNull(getMember(builder, "fileVal"));
- BasicStruct.Builder basicStructBuilder = (BasicStruct.Builder)getMember(builder, "basicStruct");
+ BasicStruct.Builder basicStructBuilder = (BasicStruct.Builder) getMember(builder, "basicStruct");
assertNotNull(getMember(basicStructBuilder, "foo"));
assertNotNull(getMember(basicStructBuilder, "bar"));
}
@Test
- public void require_that_config_can_be_recreated_from_another_configs_builder() {
+ void require_that_config_can_be_recreated_from_another_configs_builder() {
FunctionTestConfig original = createVariableAccessConfigWithBuilder();
FunctionTestConfig copy = new FunctionTestConfig(new FunctionTestConfig.Builder(original));
assertVariableAccessValues(copy, ":parent:");
@@ -330,13 +330,13 @@ public class ConfigInstanceBuilderTest
}
@Test
- public void require_that_config_class_reports_any_restart_values() throws Exception {
+ void require_that_config_class_reports_any_restart_values() throws Exception {
assertTrue(callContainsFieldsFlaggedWithRestart(RestartConfig.class));
assertFalse(callContainsFieldsFlaggedWithRestart(IntConfig.class));
}
@Test
- public void require_that_config_class_can_make_change_report() throws Exception {
+ void require_that_config_class_can_make_change_report() throws Exception {
IntConfig noRestart1 = new IntConfig(new IntConfig.Builder().intVal(42));
IntConfig noRestart2 = new IntConfig(new IntConfig.Builder().intVal(21));
ChangesRequiringRestart report = callGetChangesRequiringRestart(noRestart1, noRestart2);
@@ -370,33 +370,33 @@ public class ConfigInstanceBuilderTest
assertEquals("function-test", report.getName());
assertTrue(
report.toString().startsWith(
- "# An int value\n" +
- "# Also test that multiline comments\n" +
- "# work.\n" +
- "function-test.int_val has changed from 5 to 100\n" +
- "function-test.stringarr[0] has changed from \"bar\" to \"foo\"\n" +
- "# This is a map of ints.\n" +
- "function-test.intMap{one} has changed from 1 to 42\n" +
- "# This is a map of ints.\n" +
- "function-test.intMap{two} with value 2 was removed\n" +
- "# This is a map of ints.\n" +
- "function-test.intMap{three} was added with value 3\n" +
- "# A basic struct\n" +
- "function-test.basicStruct.foo has changed from \"basicFoo\" to \"basic\"\n" +
- "function-test.basicStruct.bar has changed from 3 to 1234\n" +
- "function-test.basicStruct.intArr[0] with value 310 was removed\n" +
- "function-test.basicStruct.intArr[1] with value 311 was removed\n" +
- "function-test.myarray[0].anotherarray[0].foo has changed from 7 to 32\n" +
- "# This is my array\n" +
- "function-test.myarray[1].intval has changed from 5 to 17\n" +
- "function-test.myarray[2] was added with value \n"
+ "# An int value\n" +
+ "# Also test that multiline comments\n" +
+ "# work.\n" +
+ "function-test.int_val has changed from 5 to 100\n" +
+ "function-test.stringarr[0] has changed from \"bar\" to \"foo\"\n" +
+ "# This is a map of ints.\n" +
+ "function-test.intMap{one} has changed from 1 to 42\n" +
+ "# This is a map of ints.\n" +
+ "function-test.intMap{two} with value 2 was removed\n" +
+ "# This is a map of ints.\n" +
+ "function-test.intMap{three} was added with value 3\n" +
+ "# A basic struct\n" +
+ "function-test.basicStruct.foo has changed from \"basicFoo\" to \"basic\"\n" +
+ "function-test.basicStruct.bar has changed from 3 to 1234\n" +
+ "function-test.basicStruct.intArr[0] with value 310 was removed\n" +
+ "function-test.basicStruct.intArr[1] with value 311 was removed\n" +
+ "function-test.myarray[0].anotherarray[0].foo has changed from 7 to 32\n" +
+ "# This is my array\n" +
+ "function-test.myarray[1].intval has changed from 5 to 17\n" +
+ "function-test.myarray[2] was added with value \n"
)
);
assertTrue(
report.toString().contains(
- "function-test.myStructMap{one}.myInt has changed from 1 to 42\n" +
- "function-test.myStructMap{new} was added with value \n"
+ "function-test.myStructMap{one}.myInt has changed from 1 to 42\n" +
+ "function-test.myStructMap{new} was added with value \n"
)
);
diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
index 536c18786da..1584293a137 100644
--- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
@@ -3,8 +3,8 @@ package com.yahoo.config;
import com.yahoo.test.AppConfig;
import com.yahoo.test.FunctionTestConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.Arrays;
@@ -14,15 +14,15 @@ import static com.yahoo.test.FunctionTestConfig.Enum_val;
import static com.yahoo.test.FunctionTestConfig.Enumarr;
import static com.yahoo.test.FunctionTestConfig.Myarray;
import static com.yahoo.test.FunctionTestConfig.RootStruct;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class ConfigInstanceEqualsTest {
FunctionTestConfig config1;
FunctionTestConfig.Builder builder2;
FunctionTestConfig config2;
- @Before
+ @BeforeEach
public void reset() {
config1 = new FunctionTestConfig(newBuilder());
builder2 = newBuilder();
@@ -30,28 +30,28 @@ public class ConfigInstanceEqualsTest {
}
@Test
- public void require_same_hashCode_for_equal_instances() {
+ void require_same_hashCode_for_equal_instances() {
assertEquals(config1.hashCode(), config2.hashCode());
}
@Test
- public void require_true_for_equal_instances() {
+ void require_true_for_equal_instances() {
assertEquals(config1, config2);
}
@Test
- public void require_false_for_null() {
+ void require_false_for_null() {
assertNotEquals(null, config1);
}
@Test
- public void require_false_for_different_subclass() {
+ void require_false_for_different_subclass() {
assertNotEquals(config1, new AppConfig(new AppConfig.Builder()));
}
@Test
- public void require_false_for_different_scalars_at_root_node() {
+ void require_false_for_different_scalars_at_root_node() {
assertNotEquals(config1, new FunctionTestConfig(newBuilder().bool_val(true)));
assertNotEquals(config1, new FunctionTestConfig(newBuilder().int_val(0)));
assertNotEquals(config1, new FunctionTestConfig(newBuilder().long_val(0L)));
@@ -63,50 +63,50 @@ public class ConfigInstanceEqualsTest {
}
@Test
- public void require_false_for_different_leaf_array_at_root_node() {
+ void require_false_for_different_leaf_array_at_root_node() {
builder2.longarr.set(0, 0L);
assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
- public void require_false_for_different_scalar_in_struct() {
+ void require_false_for_different_scalar_in_struct() {
builder2.basicStruct(new BasicStruct.Builder(config1.basicStruct()).bar(0));
assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
- public void require_false_for_different_scalar_in_inner_array() {
+ void require_false_for_different_scalar_in_inner_array() {
builder2.myarray.get(0).intval(0);
assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
- public void require_false_for_different_leaf_array_in_inner_array() {
+ void require_false_for_different_leaf_array_in_inner_array() {
builder2.myarray.get(0).stringval.set(0, "");
assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
- public void require_equal_structs_for_equal_configs() {
+ void require_equal_structs_for_equal_configs() {
assertEquals(config1.basicStruct(), config2.basicStruct());
assertEquals(config1.rootStruct(), config2.rootStruct());
assertEquals(config1.rootStruct().inner0(), config2.rootStruct().inner0());
}
@Test
- public void require_equal_inner_arrays_for_equal_configs() {
+ void require_equal_inner_arrays_for_equal_configs() {
assertEquals(config1.myarray(), config2.myarray());
assertEquals(config1.myarray(0).anotherarray(), config2.myarray(0).anotherarray());
}
@Test
- public void require_equal_inner_array_elements_for_equal_configs() {
+ void require_equal_inner_array_elements_for_equal_configs() {
assertEquals(config1.myarray(0), config2.myarray(0));
assertEquals(config1.myarray(0).anotherarray(0), config2.myarray(0).anotherarray(0));
}
@Test
- public void require_equal_leaf_arrays_for_equal_configs() {
+ void require_equal_leaf_arrays_for_equal_configs() {
assertEquals(config1.intarr(), config2.intarr());
assertEquals(config1.boolarr(), config2.boolarr());
assertEquals(config1.longarr(), config2.longarr());
diff --git a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java
index 1192cc6673e..475a33104b0 100644
--- a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
*/
public class DoubleNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
DoubleNode n = new DoubleNode();
assertFalse(n.doSetValue("invalid"));
assertTrue(n.doSetValue("3.14"));
diff --git a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
index fac765f40aa..e7723409736 100644
--- a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Ulf Lilleengen
@@ -30,7 +30,7 @@ public class EnumNodeTest {
}
@Test
- public void testEnumNode() {
+ void testEnumNode() {
MyNode n = new MyNode();
assertNull(n.getValue());
assertEquals("(null)", n.toString());
diff --git a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java
index 42e4978091d..8bec9378f8f 100644
--- a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Ulf Lilleengen
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
public class FileNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
FileNode n = new FileNode();
assertEquals("(null)", n.toString());
assertTrue(n.doSetValue("foo.txt"));
@@ -24,7 +24,7 @@ public class FileNodeTest {
assertEquals("\"foo.txt\"", n.toString());
assertEquals("path may not start with '..', but got: foo/../../boo",
- assertThrows(IllegalArgumentException.class, () -> new FileNode("foo/../../boo")).getMessage());
+ assertThrows(IllegalArgumentException.class, () -> new FileNode("foo/../../boo")).getMessage());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java
index 899e34edce4..a195a5f65fb 100644
--- a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Ulf Lilleengen
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue;
*/
public class IntegerNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
IntegerNode n = new IntegerNode();
assertFalse(n.setValue("invalid"));
assertTrue(n.setValue("10"));
diff --git a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java
index fc603ba65ac..dc6d59bbc46 100644
--- a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Ulf Lilleengen
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue;
*/
public class LongNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
LongNode n = new LongNode();
assertFalse(n.setValue("invalid"));
assertTrue(n.setValue("10"));
diff --git a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
index 9637ab25278..e6b3b4b6a71 100644
--- a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
@@ -1,13 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Ulf Lilleengen
@@ -15,38 +16,78 @@ import static org.junit.Assert.assertTrue;
*/
public class NodeVectorTest {
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_add_throws_exception() { new TestNodeVector("foo").add(barNode()); }
+ @Test
+ void require_that_add_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").add(barNode());
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_addindex_throws_exception() { new TestNodeVector("foo").add(0, barNode()); }
+ @Test
+ void require_that_addindex_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").add(0, barNode());
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_addAll_throws_exception() { new TestNodeVector("foo").addAll(Arrays.asList(barNode())); }
+ @Test
+ void require_that_addAll_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").addAll(Arrays.asList(barNode()));
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_addAllindex_throws_exception() { new TestNodeVector("foo").addAll(0, Arrays.asList(barNode())); }
+ @Test
+ void require_that_addAllindex_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").addAll(0, Arrays.asList(barNode()));
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_clear_throws_exception() { new TestNodeVector("foo").clear(); }
+ @Test
+ void require_that_clear_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").clear();
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_remove_index_throws_exception() { new TestNodeVector("foo").remove(0); }
+ @Test
+ void require_that_remove_index_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").remove(0);
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_remove_object_throws_exception() { new TestNodeVector("foo").remove(null); }
+ @Test
+ void require_that_remove_object_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").remove(null);
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_removeAll_throws_exception() { new TestNodeVector("foo").removeAll(null); }
+ @Test
+ void require_that_removeAll_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").removeAll(null);
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_retainAll_throws_exception() { new TestNodeVector("foo").retainAll(null); }
+ @Test
+ void require_that_retainAll_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").retainAll(null);
+ });
+ }
- @Test(expected = NodeVector.ReadOnlyException.class)
- public void require_that_set_throws_exception() { new TestNodeVector("foo").set(0, null); }
+ @Test
+ void require_that_set_throws_exception() {
+ assertThrows(NodeVector.ReadOnlyException.class, () -> {
+ new TestNodeVector("foo").set(0, null);
+ });
+ }
@Test
- public void require_that_contains_works() {
+ void require_that_contains_works() {
StringNode val = new StringNode("foo");
TestNodeVector v = new TestNodeVector(val.getValue());
assertTrue(v.contains(val));
@@ -56,7 +97,7 @@ public class NodeVectorTest {
}
@Test
- public void require_that_indexOf_works() {
+ void require_that_indexOf_works() {
StringNode val = new StringNode("foo");
TestNodeVector v = new TestNodeVector(val.getValue());
assertFalse(v.isEmpty());
@@ -67,7 +108,7 @@ public class NodeVectorTest {
}
@Test
- public void require_that_iterators_work() {
+ void require_that_iterators_work() {
String val = "foo";
TestNodeVector v = new TestNodeVector(val, val, val);
assertTrue(v.listIterator().hasNext());
@@ -78,7 +119,7 @@ public class NodeVectorTest {
}
@Test
- public void require_that_sublisting_works() {
+ void require_that_sublisting_works() {
String val = "foo";
TestNodeVector v = new TestNodeVector(val, val, val);
assertEquals(1, v.subList(0, 1).size());
diff --git a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java
index 016c53b42e3..ad8f5e2e65f 100644
--- a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author gjoranv
@@ -15,7 +15,7 @@ import static org.junit.Assert.assertThrows;
public class PathNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
PathNode n = new PathNode();
assertEquals("(null)", n.toString());
@@ -23,7 +23,7 @@ public class PathNodeTest {
assertEquals(new File("foo.txt").toPath(), n.value());
assertEquals("path may not start with '..', but got: foo/../../boo",
- assertThrows(IllegalArgumentException.class, () -> new PathNode(new FileReference("foo/../../boo"))).getMessage());
+ assertThrows(IllegalArgumentException.class, () -> new PathNode(new FileReference("foo/../../boo"))).getMessage());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
index 5d606e12454..d0baf8d1837 100644
--- a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
@@ -1,9 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author hmusum
@@ -12,7 +13,7 @@ import static org.junit.Assert.assertEquals;
public class StringNodeTest {
@Test
- public void testUnescapeQuotedString() {
+ void testUnescapeQuotedString() {
String a = "\"Hei\"";
assertEquals("Hei", StringNode.unescapeQuotedString(a));
assertEquals("foo\"bar\"", StringNode.unescapeQuotedString("foo\"bar\""));
@@ -21,13 +22,15 @@ public class StringNodeTest {
assertEquals("U", StringNode.unescapeQuotedString("\\x55"));
}
- @Test(expected = IllegalArgumentException.class)
- public void testUnescapedQuotedStringExceptions() {
- StringNode.unescapeQuotedString("foo\\");
+ @Test
+ void testUnescapedQuotedStringExceptions() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ StringNode.unescapeQuotedString("foo\\");
+ });
}
@Test
- public void testToString() {
+ void testToString() {
StringNode n = new StringNode();
assertEquals("(null)", n.toString());
n.setValue("foo");
@@ -35,7 +38,7 @@ public class StringNodeTest {
}
@Test
- public void testSetValue() {
+ void testSetValue() {
StringNode n = new StringNode();
n.setValue("\"foo\"");
assertEquals("foo", n.getValue());
diff --git a/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java b/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java
index abf04c34bb8..1f40cb58a71 100644
--- a/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author lesters
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
public class UrlNodeTest {
@Test
- public void testSetValue() {
+ void testSetValue() {
UrlNode url = new UrlNode();
assertEquals("(null)", url.toString());
diff --git a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
index 54e2271f7dc..39e5f64e5e2 100644
--- a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
@@ -4,9 +4,9 @@ package com.yahoo.config.codegen;
import com.github.myproject.NamespaceAndPackageConfig;
import com.github.myproject.PackageConfig;
import com.yahoo.my.namespace.NamespaceConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author gjoranv
@@ -16,17 +16,17 @@ public class NamespaceAndPackageTest {
private static String PACKAGE = "com.github.myproject";
@Test
- public void namespace_is_set_from_def_file() {
+ void namespace_is_set_from_def_file() {
assertEquals(NAMESPACE, NamespaceConfig.CONFIG_DEF_NAMESPACE);
}
@Test
- public void package_is_used_as_namespace_when_namespace_is_not_set_explicitly() {
+ void package_is_used_as_namespace_when_namespace_is_not_set_explicitly() {
assertEquals(PACKAGE, PackageConfig.CONFIG_DEF_NAMESPACE);
}
@Test
- public void package_does_not_override_namespace() {
+ void package_does_not_override_namespace() {
assertEquals(NAMESPACE, NamespaceAndPackageConfig.CONFIG_DEF_NAMESPACE);
}
diff --git a/config-proxy/pom.xml b/config-proxy/pom.xml
index b28714925ee..476f5f99b86 100644
--- a/config-proxy/pom.xml
+++ b/config-proxy/pom.xml
@@ -14,11 +14,6 @@
<version>8-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>config-lib</artifactId>
<version>${project.version}</version>
@@ -59,9 +54,19 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>compile</scope>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
index f743c0ed231..a946704234d 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
@@ -11,17 +11,17 @@ import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Target;
import com.yahoo.jrt.Transport;
import com.yahoo.vespa.config.RawConfig;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import java.io.File;
import java.io.IOException;
import java.time.Duration;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author hmusum
@@ -34,16 +34,16 @@ public class ConfigProxyRpcServerTest {
private static TestServer server;
private static TestClient client;
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
- @BeforeClass
+ @BeforeAll
public static void setup() throws ListenFailedException {
server = new TestServer();
client = new TestClient(server.listenPort());
}
- @AfterClass
+ @AfterAll
public static void teardown() {
client.close();
server.close();
@@ -55,7 +55,7 @@ public class ConfigProxyRpcServerTest {
}
@Test
- public void basic() {
+ void basic() {
ProxyServer proxy = createTestServer(new MockConfigSource());
Spec spec = new Spec("localhost", 12345);
ConfigProxyRpcServer server = new ConfigProxyRpcServer(proxy, new Supervisor(new Transport()), spec);
@@ -66,11 +66,11 @@ public class ConfigProxyRpcServerTest {
* Tests ping RPC command
*/
@Test
- public void testRpcMethodPing() {
+ void testRpcMethodPing() {
Request req = new Request("ping");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals(0, req.returnValues().get(0).asInt32());
}
@@ -79,13 +79,13 @@ public class ConfigProxyRpcServerTest {
* Tests listCachedConfig RPC command
*/
@Test
- public void testRpcMethodListCachedConfig() throws ListenFailedException {
+ void testRpcMethodListCachedConfig() throws ListenFailedException {
reset();
Request req = new Request("listCachedConfig");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(1, req.returnValues().size());
assertEquals(0, ret.length);
@@ -94,24 +94,24 @@ public class ConfigProxyRpcServerTest {
server.proxyServer().memoryCache().update(config);
req = new Request("listCachedConfig");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
ret = req.returnValues().get(0).asStringArray();
assertEquals(1, ret.length);
assertEquals(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," +
- config.getGeneration() + "," + config.getPayloadChecksums(),
- ret[0]);
+ config.getGeneration() + "," + config.getPayloadChecksums(),
+ ret[0]);
}
/**
* Tests listCachedConfig RPC command
*/
@Test
- public void testRpcMethodListCachedConfigFull() {
+ void testRpcMethodListCachedConfigFull() {
Request req = new Request("listCachedConfigFull");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(0, ret.length);
@@ -120,25 +120,25 @@ public class ConfigProxyRpcServerTest {
server.proxyServer().memoryCache().update(config);
req = new Request("listCachedConfigFull");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
ret = req.returnValues().get(0).asStringArray();
assertEquals(1, ret.length);
assertEquals(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," +
- config.getGeneration() + "," + config.getPayloadChecksums() + "," + config.getPayload().getData(),
- ret[0]);
+ config.getGeneration() + "," + config.getPayloadChecksums() + "," + config.getPayload().getData(),
+ ret[0]);
}
/**
* Tests listSourceConnections RPC command
*/
@Test
- public void testRpcMethodListSourceConnections() throws ListenFailedException {
+ void testRpcMethodListSourceConnections() throws ListenFailedException {
reset();
Request req = new Request("listSourceConnections");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
final String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
@@ -150,11 +150,11 @@ public class ConfigProxyRpcServerTest {
* Tests invalidateCache RPC command
*/
@Test
- public void testRpcMethodInvalidateCache() {
+ void testRpcMethodInvalidateCache() {
Request req = new Request("invalidateCache");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
final String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
@@ -166,10 +166,10 @@ public class ConfigProxyRpcServerTest {
* Tests getMode and setMode RPC commands
*/
@Test
- public void testRpcMethodGetModeAndSetMode() {
+ void testRpcMethodGetModeAndSetMode() {
Request req = new Request("getMode");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("default", req.returnValues().get(0).asString());
@@ -177,7 +177,7 @@ public class ConfigProxyRpcServerTest {
String mode = "memorycache";
req.parameters().add(new StringValue(mode));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
@@ -187,7 +187,7 @@ public class ConfigProxyRpcServerTest {
req = new Request("getMode");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals(mode, req.returnValues().get(0).asString());
@@ -197,7 +197,7 @@ public class ConfigProxyRpcServerTest {
req.parameters().add(new StringValue(mode));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
assertEquals("1", ret[0]);
@@ -209,7 +209,7 @@ public class ConfigProxyRpcServerTest {
* Tests updateSources RPC command
*/
@Test
- public void testRpcMethodUpdateSources() throws ListenFailedException {
+ void testRpcMethodUpdateSources() throws ListenFailedException {
reset();
Request req = new Request("updateSources");
@@ -217,7 +217,7 @@ public class ConfigProxyRpcServerTest {
String spec2 = "tcp/b:19070";
req.parameters().add(new StringValue(spec1 + "," + spec2));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("Updated config sources to: " + spec1 + "," + spec2, req.returnValues().get(0).asString());
@@ -227,7 +227,7 @@ public class ConfigProxyRpcServerTest {
req = new Request("updateSources");
req.parameters().add(new StringValue(spec1 + "," + spec2));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("Cannot update sources when in '" + Mode.ModeName.MEMORYCACHE.name().toLowerCase() + "' mode", req.returnValues().get(0).asString());
@@ -246,12 +246,12 @@ public class ConfigProxyRpcServerTest {
* Tests dumpCache RPC command
*/
@Test
- public void testRpcMethodDumpCache() throws IOException {
+ void testRpcMethodDumpCache() throws IOException {
Request req = new Request("dumpCache");
- String path = temporaryFolder.newFolder().getAbsolutePath();
+ String path = temporaryFolder.getAbsolutePath();
req.parameters().add(new StringValue(path));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("success", req.returnValues().get(0).asString());
}
@@ -287,6 +287,15 @@ public class ConfigProxyRpcServerTest {
supervisor.transport().shutdown().join();
rpcServer.shutdown();
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
private static class TestClient implements AutoCloseable {
@@ -308,5 +317,23 @@ public class ConfigProxyRpcServerTest {
target.close();
supervisor.transport().shutdown().join();
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+ }
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
}
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
index 8a668b34fd0..7fbd6b2e68f 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
@@ -1,12 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-import static org.junit.Assert.assertEquals;
+import java.io.File;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
@@ -15,17 +16,17 @@ public class DelayedResponseHandlerTest {
private final MockConfigSource source = new MockConfigSource();
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
- @Before
+ @BeforeEach
public void setup() {
source.clear();
source.put(ProxyServerTest.fooConfig.getKey(), ProxyServerTest.createConfigWithNextConfigGeneration(ProxyServerTest.fooConfig, 0));
}
@Test
- public void basic() {
+ void basic() {
ConfigTester tester = new ConfigTester();
DelayedResponses delayedResponses = new DelayedResponses();
MemoryCache memoryCache = new MemoryCache();
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
index d8c03961ddb..6bb9f74105c 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
@@ -2,13 +2,13 @@
package com.yahoo.vespa.config.proxy;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -20,7 +20,7 @@ public class DelayedResponseTest {
private static final String namespace = "bar";
@Test
- public void basic() {
+ void basic() {
ConfigTester tester = new ConfigTester();
final long returnTime = System.currentTimeMillis();
final long timeout = 1;
@@ -51,7 +51,7 @@ public class DelayedResponseTest {
}
@Test
- public void testDelayedResponse() {
+ void testDelayedResponse() {
ConfigTester tester = new ConfigTester();
final long timeout = 20000;
JRTServerConfigRequest request1 = tester.createRequest("baz", configId, namespace, timeout);
@@ -69,9 +69,9 @@ public class DelayedResponseTest {
// New request, should have larger delay than the first
JRTServerConfigRequest request2 = tester.createRequest("baz", configId, namespace, timeout);
DelayedResponse delayed2 = new DelayedResponse(request2);
- assertTrue("delayed1=" + delayed1.getReturnTime() + ", delayed2=" +
- delayed2.getReturnTime() + ": delayed2 should be greater than delayed1",
- delayed2.getReturnTime() > delayed1.getReturnTime());
+ assertTrue(delayed2.getReturnTime() > delayed1.getReturnTime(),
+ "delayed1=" + delayed1.getReturnTime() + ", delayed2=" +
+ delayed2.getReturnTime() + ": delayed2 should be greater than delayed1");
// Test compareTo() method
assertEquals(0, delayed1.compareTo(delayed1));
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
index c9e714a11a3..6d9fa668bf5 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
public class DelayedResponsesTest {
@Test
- public void basic() throws InterruptedException {
+ void basic() throws InterruptedException {
ConfigTester tester = new ConfigTester();
DelayedResponses responses = new DelayedResponses();
DelayedResponse delayedResponse = new DelayedResponse(tester.createRequest("foo", "id", "bar", 10));
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
index d243d9c6dff..ff30a5b2381 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
public class MemoryCacheConfigClientTest {
@Test
- public void basic() {
+ void basic() {
MemoryCacheConfigClient client = new MemoryCacheConfigClient(new MemoryCache());
client.memoryCache().update(ConfigTester.fooConfig);
assertEquals(ConfigTester.fooConfig, client.getConfig(ConfigTester.fooConfig, null).orElseThrow());
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
index b0cba728a0c..2732a84527e 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
@@ -8,14 +8,14 @@ import com.yahoo.vespa.config.ConfigPayload;
import com.yahoo.vespa.config.PayloadChecksums;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.Payload;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -47,7 +47,7 @@ public class MemoryCacheTest {
private Payload payload2;
private Payload payloadDifferentMd5;
- @Before
+ @BeforeEach
public void setup() {
ArrayList<String> defContent = new ArrayList<>();
defContent.add("bar string");
@@ -74,7 +74,7 @@ public class MemoryCacheTest {
}
@Test
- public void basic() {
+ void basic() {
MemoryCache cache = new MemoryCache();
cache.update(config);
@@ -97,7 +97,7 @@ public class MemoryCacheTest {
}
@Test
- public void testSameConfigNameDifferentMd5() {
+ void testSameConfigNameDifferentMd5() {
MemoryCache cache = new MemoryCache();
cache.update(config);
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
index 0e25e62b925..0277ea60b49 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
@@ -8,18 +8,18 @@ import com.yahoo.vespa.config.ErrorCode;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequest;
import com.yahoo.vespa.config.protocol.Payload;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import java.io.File;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -38,10 +38,10 @@ public class ProxyServerTest {
fooConfig.getPayloadChecksums(), fooConfig.getGeneration(), false,
ErrorCode.UNKNOWN_DEFINITION, fooConfig.getDefContent(), Optional.empty());
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
- @Before
+ @BeforeEach
public void setup() {
source.clear();
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, 0));
@@ -49,13 +49,13 @@ public class ProxyServerTest {
proxy = createTestServer(source, client);
}
- @After
+ @AfterEach
public void shutdown() {
proxy.stop();
}
@Test
- public void basic() {
+ void basic() {
assertTrue(proxy.getMode().isDefault());
assertEquals(0, proxy.memoryCache().size());
@@ -72,7 +72,7 @@ public class ProxyServerTest {
* Tests that the proxy server RPC commands for setting and getting mode works..
*/
@Test
- public void testModeSwitch() {
+ void testModeSwitch() {
ProxyServer proxy = createTestServer(source, client);
assertTrue(proxy.getMode().isDefault());
@@ -106,7 +106,7 @@ public class ProxyServerTest {
* when it is found there.
*/
@Test
- public void testGetConfigAndCaching() {
+ void testGetConfigAndCaching() {
ConfigTester tester = new ConfigTester();
MemoryCache memoryCache = proxy.memoryCache();
assertEquals(0, memoryCache.size());
@@ -127,7 +127,7 @@ public class ProxyServerTest {
* it must be updated in cache.
*/
@Test
- public void testNoCachingOfErrorRequests() {
+ void testNoCachingOfErrorRequests() {
ConfigTester tester = new ConfigTester();
// Simulate an error response
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, ErrorCode.INTERNAL_ERROR));
@@ -163,7 +163,7 @@ public class ProxyServerTest {
* When the config has been successfully retrieved it must be updated in cache.
*/
@Test
- public void testNoCachingOfEmptyConfig() {
+ void testNoCachingOfEmptyConfig() {
ConfigTester tester = new ConfigTester();
MemoryCache cache = proxy.memoryCache();
@@ -175,8 +175,8 @@ public class ProxyServerTest {
// Simulate an empty response
RawConfig emptyConfig = new RawConfig(fooConfig.getKey(), fooConfig.getDefMd5(), Payload.from("{}"),
- fooConfig.getPayloadChecksums(), 0, false,
- 0, fooConfig.getDefContent(), Optional.empty());
+ fooConfig.getPayloadChecksums(), 0, false,
+ 0, fooConfig.getDefContent(), Optional.empty());
source.put(fooConfig.getKey(), emptyConfig);
res = proxy.resolveConfig(tester.createRequest(fooConfig)).orElseThrow();
@@ -195,7 +195,7 @@ public class ProxyServerTest {
}
@Test
- public void testReconfiguration() {
+ void testReconfiguration() {
ConfigTester tester = new ConfigTester();
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig)).orElseThrow();
assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
@@ -210,7 +210,7 @@ public class ProxyServerTest {
}
@Test
- public void testReadingSystemProperties() {
+ void testReadingSystemProperties() {
ProxyServer.Properties properties = ProxyServer.getSystemProperties();
assertEquals(1, properties.configSources.length);
assertEquals(ProxyServer.DEFAULT_PROXY_CONFIG_SOURCES, properties.configSources[0]);
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java
index ada98f4b30e..b55d6fb9e26 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java
@@ -5,12 +5,13 @@ import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.JRTConfigRequestFactory;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-import static org.junit.Assert.assertEquals;
+import java.io.File;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
@@ -20,18 +21,18 @@ public class RpcConfigSourceClientTest {
private ResponseHandler responseHandler;
private RpcConfigSourceClient rpcConfigSourceClient;
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
- @Before
+ @BeforeEach
public void setup() {
responseHandler = new ResponseHandler(true);
rpcConfigSourceClient = new RpcConfigSourceClient(responseHandler, new MockConfigSource());
}
@Test
- public void basic() {
+ void basic() {
final RawConfig fooConfig = ProxyServerTest.fooConfig;
configUpdatedSendResponse(fooConfig);
// Nobody asked for the config, so no response sent
@@ -48,13 +49,13 @@ public class RpcConfigSourceClientTest {
}
@Test
- public void errorResponse() {
+ void errorResponse() {
configUpdatedSendResponse(ProxyServerTest.errorConfig);
assertSentResponses(0);
}
@Test
- public void it_does_not_send_old_config_in_response() {
+ void it_does_not_send_old_config_in_response() {
RawConfig fooConfigOldGeneration = ProxyServerTest.fooConfig;
RawConfig fooConfig = createConfigWithNextConfigGeneration(fooConfigOldGeneration);
@@ -74,7 +75,7 @@ public class RpcConfigSourceClientTest {
}
@Test
- public void it_does_send_config_with_generation_0_in_response() {
+ void it_does_send_config_with_generation_0_in_response() {
RawConfig fooConfigOldGeneration = ProxyServerTest.fooConfig;
RawConfig fooConfig = createConfigWithNextConfigGeneration(fooConfigOldGeneration, 1);
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java
index 3987ba176d7..a491a7b4fc4 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java
@@ -2,18 +2,17 @@
package com.yahoo.vespa.config.proxy.filedistribution;
import com.yahoo.io.IOUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author hmusum
@@ -24,18 +23,18 @@ public class CachedFilesMaintainerTest {
private File cachedDownloads;
private CachedFilesMaintainer cachedFilesMaintainer;
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
- @Before
+ @BeforeEach
public void setup() throws IOException {
- cachedFileReferences = tempFolder.newFolder();
- cachedDownloads = tempFolder.newFolder();
+ cachedFileReferences = newFolder(tempFolder, "cachedFileReferences");
+ cachedDownloads = newFolder(tempFolder, "cachedDownloads");
cachedFilesMaintainer = new CachedFilesMaintainer(cachedFileReferences, cachedDownloads, Duration.ofMinutes(1));
}
@Test
- public void require_old_files_to_be_deleted() throws IOException {
+ void require_old_files_to_be_deleted() throws IOException {
runMaintainerAndAssertFiles(0, 0);
File fileReference = writeFile(cachedFileReferences, "fileReference");
@@ -72,4 +71,13 @@ public class CachedFilesMaintainerTest {
return file;
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
diff --git a/configgen/pom.xml b/configgen/pom.xml
index 11d6a195bc6..3c7032d684b 100644
--- a/configgen/pom.xml
+++ b/configgen/pom.xml
@@ -15,8 +15,13 @@
<description>Config java code generation from config definition files for Java Vespa components.</description>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java
index 9cf363376cc..53d02689fed 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java
@@ -1,12 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests parsing of a single line of a .def file
@@ -16,13 +13,15 @@ import static org.junit.Assert.assertTrue;
*/
public class DefLineParsingTest {
- @Test(expected = IllegalArgumentException.class)
- public void require_that_null_default_is_not_allowed() {
- new DefLine("s string default=null");
+ @Test
+ void require_that_null_default_is_not_allowed() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ new DefLine("s string default=null");
+ });
}
@Test
- public void testParseIntArray() {
+ void testParseIntArray() {
DefLine l = new DefLine("foo[] int");
assertEquals("foo[]", l.getName());
@@ -31,7 +30,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseIntMap() {
+ void testParseIntMap() {
DefLine l = new DefLine("foo{} int");
assertEquals("foo{}", l.getName());
@@ -40,7 +39,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseInnerMap() {
+ void testParseInnerMap() {
DefLine l = new DefLine("foo{}.i int");
assertEquals("foo{}.i", l.getName());
@@ -49,7 +48,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseEnum() {
+ void testParseEnum() {
DefLine l = new DefLine("idtype enum { us_east, US_WEST, EMEA } default=EMEA");
assertEquals("idtype", l.getName());
@@ -62,7 +61,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultReference() {
+ void testParseDefaultReference() {
DefLine l = new DefLine("foo.bar reference default=\"value\"");
assertEquals("foo.bar", l.getName());
@@ -72,7 +71,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseNoDefaultReference() {
+ void testParseNoDefaultReference() {
DefLine l = new DefLine("foo.bar reference");
assertEquals("foo.bar", l.getName());
@@ -85,7 +84,7 @@ public class DefLineParsingTest {
* the future, so the test is included to verify that value and name can be retrieved.
*/
@Test
- public void testParseDefaultFile() {
+ void testParseDefaultFile() {
DefLine l = new DefLine("fileWithDef file default=\"value\"");
assertEquals("fileWithDef", l.getName());
@@ -95,7 +94,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseNoDefaultFile() {
+ void testParseNoDefaultFile() {
DefLine l = new DefLine("fileVal file");
assertEquals("fileVal", l.getName());
@@ -104,7 +103,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseUrls() {
+ void testParseUrls() {
DefLine l = new DefLine("urlVal url");
assertEquals("urlVal", l.getName());
@@ -113,7 +112,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultUrls() {
+ void testParseDefaultUrls() {
DefLine l = new DefLine("urlVal url default=\"http://docs.vespa.ai\"");
assertEquals("urlVal", l.getName());
@@ -124,7 +123,7 @@ public class DefLineParsingTest {
@Test
- public void testParseDefaultInt() {
+ void testParseDefaultInt() {
DefLine l = new DefLine("foo int default=1000");
assertEquals("foo", l.getName());
@@ -134,7 +133,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultLong() {
+ void testParseDefaultLong() {
DefLine l = new DefLine("foo long default=9223372036854775807");
assertEquals("foo", l.getName());
@@ -144,7 +143,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultDouble() {
+ void testParseDefaultDouble() {
DefLine l = new DefLine("foo double default=5.37");
assertEquals("foo", l.getName());
@@ -154,7 +153,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultFalseBoolean() {
+ void testParseDefaultFalseBoolean() {
DefLine l = new DefLine("foo bool default=false");
assertEquals("foo", l.getName());
@@ -164,7 +163,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultTrueBoolean() {
+ void testParseDefaultTrueBoolean() {
DefLine l = new DefLine("foo bool default=true");
assertEquals("foo", l.getName());
@@ -174,7 +173,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseNoDefaultString() {
+ void testParseNoDefaultString() {
DefLine l = new DefLine("foo.bar string");
assertEquals("foo.bar", l.getName());
@@ -183,7 +182,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultString() {
+ void testParseDefaultString() {
DefLine l = new DefLine("foo.bar string default=\"value\"");
assertEquals("foo.bar", l.getName());
@@ -193,7 +192,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultEmptyString() {
+ void testParseDefaultEmptyString() {
DefLine l = new DefLine("foo.bar string default=\"\"");
assertEquals("foo.bar", l.getName());
@@ -203,7 +202,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseDefaultStringUnquoted() {
+ void testParseDefaultStringUnquoted() {
DefLine l = new DefLine("foo.bar string default=value");
assertEquals("foo.bar", l.getName());
@@ -213,7 +212,7 @@ public class DefLineParsingTest {
}
@Test
- public void testParseStringnullDefaultString() {
+ void testParseStringnullDefaultString() {
DefLine l = new DefLine("foo.bar string default=\"null\"");
assertEquals("foo.bar", l.getName());
@@ -223,7 +222,7 @@ public class DefLineParsingTest {
}
@Test
- public void testRanges() {
+ void testRanges() {
DefLine i = new DefLine("i int range=[0, 100]");
DefLine l = new DefLine("l long range=[-1e10, 0]");
DefLine d = new DefLine("d double range=[0, 1.0]");
@@ -233,7 +232,7 @@ public class DefLineParsingTest {
}
@Test
- public void testRestartSpecification() {
+ void testRestartSpecification() {
DefLine r0 = new DefLine("i int");
DefLine r1 = new DefLine("i int restart");
assertFalse(r0.getRestart());
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java
index 2eb86546e51..c57114a9ba8 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java
@@ -1,15 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import static com.yahoo.config.codegen.DefParserTest.assertLineFails;
import static com.yahoo.config.codegen.DefParserTest.createDefTemplate;
import static com.yahoo.config.codegen.DefParserTest.createParser;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author gjoranv
@@ -18,49 +17,53 @@ import static org.junit.Assert.assertNotEquals;
public class DefParserNamespaceTest {
@Test
- public void namespace_is_set_on_root_node() {
+ void namespace_is_set_on_root_node() {
DefParser parser = createParser("namespace=myproject.config\n");
CNode root = parser.getTree();
assertEquals("myproject.config", root.getNamespace());
}
@Test
- public void package_is_used_as_namespace_when_no_namespace_is_given() {
+ void package_is_used_as_namespace_when_no_namespace_is_given() {
String PACKAGE = "com.github.myproject";
DefParser parser = createParser("package=" + PACKAGE + "\n");
CNode root = parser.getTree();
assertEquals(PACKAGE, root.getNamespace());
}
- @Test(expected = CodegenRuntimeException.class)
- public void uppercase_chars_are_not_allowed() {
- createParser("namespace=Foo\n").getTree();
+ @Test
+ void uppercase_chars_are_not_allowed() {
+ assertThrows(CodegenRuntimeException.class, () -> {
+ createParser("namespace=Foo\n").getTree();
+ });
}
- @Test(expected = CodegenRuntimeException.class)
- public void explicit_com_yahoo_prefix_is_not_allowed() {
- createParser("namespace=com.yahoo.myproject.config\n").getTree();
+ @Test
+ void explicit_com_yahoo_prefix_is_not_allowed() {
+ assertThrows(CodegenRuntimeException.class, () -> {
+ createParser("namespace=com.yahoo.myproject.config\n").getTree();
+ });
}
@Test
- public void spaces_are_allowed_around_equals_sign() {
+ void spaces_are_allowed_around_equals_sign() {
DefParser parser = createParser("namespace = myproject.config\n");
CNode root = parser.getTree();
assertEquals("myproject.config", root.getNamespace());
}
@Test
- public void empty_namespace_is_not_allowed() {
+ void empty_namespace_is_not_allowed() {
assertLineFails("namespace");
}
@Test
- public void consecutive_dots_are_not_allowed() {
+ void consecutive_dots_are_not_allowed() {
assertLineFails("namespace=a..b");
}
@Test
- public void namespace_alters_def_md5() {
+ void namespace_alters_def_md5() {
DefParser parser = createParser("");
CNode root = parser.getTree();
@@ -72,7 +75,7 @@ public class DefParserNamespaceTest {
@Test
- public void number_is_allowed_as_non_leading_char_in_namespace() throws IOException, DefParser.DefParserException {
+ void number_is_allowed_as_non_leading_char_in_namespace() throws IOException, DefParser.DefParserException {
StringBuilder sb = createDefTemplate();
String line = "namespace=a.b.c2\n";
sb.append(line);
@@ -80,17 +83,17 @@ public class DefParserNamespaceTest {
}
@Test
- public void number_is_not_allowed_as_namespace_start_char() {
+ void number_is_not_allowed_as_namespace_start_char() {
assertLineFails("namespace=2.a.b");
}
@Test
- public void number_is_not_allowed_as_leading_char_in_namespace_token() {
+ void number_is_not_allowed_as_leading_char_in_namespace_token() {
assertLineFails("namespace=a.b.2c");
}
@Test
- public void underscore_in_namespace_is_allowed() throws IOException, DefParser.DefParserException {
+ void underscore_in_namespace_is_allowed() throws IOException, DefParser.DefParserException {
StringBuilder sb = createDefTemplate();
String line = "namespace=a_b.c\n";
sb.append(line);
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java
index cd7ca1a89b9..4aa40ae902c 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java
@@ -1,16 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import static com.yahoo.config.codegen.DefParserTest.assertLineFails;
import static com.yahoo.config.codegen.DefParserTest.createDefTemplate;
import static com.yahoo.config.codegen.DefParserTest.createParser;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests setting explicit java package in the def file.
@@ -21,17 +19,17 @@ public class DefParserPackageTest {
String PACKAGE = "com.github.myproject";
@Test
- public void package_is_set_on_root_node() {
+ void package_is_set_on_root_node() {
DefParser parser = createParser("package=" + PACKAGE + "\n");
CNode root = parser.getTree();
assertEquals(PACKAGE, root.getPackage());
}
@Test
- public void package_and_namespace_can_coexist() {
+ void package_and_namespace_can_coexist() {
String namespace = "test.namespace";
DefParser parser = createParser("package=" + PACKAGE +
- "\nnamespace=" + namespace +"\n");
+ "\nnamespace=" + namespace + "\n");
CNode root = parser.getTree();
assertEquals(PACKAGE, root.getPackage());
assertEquals(namespace, root.getNamespace());
@@ -39,37 +37,39 @@ public class DefParserPackageTest {
// Required by JavaClassBuilder ctor.
@Test
- public void package_is_null_when_not_explicitly_given() {
+ void package_is_null_when_not_explicitly_given() {
String namespace = "test.namespace";
DefParser parser = createParser("namespace=" + namespace + "\n");
CNode root = parser.getTree();
assertNull(root.getPackage());
}
- @Test(expected = CodegenRuntimeException.class)
- public void uppercase_chars_are_not_allowed() {
- createParser("package=Foo.bar\n").getTree();
+ @Test
+ void uppercase_chars_are_not_allowed() {
+ assertThrows(CodegenRuntimeException.class, () -> {
+ createParser("package=Foo.bar\n").getTree();
+ });
}
@Test
- public void spaces_are_allowed_around_equals_sign() {
+ void spaces_are_allowed_around_equals_sign() {
DefParser parser = createParser("package = " + PACKAGE + "\n");
CNode root = parser.getTree();
assertEquals(PACKAGE, root.getPackage());
}
@Test
- public void empty_package_is_not_allowed() {
- assertLineFails("package");
+ void empty_package_is_not_allowed() {
+ assertLineFails("package");
}
@Test
- public void consecutive_dots_are_not_allowed() {
+ void consecutive_dots_are_not_allowed() {
assertLineFails("package=a..b");
}
@Test
- public void package_alters_def_md5() {
+ void package_alters_def_md5() {
DefParser parser = createParser("a string\n");
CNode root = parser.getTree();
@@ -81,7 +81,7 @@ public class DefParserPackageTest {
@Test
- public void number_is_allowed_as_non_leading_char() throws IOException, DefParser.DefParserException {
+ void number_is_allowed_as_non_leading_char() throws IOException, DefParser.DefParserException {
StringBuilder sb = createDefTemplate();
String line = "package=a.b.c2\n";
sb.append(line);
@@ -89,17 +89,17 @@ public class DefParserPackageTest {
}
@Test
- public void number_is_not_allowed_as_package_start_char() {
+ void number_is_not_allowed_as_package_start_char() {
assertLineFails("package=2.a.b");
}
@Test
- public void number_is_not_allowed_as_leading_char_in_package_token() {
+ void number_is_not_allowed_as_leading_char_in_package_token() {
assertLineFails("package=a.b.2c");
}
@Test
- public void underscore_in_package_is_allowed() throws IOException, DefParser.DefParserException {
+ void underscore_in_package_is_allowed() throws IOException, DefParser.DefParserException {
StringBuilder sb = createDefTemplate();
String line = "package=a_b.c\n";
sb.append(line);
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java
index 915edce1440..4fbf01892cc 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java
@@ -1,17 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Unit tests for DefParser.
@@ -25,7 +23,7 @@ public class DefParserTest {
private static final String DEF_NAME = TEST_DIR + "configgen.allfeatures.def";
@Test
- public void testTraverseTree() throws IOException {
+ void testTraverseTree() throws IOException {
File defFile = new File(DEF_NAME);
CNode root = new DefParser("test", new FileReader(defFile)).getTree();
assertNotNull(root);
@@ -62,21 +60,21 @@ public class DefParserTest {
}
@Test
- public void testFileWithNamespaceInFilename() throws IOException {
+ void testFileWithNamespaceInFilename() throws IOException {
File defFile = new File(TEST_DIR + "baz.bar.foo.def");
CNode root = new DefParser("test", new FileReader(defFile)).getTree();
assertEquals("31a0f9bda0e5ff929762a29569575a7e", root.defMd5);
}
@Test
- public void testMd5Sum() throws IOException {
+ void testMd5Sum() throws IOException {
File defFile = new File(DEF_NAME);
CNode root = new DefParser("test", new FileReader(defFile)).getTree();
assertEquals("f901bdc5c96e7005130399c63f247823", root.defMd5);
}
@Test
- public void testMd5Sum2() {
+ void testMd5Sum2() {
String def = "a string\n";
CNode root = new DefParser("testMd5Sum2", new StringReader(def)).getTree();
assertEquals("a5e5fdbb2b27e56ba7d5e60e335c598b", root.defMd5);
@@ -84,7 +82,7 @@ public class DefParserTest {
// TODO: Version is not used anymore, remove test in Vespa 9
@Test
- public void testValidVersions() {
+ void testValidVersions() {
try {
parse("version=8");
parse("version=8-1");
@@ -103,7 +101,7 @@ public class DefParserTest {
}
@Test
- public void testInvalidType() {
+ void testInvalidType() {
String line = "a sting";
assertLineFails(line, "Could not create sting a");
}
@@ -113,20 +111,23 @@ public class DefParserTest {
}
@Test
- public void verify_fail_on_default_for_file() {
+ void verify_fail_on_default_for_file() {
assertLineFails("f file default=\"file1.txt\"",
- "Invalid default value");
+ "Invalid default value");
}
- @Test(expected = CodegenRuntimeException.class)
- @Ignore("Not implemented yet")
- public void testInvalidEnum() {
- DefParser parser = createParser("anEnum enum {A, B, A}\n");
+ @Test
+ @Disabled("Not implemented yet")
+ void testInvalidEnum() {
+ assertThrows(CodegenRuntimeException.class, () -> {
+ DefParser parser = createParser("anEnum enum {A, B, A}\n");
+ //parser.validateDef(def);
+ });
//parser.validateDef(def);
}
@Test
- public void testEnum() {
+ void testEnum() {
StringBuilder sb = createDefTemplate();
sb.append("enum1 enum {A,B} default=A\n");
sb.append("enum2 enum {A, B} default=A\n");
@@ -148,20 +149,22 @@ public class DefParserTest {
assertEquals("A", node.getDefaultValue().getStringRepresentation());
}
- @Test(expected = DefParser.DefParserException.class)
- public void testInvalidCommaInEnum() throws DefParser.DefParserException, IOException {
- String invalidEnum = "anEnum enum {A, B, } default=A\n";
- String validEnum = "anotherEnum enum {A, B} default=A\n";
- StringBuilder sb = createDefTemplate();
- sb.append(invalidEnum);
- sb.append(validEnum);
- DefParser parser = createParser(sb.toString());
- parser.parse();
+ @Test
+ void testInvalidCommaInEnum() throws DefParser.DefParserException, IOException {
+ assertThrows(DefParser.DefParserException.class, () -> {
+ String invalidEnum = "anEnum enum {A, B, } default=A\n";
+ String validEnum = "anotherEnum enum {A, B} default=A\n";
+ StringBuilder sb = createDefTemplate();
+ sb.append(invalidEnum);
+ sb.append(validEnum);
+ DefParser parser = createParser(sb.toString());
+ parser.parse();
+ });
}
- @Ignore //TODO: finish this! The numeric leaf nodes must contain their range.
+ @Disabled //TODO: finish this! The numeric leaf nodes must contain their range.
@Test
- public void testRanges() {
+ void testRanges() {
StringBuilder sb = new StringBuilder();
sb.append("i int range=[0,10]");
sb.append("l long range=[-1e20,0]");
@@ -173,7 +176,7 @@ public class DefParserTest {
}
@Test
- public void duplicate_parameter_is_illegal() {
+ void duplicate_parameter_is_illegal() {
Class<?> exceptionClass = DefParser.DefParserException.class;
StringBuilder sb = createDefTemplate();
String duplicateLine = "b int\n";
@@ -189,76 +192,76 @@ public class DefParserTest {
}
@Test
- public void testIllegalCharacterInName() {
- assertLineFails("a-b int",
- "a-b contains unexpected character");
+ void testIllegalCharacterInName() {
+ assertLineFails("a-b int",
+ "a-b contains unexpected character");
}
@Test
- public void parameter_name_starting_with_digit_is_illegal() {
+ void parameter_name_starting_with_digit_is_illegal() {
assertLineFails("1a int",
- "1a must start with a non-digit character");
+ "1a must start with a non-digit character");
}
@Test
- public void parameter_name_starting_with_uppercase_is_illegal() {
+ void parameter_name_starting_with_uppercase_is_illegal() {
assertLineFails("SomeInt int",
- "'SomeInt' cannot start with an uppercase letter");
+ "'SomeInt' cannot start with an uppercase letter");
}
@Test
- public void parameter_name_starting_with_the_internal_prefix_is_illegal() {
+ void parameter_name_starting_with_the_internal_prefix_is_illegal() {
String internalPrefix = ReservedWords.INTERNAL_PREFIX;
assertLineFails(internalPrefix + "i int",
- "'" + internalPrefix + "i' cannot start with '" + internalPrefix + "'");
+ "'" + internalPrefix + "i' cannot start with '" + internalPrefix + "'");
}
@Test
- public void testIllegalArray() {
+ void testIllegalArray() {
assertLineFails("intArr[ int",
- "intArr[ Expected ] to terminate array definition");
+ "intArr[ Expected ] to terminate array definition");
}
@Test
- public void testIllegalDefault() {
+ void testIllegalDefault() {
assertLineFails("a int deflt 10",
- " deflt 10");
+ " deflt 10");
}
@Test
- public void testReservedWordInC() {
+ void testReservedWordInC() {
assertLineFails("auto int",
- "auto is a reserved word in C");
+ "auto is a reserved word in C");
}
@Test
- public void testReservedWordInCForArray() {
+ void testReservedWordInCForArray() {
assertLineFails("auto[] int",
- "auto is a reserved word in C");
+ "auto is a reserved word in C");
}
@Test
- public void testReservedWordInJava() {
+ void testReservedWordInJava() {
assertLineFails("abstract int",
- "abstract is a reserved word in Java");
+ "abstract is a reserved word in Java");
}
@Test
- public void testReservedWordInJavaForMap() {
+ void testReservedWordInJavaForMap() {
assertLineFails("abstract{} int",
- "abstract is a reserved word in Java");
+ "abstract is a reserved word in Java");
}
@Test
- public void testReservedWordInCAndJava() {
+ void testReservedWordInCAndJava() {
assertLineFails("continue int",
- "continue is a reserved word in C and Java");
+ "continue is a reserved word in C and Java");
}
@Test
- public void testReservedWordInCAndJavaForArray() {
+ void testReservedWordInCAndJavaForArray() {
assertLineFails("continue[] int",
- "continue is a reserved word in C and Java");
+ "continue is a reserved word in C and Java");
}
static StringBuilder createDefTemplate() {
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java b/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java
index e6e86b2c2a3..69a690b0e82 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringReader;
@@ -12,9 +12,7 @@ import java.util.List;
import static com.yahoo.config.codegen.ConfiggenUtil.createClassName;
import static com.yahoo.config.codegen.JavaClassBuilder.createUniqueSymbol;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author gjoranv
@@ -26,44 +24,44 @@ public class JavaClassBuilderTest {
private static final String DEF_NAME = TEST_DIR + "configgen.allfeatures.def";
private static final String REFERENCE_NAME = TEST_DIR + "allfeatures.reference";
- @Ignore
+ @Disabled
@Test
- public void visual_inspection_of_generated_class() {
+ void visual_inspection_of_generated_class() {
final String testDefinition =
"namespace=test\n" + //
- "p path\n" + //
- "pathArr[] path\n" + //
- "u url\n" + //
- "urlArr[] url\n" + //
- "f file\n" + //
- "fileArr[] file\n" + //
- "i int default=0\n" + //
- "# A long value\n" + //
- "l long default=0\n" + //
- "s string default=\"\"\n" + //
- "b bool\n" + //
- "# An enum value\n" + //
- "e enum {A, B, C}\n" + //
- "intArr[] int\n" + //
- "boolArr[] bool\n" + //
- "enumArr[] enum {FOO, BAR}\n" + //
- "intMap{} int\n" + //
- "# A struct\n" + //
- "# with multi-line\n" + //
- "# comment and \"quotes\".\n" + //
- "myStruct.i int\n" + //
- "myStruct.s string\n" + //
- "# An inner array\n" + //
- "myArr[].i int\n" + //
- "myArr[].newStruct.s string\n" + //
- "myArr[].newStruct.b bool\n" + //
- "myArr[].intArr[] int\n" + //
- "# An inner map\n" + //
- "myMap{}.i int\n" + //
- "myMap{}.newStruct.s string\n" + //
- "myMap{}.newStruct.b bool\n" + //
- "myMap{}.intArr[] int\n" + //
- "intMap{} int\n";
+ "p path\n" + //
+ "pathArr[] path\n" + //
+ "u url\n" + //
+ "urlArr[] url\n" + //
+ "f file\n" + //
+ "fileArr[] file\n" + //
+ "i int default=0\n" + //
+ "# A long value\n" + //
+ "l long default=0\n" + //
+ "s string default=\"\"\n" + //
+ "b bool\n" + //
+ "# An enum value\n" + //
+ "e enum {A, B, C}\n" + //
+ "intArr[] int\n" + //
+ "boolArr[] bool\n" + //
+ "enumArr[] enum {FOO, BAR}\n" + //
+ "intMap{} int\n" + //
+ "# A struct\n" + //
+ "# with multi-line\n" + //
+ "# comment and \"quotes\".\n" + //
+ "myStruct.i int\n" + //
+ "myStruct.s string\n" + //
+ "# An inner array\n" + //
+ "myArr[].i int\n" + //
+ "myArr[].newStruct.s string\n" + //
+ "myArr[].newStruct.b bool\n" + //
+ "myArr[].intArr[] int\n" + //
+ "# An inner map\n" + //
+ "myMap{}.i int\n" + //
+ "myMap{}.newStruct.s string\n" + //
+ "myMap{}.newStruct.b bool\n" + //
+ "myMap{}.intArr[] int\n" + //
+ "intMap{} int\n";
DefParser parser = new DefParser("test", new StringReader(testDefinition));
InnerCNode root = parser.getTree();
@@ -73,11 +71,11 @@ public class JavaClassBuilderTest {
}
@Test
- public void testCreateUniqueSymbol() {
+ void testCreateUniqueSymbol() {
final String testDefinition =
"namespace=test\n" + //
- "m int\n" + //
- "n int\n";
+ "m int\n" + //
+ "n int\n";
InnerCNode root = new DefParser("test", new StringReader(testDefinition)).getTree();
assertEquals("f", createUniqueSymbol(root, "foo"));
@@ -90,7 +88,7 @@ public class JavaClassBuilderTest {
}
@Test
- public void testCreateClassName() {
+ void testCreateClassName() {
assertEquals("SimpleConfig", createClassName("simple"));
assertEquals("AConfig", createClassName("a"));
assertEquals("ABCConfig", createClassName("a-b-c"));
@@ -99,13 +97,15 @@ public class JavaClassBuilderTest {
assertEquals("MyAppConfig", createClassName("MyApp"));
}
- @Test(expected = CodegenRuntimeException.class)
- public void testIllegalClassName() {
- createClassName("+illegal");
+ @Test
+ void testIllegalClassName() {
+ assertThrows(CodegenRuntimeException.class, () -> {
+ createClassName("+illegal");
+ });
}
@Test
- public void verify_generated_class_against_reference() throws IOException {
+ void verify_generated_class_against_reference() throws IOException {
String testDefinition = String.join("\n", Files.readAllLines(FileSystems.getDefault().getPath(DEF_NAME)));
List<String> referenceClassLines = Files.readAllLines(FileSystems.getDefault().getPath(REFERENCE_NAME));
@@ -114,11 +114,13 @@ public class JavaClassBuilderTest {
JavaClassBuilder builder = new JavaClassBuilder(root, parser.getNormalizedDefinition(), null, null);
String[] configClassLines = builder.getConfigClass("AllfeaturesConfig").split("\n");
- for (var line : configClassLines) { System.out.println(line); }
+ for (var line : configClassLines) {
+ System.out.println(line);
+ }
for (int i = 0; i < referenceClassLines.size(); i++) {
if (configClassLines.length <= i)
fail("Missing lines i generated config class. First missing line:\n" + referenceClassLines.get(i));
- assertEquals("Line " + i, referenceClassLines.get(i), configClassLines[i]);
+ assertEquals(referenceClassLines.get(i), configClassLines[i], "Line " + i);
}
}
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java b/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java
index 9b3e9c31363..d967e16ba0b 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java
@@ -1,26 +1,26 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class MakeConfigTest {
private File dest;
- @Before
+ @BeforeEach
public void setUp() {
dest = new File("/tmp/"+System.currentTimeMillis()+File.separator);
dest.mkdir();
}
- @After
+ @AfterEach
public void tearDown() {
recursiveDeleteDir(dest);
}
@@ -40,9 +40,9 @@ public class MakeConfigTest {
// The directory is now empty so delete it
return dir.delete();
}
-
+
@Test
- public void testProps() throws PropertyException {
+ void testProps() throws PropertyException {
System.setProperty("config.dumpTree", "true");
System.setProperty("config.useFramework", "true");
System.setProperty("config.dest", dest.getAbsolutePath());
@@ -53,7 +53,7 @@ public class MakeConfigTest {
assertTrue(p.generateFrameworkCode);
assertEquals(p.specFiles.size(), 1);
assertEquals(p.specFiles.get(0).getAbsolutePath(), new File("src/test/resources/configgen.allfeatures.def").getAbsolutePath());
-
+
System.setProperty("config.dumpTree", "false");
System.setProperty("config.useFramework", "false");
System.setProperty("config.dest", dest.getAbsolutePath());
@@ -66,7 +66,7 @@ public class MakeConfigTest {
}
@Test
- public void testMake() throws IOException {
+ void testMake() throws IOException {
System.setProperty("config.dumpTree", "true");
System.setProperty("config.useFramework", "true");
System.setProperty("config.dest", dest.getAbsolutePath());
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java b/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java
index d57210dd9ed..61b5eb5a759 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java
@@ -9,10 +9,10 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
@@ -21,13 +21,13 @@ import static org.junit.Assert.assertNotNull;
public class NormalizedDefinitionTest {
@Test
- public void testNormalizingFromReader() {
+ void testNormalizingFromReader() {
String def =
"aString string \n" +
- "anInt int #comment \n" +
- "aStringCommentCharacterAfter string default=\"ab\" #foo\n" +
- "aStringWithCommentCharacter string default=\"a#b\"\n" +
- "aStringWithEscapedQuote string default=\"a\"b\"\n";
+ "anInt int #comment \n" +
+ "aStringCommentCharacterAfter string default=\"ab\" #foo\n" +
+ "aStringWithCommentCharacter string default=\"a#b\"\n" +
+ "aStringWithEscapedQuote string default=\"a\"b\"\n";
StringReader reader = new StringReader(def);
@@ -52,7 +52,7 @@ public class NormalizedDefinitionTest {
}
@Test
- public void testNormalizingFromFile() throws IOException {
+ void testNormalizingFromFile() throws IOException {
FileReader fileReader = null;
try {
fileReader = new FileReader("src/test/resources/configgen.allfeatures.def");