Skip to content

Commit

Permalink
KAFKA-17194 Don't create cluster for MetadataQuorumCommandTest#testCo…
Browse files Browse the repository at this point in the history
…mmandConfig (#16682)

Reviewers: TengYao Chi <[email protected]>, Chia-Ping Tsai <[email protected]>
  • Loading branch information
wernerdv authored Jul 29, 2024
1 parent fdee225 commit 4e69bc0
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.kafka.common.errors.UnsupportedVersionException;
import org.apache.kafka.test.TestUtils;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
Expand All @@ -45,11 +46,6 @@
@ExtendWith(value = ClusterTestExtensions.class)
class MetadataQuorumCommandTest {

private final ClusterInstance cluster;
public MetadataQuorumCommandTest(ClusterInstance cluster) {
this.cluster = cluster;
}

/**
* 1. The same number of broker controllers
* 2. More brokers than controllers
Expand All @@ -60,7 +56,7 @@ public MetadataQuorumCommandTest(ClusterInstance cluster) {
@ClusterTest(types = {Type.KRAFT, Type.CO_KRAFT}, brokers = 2, controllers = 1),
@ClusterTest(types = {Type.KRAFT, Type.CO_KRAFT}, brokers = 1, controllers = 2),
})
public void testDescribeQuorumReplicationSuccessful() throws InterruptedException {
public void testDescribeQuorumReplicationSuccessful(ClusterInstance cluster) throws InterruptedException {
cluster.waitForReadyBrokers();
String describeOutput = ToolsTestUtils.captureStandardOut(() ->
MetadataQuorumCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(), "describe", "--replication")
Expand All @@ -87,7 +83,6 @@ public void testDescribeQuorumReplicationSuccessful() throws InterruptedExceptio
assertEquals(cluster.config().numBrokers(), outputs.stream().filter(o -> observerPattern.matcher(o).find()).count());
}


/**
* 1. The same number of broker controllers
* 2. More brokers than controllers
Expand All @@ -98,7 +93,7 @@ public void testDescribeQuorumReplicationSuccessful() throws InterruptedExceptio
@ClusterTest(types = {Type.KRAFT, Type.CO_KRAFT}, brokers = 2, controllers = 1),
@ClusterTest(types = {Type.KRAFT, Type.CO_KRAFT}, brokers = 1, controllers = 2),
})
public void testDescribeQuorumStatusSuccessful() throws InterruptedException {
public void testDescribeQuorumStatusSuccessful(ClusterInstance cluster) throws InterruptedException {
cluster.waitForReadyBrokers();
String describeOutput = ToolsTestUtils.captureStandardOut(
() -> MetadataQuorumCommand.mainNoExit(
Expand Down Expand Up @@ -134,7 +129,7 @@ public void testDescribeQuorumStatusSuccessful() throws InterruptedException {
}

@ClusterTest(types = {Type.KRAFT, Type.CO_KRAFT})
public void testOnlyOneBrokerAndOneController() {
public void testOnlyOneBrokerAndOneController(ClusterInstance cluster) {
String statusOutput = ToolsTestUtils.captureStandardOut(() ->
MetadataQuorumCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(), "describe", "--status")
);
Expand All @@ -147,16 +142,16 @@ public void testOnlyOneBrokerAndOneController() {
assertEquals("0", replicationOutput.split("\n")[1].split("\\s+")[2]);
}

@ClusterTest(types = {Type.CO_KRAFT})
@Test
public void testCommandConfig() throws IOException {
// specifying a --command-config containing properties that would prevent login must fail
File tmpfile = TestUtils.tempFile(AdminClientConfig.SECURITY_PROTOCOL_CONFIG + "=SSL_PLAINTEXT");
assertEquals(1, MetadataQuorumCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(),
assertEquals(1, MetadataQuorumCommand.mainNoExit("--bootstrap-server", "localhost:9092",
"--command-config", tmpfile.getAbsolutePath(), "describe", "--status"));
}

@ClusterTest(types = {Type.ZK})
public void testDescribeQuorumInZkMode() {
public void testDescribeQuorumInZkMode(ClusterInstance cluster) {
assertInstanceOf(UnsupportedVersionException.class, assertThrows(
ExecutionException.class,
() -> MetadataQuorumCommand.execute("--bootstrap-server", cluster.bootstrapServers(), "describe", "--status")
Expand All @@ -166,11 +161,10 @@ public void testDescribeQuorumInZkMode() {
ExecutionException.class,
() -> MetadataQuorumCommand.execute("--bootstrap-server", cluster.bootstrapServers(), "describe", "--replication")
).getCause());

}

@ClusterTest(types = {Type.CO_KRAFT})
public void testHumanReadableOutput() {
public void testHumanReadableOutput(ClusterInstance cluster) {
assertEquals(1, MetadataQuorumCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(), "describe", "--human-readable"));
assertEquals(1, MetadataQuorumCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(), "describe", "--status", "--human-readable"));
String out0 = ToolsTestUtils.captureStandardOut(() ->
Expand Down

0 comments on commit 4e69bc0

Please sign in to comment.