diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-06-03 15:45:50 +0200 |
---|---|---|
committer | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-06-03 15:45:50 +0200 |
commit | 7ed6eea8e86218398d5d62af4dc35e712f2ecf51 (patch) | |
tree | 817d01d1aa044d466401c8cf49ec7ab434c2b703 /controller-server/src/test/java | |
parent | fa09b83d6de9bcb041f00d74176bd3afe6cc8a6b (diff) |
Support both old rotation field and new endpoints field
Now we support both fields again in both serialization and deserialization
to avoid issues with upgrades.
Diffstat (limited to 'controller-server/src/test/java')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java index 084ac593f4c..be9624fc693 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java @@ -116,6 +116,7 @@ public class ApplicationSerializerTest { OptionalInt.of(7), new MetricsService.ApplicationMetrics(0.5, 0.9), Optional.of("-----BEGIN PUBLIC KEY-----\n∠( ᐛ 」∠)_\n-----END PUBLIC KEY-----"), + Optional.of(new RotationId("my-rotation")), List.of(new RotationId("my-rotation")), rotationStatus); @@ -254,7 +255,6 @@ public class ApplicationSerializerTest { // Add the necessary fields to the Slime representation of the application final var cursor = slime.get(); - cursor.setString("rotation", "single-rotation"); final var rotations = cursor.setArray("endpoints"); @@ -272,5 +272,31 @@ public class ApplicationSerializerTest { ), application.rotations() ); + + assertEquals( + Optional.of(new RotationId("single-rotation")), application.legacyRotation() + ); + } + + @Test + public void testParsingOnlyLegacyRotationElement() throws IOException { + // Use the 'complete-application.json' as a baseline + final var applicationJson = Files.readAllBytes(testData.resolve("complete-application.json")); + final var slime = SlimeUtils.jsonToSlime(applicationJson); + + // Add the necessary fields to the Slime representation of the application + final var cursor = slime.get(); + + cursor.setString("rotation", "single-rotation"); + + // Parse and test the output from parsing contains both legacy rotation and multiple rotations + final var application = applicationSerializer.fromSlime(slime); + + assertEquals( + List.of( + new RotationId("single-rotation") + ), + application.rotations() + ); } } |