mirror of https://github.com/apache/kafka.git
KAFKA-16679 merge unit test down to the class of integration test (#15884)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
47841e0bb9
commit
643db430a7
|
@ -53,13 +53,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
@Tag("integration")
|
||||
public class DeleteRecordsCommandTest {
|
||||
|
||||
private final ClusterInstance cluster;
|
||||
public DeleteRecordsCommandTest(ClusterInstance cluster) {
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@ClusterTest
|
||||
public void testCommand() throws Exception {
|
||||
public void testCommand(ClusterInstance cluster) throws Exception {
|
||||
Properties adminProps = new Properties();
|
||||
|
||||
adminProps.put(AdminClientConfig.RETRIES_CONFIG, 1);
|
||||
|
@ -112,12 +107,11 @@ public class DeleteRecordsCommandTest {
|
|||
});
|
||||
assertTrue(output.contains(expOut));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Unit test of {@link DeleteRecordsCommand} tool.
|
||||
*/
|
||||
class DeleteRecordsCommandUnitTest {
|
||||
|
||||
@Test
|
||||
public void testOffsetFileNotExists() {
|
||||
assertThrows(IOException.class, () -> DeleteRecordsCommand.execute(new String[]{
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import kafka.test.ClusterInstance;
|
||||
import kafka.test.annotation.ClusterTest;
|
||||
import kafka.test.annotation.ClusterTestDefaults;
|
||||
import kafka.test.annotation.Type;
|
||||
import kafka.test.junit.ClusterTestExtensions;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
@ -44,17 +43,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ExtendWith(value = ClusterTestExtensions.class)
|
||||
@ClusterTestDefaults(clusterType = Type.KRAFT)
|
||||
@Tag("integration")
|
||||
public class FeatureCommandTest {
|
||||
|
||||
private final ClusterInstance cluster;
|
||||
public FeatureCommandTest(ClusterInstance cluster) {
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.ZK, metadataVersion = MetadataVersion.IBP_3_3_IV1)
|
||||
public void testDescribeWithZK() {
|
||||
public void testDescribeWithZK(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(0, FeatureCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(), "describe"))
|
||||
);
|
||||
|
@ -62,7 +54,7 @@ public class FeatureCommandTest {
|
|||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_3_IV1)
|
||||
public void testDescribeWithKRaft() {
|
||||
public void testDescribeWithKRaft(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(0, FeatureCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(), "describe"))
|
||||
);
|
||||
|
@ -72,7 +64,7 @@ public class FeatureCommandTest {
|
|||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_7_IV4)
|
||||
public void testDescribeWithKRaftAndBootstrapControllers() {
|
||||
public void testDescribeWithKRaftAndBootstrapControllers(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(0, FeatureCommand.mainNoExit("--bootstrap-controller", cluster.bootstrapControllers(), "describe"))
|
||||
);
|
||||
|
@ -82,7 +74,7 @@ public class FeatureCommandTest {
|
|||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.ZK, metadataVersion = MetadataVersion.IBP_3_3_IV1)
|
||||
public void testUpgradeMetadataVersionWithZk() {
|
||||
public void testUpgradeMetadataVersionWithZk(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(1, FeatureCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(),
|
||||
"upgrade", "--metadata", "3.3-IV2"))
|
||||
|
@ -92,7 +84,7 @@ public class FeatureCommandTest {
|
|||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_3_IV1)
|
||||
public void testUpgradeMetadataVersionWithKraft() {
|
||||
public void testUpgradeMetadataVersionWithKraft(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(0, FeatureCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(),
|
||||
"upgrade", "--feature", "metadata.version=5"))
|
||||
|
@ -107,7 +99,7 @@ public class FeatureCommandTest {
|
|||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.ZK, metadataVersion = MetadataVersion.IBP_3_3_IV1)
|
||||
public void testDowngradeMetadataVersionWithZk() {
|
||||
public void testDowngradeMetadataVersionWithZk(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(1, FeatureCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(),
|
||||
"disable", "--feature", "metadata.version"))
|
||||
|
@ -130,7 +122,7 @@ public class FeatureCommandTest {
|
|||
}
|
||||
|
||||
@ClusterTest(clusterType = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_3_IV1)
|
||||
public void testDowngradeMetadataVersionWithKRaft() {
|
||||
public void testDowngradeMetadataVersionWithKRaft(ClusterInstance cluster) {
|
||||
String commandOutput = ToolsTestUtils.captureStandardOut(() ->
|
||||
assertEquals(1, FeatureCommand.mainNoExit("--bootstrap-server", cluster.bootstrapServers(),
|
||||
"disable", "--feature", "metadata.version"))
|
||||
|
@ -160,9 +152,11 @@ public class FeatureCommandTest {
|
|||
int pos = output.indexOf("Epoch: ");
|
||||
return (pos > 0) ? output.substring(0, pos) : output;
|
||||
}
|
||||
}
|
||||
|
||||
class FeatureCommandUnitTest {
|
||||
/**
|
||||
* Unit test of {@link FeatureCommand} tool.
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testLevelToString() {
|
||||
assertEquals("5", FeatureCommand.levelToString("foo.bar", (short) 5));
|
||||
|
@ -177,7 +171,7 @@ class FeatureCommandUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testdowngradeType() {
|
||||
public void testDowngradeType() {
|
||||
assertEquals(SAFE_DOWNGRADE, FeatureCommand.downgradeType(
|
||||
new Namespace(singletonMap("unsafe", Boolean.FALSE))));
|
||||
assertEquals(UNSAFE_DOWNGRADE, FeatureCommand.downgradeType(
|
||||
|
|
Loading…
Reference in New Issue