summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-06-07 14:21:38 +0200
committerGitHub <noreply@github.com>2021-06-07 14:21:38 +0200
commitfacc295e58c32bbcc438c7d40349c6cab1b80861 (patch)
treeeab3cb28e571d64a2d74e07c6e6b83a4de27f288 /config-model/src/test/java/com
parent13275ff0cc24dd1cdaacdf9556448d06b66fdc07 (diff)
parenta34f2f419eaace74ecadb2bc9d573957c6b6d536 (diff)
Merge pull request #18152 from vespa-engine/brattseth/redundancy-increase-validation
Add redundancy increase validation override
Diffstat (limited to 'config-model/src/test/java/com')
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RedundancyIncreaseValidatorTest.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RedundancyIncreaseValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RedundancyIncreaseValidatorTest.java
new file mode 100644
index 00000000000..ddeada8b33f
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RedundancyIncreaseValidatorTest.java
@@ -0,0 +1,64 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.model.application.validation.change;
+
+import com.yahoo.config.application.api.ValidationId;
+import com.yahoo.config.application.api.ValidationOverrides;
+import com.yahoo.config.provision.Environment;
+import com.yahoo.vespa.model.VespaModel;
+import com.yahoo.vespa.model.application.validation.ValidationTester;
+import com.yahoo.yolean.Exceptions;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * @author bratseth
+ */
+public class RedundancyIncreaseValidatorTest {
+
+ private final ValidationTester tester = new ValidationTester(7);
+
+ @Test
+ public void testRedundancyIncreaseValidation() {
+ VespaModel previous = tester.deploy(null, getServices(2), Environment.prod, null).getFirst();
+ try {
+ tester.deploy(previous, getServices(3), Environment.prod, null);
+ fail("Expected exception due to redundancy increase");
+ }
+ catch (IllegalArgumentException expected) {
+ assertEquals("redundancy-increase: " +
+ "Increasing redundancy from 2 to 3 in 'content cluster 'contentClusterId'. " +
+ "This is a safe operation but verify that you have room for a 3/2x increase in content size. " +
+ ValidationOverrides.toAllowMessage(ValidationId.redundancyIncrease),
+ Exceptions.toMessageString(expected));
+ }
+ }
+
+ @Test
+ public void testOverridingContentRemovalValidation() {
+ VespaModel previous = tester.deploy(null, getServices(2), Environment.prod, null).getFirst();
+ tester.deploy(previous, getServices(3), Environment.prod, redundancyIncreaseOverride); // Allowed due to override
+ }
+
+ private static String getServices(int redundancy) {
+ return "<services version='1.0'>" +
+ " <content id='contentClusterId' version='1.0'>" +
+ " <redundancy>" + redundancy + "</redundancy>" +
+ " <engine>" +
+ " <proton/>" +
+ " </engine>" +
+ " <documents>" +
+ " <document type='music' mode='index'/>" +
+ " </documents>" +
+ " <nodes count='3'/>" +
+ " </content>" +
+ "</services>";
+ }
+
+ private static final String redundancyIncreaseOverride =
+ "<validation-overrides>\n" +
+ " <allow until='2000-01-03'>redundancy-increase</allow>\n" +
+ "</validation-overrides>\n";
+
+}