summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@verizonmedia.com>2022-01-28 12:27:26 +0100
committerOla Aunrønning <olaa@verizonmedia.com>2022-01-28 12:27:26 +0100
commit1540a0c6527f28634631bee9ae2efc89526a5273 (patch)
tree3cfd96aef5fe94e3d5f5ad2b299ef5eb02a35c50 /controller-server
parent3161b9bc70f9dce6519e628267300e81cda2e0f6 (diff)
Add unit test
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java22
-rw-r--r--controller-server/src/test/resources/application-packages/changed-deployment-xml.zipbin0 -> 826 bytes
-rw-r--r--controller-server/src/test/resources/application-packages/changed-services-xml.zipbin0 -> 819 bytes
-rw-r--r--controller-server/src/test/resources/application-packages/original.zipbin0 -> 818 bytes
4 files changed, 22 insertions, 0 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java
index 2ee03457046..cf0b46dfba2 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java
@@ -7,6 +7,8 @@ import org.junit.Assert;
import org.junit.Test;
import java.io.ByteArrayInputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.time.Instant;
import java.util.List;
import java.util.Map;
@@ -14,6 +16,7 @@ import java.util.stream.Collectors;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -108,6 +111,21 @@ public class ApplicationPackageTest {
}
}
+ @Test
+ public void testBundleHashesAreSameWithDifferentDeploymentXml() throws Exception {
+ var originalPackage = getApplicationZip("original.zip");
+ var changedDeploymentXml = getApplicationZip("changed-deployment-xml.zip");
+ var changedServices = getApplicationZip("changed-services-xml.zip");
+
+ // services.xml is changed -> different bundle hash
+ assertNotEquals(originalPackage.bundleHash(), changedServices.bundleHash());
+ assertNotEquals(originalPackage.hash(), changedServices.hash());
+
+ // deployment.xml is changed -> same bundle hash
+ assertEquals(originalPackage.bundleHash(), changedDeploymentXml.bundleHash());
+ assertNotEquals(originalPackage.hash(), changedDeploymentXml.hash());
+ }
+
private static Map<String, String> unzip(byte[] zip) {
return new ZipStreamReader(new ByteArrayInputStream(zip), __ -> true, 1 << 10, true)
.entries().stream()
@@ -115,4 +133,8 @@ public class ApplicationPackageTest {
entry -> new String(entry.contentOrThrow(), UTF_8)));
}
+ private ApplicationPackage getApplicationZip(String path) throws Exception {
+ return new ApplicationPackage(Files.readAllBytes(Path.of("src/test/resources/application-packages/" + path)), true);
+ }
+
}
diff --git a/controller-server/src/test/resources/application-packages/changed-deployment-xml.zip b/controller-server/src/test/resources/application-packages/changed-deployment-xml.zip
new file mode 100644
index 00000000000..90d52524fb3
--- /dev/null
+++ b/controller-server/src/test/resources/application-packages/changed-deployment-xml.zip
Binary files differ
diff --git a/controller-server/src/test/resources/application-packages/changed-services-xml.zip b/controller-server/src/test/resources/application-packages/changed-services-xml.zip
new file mode 100644
index 00000000000..3051d27836a
--- /dev/null
+++ b/controller-server/src/test/resources/application-packages/changed-services-xml.zip
Binary files differ
diff --git a/controller-server/src/test/resources/application-packages/original.zip b/controller-server/src/test/resources/application-packages/original.zip
new file mode 100644
index 00000000000..4cf2ffa7c46
--- /dev/null
+++ b/controller-server/src/test/resources/application-packages/original.zip
Binary files differ