aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java
diff options
context:
space:
mode:
authorMartin Polden <martin.polden@gmail.com>2017-08-22 13:33:30 +0200
committerMartin Polden <martin.polden@gmail.com>2017-08-24 12:45:09 +0200
commit56b9aae782b782066d7e9603fce9095aa5cafd30 (patch)
tree8f4d1a590e3745737bf60b0b47ead54d186e5821 /controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java
parent08c2a0490261a4666b65882616756ecfbe1c8c9b (diff)
Import controller
Diffstat (limited to 'controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java
new file mode 100644
index 00000000000..78b4f7f895f
--- /dev/null
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java
@@ -0,0 +1,56 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.controller.maintenance;
+
+import com.yahoo.component.Version;
+import com.yahoo.vespa.hosted.controller.api.integration.BuildService;
+import com.yahoo.vespa.hosted.controller.application.Change;
+import com.yahoo.vespa.hosted.controller.application.DeploymentJobs;
+import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
+import com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb;
+import org.junit.Test;
+
+import java.time.Duration;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author bratseth
+ */
+public class OutstandingChangeDeployerTest {
+
+ @Test
+ public void testChangeDeployer() {
+ DeploymentTester tester = new DeploymentTester();
+ OutstandingChangeDeployer deployer = new OutstandingChangeDeployer(tester.controller(), Duration.ofMinutes(10),
+ new JobControl(new MockCuratorDb()));
+
+ tester.createAndDeploy("app1", 11, "default");
+ tester.createAndDeploy("app2", 22, "default");
+
+ Version version = new Version(5, 2);
+ tester.deploymentTrigger().triggerChange(tester.application("app1").id(), new Change.VersionChange(version));
+
+ assertEquals(new Change.VersionChange(version), tester.application("app1").deploying().get());
+ assertFalse(tester.application("app1").hasOutstandingChange());
+ tester.notifyJobCompletion(DeploymentJobs.JobType.component, tester.application("app1"), true);
+ assertTrue(tester.application("app1").hasOutstandingChange());
+ assertEquals(1, tester.buildSystem().jobs().size());
+
+ deployer.maintain();
+ assertEquals("No effect as job is in progress", 1, tester.buildSystem().jobs().size());
+
+ tester.deployCompletely("app1");
+ assertEquals("Upgrade done", 0, tester.buildSystem().jobs().size());
+
+ deployer.maintain();
+ List<BuildService.BuildJob> jobs = tester.buildSystem().jobs();
+ assertEquals(1, jobs.size());
+ assertEquals(11, jobs.get(0).projectId());
+ assertEquals(DeploymentJobs.JobType.systemTest.id(), jobs.get(0).jobName());
+ assertFalse(tester.application("app1").hasOutstandingChange());
+ }
+
+}