use of org.apache.kafka.trogdor.rest.AgentStatusResponse in project apache-kafka-on-k8s by banzaicloud.
the class JsonSerializationTest method testDeserializationDoesNotProduceNulls.
@Test
public void testDeserializationDoesNotProduceNulls() throws Exception {
verify(new FilesUnreadableFaultSpec(0, 0, null, null, null, 0));
verify(new Kibosh.KiboshControlFile(null));
verify(new NetworkPartitionFaultSpec(0, 0, null));
verify(new ProcessStopFaultSpec(0, 0, null, null));
verify(new AgentStatusResponse(0, null));
verify(new TasksResponse(null));
verify(new WorkerDone(null, 0, 0, null, null));
verify(new WorkerRunning(null, 0, null));
verify(new WorkerStopping(null, 0, null));
verify(new ProduceBenchSpec(0, 0, null, null, 0, 0, null, null, null, 0, 0, "test-topic", 1, (short) 3));
verify(new RoundTripWorkloadSpec(0, 0, null, null, 0, null, null, 0));
verify(new SampleTaskSpec(0, 0, 0, null));
}
use of org.apache.kafka.trogdor.rest.AgentStatusResponse in project kafka by apache.
the class AgentTest method testCreateExpiredWorkerIsNotScheduled.
@Test
public void testCreateExpiredWorkerIsNotScheduled() throws Exception {
long initialTimeMs = 100;
long tickMs = 15;
final boolean[] toSleep = { true };
MockTime time = new MockTime(tickMs, initialTimeMs, 0) {
/**
* Modify sleep() to call super.sleep() every second call
* in order to avoid the endless loop in the tick() calls to the MockScheduler listener
*/
@Override
public void sleep(long ms) {
toSleep[0] = !toSleep[0];
if (toSleep[0])
super.sleep(ms);
}
};
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(10, 10);
client.createWorker(new CreateWorkerRequest(0, "foo", fooSpec));
long actualStartTimeMs = initialTimeMs + tickMs;
long doneMs = actualStartTimeMs + 2 * tickMs;
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone("foo", fooSpec, actualStartTimeMs, doneMs, null, "worker expired")).taskState(new TaskDone(fooSpec, actualStartTimeMs, doneMs, "worker expired", false, null)).build()).waitFor(client);
}
use of org.apache.kafka.trogdor.rest.AgentStatusResponse in project kafka by apache.
the class JsonSerializationTest method testDeserializationDoesNotProduceNulls.
@Test
public void testDeserializationDoesNotProduceNulls() throws Exception {
verify(new FilesUnreadableFaultSpec(0, 0, null, null, null, 0));
verify(new Kibosh.KiboshControlFile(null));
verify(new NetworkPartitionFaultSpec(0, 0, null));
verify(new ProcessStopFaultSpec(0, 0, null, null));
verify(new AgentStatusResponse(0, null));
verify(new TasksResponse(null));
verify(new WorkerDone(null, null, 0, 0, null, null));
verify(new WorkerRunning(null, null, 0, null));
verify(new WorkerStopping(null, null, 0, null));
verify(new ProduceBenchSpec(0, 0, null, null, 0, 0, null, null, Optional.empty(), null, null, null, null, null, false, false));
verify(new RoundTripWorkloadSpec(0, 0, null, null, null, null, null, null, 0, null, null, 0));
verify(new TopicsSpec());
verify(new PartitionsSpec(0, (short) 0, null, null));
Map<Integer, List<Integer>> partitionAssignments = new HashMap<Integer, List<Integer>>();
partitionAssignments.put(0, Arrays.asList(1, 2, 3));
partitionAssignments.put(1, Arrays.asList(1, 2, 3));
verify(new PartitionsSpec(0, (short) 0, partitionAssignments, null));
verify(new PartitionsSpec(0, (short) 0, null, null));
}
use of org.apache.kafka.trogdor.rest.AgentStatusResponse in project kafka by apache.
the class ExpectedTasks method waitFor.
public ExpectedTasks waitFor(final AgentClient client) throws InterruptedException {
TestUtils.waitForCondition(() -> {
AgentStatusResponse status = null;
try {
status = client.status();
} catch (Exception e) {
log.info("Unable to get agent status", e);
throw new RuntimeException(e);
}
StringBuilder errors = new StringBuilder();
HashMap<String, WorkerState> taskIdToWorkerState = new HashMap<>();
for (WorkerState state : status.workers().values()) {
taskIdToWorkerState.put(state.taskId(), state);
}
for (Map.Entry<String, ExpectedTask> entry : expected.entrySet()) {
String id = entry.getKey();
ExpectedTask worker = entry.getValue();
String differences = worker.compare(taskIdToWorkerState.get(id));
if (differences != null) {
errors.append(differences);
}
}
String errorString = errors.toString();
if (!errorString.isEmpty()) {
log.info("EXPECTED WORKERS: {}", JsonUtil.toJsonString(expected));
log.info("ACTUAL WORKERS : {}", JsonUtil.toJsonString(status.workers()));
log.info(errorString);
return false;
}
return true;
}, "Timed out waiting for expected workers " + JsonUtil.toJsonString(expected));
return this;
}
Aggregations