diff options
author | gjoranv <gv@verizonmedia.com> | 2022-07-19 00:48:31 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-07-19 00:48:49 +0200 |
commit | 1f30a244e5efb5f778b076340f39372d11b21ccb (patch) | |
tree | 312f6a7c569b226a6bdb30aaf3f389b81e03e223 /config-model/src/test/java | |
parent | 96f4c5a4d1280b1c1eeaa069e2674c8a5c380519 (diff) |
Rename and rearrange test helpers, and declare static.
Diffstat (limited to 'config-model/src/test/java')
-rwxr-xr-x | config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java index ac6c5009852..3ff88e22b5d 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java @@ -92,7 +92,7 @@ public class ContainerClusterTest { @Test public void search_and_docproc_bundles_are_installed_for_application_clusters_with_search() { - ApplicationContainerCluster cluster = createContainerCluster(createRoot(false), false, null); + ApplicationContainerCluster cluster = newClusterWithSearch(createRoot(false), false, null); var bundleBuilder = new PlatformBundlesConfig.Builder(); cluster.getConfig(bundleBuilder); @@ -115,37 +115,11 @@ public class ContainerClusterTest { assertEquals("cd", config.system()); } - private ApplicationContainerCluster createContainerCluster(MockRoot root) { - return createContainerCluster(root, false, null); - } - - private ApplicationContainerCluster createContainerCluster(MockRoot root, boolean isCombinedCluster, Integer memoryPercentage) { - ApplicationContainerCluster cluster = new ApplicationContainerCluster(root, "container0", "container1", root.getDeployState()); - if (isCombinedCluster) - cluster.setHostClusterId("test-content-cluster"); - cluster.setMemoryPercentage(memoryPercentage); - cluster.setSearch(new ContainerSearch(cluster, new SearchChains(cluster, "search-chain"), new ContainerSearch.Options())); - return cluster; - } - - private ClusterControllerContainerCluster createClusterControllerCluster(MockRoot root) { - return new ClusterControllerContainerCluster(root, "container0", "container1", root.getDeployState()); - } - - private MockRoot createRoot(boolean isHosted) { - DeployState state = new DeployState.Builder().properties(new TestProperties().setHostedVespa(isHosted)).build(); - return createRoot(state); - } - - private MockRoot createRoot(DeployState deployState) { - return new MockRoot("foo", deployState); - } - private void verifyHeapSizeAsPercentageOfPhysicalMemory(boolean isHosted, boolean isCombinedCluster, Integer explicitMemoryPercentage, int expectedMemoryPercentage) { - ApplicationContainerCluster cluster = createContainerCluster(createRoot(isHosted), isCombinedCluster, explicitMemoryPercentage); + ApplicationContainerCluster cluster = newClusterWithSearch(createRoot(isHosted), isCombinedCluster, explicitMemoryPercentage); QrStartConfig.Builder qsB = new QrStartConfig.Builder(); cluster.getConfig(qsB); QrStartConfig qsC= new QrStartConfig(qsB); @@ -181,7 +155,7 @@ public class ContainerClusterTest { private void verifyJvmArgs(boolean isHosted, boolean hasDocProc) { MockRoot root = createRoot(isHosted); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); if (hasDocProc) { cluster.setDocproc(new ContainerDocproc(cluster, null)); } @@ -257,7 +231,7 @@ public class ContainerClusterTest { public void requireThatJvmOmitStackTraceInFastThrowOptionWorks() { // Empty option if option not set in property MockRoot root = createRoot(new DeployState.Builder().build()); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); ApplicationContainer container = cluster.getContainers().get(0); assertEquals("", container.getJvmOptions()); @@ -265,7 +239,7 @@ public class ContainerClusterTest { String jvmOption = "-XX:-foo"; DeployState deployState = new DeployState.Builder().properties(new TestProperties().setJvmOmitStackTraceInFastThrowOption(jvmOption)).build(); root = createRoot(deployState); - cluster = createContainerCluster(root); + cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); container = cluster.getContainers().get(0); assertEquals(jvmOption, container.getJvmOptions()); @@ -274,7 +248,7 @@ public class ContainerClusterTest { @Test public void requireThatWeCanHandleNullJvmOptions() { MockRoot root = createRoot(false); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); Container container = cluster.getContainers().get(0); container.setJvmOptions(""); @@ -286,7 +260,7 @@ public class ContainerClusterTest { @Test public void requireThatNonHostedUsesExpectedDefaultThreadpoolConfiguration() { MockRoot root = new MockRoot("foo"); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); @@ -298,7 +272,7 @@ public class ContainerClusterTest { @Test public void container_cluster_has_default_threadpool_provider() { MockRoot root = new MockRoot("foo"); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); @@ -317,7 +291,7 @@ public class ContainerClusterTest { .properties(new TestProperties().setHostedVespa(true)) .applicationPackage(new MockApplicationPackage.Builder().build()) .build()); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); @@ -334,7 +308,7 @@ public class ContainerClusterTest { .properties(new TestProperties().setHostedVespa(true)) .applicationPackage(new MockApplicationPackage.Builder().build()) .build()); - ApplicationContainerCluster cluster = createContainerCluster(root); + ApplicationContainerCluster cluster = newClusterWithSearch(root); addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); @@ -508,6 +482,31 @@ public class ContainerClusterTest { expectedBundleNames.forEach(b -> assertTrue(installedBundles.stream().filter(p -> p.endsWith(b)).count() > 0)); } + private static ApplicationContainerCluster newClusterWithSearch(MockRoot root) { + return newClusterWithSearch(root, false, null); + } + + private static ApplicationContainerCluster newClusterWithSearch(MockRoot root, boolean isCombinedCluster, Integer memoryPercentage) { + ApplicationContainerCluster cluster = new ApplicationContainerCluster(root, "container0", "container1", root.getDeployState()); + if (isCombinedCluster) + cluster.setHostClusterId("test-content-cluster"); + cluster.setMemoryPercentage(memoryPercentage); + cluster.setSearch(new ContainerSearch(cluster, new SearchChains(cluster, "search-chain"), new ContainerSearch.Options())); + return cluster; + } + + private static ClusterControllerContainerCluster createClusterControllerCluster(MockRoot root) { + return new ClusterControllerContainerCluster(root, "container0", "container1", root.getDeployState()); + } + + private static MockRoot createRoot(boolean isHosted) { + DeployState state = new DeployState.Builder().properties(new TestProperties().setHostedVespa(isHosted)).build(); + return createRoot(state); + } + + private static MockRoot createRoot(DeployState deployState) { + return new MockRoot("foo", deployState); + } private static void addContainer(MockRoot root, ApplicationContainerCluster cluster, String name, String hostName) { addContainerWithHostResource(root, cluster, name, new HostResource(new Host(null, hostName))); |