summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2022-07-05 16:21:19 +0200
committergjoranv <gv@verizonmedia.com>2022-07-05 20:23:10 +0200
commited809f4f7783487be4289adc839348d98edcb620 (patch)
tree6f76135d2d9b4b5bc8a1b25b6699a3230ab1ec3a /config-model
parent021f0b2f244f67d84aa5f6862bf5a07f7864e446 (diff)
Move accesslog related test to appropriate class.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessLogTest.java45
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java35
2 files changed, 46 insertions, 34 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessLogTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessLogTest.java
index 0486d463279..81b6de8f2ee 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessLogTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessLogTest.java
@@ -2,7 +2,14 @@
package com.yahoo.vespa.model.container.xml;
import com.yahoo.component.ComponentId;
+import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.builder.xml.test.DomBuilderTest;
+import com.yahoo.config.model.deploy.DeployState;
+import com.yahoo.config.model.deploy.TestProperties;
+import com.yahoo.config.model.test.MockApplicationPackage;
+import com.yahoo.config.provision.Environment;
+import com.yahoo.config.provision.RegionName;
+import com.yahoo.config.provision.Zone;
import com.yahoo.container.core.AccessLogConfig;
import com.yahoo.container.logging.ConnectionLogConfig;
import com.yahoo.container.logging.FileConnectionLog;
@@ -13,8 +20,12 @@ import com.yahoo.vespa.model.container.component.Component;
import org.junit.Test;
import org.w3c.dom.Element;
+import java.util.logging.Level;
+
+import static com.yahoo.config.model.test.TestUtil.joinLines;
import static com.yahoo.text.StringUtilities.quote;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -132,4 +143,38 @@ public class AccessLogTest extends ContainerModelBuilderTestBase {
Component<?, ?> fileConnectionLogComponent = getContainerComponent("default", FileConnectionLog.class.getName());
assertNull(fileConnectionLogComponent);
}
+
+ @Test
+ public void hosted_applications_get_a_log_warning_when_overriding_accesslog() {
+ String containerService = joinLines("<container id='foo' version='1.0'>",
+ " <accesslog type='json' fileNamePattern='logs/vespa/qrs/access.%Y%m%d%H%M%S' symlinkName='json_access' />",
+ " <nodes count=\"2\">",
+ " </nodes>",
+ "</container>");
+
+ String deploymentXml = joinLines("<deployment version='1.0'>",
+ " <prod>",
+ " <region>us-east-1</region>",
+ " </prod>",
+ "</deployment>");
+
+ ApplicationPackage applicationPackage = new MockApplicationPackage.Builder()
+ .withServices(containerService)
+ .withDeploymentSpec(deploymentXml)
+ .build();
+
+ TestLogger logger = new TestLogger();
+ DeployState deployState = new DeployState.Builder()
+ .applicationPackage(applicationPackage)
+ .zone(new Zone(Environment.prod, RegionName.from("us-east-1")))
+ .properties(new TestProperties().setHostedVespa(true))
+ .deployLogger(logger)
+ .build();
+ createModel(root, deployState, null, DomBuilderTest.parse(containerService));
+ assertFalse(logger.msgs.isEmpty());
+ assertEquals(Level.WARNING, logger.msgs.get(0).getFirst());
+ assertEquals("Applications are not allowed to override the 'accesslog' element",
+ logger.msgs.get(0).getSecond());
+ }
+
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
index b65570d29cc..5a0759cb097 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
@@ -80,11 +80,11 @@ import static com.yahoo.vespa.model.container.ContainerCluster.ROOT_HANDLER_BIND
import static com.yahoo.vespa.model.container.ContainerCluster.STATE_HANDLER_BINDING_1;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -995,39 +995,6 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
logger.msgs.get(1).getSecond());
}
- @Test
- public void logs_accesslog_not_overidable_in_hosted() {
- String containerService = joinLines("<container id='foo' version='1.0'>",
- " <accesslog type='json' fileNamePattern='logs/vespa/qrs/access.%Y%m%d%H%M%S' symlinkName='json_access' />",
- " <nodes count=\"2\">",
- " </nodes>",
- "</container>");
-
- String deploymentXml = joinLines("<deployment version='1.0'>",
- " <prod>",
- " <region>us-east-1</region>",
- " </prod>",
- "</deployment>");
-
- ApplicationPackage applicationPackage = new MockApplicationPackage.Builder()
- .withServices(containerService)
- .withDeploymentSpec(deploymentXml)
- .build();
-
- TestLogger logger = new TestLogger();
- DeployState deployState = new DeployState.Builder()
- .applicationPackage(applicationPackage)
- .zone(new Zone(Environment.prod, RegionName.from("us-east-1")))
- .properties(new TestProperties().setHostedVespa(true))
- .deployLogger(logger)
- .build();
- createModel(root, deployState, null, DomBuilderTest.parse(containerService));
- assertFalse(logger.msgs.isEmpty());
- assertEquals(Level.WARNING, logger.msgs.get(0).getFirst());
- assertEquals("Applications are not allowed to override the 'accesslog' element",
- logger.msgs.get(0).getSecond());
- }
-
private void assertComponentConfigured(ApplicationContainerCluster cluster, String componentId) {
Component<?, ?> component = cluster.getComponentsMap().get(ComponentId.fromString(componentId));
assertNotNull(component);