ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.launchedTasks("hello-0-server")); ticks.add(Send.taskStatus("hello-0-server", Protos.TaskState.TASK_RUNNING).build());
/** * Specifies that the previously reserved resources from a previously launched pod should be used in this offer, * instead of new unreserved resources. * * @param podIndex the index of the previous pod to be offered */ public Builder setPodIndexToReoffer(int podIndex) { this.podToReuse = Optional.of(getPodName(podType, podIndex)); return this; }
@Test public void testParallelStrategyParallelSteps() throws Exception { Collection<SimulationTick> ticks = new ArrayList<>(); ticks.add(Send.register()); ticks.add(Expect.reconciledImplicitly()); // Service should launch all of hello-0/1-first/second using the provided offers: ticks.add(Send.offerBuilder("hello").setCount(3).build()); // Launches will end up being split across two offers/agents: ticks.add(Expect.launchedTasks(2, "hello-0-first", "hello-0-second", "hello-1-first", "hello-1-second")); ticks.add(Send.taskStatus("hello-0-first", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Send.taskStatus("hello-0-second", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Send.taskStatus("hello-1-first", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Send.taskStatus("hello-1-second", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Expect.samePod("hello-0-first", "hello-0-second")); ticks.add(Expect.samePod("hello-1-first", "hello-1-second")); // No more hellos to launch: ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Expect.allPlansComplete()); new ServiceTestRunner("custom_steps.yml") .setSchedulerEnv( "DEPLOY_STRATEGY", "parallel", "DEPLOY_STEPS", "[[first, second]]") .run(ticks); }
ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.recoveryStepStatus("world-0:[server]", "world-0:[server]", Status.STARTING)); ticks.add(Expect.launchedTasks("world-0-server")); ticks.add(Send.offerBuilder("hello").setPodIndexToReoffer(0).build()); ticks.add(Expect.deployStepStatus("hello", "hello-0:[server]", Status.STARTING)); ticks.add(Expect.launchedTasks("hello-0-server")); ticks.add(Send.offerBuilder("world").setPodIndexToReoffer(0).build()); ticks.add(Expect.deployStepStatus("world", "world-0:[server]", Status.STARTING)); ticks.add(Expect.launchedTasks("world-0-server")); ticks.add(Send.offerBuilder("world").setPodIndexToReoffer(1).build()); ticks.add(Expect.recoveryStepStatus("world-1:[server]", "world-1:[server]", Status.STARTING)); ticks.add(Expect.launchedTasks("world-1-server")); ticks.add(Send.offerBuilder("world").setPodIndexToReoffer(1).build()); ticks.add(Expect.deployStepStatus("world", "world-1:[server]", Status.STARTING)); ticks.add(Expect.launchedTasks("world-1-server"));
ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.launchedTasks("hello-0-server")); ticks.add(Expect.deployStepStatus("hello-deploy", "hello-0:[server]", Status.STARTING)); ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.taskNameKilled("hello-0-server", 1)); ticks.add(Send.offerBuilder("hello").setPodIndexToReoffer(0).build()); ticks.add(Expect.launchedTasks("hello-0-server")); ticks.add(Expect.deployStepStatus("hello-deploy", "hello-0:[server]", Status.STARTING)); ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Expect.suppressedOffers(1)); ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.reconciledImplicitly()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("world").setPodIndexToReoffer(0).build()); ticks.add(new ExpectDecommissionPlanProgress(Arrays.asList( new StepCount("world-1", stepCount - 2, 1, 1), new StepCount("world-0", stepCount, 0, 0)))); ticks.add(Send.offerBuilder("world").setPodIndexToReoffer(1).build()); ticks.add(Expect.unreservedTasks("world-1-server")); ticks.add(new ExpectDecommissionPlanProgress(Arrays.asList( ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Expect.knownTasks(result.getPersister(), "hello-0-server", "world-0-server")); ticks.add(Send.offerBuilder("world").setPodIndexToReoffer(0).build()); ticks.add(new ExpectDecommissionPlanProgress(Arrays.asList( new StepCount("world-1", 0, 0, stepCount), new StepCount("world-0", 1, 0, stepCount - 1)))); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Expect.knownTasks(result.getPersister(), "hello-0-server"));
ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.launchedTasks("hello-0-essential", "hello-0-nonessential")); ticks.add(Send.offerBuilder("hello").setHostname("host-foo").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Expect.allPlansComplete()); ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.declinedLastOffer()); if (essential) { ticks.add(Send.offerBuilder("hello").setPodIndexToReoffer(0).build());
ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.launchedTasks("hello-0-server")); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.launchedTasks("world-0-server")); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("world").setHostname("host-foo").build()); ticks.add(Expect.launchedTasks("world-1-server")); ticks.add(Send.taskStatus("world-1-server", Protos.TaskState.TASK_RUNNING).setReadinessCheckExitCode(0).build()); ticks.add(Send.offerBuilder("world").setHostname("host-bar").build()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.reconciledImplicitly()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Expect.launchedTasks("hello-0-second", "hello-0-third")); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Expect.launchedTasks("hello-1-second", "hello-1-third")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.launchedTasks("hello-0-first")); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Expect.launchedTasks("hello-0-second", "hello-0-third")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.launchedTasks("hello-1-first")); // hello-0 complete ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Expect.launchedTasks("hello-1-second", "hello-1-third")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.launchedTasks("hello-0-server")); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.launchedTasks("world-0-server")); ticks.add(Send.offerBuilder("world").build()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Expect.launchedTasks("hello-0-second")); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Expect.launchedTasks("hello-1-second")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer());
ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.launchedTasks("hello-0-first")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(0).build()); ticks.add(Expect.launchedTasks("hello-0-second")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.launchedTasks("hello-1-first")); ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.offerBuilder("hello").setCount(3).setPodIndexToReoffer(1).build()); ticks.add(Expect.launchedTasks("hello-1-second"));
@Test public void testSerialStrategyParallelSteps() throws Exception { Collection<SimulationTick> ticks = new ArrayList<>(); ticks.add(Send.register()); ticks.add(Expect.reconciledImplicitly()); // Service should launch hello-0-first and hello-0-second at the same time. ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.launchedTasks("hello-0-first", "hello-0-second")); ticks.add(Send.taskStatus("hello-0-first", Protos.TaskState.TASK_RUNNING).build()); // New offer declined since hello-0-second isn't RUNNING yet: ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Send.taskStatus("hello-0-second", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Expect.samePod("hello-0-first", "hello-0-second")); // Now hello-1 may be deployed: ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.launchedTasks("hello-1-first", "hello-1-second")); ticks.add(Send.taskStatus("hello-1-first", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Send.taskStatus("hello-1-second", Protos.TaskState.TASK_RUNNING).build()); ticks.add(Expect.samePod("hello-1-first", "hello-1-second")); // No more hellos to launch: ticks.add(Send.offerBuilder("hello").setCount(3).build()); ticks.add(Expect.declinedLastOffer()); ticks.add(Expect.allPlansComplete()); new ServiceTestRunner("custom_steps.yml") .setSchedulerEnv( "DEPLOY_STRATEGY", "serial", "DEPLOY_STEPS", "[[first, second]]") .run(ticks); }
/** * Checks that unexpected Tasks are killed. */ @Test public void testZombieTaskKilling() throws Exception { Collection<SimulationTick> ticks = new ArrayList<>(); ticks.add(Send.register()); ticks.add(Expect.reconciledImplicitly()); // Verify that service launches 1 hello pod. ticks.add(Send.offerBuilder("hello").build()); ticks.add(Expect.launchedTasks("hello-0-server")); // Running, no readiness check is applicable: ticks.add(Send.taskStatus("hello-0-server", Protos.TaskState.TASK_RUNNING).build()); String taskId = CommonIdUtils.toTaskId("bogus", "taskid").getValue(); ticks.add(Send.taskStatus("hello-0-server", Protos.TaskState.TASK_RUNNING) .setTaskId(taskId) .build()); // Unknown task that we made up above was killed, but the launched task was not killed: ticks.add(Expect.taskIdKilled(taskId)); ticks.add(Expect.taskNameNotKilled("hello-0-server")); new ServiceTestRunner("simple.yml").run(ticks); }
public static SendOffer.Builder offerBuilder(String podType) { return new SendOffer.Builder(podType); }