Search in sources :

Example 1 with NetworkPartitionFaultSpec

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

the class CoordinatorTest method testNetworkPartitionFault.

@Test
public void testNetworkPartitionFault() throws Exception {
    CapturingCommandRunner runner = new CapturingCommandRunner();
    MockTime time = new MockTime(0, 0, 0);
    Scheduler scheduler = new MockScheduler(time);
    try (MiniTrogdorCluster cluster = new MiniTrogdorCluster.Builder().addCoordinator("node01").addAgent("node01").addAgent("node02").addAgent("node03").commandRunner(runner).scheduler(scheduler).build()) {
        CoordinatorClient coordinatorClient = cluster.coordinatorClient();
        NetworkPartitionFaultSpec spec = new NetworkPartitionFaultSpec(0, Long.MAX_VALUE, createPartitionLists(new String[][] { new String[] { "node01", "node02" }, new String[] { "node03" } }));
        coordinatorClient.createTask(new CreateTaskRequest("netpart", spec));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("netpart").taskSpec(spec).build()).waitFor(coordinatorClient);
        checkLines("-A", runner);
    }
    checkLines("-D", runner);
}
Also used : MockScheduler(org.apache.kafka.common.utils.MockScheduler) ExpectedTasks(org.apache.kafka.trogdor.common.ExpectedTasks) CreateTaskRequest(org.apache.kafka.trogdor.rest.CreateTaskRequest) MockScheduler(org.apache.kafka.common.utils.MockScheduler) Scheduler(org.apache.kafka.common.utils.Scheduler) MiniTrogdorCluster(org.apache.kafka.trogdor.common.MiniTrogdorCluster) NetworkPartitionFaultSpec(org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec) ExpectedTaskBuilder(org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder) CapturingCommandRunner(org.apache.kafka.trogdor.common.CapturingCommandRunner) MockTime(org.apache.kafka.common.utils.MockTime) Test(org.junit.jupiter.api.Test)

Example 2 with NetworkPartitionFaultSpec

use of org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec 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 3 with NetworkPartitionFaultSpec

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

the class CoordinatorTest method testNetworkPartitionFault.

@Test
public void testNetworkPartitionFault() throws Exception {
    CapturingCommandRunner runner = new CapturingCommandRunner();
    try (MiniTrogdorCluster cluster = new MiniTrogdorCluster.Builder().addCoordinator("node01").addAgent("node01").addAgent("node02").addAgent("node03").commandRunner(runner).build()) {
        CoordinatorClient coordinatorClient = cluster.coordinatorClient();
        NetworkPartitionFaultSpec spec = new NetworkPartitionFaultSpec(0, Long.MAX_VALUE, createPartitionLists(new String[][] { new String[] { "node01", "node02" }, new String[] { "node03" } }));
        coordinatorClient.createTask(new CreateTaskRequest("netpart", spec));
        new ExpectedTasks().addTask(new ExpectedTaskBuilder("netpart").taskSpec(spec).build()).waitFor(coordinatorClient);
        checkLines("-A", runner);
    }
    checkLines("-D", runner);
}
Also used : ExpectedTasks(org.apache.kafka.trogdor.common.ExpectedTasks) CreateTaskRequest(org.apache.kafka.trogdor.rest.CreateTaskRequest) ExpectedTaskBuilder(org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder) MiniTrogdorCluster(org.apache.kafka.trogdor.common.MiniTrogdorCluster) NetworkPartitionFaultSpec(org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec) ExpectedTaskBuilder(org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder) CapturingCommandRunner(org.apache.kafka.trogdor.common.CapturingCommandRunner) Test(org.junit.Test)

Example 4 with NetworkPartitionFaultSpec

use of org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec 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

NetworkPartitionFaultSpec (org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec)4 CapturingCommandRunner (org.apache.kafka.trogdor.common.CapturingCommandRunner)2 ExpectedTasks (org.apache.kafka.trogdor.common.ExpectedTasks)2 ExpectedTaskBuilder (org.apache.kafka.trogdor.common.ExpectedTasks.ExpectedTaskBuilder)2 MiniTrogdorCluster (org.apache.kafka.trogdor.common.MiniTrogdorCluster)2 FilesUnreadableFaultSpec (org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec)2 Kibosh (org.apache.kafka.trogdor.fault.Kibosh)2 ProcessStopFaultSpec (org.apache.kafka.trogdor.fault.ProcessStopFaultSpec)2 AgentStatusResponse (org.apache.kafka.trogdor.rest.AgentStatusResponse)2 CreateTaskRequest (org.apache.kafka.trogdor.rest.CreateTaskRequest)2 TasksResponse (org.apache.kafka.trogdor.rest.TasksResponse)2 WorkerDone (org.apache.kafka.trogdor.rest.WorkerDone)2 WorkerRunning (org.apache.kafka.trogdor.rest.WorkerRunning)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 Test (org.junit.jupiter.api.Test)2 HashMap (java.util.HashMap)1 List (java.util.List)1