diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-10-18 16:22:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-18 16:22:29 +0200 |
commit | 09eff545deb18bb087520988be53eab0687d0052 (patch) | |
tree | 94337fc33e51cbf60f298fe4943ae5f5aa1259db /configserver | |
parent | 863a8c5c99587155f941a2ab6444d89db501eed1 (diff) | |
parent | 8a5dccae0bdc6ecf595e352718d1a307bd1c9f3e (diff) |
Merge pull request #7360 from vespa-engine/bratseth/handle-major-version
Bratseth/handle major version
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java index 459604fa333..ea0b187dee2 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.Optional; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -165,21 +166,25 @@ public class RemoteSessionTest { @Test public void require_that_an_application_package_can_limit_to_one_major_version() { ApplicationPackage application = - new MockApplicationPackage.Builder().withServices("<services major-version='2' version=\"1.0\"></services>").build(); + new MockApplicationPackage.Builder().withServices("<services version='1.0'/>") + .withDeploymentSpec("<deployment version='1.0' major-version='2'/>") + .build(); + assertTrue(application.getMajorVersion().isPresent()); + assertEquals(2, (int)application.getMajorVersion().get()); MockModelFactory failingFactory = new MockModelFactory(); failingFactory.vespaVersion = Version.fromIntValues(3, 0, 0); - failingFactory.throwOnLoad = true; + failingFactory.throwErrorOnLoad = true; MockModelFactory okFactory = new MockModelFactory(); okFactory.vespaVersion = Version.fromIntValues(2, 0, 0); - okFactory.throwOnLoad = false; + okFactory.throwErrorOnLoad = false; SessionZooKeeperClient zkc = new MockSessionZKClient(curator, tenantName, 3, application); RemoteSession session = createSession(3, zkc, Arrays.asList(okFactory, failingFactory), failingFactory.clock()); session.loadPrepared(); - // Does not cause an exception because model version 3 is skipped + // Does not cause an error because model version 3 is skipped } @Test @@ -242,7 +247,12 @@ public class RemoteSessionTest { private class MockModelFactory implements ModelFactory { + /** Throw a RuntimeException on load - this is handled gracefully during model building */ public boolean throwOnLoad = false; + + /** Throw an Error on load - this is useful to propagate this condition all the way to the test */ + public boolean throwErrorOnLoad = false; + public ModelContext modelContext; public Version vespaVersion = Version.fromIntValues(1, 2, 3); @@ -267,9 +277,10 @@ public class RemoteSessionTest { @Override public Model createModel(ModelContext modelContext) { - if (throwOnLoad) { + if (throwErrorOnLoad) + throw new Error("Foo"); + if (throwOnLoad) throw new IllegalArgumentException("Foo"); - } this.modelContext = modelContext; return loadModel(); } @@ -286,9 +297,10 @@ public class RemoteSessionTest { @Override public ModelCreateResult createAndValidateModel(ModelContext modelContext, ValidationParameters validationParameters) { - if (throwOnLoad) { + if (throwErrorOnLoad) + throw new Error("Foo"); + if (throwOnLoad) throw new IllegalArgumentException("Foo"); - } this.modelContext = modelContext; return new ModelCreateResult(loadModel(), new ArrayList<>()); } |