Search in sources :

Example 1 with FilesUnreadableFaultSpec

use of org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec in project kafka by apache.

the class AgentTest method testKiboshFaults.

@Test
public void testKiboshFaults() 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);
    try (MockKibosh mockKibosh = new MockKibosh()) {
        assertEquals(KiboshControlFile.EMPTY, mockKibosh.read());
        FilesUnreadableFaultSpec fooSpec = new FilesUnreadableFaultSpec(0, 900000, Collections.singleton("myAgent"), mockKibosh.tempDir.getPath(), "/foo", 123);
        client.createWorker(new CreateWorkerRequest(0, "foo", fooSpec));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec, 0, new TextNode("Added fault foo"))).build()).waitFor(client);
        assertEquals(new KiboshControlFile(Collections.singletonList(new KiboshFilesUnreadableFaultSpec("/foo", 123))), mockKibosh.read());
        FilesUnreadableFaultSpec barSpec = new FilesUnreadableFaultSpec(0, 900000, Collections.singleton("myAgent"), mockKibosh.tempDir.getPath(), "/bar", 456);
        client.createWorker(new CreateWorkerRequest(1, "bar", barSpec));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec, 0, new TextNode("Added fault foo"))).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning("bar", barSpec, 0, new TextNode("Added fault bar"))).build()).waitFor(client);
        assertEquals(new KiboshControlFile(asList(new KiboshFilesUnreadableFaultSpec("/foo", 123), new KiboshFilesUnreadableFaultSpec("/bar", 456))), mockKibosh.read());
        time.sleep(1);
        client.stopWorker(new StopWorkerRequest(0));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone("foo", fooSpec, 0, 1, new TextNode("Removed fault foo"), "")).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning("bar", barSpec, 0, new TextNode("Added fault bar"))).build()).waitFor(client);
        assertEquals(new KiboshControlFile(Collections.singletonList(new KiboshFilesUnreadableFaultSpec("/bar", 456))), mockKibosh.read());
    }
}
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) KiboshFilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.Kibosh.KiboshFilesUnreadableFaultSpec) ExpectedTasks(org.apache.kafka.trogdor.common.ExpectedTasks) StopWorkerRequest(org.apache.kafka.trogdor.rest.StopWorkerRequest) KiboshControlFile(org.apache.kafka.trogdor.fault.Kibosh.KiboshControlFile) KiboshFilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.Kibosh.KiboshFilesUnreadableFaultSpec) FilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec) CreateWorkerRequest(org.apache.kafka.trogdor.rest.CreateWorkerRequest) MockTime(org.apache.kafka.common.utils.MockTime) Test(org.junit.jupiter.api.Test)

Example 2 with FilesUnreadableFaultSpec

use of org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec in project apache-kafka-on-k8s by banzaicloud.

the class AgentTest method testKiboshFaults.

@Test
public void testKiboshFaults() 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);
    try (MockKibosh mockKibosh = new MockKibosh()) {
        Assert.assertEquals(KiboshControlFile.EMPTY, mockKibosh.read());
        FilesUnreadableFaultSpec fooSpec = new FilesUnreadableFaultSpec(0, 900000, Collections.singleton("myAgent"), mockKibosh.tempDir.getPath().toString(), "/foo", 123);
        client.createWorker(new CreateWorkerRequest("foo", fooSpec));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning(fooSpec, 0, "")).build()).waitFor(client);
        Assert.assertEquals(new KiboshControlFile(Collections.<Kibosh.KiboshFaultSpec>singletonList(new KiboshFilesUnreadableFaultSpec("/foo", 123))), mockKibosh.read());
        FilesUnreadableFaultSpec barSpec = new FilesUnreadableFaultSpec(0, 900000, Collections.singleton("myAgent"), mockKibosh.tempDir.getPath().toString(), "/bar", 456);
        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);
        Assert.assertEquals(new KiboshControlFile(new ArrayList<Kibosh.KiboshFaultSpec>() {

            {
                add(new KiboshFilesUnreadableFaultSpec("/foo", 123));
                add(new KiboshFilesUnreadableFaultSpec("/bar", 456));
            }
        }), mockKibosh.read());
        time.sleep(1);
        client.stopWorker(new StopWorkerRequest("foo"));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone(fooSpec, 0, 1, "", "")).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning(barSpec, 0, "")).build()).waitFor(client);
        Assert.assertEquals(new KiboshControlFile(Collections.<Kibosh.KiboshFaultSpec>singletonList(new KiboshFilesUnreadableFaultSpec("/bar", 456))), mockKibosh.read());
    }
}
Also used : MockScheduler(org.apache.kafka.common.utils.MockScheduler) WorkerDone(org.apache.kafka.trogdor.rest.WorkerDone) WorkerRunning(org.apache.kafka.trogdor.rest.WorkerRunning) ArrayList(java.util.ArrayList) ExpectedTaskBuilder(org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder) KiboshFilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.Kibosh.KiboshFilesUnreadableFaultSpec) Kibosh(org.apache.kafka.trogdor.fault.Kibosh) ExpectedTasks(org.apache.kafka.trogdor.common.ExpectedTasks) StopWorkerRequest(org.apache.kafka.trogdor.rest.StopWorkerRequest) KiboshControlFile(org.apache.kafka.trogdor.fault.Kibosh.KiboshControlFile) KiboshFilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.Kibosh.KiboshFilesUnreadableFaultSpec) FilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec) CreateWorkerRequest(org.apache.kafka.trogdor.rest.CreateWorkerRequest) MockTime(org.apache.kafka.common.utils.MockTime) Test(org.junit.Test)

Example 3 with FilesUnreadableFaultSpec

use of org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec 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));
}
Also used : WorkerDone(org.apache.kafka.trogdor.rest.WorkerDone) WorkerStopping(org.apache.kafka.trogdor.rest.WorkerStopping) TasksResponse(org.apache.kafka.trogdor.rest.TasksResponse) WorkerRunning(org.apache.kafka.trogdor.rest.WorkerRunning) NetworkPartitionFaultSpec(org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec) SampleTaskSpec(org.apache.kafka.trogdor.task.SampleTaskSpec) RoundTripWorkloadSpec(org.apache.kafka.trogdor.workload.RoundTripWorkloadSpec) Kibosh(org.apache.kafka.trogdor.fault.Kibosh) AgentStatusResponse(org.apache.kafka.trogdor.rest.AgentStatusResponse) ProcessStopFaultSpec(org.apache.kafka.trogdor.fault.ProcessStopFaultSpec) ProduceBenchSpec(org.apache.kafka.trogdor.workload.ProduceBenchSpec) FilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec) Test(org.junit.Test)

Example 4 with FilesUnreadableFaultSpec

use of org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec 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));
}
Also used : WorkerDone(org.apache.kafka.trogdor.rest.WorkerDone) WorkerStopping(org.apache.kafka.trogdor.rest.WorkerStopping) TasksResponse(org.apache.kafka.trogdor.rest.TasksResponse) WorkerRunning(org.apache.kafka.trogdor.rest.WorkerRunning) HashMap(java.util.HashMap) NetworkPartitionFaultSpec(org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec) RoundTripWorkloadSpec(org.apache.kafka.trogdor.workload.RoundTripWorkloadSpec) Kibosh(org.apache.kafka.trogdor.fault.Kibosh) AgentStatusResponse(org.apache.kafka.trogdor.rest.AgentStatusResponse) ProcessStopFaultSpec(org.apache.kafka.trogdor.fault.ProcessStopFaultSpec) ProduceBenchSpec(org.apache.kafka.trogdor.workload.ProduceBenchSpec) PartitionsSpec(org.apache.kafka.trogdor.workload.PartitionsSpec) FilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec) List(java.util.List) TopicsSpec(org.apache.kafka.trogdor.workload.TopicsSpec) Test(org.junit.jupiter.api.Test)

Aggregations

FilesUnreadableFaultSpec (org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec)4 WorkerDone (org.apache.kafka.trogdor.rest.WorkerDone)4 WorkerRunning (org.apache.kafka.trogdor.rest.WorkerRunning)4 Kibosh (org.apache.kafka.trogdor.fault.Kibosh)3 MockScheduler (org.apache.kafka.common.utils.MockScheduler)2 MockTime (org.apache.kafka.common.utils.MockTime)2 ExpectedTasks (org.apache.kafka.trogdor.common.ExpectedTasks)2 ExpectedTaskBuilder (org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder)2 KiboshControlFile (org.apache.kafka.trogdor.fault.Kibosh.KiboshControlFile)2 KiboshFilesUnreadableFaultSpec (org.apache.kafka.trogdor.fault.Kibosh.KiboshFilesUnreadableFaultSpec)2 NetworkPartitionFaultSpec (org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec)2 ProcessStopFaultSpec (org.apache.kafka.trogdor.fault.ProcessStopFaultSpec)2 AgentStatusResponse (org.apache.kafka.trogdor.rest.AgentStatusResponse)2 CreateWorkerRequest (org.apache.kafka.trogdor.rest.CreateWorkerRequest)2 StopWorkerRequest (org.apache.kafka.trogdor.rest.StopWorkerRequest)2 TasksResponse (org.apache.kafka.trogdor.rest.TasksResponse)2 WorkerStopping (org.apache.kafka.trogdor.rest.WorkerStopping)2 ProduceBenchSpec (org.apache.kafka.trogdor.workload.ProduceBenchSpec)2 RoundTripWorkloadSpec (org.apache.kafka.trogdor.workload.RoundTripWorkloadSpec)2 Test (org.junit.Test)2