use of org.apache.kafka.trogdor.rest.CreateWorkerResponse in project apache-kafka-on-k8s by banzaicloud.
the class AgentTest method testAgentCreateWorkers.
@Test
public void testAgentCreateWorkers() 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();
AgentStatusResponse status = client.status();
assertEquals(Collections.emptyMap(), status.workers());
new ExpectedTasks().waitFor(client);
final NoOpTaskSpec fooSpec = new NoOpTaskSpec(1000, 600000);
CreateWorkerResponse response = client.createWorker(new CreateWorkerRequest("foo", fooSpec));
assertEquals(fooSpec.toString(), response.spec().toString());
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning(fooSpec, 0, "")).build()).waitFor(client);
final NoOpTaskSpec barSpec = new NoOpTaskSpec(2000, 900000);
client.createWorker(new CreateWorkerRequest("bar", barSpec));
client.createWorker(new CreateWorkerRequest("bar", barSpec));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning(fooSpec, 0, "")).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning(barSpec, 0, "")).build()).waitFor(client);
final NoOpTaskSpec bazSpec = new NoOpTaskSpec(1, 450000);
client.createWorker(new CreateWorkerRequest("baz", bazSpec));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning(fooSpec, 0, "")).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning(barSpec, 0, "")).build()).addTask(new ExpectedTaskBuilder("baz").workerState(new WorkerRunning(bazSpec, 0, "")).build()).waitFor(client);
agent.beginShutdown();
agent.waitForShutdown();
}
Aggregations