diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-06-19 12:14:05 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-06-19 12:14:05 +0200 |
commit | 2979e7b1d18e2dfa262a815f22626e12f324e444 (patch) | |
tree | 2dd531e9d93dbdad0498fab28191b40fd45356e2 /controller-server | |
parent | db7d99e291683c5a2b3f9d651f978199a8cf0f76 (diff) |
I'm a skeleton
Diffstat (limited to 'controller-server')
43 files changed, 559 insertions, 244 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java index 295e0102782..9208537dd98 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java @@ -21,6 +21,7 @@ import com.yahoo.vespa.hosted.controller.rotation.RotationId; import java.time.Instant; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index f0e278c3e6d..57708bfc89c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -37,7 +37,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.Deployment; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.JobStatus; import com.yahoo.vespa.hosted.controller.application.JobStatus.JobRun; import com.yahoo.vespa.hosted.controller.application.SystemApplication; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java index b65d3bc0849..a6f87b3236d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java @@ -25,6 +25,9 @@ import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingSe import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry; +import com.yahoo.vespa.hosted.controller.deployment.DelegatingBuildService; +import com.yahoo.vespa.hosted.controller.deployment.InternalBuildService; +import com.yahoo.vespa.hosted.controller.deployment.JobController; import com.yahoo.vespa.hosted.controller.persistence.CuratorDb; import com.yahoo.vespa.hosted.controller.rotation.Rotation; import com.yahoo.vespa.hosted.controller.versions.VersionStatus; @@ -114,13 +117,16 @@ public class Controller extends AbstractComponent { this.clock = Objects.requireNonNull(clock, "Clock cannot be null"); this.athenzClientFactory = Objects.requireNonNull(athenzClientFactory, "AthenzClientFactory cannot be null"); + BuildService delegatingBuildService = new DelegatingBuildService(Objects.requireNonNull(buildService, "BuildService cannot be null"), + new InternalBuildService(new JobController(this))); + applicationController = new ApplicationController(this, curator, athenzClientFactory, Objects.requireNonNull(rotationsConfig, "RotationsConfig cannot be null"), Objects.requireNonNull(nameService, "NameService cannot be null"), configServer, Objects.requireNonNull(artifactRepository, "ArtifactRepository cannot be null"), Objects.requireNonNull(routingGenerator, "RoutingGenerator cannot be null"), - Objects.requireNonNull(buildService, "BuildService cannot be null"), + delegatingBuildService, clock); tenantController = new TenantController(this, curator, athenzClientFactory); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java index 3207d4b8399..79e7fa0295a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java @@ -18,7 +18,7 @@ import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.ClusterUtilization; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; import com.yahoo.vespa.hosted.controller.application.JobStatus; import com.yahoo.vespa.hosted.controller.rotation.RotationId; @@ -34,7 +34,7 @@ import java.util.OptionalLong; * An application that has been locked for modification. Provides methods for modifying an application's fields. * * @author mpolden - * @author jvenstad + * @author jonmv */ public class LockedApplication { @@ -158,7 +158,7 @@ public class LockedApplication { return with(deployments); } - public LockedApplication withoutDeploymentJob(DeploymentJobs.JobType jobType) { + public LockedApplication withoutDeploymentJob(JobType jobType) { return new LockedApplication(lock, id, deploymentSpec, validationOverrides, deployments, deploymentJobs.without(jobType), change, outstandingChange, ownershipIssueId, metrics, rotation); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/ActivateResult.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/ActivateResult.java index 271942ff9a3..a890c50a0af 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/ActivateResult.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/ActivateResult.java @@ -8,6 +8,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareRes * @author Oyvind Gronnesby */ public class ActivateResult { + // TODO jvenstad: Replace this class with just the PrepareResponse. private final RevisionId revisionId; private final PrepareResponse prepareResponse; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java new file mode 100644 index 00000000000..93ca86486d3 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java @@ -0,0 +1,98 @@ +package com.yahoo.vespa.hosted.controller.api.integration.deployment; + +import com.google.common.collect.ImmutableMap; +import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.RegionName; +import com.yahoo.config.provision.SystemName; +import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; +import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; + +import java.util.Optional; +import java.util.stream.Stream; + +/** Job types that exist in the build system */ +public enum JobType { +// | enum name ------------| job name ------------------| Zone in main system ---------------------------------------| Zone in CD system ------------------------------------------- + component ("component" , null , null ), + systemTest ("system-test" , ZoneId.from("test" , "us-east-1") , ZoneId.from("test" , "cd-us-central-1") ), + stagingTest ("staging-test" , ZoneId.from("staging", "us-east-3") , ZoneId.from("staging", "cd-us-central-1") ), + productionCorpUsEast1 ("production-corp-us-east-1" , ZoneId.from("prod" , "corp-us-east-1") , null ), + productionUsEast3 ("production-us-east-3" , ZoneId.from("prod" , "us-east-3") , null ), + productionUsWest1 ("production-us-west-1" , ZoneId.from("prod" , "us-west-1") , null ), + productionUsCentral1 ("production-us-central-1" , ZoneId.from("prod" , "us-central-1") , null ), + productionApNortheast1 ("production-ap-northeast-1" , ZoneId.from("prod" , "ap-northeast-1") , null ), + productionApNortheast2 ("production-ap-northeast-2" , ZoneId.from("prod" , "ap-northeast-2") , null ), + productionApSoutheast1 ("production-ap-southeast-1" , ZoneId.from("prod" , "ap-southeast-1") , null ), + productionEuWest1 ("production-eu-west-1" , ZoneId.from("prod" , "eu-west-1") , null ), + productionAwsUsEast1a ("production-aws-us-east-1a" , ZoneId.from("prod" , "aws-us-east-1a") , null ), + productionCdAwsUsEast1a("production-cd-aws-us-east-1a", null , ZoneId.from("prod" , "cd-aws-us-east-1a")), + productionCdUsCentral1 ("production-cd-us-central-1" , null , ZoneId.from("prod" , "cd-us-central-1") ), + productionCdUsCentral2 ("production-cd-us-central-2" , null , ZoneId.from("prod" , "cd-us-central-2") ); + + private final String jobName; + private final ImmutableMap<SystemName, ZoneId> zones; + + JobType(String jobName, ZoneId mainZone, ZoneId cdZone) { + this.jobName = jobName; + ImmutableMap.Builder<SystemName, ZoneId> builder = ImmutableMap.builder(); + if (mainZone != null) builder.put(SystemName.main, mainZone); + if (cdZone != null) builder.put(SystemName.cd, cdZone); + this.zones = builder.build(); + } + + public String jobName() { return jobName; } + + /** Returns the zone for this job in the given system, or empty if this job does not have a zone */ + public Optional<ZoneId> zone(SystemName system) { + return Optional.ofNullable(zones.get(system)); + } + + /** Returns whether this is a production job */ + public boolean isProduction() { return environment() == Environment.prod; } + + /** Returns whether this is an automated test job */ + public boolean isTest() { return environment() != null && environment().isTest(); } + + /** Returns the environment of this job type, or null if it does not have an environment */ + public Environment environment() { + switch (this) { + case component: return null; + case systemTest: return Environment.test; + case stagingTest: return Environment.staging; + default: return Environment.prod; + } + } + + /** Returns the region of this job type, or null if it does not have a region */ + public Optional<RegionName> region(SystemName system) { + return zone(system).map(ZoneId::region); + } + + public static Optional<JobType> fromOptionalJobName(String jobName) { + return Stream.of(values()) + .filter(jobType -> jobType.jobName.equals(jobName)) + .findAny(); + } + + public static JobType fromJobName(String jobName) { + return fromOptionalJobName(jobName) + .orElseThrow(() -> new IllegalArgumentException("Unknown job name '" + jobName + "'")); + } + + /** Returns the job type for the given zone */ + public static Optional<JobType> from(SystemName system, ZoneId zone) { + return Stream.of(values()) + .filter(job -> job.zone(system).filter(zone::equals).isPresent()) + .findAny(); + } + + /** Returns the job job type for the given environment and region or null if none */ + public static Optional<JobType> from(SystemName system, Environment environment, RegionName region) { + switch (environment) { + case test: return Optional.of(systemTest); + case staging: return Optional.of(stagingTest); + } + return from(system, ZoneId.from(environment, region)); + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java index d3193fd486d..4968e161a35 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java @@ -3,12 +3,9 @@ package com.yahoo.vespa.hosted.controller.application; import com.google.common.collect.ImmutableMap; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Environment; -import com.yahoo.config.provision.RegionName; -import com.yahoo.config.provision.SystemName; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; -import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import java.util.Collection; import java.util.HashMap; @@ -17,7 +14,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.OptionalLong; -import java.util.stream.Stream; /** * Information about which deployment jobs an application should run and their current status. @@ -122,93 +118,6 @@ public class DeploymentJobs { return id; } - /** Job types that exist in the build system */ - public enum JobType { -// | enum name ------------| job name ------------------| Zone in main system ---------------------------------------| Zone in CD system ------------------------------------------- - component ("component" , null , null ), - systemTest ("system-test" , ZoneId.from("test" , "us-east-1") , ZoneId.from("test" , "cd-us-central-1")), - stagingTest ("staging-test" , ZoneId.from("staging", "us-east-3") , ZoneId.from("staging", "cd-us-central-1")), - productionCorpUsEast1 ("production-corp-us-east-1" , ZoneId.from("prod" , "corp-us-east-1") , null ), - productionUsEast3 ("production-us-east-3" , ZoneId.from("prod" , "us-east-3") , null ), - productionUsWest1 ("production-us-west-1" , ZoneId.from("prod" , "us-west-1") , null ), - productionUsCentral1 ("production-us-central-1" , ZoneId.from("prod" , "us-central-1") , null ), - productionApNortheast1 ("production-ap-northeast-1" , ZoneId.from("prod" , "ap-northeast-1") , null ), - productionApNortheast2 ("production-ap-northeast-2" , ZoneId.from("prod" , "ap-northeast-2") , null ), - productionApSoutheast1 ("production-ap-southeast-1" , ZoneId.from("prod" , "ap-southeast-1") , null ), - productionEuWest1 ("production-eu-west-1" , ZoneId.from("prod" , "eu-west-1") , null ), - productionAwsUsEast1a ("production-aws-us-east-1a" , ZoneId.from("prod" , "aws-us-east-1a") , null ), - productionCdAwsUsEast1a("production-cd-aws-us-east-1a" , null , ZoneId.from("prod" , "cd-aws-us-east-1a")), - productionCdUsCentral1 ("production-cd-us-central-1", null , ZoneId.from("prod" , "cd-us-central-1")), - productionCdUsCentral2 ("production-cd-us-central-2", null , ZoneId.from("prod" , "cd-us-central-2")); - - private final String jobName; - private final ImmutableMap<SystemName, ZoneId> zones; - - JobType(String jobName, ZoneId mainZone, ZoneId cdZone) { - this.jobName = jobName; - ImmutableMap.Builder<SystemName, ZoneId> builder = ImmutableMap.builder(); - if (mainZone != null) builder.put(SystemName.main, mainZone); - if (cdZone != null) builder.put(SystemName.cd, cdZone); - this.zones = builder.build(); - } - - public String jobName() { return jobName; } - - /** Returns the zone for this job in the given system, or empty if this job does not have a zone */ - public Optional<ZoneId> zone(SystemName system) { - return Optional.ofNullable(zones.get(system)); - } - - /** Returns whether this is a production job */ - public boolean isProduction() { return environment() == Environment.prod; } - - /** Returns whether this is an automated test job */ - public boolean isTest() { return environment() != null && environment().isTest(); } - - /** Returns the environment of this job type, or null if it does not have an environment */ - public Environment environment() { - switch (this) { - case component: return null; - case systemTest: return Environment.test; - case stagingTest: return Environment.staging; - default: return Environment.prod; - } - } - - /** Returns the region of this job type, or null if it does not have a region */ - public Optional<RegionName> region(SystemName system) { - return zone(system).map(ZoneId::region); - } - - public static Optional<JobType> fromOptionalJobName(String jobName) { - return Stream.of(values()) - .filter(jobType -> jobType.jobName.equals(jobName)) - .findAny(); - } - - public static JobType fromJobName(String jobName) { - return fromOptionalJobName(jobName) - .orElseThrow(() -> new IllegalArgumentException("Unknown job name '" + jobName + "'")); - } - - /** Returns the job type for the given zone */ - public static Optional<JobType> from(SystemName system, ZoneId zone) { - return Stream.of(values()) - .filter(job -> job.zone(system).filter(zone::equals).isPresent()) - .findAny(); - } - - /** Returns the job job type for the given environment and region or null if none */ - public static Optional<JobType> from(SystemName system, Environment environment, RegionName region) { - switch (environment) { - case test: return Optional.of(systemTest); - case staging: return Optional.of(stagingTest); - } - return from(system, ZoneId.from(environment, region)); - } - - } - /** A job report. This class is immutable. */ public static class JobReport { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java index 90435e13a1b..cd15556ba9b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.application; import com.google.common.collect.ImmutableList; import com.yahoo.component.Version; import com.yahoo.vespa.hosted.controller.Application; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.JobStatus.JobRun; import java.time.Instant; @@ -16,7 +16,7 @@ import java.util.function.Predicate; /** * A list of deployment jobs that can be filtered in various ways. * - * @author jvenstad + * @author jonmv */ public class JobList { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobStatus.java index 8d15db888fd..a06a3e00340 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobStatus.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.application; import com.yahoo.component.Version; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import java.time.Instant; import java.util.Objects; @@ -18,7 +19,7 @@ import static java.util.Objects.requireNonNull; */ public class JobStatus { - private final DeploymentJobs.JobType type; + private final JobType type; private final Optional<JobRun> lastTriggered; private final Optional<JobRun> lastCompleted; @@ -31,7 +32,7 @@ public class JobStatus { * Used by the persistence layer (only) to create a complete JobStatus instance. * Other creation should be by using initial- and with- methods. */ - public JobStatus(DeploymentJobs.JobType type, Optional<DeploymentJobs.JobError> jobError, + public JobStatus(JobType type, Optional<DeploymentJobs.JobError> jobError, Optional<JobRun> lastTriggered, Optional<JobRun> lastCompleted, Optional<JobRun> firstFailing, Optional<JobRun> lastSuccess) { requireNonNull(type, "jobType cannot be null"); @@ -45,14 +46,14 @@ public class JobStatus { this.jobError = jobError; // Never say we triggered component because we don't: - this.lastTriggered = type == DeploymentJobs.JobType.component ? Optional.empty() : lastTriggered; + this.lastTriggered = type == JobType.component ? Optional.empty() : lastTriggered; this.lastCompleted = lastCompleted; this.firstFailing = firstFailing; this.lastSuccess = lastSuccess; } /** Returns an empty job status */ - public static JobStatus initial(DeploymentJobs.JobType type) { + public static JobStatus initial(JobType type) { return new JobStatus(type, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -82,7 +83,7 @@ public class JobStatus { return new JobStatus(type, jobError, lastTriggered, Optional.of(completion), firstFailing, lastSuccess); } - public DeploymentJobs.JobType type() { return type; } + public JobType type() { return type; } /** Returns true unless this job last completed with a failure */ public boolean isSuccess() { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DelegatingBuildService.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DelegatingBuildService.java new file mode 100644 index 00000000000..d2159841c9d --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DelegatingBuildService.java @@ -0,0 +1,30 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +import com.yahoo.vespa.hosted.controller.api.integration.BuildService; + +/** + * Sends build jobs to an internal build system whenever it accepts them, or to an external one otherwise. + * + * @author jonmv + */ +public class DelegatingBuildService implements BuildService { + + private final BuildService external; + private final BuildService internal; + + public DelegatingBuildService(BuildService external, BuildService internal) { + this.external = external; + this.internal = internal; + } + + @Override + public void trigger(BuildJob buildJob) { + (internal.builds(buildJob) ? internal : external).trigger(buildJob); + } + + @Override + public JobState stateOf(BuildJob buildJob) { + return (internal.builds(buildJob) ? internal : external).stateOf(buildJob); + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java index d399ef977ac..51c1e61ecb2 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java @@ -7,7 +7,7 @@ import com.yahoo.config.provision.SystemName; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.JobStatus; import java.util.Collection; @@ -46,7 +46,7 @@ public class DeploymentSteps { /** Returns job status sorted according to deployment spec */ public List<JobStatus> sortBy(Collection<JobStatus> jobStatus) { - List<DeploymentJobs.JobType> sortedJobs = jobs(); + List<JobType> sortedJobs = jobs(); return jobStatus.stream() .sorted(comparingInt(job -> sortedJobs.indexOf(job.type()))) .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java index 00b2a5c9b52..e3b4b4cef8c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java @@ -15,7 +15,7 @@ import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.Change; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.JobStatus; import com.yahoo.vespa.hosted.controller.application.JobStatus.JobRun; @@ -40,9 +40,9 @@ import static com.yahoo.vespa.hosted.controller.api.integration.BuildService.Bui import static com.yahoo.vespa.hosted.controller.api.integration.BuildService.JobState.idle; import static com.yahoo.vespa.hosted.controller.api.integration.BuildService.JobState.queued; import static com.yahoo.vespa.hosted.controller.api.integration.BuildService.JobState.running; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static java.util.Comparator.comparing; @@ -60,7 +60,7 @@ import static java.util.stream.Collectors.toList; * * @author bratseth * @author mpolden - * @author jvenstad + * @author jonmv */ public class DeploymentTrigger { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalBuildService.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalBuildService.java new file mode 100644 index 00000000000..c83c2ebb9e4 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalBuildService.java @@ -0,0 +1,33 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +import com.yahoo.vespa.hosted.controller.Controller; +import com.yahoo.vespa.hosted.controller.api.integration.BuildService; + +/** + * + * @author jonmv + */ +public class InternalBuildService implements BuildService { + + private final JobController jobs; + + public InternalBuildService(JobController jobs) { + this.jobs = jobs; + } + + @Override + public void trigger(BuildJob buildJob) { + + } + + @Override + public JobState stateOf(BuildJob buildJob) { + return null; + } + + @Override + public boolean builds(BuildJob buildJob) { + return false; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java new file mode 100644 index 00000000000..fdbbc53ce21 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -0,0 +1,83 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.vespa.hosted.controller.Controller; +import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; +import com.yahoo.vespa.hosted.controller.api.integration.LogStore; + +import java.util.List; + +public class JobController { + + private final Controller controller; + private final LogStore logs; + + public JobController(Controller controller) { + this.controller = controller; + this.logs = null; + } + + +// GET: + /** Returns whether the given application has registered with this build service. */ + boolean builds(ApplicationId application) { + return false; + } + + /** Returns a list of all application which have registered. */ + List<ApplicationId> applications() { + return null; + } + + /** Returns all job types which have been run for the given application. */ + List<DeploymentId> jobs(ApplicationId application) { + return null; + } + + /** Returns a list of meta information about all runs of the given type. */ + List<JobMeta> runs(DeploymentId deployment) { + return null; + } + + /** Returns the current status of the given job. */ + JobMeta status(JobId job) { + return null; + } + + /** Returns all details about the given job. */ + JobDetails details(JobId job) { + return null; + } + + +// POST: + /** Registers the given application, such that it may have deployment jobs run here. */ + void register(ApplicationId application) { + ; + } + + /** Orders a run of the given type, and returns the id of the created job. */ + JobId run(DeploymentId deployment) { + return null; + } + + +// PUT: + /** Stores the given details for the given job. */ + void store(JobDetails details, JobId job) { + ; + } + + +// DELETE: + /** Unregisters the given application, and deletes all associated data. */ + void unregister(ApplicationId application) { + ; + } + + /** Aborts the given job. */ + void abort(JobId job) { + ; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobDetails.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobDetails.java new file mode 100644 index 00000000000..239fde65031 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobDetails.java @@ -0,0 +1,17 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +import com.yahoo.vespa.hosted.controller.api.ActivateResult; + +public class JobDetails { + + private final ActivateResult deploymentResult; + private final String convergenceLog; + private final String testLog; + + public JobDetails(ActivateResult deploymentResult, String convergenceLog, String testLog) { + this.deploymentResult = deploymentResult; + this.convergenceLog = convergenceLog; + this.testLog = testLog; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobId.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobId.java new file mode 100644 index 00000000000..bfbb63eb2e9 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobId.java @@ -0,0 +1,55 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; + +import java.util.Objects; + +/** + * Immutable ID of a job run by an {@link InternalBuildService}. + * + * @author jonmv + */ +public class JobId { + + private final ApplicationId application; + private final String type; + private final long number; + + public JobId(ApplicationId application, String type, long number) { + this.application = Objects.requireNonNull(application, "ApplicationId cannot be null!"); + this.type = Objects.requireNonNull(type, "JobType cannot be null!"); + if (number <= 0) throw new IllegalArgumentException("Build number must be a positive long integer!"); + this.number = number; + } + + public ApplicationId application() { return application; } + public String type() { return type; } + public long number() { return number; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if ( ! (o instanceof JobId)) return false; + + JobId id = (JobId) o; + + if (number != id.number) return false; + if ( ! application.equals(id.application)) return false; + return type == id.type; + } + + @Override + public int hashCode() { + int result = application.hashCode(); + result = 31 * result + type.hashCode(); + result = 31 * result + (int) (number ^ (number >>> 32)); + return result; + } + + @Override + public String toString() { + return "Run " + number + " of " + type + " for " + application; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java new file mode 100644 index 00000000000..5b5e7d301a1 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java @@ -0,0 +1,21 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +import java.time.Instant; + +public class JobMeta { + + private final JobId id; + private final JobState state; + private final JobOutcome outcome; + private final Instant start; + private final Instant end; + + public JobMeta(JobId id, JobState state, JobOutcome outcome, Instant start, Instant end) { + this.id = id; + this.state = state; + this.outcome = outcome; + this.start = start; + this.end = end; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobOutcome.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobOutcome.java new file mode 100644 index 00000000000..caecdcffb9b --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobOutcome.java @@ -0,0 +1,31 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +/** + * Outcomes of jobs run by an {@link InternalBuildService}. + * + * @author jonmv + */ +public enum JobOutcome { + + /** Deployment of the real application was rejected due to missing capacity. */ + outOfCapacity, + + /** Deployment of the real application was rejected. */ + deploymentFailed, + + /** Convergence of the real application timed out. */ + convergenceFailed, + + /** Real application was deployed, but the tester application was not. */ + testError, + + /** Real application was deployed, but the tests failed. */ + testFailure, + + /** Deployment and tests completed with great success! */ + success, + + /** Job completed abnormally, due to user intervention or unexpected system error. */ + aborted + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java new file mode 100644 index 00000000000..19e575efaf8 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java @@ -0,0 +1,28 @@ +package com.yahoo.vespa.hosted.controller.deployment; + +/** + * Status of jobs run by an {@link InternalBuildService}. + * + * @author jonmv + */ +public enum JobState { + + /** Job is not currently running, and may be started. */ + idle, + + /** Real application is deploying. */ + deploying, + + /** Real application is converging. */ + converging, + + /** Tester is starting up, but is not yet ready to serve its status. */ + initializing, + + /** Job is up and running normally. */ + running, + + /** Tests are complete, and results may be fetched. */ + finished + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java index 16f6378d2dc..bf58bac177c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.component.Version; import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.Change; import com.yahoo.vespa.hosted.controller.application.Deployment; @@ -10,8 +11,6 @@ import com.yahoo.vespa.hosted.controller.application.JobStatus; import java.util.Optional; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; - /** * Source and target versions for an application. * @@ -102,7 +101,7 @@ public class Versions { Optional<Deployment> deployment) { return max(deployment.map(Deployment::applicationVersion), change.application()) .orElse(application.oldestDeployedApplication() - .orElse(application.deploymentJobs().jobStatus().get(component) + .orElse(application.deploymentJobs().jobStatus().get(JobType.component) .lastSuccess() .get() .application())); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java index 1a6bce2dba9..8db7231c207 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java @@ -22,7 +22,7 @@ import java.util.logging.Level; * * When to file new issues, escalate inactive ones, etc., is handled by the enclosed OwnershipIssues. * - * @author jvenstad + * @author jonmv */ public class ApplicationOwnershipConfirmer extends Maintainer { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java index d471e553bb9..91eda31d779 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java @@ -28,7 +28,7 @@ import static com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence * Maintenance job which files issues for tenants when they have jobs which fails continuously * and escalates issues which are not handled in a timely manner. * - * @author jvenstad + * @author jonmv */ public class DeploymentIssueReporter extends Maintainer { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java index 96d252d3d1c..d804afdf98e 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java @@ -13,6 +13,7 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; @@ -398,8 +399,8 @@ public class ApplicationSerializer { private Optional<JobStatus> jobStatusFromSlime(Inspector object) { // if the job type has since been removed, ignore it - Optional<DeploymentJobs.JobType> jobType = - DeploymentJobs.JobType.fromOptionalJobName(object.field(jobTypeField).asString()); + Optional<JobType> jobType = + JobType.fromOptionalJobName(object.field(jobTypeField).asString()); if (! jobType.isPresent()) return Optional.empty(); Optional<JobError> jobError = Optional.empty(); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 76a8eaec5d9..d6c0bf23da6 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -48,6 +48,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFact import com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; @@ -856,7 +857,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { } return new DeploymentJobs.JobReport( ApplicationId.from(tenantName, applicationName, report.field("instance").asString()), - DeploymentJobs.JobType.fromJobName(report.field("jobName").asString()), + JobType.fromJobName(report.field("jobName").asString()), report.field("projectId").asLong(), report.field("buildNumber").asLong(), toSourceRevision(report.field("sourceRevision")), diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java index c1a2c575fc2..26d0b1868ae 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java @@ -10,7 +10,7 @@ import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.restapi.ErrorResponse; import com.yahoo.vespa.hosted.controller.restapi.Path; import com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index 225516644eb..621eb33bd66 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -26,7 +26,7 @@ import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.Change; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.JobStatus; import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -55,12 +55,12 @@ import java.util.stream.Collectors; import static com.yahoo.config.provision.SystemName.main; import static com.yahoo.vespa.hosted.controller.ControllerTester.buildJob; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionCorpUsEast1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionCorpUsEast1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsEast3; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsWest1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java index cf2fa182d0a..d3b70ea07d8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java @@ -16,6 +16,7 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; import com.yahoo.vespa.hosted.controller.api.integration.chef.ChefMock; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.dns.MemoryNameService; import com.yahoo.vespa.hosted.controller.api.integration.entity.EntityService; import com.yahoo.vespa.hosted.controller.api.integration.entity.MemoryEntityService; @@ -25,7 +26,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRou import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.athenz.mock.AthenzClientFactoryMock; import com.yahoo.vespa.hosted.controller.athenz.mock.AthenzDbMock; import com.yahoo.vespa.hosted.controller.integration.MockMetricsService; @@ -122,7 +122,7 @@ public final class ControllerTester { }); } - public static BuildService.BuildJob buildJob(Application application, DeploymentJobs.JobType jobType) { + public static BuildService.BuildJob buildJob(Application application, JobType jobType) { return BuildService.BuildJob.of(application.id(), application.deploymentJobs().projectId().getAsLong(), jobType.jobName()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java index 821eb237530..bec909addec 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.ArtifactRepositoryMock; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.application.SourceRevision; @@ -24,7 +25,7 @@ public class BuildJob { "master", "commit1"); public static final long defaultBuildNumber = 42; - private DeploymentJobs.JobType job; + private JobType job; private ApplicationId applicationId; private Optional<DeploymentJobs.JobError> jobError = Optional.empty(); private Optional<SourceRevision> sourceRevision = Optional.of(defaultSourceRevision); @@ -41,7 +42,7 @@ public class BuildJob { this.artifactRepository = artifactRepository; } - public BuildJob type(DeploymentJobs.JobType job) { + public BuildJob type(JobType job) { this.job = job; return this; } @@ -105,7 +106,7 @@ public class BuildJob { public BuildJob uploadArtifact(ApplicationPackage applicationPackage) { Objects.requireNonNull(job, "job cannot be null"); Objects.requireNonNull(applicationId, "applicationId cannot be null"); - if (job != DeploymentJobs.JobType.component) { + if (job != JobType.component) { throw new IllegalStateException(job + " cannot upload artifact"); } artifactRepository.put(applicationId, applicationPackage, applicationVersion()); @@ -114,7 +115,7 @@ public class BuildJob { /** Send report for this build job to the controller */ public void submit() { - if (job == DeploymentJobs.JobType.component && + if (job == JobType.component && !artifactRepository.contains(applicationId, applicationVersion())) { throw new IllegalStateException(job + " must upload artifact before reporting completion"); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java index f91dce2b203..bae1f667566 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java @@ -17,7 +17,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Change; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.SystemApplication; import com.yahoo.vespa.hosted.controller.maintenance.JobControl; import com.yahoo.vespa.hosted.controller.maintenance.ReadyJobsTrigger; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java index 10f53f17153..033fddf3af8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java @@ -12,8 +12,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.maintenance.JobControl; import com.yahoo.vespa.hosted.controller.maintenance.ReadyJobsTrigger; @@ -26,13 +25,13 @@ import java.util.function.Supplier; import static com.yahoo.config.provision.SystemName.main; import static com.yahoo.vespa.hosted.controller.ControllerTester.buildJob; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionEuWest1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsCentral1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionEuWest1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsCentral1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsEast3; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsWest1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -42,7 +41,7 @@ import static org.junit.Assert.assertTrue; /** * @author bratseth * @author mpolden - * @author jvenstad + * @author jonmv */ public class DeploymentTriggerTest { @@ -61,8 +60,8 @@ public class DeploymentTriggerTest { // Deploy completely once tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); tester.deployAndNotify(app, applicationPackage, true, JobType.productionUsWest1); // New version is released @@ -229,17 +228,17 @@ public class DeploymentTriggerTest { tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); // Test environments pass - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); // Last declared job completes first - tester.deploy(DeploymentJobs.JobType.productionUsWest1, app, applicationPackage); - tester.jobCompletion(DeploymentJobs.JobType.productionUsWest1).application(app).submit(); + tester.deploy(JobType.productionUsWest1, app, applicationPackage); + tester.jobCompletion(JobType.productionUsWest1).application(app).submit(); assertTrue("Change is present as not all jobs are complete", tester.applications().require(app.id()).change().isPresent()); // All jobs complete - tester.deploy(DeploymentJobs.JobType.productionUsEast3, app, applicationPackage); + tester.deploy(JobType.productionUsEast3, app, applicationPackage); tester.jobCompletion(JobType.productionUsEast3).application(app).submit(); assertFalse("Change has been deployed", tester.applications().require(app.id()).change().isPresent()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java index b5941c441e2..703d65c8f9d 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** - * @author jvenstad + * @author jonmv */ public class ApplicationOwnershipConfirmerTest { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java index 2abd01927a1..a1aef28bd63 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java @@ -19,10 +19,10 @@ import java.time.Duration; import java.util.HashMap; import java.util.Map; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionCorpUsEast1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionCorpUsEast1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static com.yahoo.vespa.hosted.controller.maintenance.DeploymentIssueReporter.maxFailureAge; import static com.yahoo.vespa.hosted.controller.maintenance.DeploymentIssueReporter.maxInactivity; import static com.yahoo.vespa.hosted.controller.maintenance.DeploymentIssueReporter.upgradeGracePeriod; @@ -31,7 +31,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** - * @author jvenstad + * @author jonmv */ public class DeploymentIssueReporterTest { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java index af7325950e4..1bedb29ec97 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java @@ -18,8 +18,8 @@ import org.junit.Test; import java.time.Duration; import java.util.Optional; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/FailureRedeployerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/FailureRedeployerTest.java index 981b8c8c52a..307007e394a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/FailureRedeployerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/FailureRedeployerTest.java @@ -8,8 +8,8 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.ControllerTester; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import org.junit.Test; @@ -19,9 +19,9 @@ import java.nio.file.Paths; import java.time.Duration; import java.util.Collections; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsEast3; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -44,9 +44,9 @@ public class FailureRedeployerTest { Application app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.productionUsEast3); // New version is released version = Version.fromString("5.1"); @@ -56,12 +56,12 @@ public class FailureRedeployerTest { tester.readyJobTrigger().maintain(); // Test environments pass - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); // Production job fails and is retried tester.clock().advance(Duration.ofSeconds(1)); // Advance time so that we can detect jobs in progress - tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3); + tester.deployAndNotify(app, applicationPackage, false, JobType.productionUsEast3); assertEquals("Production job is retried", 1, tester.buildService().jobs().size()); assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get()); @@ -69,24 +69,24 @@ public class FailureRedeployerTest { version = Version.fromString("5.2"); tester.upgradeSystem(version); tester.upgrader().maintain(); - tester.jobCompletion(DeploymentJobs.JobType.productionUsEast3).application(app).unsuccessful().submit(); + tester.jobCompletion(JobType.productionUsEast3).application(app).unsuccessful().submit(); assertEquals("Application starts upgrading to new version", 2, tester.buildService().jobs().size()); assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get()); // Failure re-deployer did not retry failing job for prod.us-east-3, since it no longer had an available change assertFalse("Job is not retried", tester.buildService().jobs().stream() - .anyMatch(j -> j.jobName().equals(DeploymentJobs.JobType.productionUsEast3.jobName()))); + .anyMatch(j -> j.jobName().equals(JobType.productionUsEast3.jobName()))); // Test environments pass - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); // Production job fails again, and is retried - tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3); + tester.deployAndNotify(app, applicationPackage, false, JobType.productionUsEast3); assertEquals("Job is retried", Collections.singletonList(ControllerTester.buildJob(app, productionUsEast3)), tester.buildService().jobs()); // Production job finally succeeds - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3); + tester.deployAndNotify(app, applicationPackage, true, JobType.productionUsEast3); assertTrue("All jobs consumed", tester.buildService().jobs().isEmpty()); assertFalse("No failures", tester.application(app.id()).deploymentJobs().hasFailures()); } @@ -103,9 +103,9 @@ public class FailureRedeployerTest { Application app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.productionUsEast3); // New version is released version = Version.fromString("5.1"); @@ -116,7 +116,7 @@ public class FailureRedeployerTest { assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get()); // system-test fails and is left with a retry - tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, false, JobType.systemTest); // Another version is released version = Version.fromString("5.2"); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java index af61af6da52..e189a9243db 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java @@ -31,10 +31,10 @@ import java.time.Instant; import java.time.ZoneId; import java.util.Map; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsWest1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; 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 index 3b14ad4bf10..4483122d554 100644 --- 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 @@ -5,9 +5,9 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; @@ -46,7 +46,7 @@ public class OutstandingChangeDeployerTest { assertEquals(Change.of(version), tester.application("app1").change()); assertFalse(tester.application("app1").outstandingChange().isPresent()); - tester.jobCompletion(DeploymentJobs.JobType.component) + tester.jobCompletion(JobType.component) .application(tester.application("app1")) .sourceRevision(new SourceRevision("repository1","master", "cafed00d")) .nextBuildNumber() @@ -63,9 +63,9 @@ public class OutstandingChangeDeployerTest { assertEquals("No effect as job is in progress", 2, tester.buildService().jobs().size()); assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id()); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest); - tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsWest1); + tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(app, applicationPackage, true, JobType.productionUsWest1); assertEquals("Upgrade done", 0, tester.buildService().jobs().size()); deployer.maintain(); @@ -75,8 +75,8 @@ public class OutstandingChangeDeployerTest { List<BuildService.BuildJob> jobs = tester.buildService().jobs(); assertEquals(2, jobs.size()); assertEquals(11, jobs.get(0).projectId()); - tester.assertRunning(DeploymentJobs.JobType.systemTest, app.id()); - tester.assertRunning(DeploymentJobs.JobType.stagingTest, app.id()); + tester.assertRunning(JobType.systemTest, app.id()); + tester.assertRunning(JobType.stagingTest, app.id()); assertFalse(tester.application("app1").outstandingChange().isPresent()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java index cf32a18522f..781933eda64 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java @@ -7,10 +7,10 @@ import com.yahoo.config.provision.RegionName; import com.yahoo.test.ManualClock; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.ControllerTester; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.versions.VespaVersion; @@ -19,12 +19,12 @@ import org.junit.Test; import java.time.Duration; import java.time.Instant; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsCentral1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsCentral1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsEast3; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsWest1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -220,7 +220,7 @@ public class UpgraderTest { tester.completeUpgradeWithError(default3, version54, "default", stagingTest); - tester.completeUpgradeWithError(default4, version54, "default", DeploymentJobs.JobType.productionUsWest1); + tester.completeUpgradeWithError(default4, version54, "default", JobType.productionUsWest1); // State: Default applications started upgrading to 5.5 tester.clock().advance(Duration.ofHours(1)); tester.upgrader().maintain(); @@ -231,13 +231,13 @@ public class UpgraderTest { tester.completeUpgradeWithError(default2, version55, "default", stagingTest); tester.clock().advance(Duration.ofHours(2).plus(Duration.ofSeconds(1))); // Retry failing job for default3 tester.readyJobTrigger().maintain(); - tester.completeUpgradeWithError(default3, version55, "default", DeploymentJobs.JobType.productionUsWest1); + tester.completeUpgradeWithError(default3, version55, "default", JobType.productionUsWest1); tester.upgradeSystem(version55); assertEquals(VespaVersion.Confidence.broken, tester.controller().versionStatus().systemVersion().get().confidence()); // Finish running job, without retry. tester.clock().advance(Duration.ofHours(1)); - tester.jobCompletion(DeploymentJobs.JobType.productionUsWest1).application(default3).unsuccessful().submit(); + tester.jobCompletion(JobType.productionUsWest1).application(default3).unsuccessful().submit(); tester.upgrader().maintain(); tester.buildService().clear(); 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 656c377b84b..95a785ca0df 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 @@ -10,6 +10,7 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.api.integration.MetricsService; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; @@ -78,13 +79,13 @@ public class ApplicationSerializerTest { OptionalLong projectId = OptionalLong.of(123L); List<JobStatus> statusList = new ArrayList<>(); - statusList.add(JobStatus.initial(DeploymentJobs.JobType.systemTest) + statusList.add(JobStatus.initial(JobType.systemTest) .withTriggering(Version.fromString("5.6.7"), ApplicationVersion.unknown, empty(), "Test", Instant.ofEpochMilli(7)) .withCompletion(30, empty(), Instant.ofEpochMilli(8))); - statusList.add(JobStatus.initial(DeploymentJobs.JobType.stagingTest) + statusList.add(JobStatus.initial(JobType.stagingTest) .withTriggering(Version.fromString("5.6.6"), ApplicationVersion.unknown, empty(), "Test 2", Instant.ofEpochMilli(5)) .withCompletion(11, Optional.of(JobError.unknown), Instant.ofEpochMilli(6))); - statusList.add(JobStatus.initial(DeploymentJobs.JobType.from(main, zone1).get()) + statusList.add(JobStatus.initial(JobType.from(main, zone1).get()) .withTriggering(Version.fromString("5.6.6"), ApplicationVersion.unknown, deployments.stream().findFirst(), "Test 3", Instant.ofEpochMilli(6)) .withCompletion(11, empty(), Instant.ofEpochMilli(7))); @@ -119,10 +120,10 @@ public class ApplicationSerializerTest { assertEquals(original.deploymentJobs().projectId(), serialized.deploymentJobs().projectId()); assertEquals(original.deploymentJobs().jobStatus().size(), serialized.deploymentJobs().jobStatus().size()); - assertEquals( original.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.systemTest), - serialized.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.systemTest)); - assertEquals( original.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest), - serialized.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest)); + assertEquals( original.deploymentJobs().jobStatus().get(JobType.systemTest), + serialized.deploymentJobs().jobStatus().get(JobType.systemTest)); + assertEquals( original.deploymentJobs().jobStatus().get(JobType.stagingTest), + serialized.deploymentJobs().jobStatus().get(JobType.stagingTest)); assertEquals(original.outstandingChange(), serialized.outstandingChange()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java index 51437be2832..6d88cf79241 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java @@ -12,14 +12,12 @@ import com.yahoo.vespa.hosted.controller.ArtifactRepositoryMock; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.TestIdentities; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions; -import com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch; -import com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit; -import com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId; import com.yahoo.vespa.hosted.controller.api.integration.athenz.ApplicationAction; import com.yahoo.vespa.hosted.controller.api.integration.athenz.HostedAthenzIdentities; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; @@ -38,7 +36,7 @@ import java.io.IOException; import java.time.Duration; import java.util.Optional; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; import static org.junit.Assert.assertFalse; /** @@ -92,7 +90,7 @@ public class ContainerControllerTester { } /** Notify the controller about a job completing */ - public BuildJob jobCompletion(DeploymentJobs.JobType job) { + public BuildJob jobCompletion(JobType job) { return new BuildJob(this::notifyJobCompletion, artifactRepository()).type(job); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 545ee529635..c748d32ef0b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -27,6 +27,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.MetricsService.Applicat import com.yahoo.vespa.hosted.controller.api.integration.athenz.ApplicationAction; import com.yahoo.vespa.hosted.controller.api.integration.athenz.HostedAthenzIdentities; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.organization.MockOrganization; import com.yahoo.vespa.hosted.controller.api.integration.organization.User; @@ -194,7 +195,7 @@ public class ApplicationApiTest extends ControllerContainerTest { new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(id.application().value())); // (Necessary but not provided in this API) // Trigger deployment from completion of component job - controllerTester.jobCompletion(DeploymentJobs.JobType.component) + controllerTester.jobCompletion(JobType.component) .application(id) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) @@ -209,7 +210,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .screwdriverIdentity(SCREWDRIVER_ID), "Deactivated tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default"); // Called through the separate screwdriver/v1 API - controllerTester.jobCompletion(DeploymentJobs.JobType.systemTest) + controllerTester.jobCompletion(JobType.systemTest) .application(id) .projectId(screwdriverProjectId) .submit(); @@ -222,7 +223,7 @@ public class ApplicationApiTest extends ControllerContainerTest { tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/staging/region/us-east-3/instance/default", DELETE) .screwdriverIdentity(SCREWDRIVER_ID), "Deactivated tenant/tenant1/application/application1/environment/staging/region/us-east-3/instance/default"); - controllerTester.jobCompletion(DeploymentJobs.JobType.stagingTest) + controllerTester.jobCompletion(JobType.stagingTest) .application(id) .projectId(screwdriverProjectId) .submit(); @@ -232,7 +233,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .data(createApplicationDeployData(applicationPackage, false)) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); - controllerTester.jobCompletion(DeploymentJobs.JobType.productionCorpUsEast1) + controllerTester.jobCompletion(JobType.productionCorpUsEast1) .application(id) .projectId(screwdriverProjectId) .unsuccessful() @@ -492,7 +493,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .data(deployData) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); - controllerTester.jobCompletion(DeploymentJobs.JobType.productionUsEast3) + controllerTester.jobCompletion(JobType.productionUsEast3) .application(id) .projectId(projectId) .submit(); @@ -511,7 +512,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .data(deployData) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); - controllerTester.jobCompletion(DeploymentJobs.JobType.productionUsWest1) + controllerTester.jobCompletion(JobType.productionUsWest1) .application(id) .projectId(projectId) .submit(); @@ -521,7 +522,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .data(deployData) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); - controllerTester.jobCompletion(DeploymentJobs.JobType.productionUsEast3) + controllerTester.jobCompletion(JobType.productionUsEast3) .application(id) .projectId(projectId) .submit(); @@ -830,7 +831,7 @@ public class ApplicationApiTest extends ControllerContainerTest { controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); // Allow systemtest to succeed by notifying completion of system test - controllerTester.jobCompletion(DeploymentJobs.JobType.component) + controllerTester.jobCompletion(JobType.component) .application(application.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) @@ -859,27 +860,27 @@ public class ApplicationApiTest extends ControllerContainerTest { BuildJob job = new BuildJob(report -> notifyCompletion(report, tester), tester.artifactRepository()) .application(app) .projectId(projectId); - job.type(DeploymentJobs.JobType.component).uploadArtifact(applicationPackage).submit(); + job.type(JobType.component).uploadArtifact(applicationPackage).submit(); tester.deploy(app, applicationPackage, TEST_ZONE, projectId); - job.type(DeploymentJobs.JobType.systemTest).submit(); + job.type(JobType.systemTest).submit(); // Notifying about unknown job fails Request request = request("/application/v4/tenant/tenant1/application/application1/jobreport", POST) - .data(asJson(job.type(DeploymentJobs.JobType.productionUsEast3).report())) + .data(asJson(job.type(JobType.productionUsEast3).report())) .userIdentity(HOSTED_VESPA_OPERATOR) .get(); tester.containerTester().assertResponse(request, new File("jobreport-unexpected-completion.json"), 400); // ... and assert it was recorded JobStatus recordedStatus = - tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.component); + tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(JobType.component); assertNotNull("Status was recorded", recordedStatus); assertTrue(recordedStatus.isSuccess()); assertEquals(vespaVersion, recordedStatus.lastCompleted().get().platform()); recordedStatus = - tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.productionApNortheast2); + tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(JobType.productionApNortheast2); assertNull("Status of never-triggered jobs is empty", recordedStatus); Response response; @@ -906,19 +907,19 @@ public class ApplicationApiTest extends ControllerContainerTest { BuildJob job = new BuildJob(report -> notifyCompletion(report, tester), tester.artifactRepository()) .application(app) .projectId(projectId); - job.type(DeploymentJobs.JobType.component).uploadArtifact(applicationPackage).submit(); + job.type(JobType.component).uploadArtifact(applicationPackage).submit(); tester.deploy(app, applicationPackage, TEST_ZONE, projectId); - job.type(DeploymentJobs.JobType.systemTest).submit(); + job.type(JobType.systemTest).submit(); tester.deploy(app, applicationPackage, STAGING_ZONE, projectId); - job.type(DeploymentJobs.JobType.stagingTest).error(DeploymentJobs.JobError.outOfCapacity).submit(); + job.type(JobType.stagingTest).error(DeploymentJobs.JobError.outOfCapacity).submit(); // Appropriate error is recorded JobStatus jobStatus = tester.controller().applications().get(app.id()) .get() .deploymentJobs() .jobStatus() - .get(DeploymentJobs.JobType.stagingTest); + .get(JobType.stagingTest); assertFalse(jobStatus.isSuccess()); assertEquals(DeploymentJobs.JobError.outOfCapacity, jobStatus.jobError().get()); } @@ -1062,7 +1063,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // Trigger application change controllerTester.artifactRepository().put(application, applicationPackage,"1.0." + buildNumber + "-commit1"); - controllerTester.jobCompletion(DeploymentJobs.JobType.component) + controllerTester.jobCompletion(JobType.component) .application(application) .projectId(projectId) .buildNumber(buildNumber) @@ -1078,7 +1079,7 @@ public class ApplicationApiTest extends ControllerContainerTest { tester.assertResponse(request(testPath, DELETE) .screwdriverIdentity(SCREWDRIVER_ID), "Deactivated " + testPath.replaceFirst("/application/v4/", "")); - controllerTester.jobCompletion(DeploymentJobs.JobType.systemTest) + controllerTester.jobCompletion(JobType.systemTest) .application(application) .projectId(projectId) .submit(); @@ -1093,7 +1094,7 @@ public class ApplicationApiTest extends ControllerContainerTest { tester.assertResponse(request(stagingPath, DELETE) .screwdriverIdentity(SCREWDRIVER_ID), "Deactivated " + stagingPath.replaceFirst("/application/v4/", "")); - controllerTester.jobCompletion(DeploymentJobs.JobType.stagingTest) + controllerTester.jobCompletion(JobType.stagingTest) .application(application) .projectId(projectId) .submit(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java index fa93c0f1df1..61f915f3c1e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java @@ -8,9 +8,9 @@ import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.RegionName; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester; import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest; @@ -102,20 +102,20 @@ public class DeploymentApiTest extends ControllerContainerTest { private void deployCompletely(Application application, ApplicationPackage applicationPackage, long projectId, boolean success) { - tester.jobCompletion(DeploymentJobs.JobType.component) + tester.jobCompletion(JobType.component) .application(application) .projectId(projectId) .uploadArtifact(applicationPackage) .submit(); tester.deploy(application, applicationPackage, ZoneId.from(Environment.test, RegionName.from("us-east-1")), projectId); - tester.jobCompletion(DeploymentJobs.JobType.systemTest) + tester.jobCompletion(JobType.systemTest) .application(application) .projectId(projectId) .submit(); tester.deploy(application, applicationPackage, ZoneId.from(Environment.staging, RegionName.from("us-east-3")), projectId); - tester.jobCompletion(DeploymentJobs.JobType.stagingTest) + tester.jobCompletion(JobType.stagingTest) .application(application) .projectId(projectId) .success(success) @@ -123,7 +123,7 @@ public class DeploymentApiTest extends ControllerContainerTest { if (success) { tester.deploy(application, applicationPackage, ZoneId.from(Environment.prod, RegionName.from("corp-us-east-1")), projectId); - tester.jobCompletion(DeploymentJobs.JobType.productionCorpUsEast1) + tester.jobCompletion(JobType.productionCorpUsEast1) .application(application) .projectId(projectId) .submit(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java index 99274fd9f44..6cd4464dce4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.restapi.screwdriver; import com.yahoo.application.container.handler.Request; import com.yahoo.vespa.hosted.controller.Application; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport; import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester; @@ -18,7 +18,7 @@ import java.util.OptionalLong; /** * @author bratseth - * @author jvenstad + * @author jonmv */ public class ScrewdriverApiTest extends ControllerContainerTest { @@ -62,7 +62,7 @@ public class ScrewdriverApiTest extends ControllerContainerTest { new byte[0], Request.Method.POST, () -> "user"), 200, "{\"message\":\"Triggered component for tenant1.application1\"}"); tester.controller().applications().deploymentTrigger().notifyOfCompletion(new JobReport(app.id(), - DeploymentJobs.JobType.component, + JobType.component, 1, 42, Optional.of(new SourceRevision("repo", "branch", "commit")), diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java index 57676ffc3f5..09216eec3c7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java @@ -24,10 +24,10 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; -import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsEast3; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.productionUsWest1; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest; +import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; |