use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class JobScenarioBuilder method updateJobCapacityDesired.
public JobScenarioBuilder updateJobCapacityDesired(int desired, int unchangedMin, int unchangedMax) {
logger.info("[{}] Changing job {} capacity desired to {}...", discoverActiveTest(), jobId, desired);
Stopwatch stopWatch = Stopwatch.createStarted();
TestStreamObserver<Empty> responseObserver = new TestStreamObserver<>();
client.updateJobCapacityWithOptionalAttributes(JobCapacityUpdateWithOptionalAttributes.newBuilder().setJobId(jobId).setJobCapacityWithOptionalAttributes(JobCapacityWithOptionalAttributes.newBuilder().setDesired(UInt32Value.newBuilder().setValue(desired).build()).build()).build(), responseObserver);
rethrow(() -> responseObserver.awaitDone(TIMEOUT_MS, TimeUnit.MILLISECONDS));
expectJobUpdateEvent(job -> {
ServiceJobExt ext = (ServiceJobExt) job.getJobDescriptor().getExtensions();
Capacity capacity = ext.getCapacity();
return capacity.getDesired() == desired && capacity.getMin() == unchangedMin && capacity.getMax() == unchangedMax;
}, "Job capacity update did not complete in time");
logger.info("[{}] Job {} scaled to new desired size in {}ms", discoverActiveTest(), jobId, stopWatch.elapsed(TimeUnit.MILLISECONDS));
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class JobScenarioBuilder method updateJobCapacityMax.
public JobScenarioBuilder updateJobCapacityMax(int max, int expectedMin, int expectedDesired) {
logger.info("[{}] Changing job {} capacity max to {}...", discoverActiveTest(), jobId, max);
Stopwatch stopWatch = Stopwatch.createStarted();
TestStreamObserver<Empty> responseObserver = new TestStreamObserver<>();
client.updateJobCapacityWithOptionalAttributes(JobCapacityUpdateWithOptionalAttributes.newBuilder().setJobId(jobId).setJobCapacityWithOptionalAttributes(JobCapacityWithOptionalAttributes.newBuilder().setMax(UInt32Value.newBuilder().setValue(max).build()).build()).build(), responseObserver);
rethrow(() -> responseObserver.awaitDone(TIMEOUT_MS, TimeUnit.MILLISECONDS));
expectJobUpdateEvent(job -> {
ServiceJobExt ext = (ServiceJobExt) job.getJobDescriptor().getExtensions();
Capacity capacity = ext.getCapacity();
return capacity.getMax() == max && capacity.getMin() == expectedMin && capacity.getDesired() == expectedDesired;
}, "Job capacity update did not complete in time");
logger.info("[{}] Job {} scaled to new max size in {}ms", discoverActiveTest(), jobId, stopWatch.elapsed(TimeUnit.MILLISECONDS));
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class JobScenarioBuilder method expectJobToScaleDown.
public JobScenarioBuilder expectJobToScaleDown() {
JobDescriptor.JobDescriptorExt ext = getJob().getJobDescriptor().getExtensions();
Preconditions.checkState(ext instanceof ServiceJobExt, "Not a service job %s", jobId);
int size = ((ServiceJobExt) ext).getCapacity().getDesired();
logger.info("[{}] Expect job {} to scale down to the desired size {}...", discoverActiveTest(), jobId, size);
Stopwatch stopWatch = Stopwatch.createStarted();
await().timeout(TIMEOUT_MS, TimeUnit.MILLISECONDS).until(() -> {
List<TaskHolder> lastTaskHolders = getLastTaskHolders();
return lastTaskHolders.stream().filter(t -> {
TaskState state = t.getTaskScenarioBuilder().getTask().getStatus().getState();
return state != TaskState.KillInitiated;
}).count() <= size;
});
logger.info("[{}] Expected job {} scale down to the desired size {} completed in {}ms", discoverActiveTest(), jobId, size, stopWatch.elapsed(TimeUnit.MILLISECONDS));
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class JobScenarioBuilder method updateJobCapacityDesiredInvalid.
public JobScenarioBuilder updateJobCapacityDesiredInvalid(int targetDesired, int currentDesired) {
logger.info("[{}] Changing job {} capacity desired to {}...", discoverActiveTest(), jobId, targetDesired);
TestStreamObserver<Empty> responseObserver = new TestStreamObserver<>();
client.updateJobCapacityWithOptionalAttributes(JobCapacityUpdateWithOptionalAttributes.newBuilder().setJobId(jobId).setJobCapacityWithOptionalAttributes(JobCapacityWithOptionalAttributes.newBuilder().setDesired(UInt32Value.newBuilder().setValue(targetDesired).build()).build()).build(), responseObserver);
await().timeout(TIMEOUT_MS, TimeUnit.MILLISECONDS).until(responseObserver::hasError);
Throwable error = responseObserver.getError();
assertThat(error).isNotNull();
assertThat(error).isInstanceOf(StatusRuntimeException.class);
StatusRuntimeException statusRuntimeException = (StatusRuntimeException) error;
assertThat(statusRuntimeException.getStatus().getCode() == Status.Code.INVALID_ARGUMENT).isTrue();
// Make sure desired count is unchanged
Job job = getJob();
JobDescriptor.JobDescriptorExt ext = job.getJobDescriptor().getExtensions();
int currentCapacity = ext instanceof BatchJobExt ? ((BatchJobExt) ext).getSize() : ((ServiceJobExt) ext).getCapacity().getDesired();
assertThat(currentCapacity).isEqualTo(currentDesired);
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class JobScenarioBuilder method updateJobStatus.
public JobScenarioBuilder updateJobStatus(boolean enabled) {
logger.info("[{}] Changing job {} enable status to {}...", discoverActiveTest(), jobId, enabled);
Stopwatch stopWatch = Stopwatch.createStarted();
TestStreamObserver<Empty> responseObserver = new TestStreamObserver<>();
client.updateJobStatus(JobStatusUpdate.newBuilder().setId(jobId).setEnableStatus(enabled).build(), responseObserver);
rethrow(() -> responseObserver.awaitDone(TIMEOUT_MS, TimeUnit.MILLISECONDS));
expectJobUpdateEvent(job -> {
ServiceJobExt ext = (ServiceJobExt) job.getJobDescriptor().getExtensions();
return ext.isEnabled() == enabled;
}, "Job status update did not complete in time");
logger.info("[{}] Changing job {} enable status to {} finished in {}ms", discoverActiveTest(), jobId, enabled, stopWatch.elapsed(TimeUnit.MILLISECONDS));
return this;
}
Aggregations