Search in sources :

Example 11 with CreateWorkerRequest

use of org.apache.kafka.trogdor.rest.CreateWorkerRequest in project kafka by apache.

the class AgentTest method testDestroyWorkers.

@Test
public void testDestroyWorkers() throws Exception {
    MockTime time = new MockTime(0, 0, 0);
    MockScheduler scheduler = new MockScheduler(time);
    Agent agent = createAgent(scheduler);
    AgentClient client = new AgentClient.Builder().maxTries(10).target("localhost", agent.port()).build();
    new ExpectedTasks().waitFor(client);
    final NoOpTaskSpec fooSpec = new NoOpTaskSpec(0, 5);
    client.createWorker(new CreateWorkerRequest(0, "foo", fooSpec));
    new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec, 0, new TextNode("active"))).build()).waitFor(client);
    time.sleep(1);
    client.destroyWorker(new DestroyWorkerRequest(0));
    client.destroyWorker(new DestroyWorkerRequest(0));
    client.destroyWorker(new DestroyWorkerRequest(1));
    new ExpectedTasks().waitFor(client);
    time.sleep(1);
    final NoOpTaskSpec fooSpec2 = new NoOpTaskSpec(2, 1);
    client.createWorker(new CreateWorkerRequest(1, "foo", fooSpec2));
    new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec2, 2, new TextNode("active"))).build()).waitFor(client);
    time.sleep(2);
    new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone("foo", fooSpec2, 2, 4, new TextNode("done"), "")).build()).waitFor(client);
    time.sleep(1);
    client.destroyWorker(new DestroyWorkerRequest(1));
    new ExpectedTasks().waitFor(client);
    agent.beginShutdown();
    agent.waitForShutdown();
}
Also used : MockScheduler(org.apache.kafka.common.utils.MockScheduler) WorkerDone(org.apache.kafka.trogdor.rest.WorkerDone) WorkerRunning(org.apache.kafka.trogdor.rest.WorkerRunning) TextNode(com.fasterxml.jackson.databind.node.TextNode) ExpectedTaskBuilder(org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder) NoOpTaskSpec(org.apache.kafka.trogdor.task.NoOpTaskSpec) DestroyWorkerRequest(org.apache.kafka.trogdor.rest.DestroyWorkerRequest) ExpectedTasks(org.apache.kafka.trogdor.common.ExpectedTasks) CreateWorkerRequest(org.apache.kafka.trogdor.rest.CreateWorkerRequest) MockTime(org.apache.kafka.common.utils.MockTime) Test(org.junit.jupiter.api.Test)

Aggregations

CreateWorkerRequest (org.apache.kafka.trogdor.rest.CreateWorkerRequest)11 MockScheduler (org.apache.kafka.common.utils.MockScheduler)10 MockTime (org.apache.kafka.common.utils.MockTime)10 ExpectedTasks (org.apache.kafka.trogdor.common.ExpectedTasks)10 ExpectedTaskBuilder (org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder)10 WorkerRunning (org.apache.kafka.trogdor.rest.WorkerRunning)9 WorkerDone (org.apache.kafka.trogdor.rest.WorkerDone)8 NoOpTaskSpec (org.apache.kafka.trogdor.task.NoOpTaskSpec)6 Test (org.junit.jupiter.api.Test)6 TextNode (com.fasterxml.jackson.databind.node.TextNode)5 StopWorkerRequest (org.apache.kafka.trogdor.rest.StopWorkerRequest)5 AgentStatusResponse (org.apache.kafka.trogdor.rest.AgentStatusResponse)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 FilesUnreadableFaultSpec (org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec)2 KiboshControlFile (org.apache.kafka.trogdor.fault.Kibosh.KiboshControlFile)2 KiboshFilesUnreadableFaultSpec (org.apache.kafka.trogdor.fault.Kibosh.KiboshFilesUnreadableFaultSpec)2 DestroyWorkerRequest (org.apache.kafka.trogdor.rest.DestroyWorkerRequest)2 SampleTaskSpec (org.apache.kafka.trogdor.task.SampleTaskSpec)2 ZoneOffset (java.time.ZoneOffset)1