aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/vespa/model/container
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2024-05-16 14:04:37 +0200
committerHarald Musum <musum@yahooinc.com>2024-05-16 14:04:37 +0200
commit4c5dd194ebb2e5d82f3e2ba5871bc54065059947 (patch)
treef7a652965a7dee8bbcbebd3f701f2b5ed36a164c /config-model/src/test/java/com/yahoo/vespa/model/container
parentebc496f2186afadde852ea05ee0c55af720b8546 (diff)
Fix Jvm options in combination with feature flag
Need to set jvm options from services.xml first, code prevents overriding jvm config that is already set on container (not cluster) level.
Diffstat (limited to 'config-model/src/test/java/com/yahoo/vespa/model/container')
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java18
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java24
2 files changed, 24 insertions, 18 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 2ea4249883d..9cf34b55ebf 100644
--- 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
@@ -221,24 +221,6 @@ public class ContainerClusterTest {
}
@Test
- void requireThatJvmOmitStackTraceInFastThrowOptionWorks() {
- // Empty option if option not set in property
- MockRoot root = createRoot(new DeployState.Builder().build());
- ApplicationContainerCluster cluster = newClusterWithSearch(root);
- addContainer(root, cluster, "c1", "host-c1");
- ApplicationContainer container = cluster.getContainers().get(0);
- assertEquals("", container.getJvmOptions());
-
- String jvmOption = "-XX:-foo";
- DeployState deployState = new DeployState.Builder().properties(new TestProperties().setJvmOmitStackTraceInFastThrowOption(jvmOption)).build();
- root = createRoot(deployState);
- cluster = newClusterWithSearch(root);
- addContainer(root, cluster, "c1", "host-c1");
- container = cluster.getContainers().get(0);
- assertEquals(jvmOption, container.getJvmOptions());
- }
-
- @Test
void requireThatWeCanHandleNullJvmOptions() {
MockRoot root = createRoot(false);
ApplicationContainerCluster cluster = newClusterWithSearch(root);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java
index 46097da434e..64afd444989 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.model.container.xml;
+import com.yahoo.cloud.config.SentinelConfig;
import com.yahoo.collections.Pair;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.NullConfigModelRegistry;
@@ -205,6 +206,29 @@ public class JvmOptionsTest extends ContainerModelBuilderTestBase {
assertEquals("-XX:+UseParNewGC", qrStartConfig.jvm().gcopts());
}
+ @Test
+ void verify_jvm_option_and_value_from_feature_flag_are_both_included() throws IOException, SAXException {
+ String servicesXml = """
+ <container version='1.0'>
+ <search/>
+ <nodes>
+ <jvm options="-Xms1024m -Xmx2048m" />
+ <node hostalias="node1" />
+ </nodes>
+ </container>
+ """;
+ ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
+ // Need to create VespaModel to make deploy properties have effect
+ VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder()
+ .applicationPackage(applicationPackage)
+ .properties(new TestProperties().setJvmOmitStackTraceInFastThrowOption("-XX:-OmitStackTraceInFastThrow"))
+ .build());
+ SentinelConfig.Builder builder = new SentinelConfig.Builder();
+ model.getConfig(builder, "hosts/localhost");
+ SentinelConfig config = builder.build();
+ assertEquals("PRELOAD=/opt/vespa/lib64/vespa/malloc/libvespamalloc.so exec ${VESPA_HOME}/libexec/vespa/vespa-wrapper vespa-start-container-daemon -Xms1024m -Xmx2048m -XX:-OmitStackTraceInFastThrow ", config.service().get(0).command());
+ }
+
private void verifyLoggingOfJvmGcOptions(boolean isHosted, String override, String... invalidOptions) throws IOException, SAXException {
verifyLogMessage(isHosted, "gc-options", override, invalidOptions);
}