Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix and improve the test QuickDegradeAndRestoreCommandTopicIntegrationTest #8275

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.confluent.ksql.rest.integration.RestIntegrationTestUtil;
import io.confluent.ksql.rest.server.TestKsqlRestApp;
import io.confluent.ksql.rest.server.restore.KsqlRestoreCommandTopic;
import io.confluent.ksql.test.util.EmbeddedSingleNodeKafkaCluster;
import io.confluent.ksql.test.util.KsqlTestFolder;
import io.confluent.ksql.util.KsqlConfig;
import io.confluent.ksql.util.ReservedInternalTopics;
Expand Down Expand Up @@ -44,7 +45,11 @@

@Category({IntegrationTest.class})
public class QuickDegradeAndRestoreCommandTopicIntegrationTest {
private static final IntegrationTestHarness TEST_HARNESS = IntegrationTestHarness.build();
private static final IntegrationTestHarness TEST_HARNESS = IntegrationTestHarness.builder()
.withKafkaCluster(
EmbeddedSingleNodeKafkaCluster.newBuilder()
.withoutAutoCreateTopics()
).build();

@ClassRule
public static final RuleChain CHAIN = RuleChain
Expand Down Expand Up @@ -117,12 +122,13 @@ public void shouldBeInDegradeModeAfterCmdTopicDeleteAndRestart() throws Excepti
// When
// Delete the command topic and restart
TEST_HARNESS.deleteTopics(Collections.singletonList(commandTopic));
assertThatEventually("Topic Deleted", this::isCommandTopicDeleted, is(true));
REST_APP.stop();
REST_APP.start();

// Then
assertThatEventually("Topic Deleted", this::isCommandTopicDeleted, is(true));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good check

assertThatEventually("Degraded State", this::isDegradedState, is(true));
assertThat(TEST_HARNESS.topicExists(commandTopic), is(false));
REST_APP.stop();
KsqlRestoreCommandTopic.main(
new String[]{
Expand All @@ -139,6 +145,10 @@ public void shouldBeInDegradeModeAfterCmdTopicDeleteAndRestart() throws Excepti
assertThatEventually("Degraded State", this::isDegradedState, is(false));
}

private boolean isCommandTopicDeleted() {
return !TEST_HARNESS.topicExists(commandTopic);
}

private boolean isDegradedState() {
// If in degraded state, then the following command will return a warning
final List<KsqlEntity> response = makeKsqlRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,6 @@ private Properties buildBrokerConfig(final String logDir) {
// Need to know where ZK is:
config.put(KafkaConfig.ZkConnectProp(), zookeeper.connectString());
config.put(AclAuthorizer.ZkUrlProp(), zookeeper.connectString());
// Do not require tests to explicitly create tests:
config.put(KafkaConfig.AutoCreateTopicsEnableProp(), true);
// Default to small number of partitions for auto-created topics:
config.put(KafkaConfig.NumPartitionsProp(), 1);
// Allow tests to delete topics:
Expand Down Expand Up @@ -694,6 +692,14 @@ public static final class Builder {
brokerConfig.put(AclAuthorizer.AllowEveryoneIfNoAclIsFoundProp(),
true);
brokerConfig.put(KafkaConfig.ListenersProp(), "PLAINTEXT://:0");
brokerConfig.put(KafkaConfig.AutoCreateTopicsEnableProp(), true);
}

public Builder withoutAutoCreateTopics() {
// Create topics explicitly when needed to avoid a race which
// automatically recreates deleted topic:
brokerConfig.put(KafkaConfig.AutoCreateTopicsEnableProp(), false);
return this;
}

public Builder withoutPlainListeners() {
Expand Down