use of kafka.tools.StreamsResetter in project apache-kafka-on-k8s by banzaicloud.
the class AbstractResetIntegrationTest method shouldNotAllowToResetWhenInputTopicAbsent.
public void shouldNotAllowToResetWhenInputTopicAbsent() throws Exception {
appID = testId + "-not-reset-without-input-topic";
final String[] parameters = new String[] { "--application-id", appID, "--bootstrap-servers", cluster.bootstrapServers(), "--input-topics", NON_EXISTING_TOPIC, "--execute" };
final Properties cleanUpConfig = new Properties();
cleanUpConfig.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 100);
cleanUpConfig.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, "" + CLEANUP_CONSUMER_TIMEOUT);
final int exitCode = new StreamsResetter().run(parameters, cleanUpConfig);
Assert.assertEquals(1, exitCode);
}
use of kafka.tools.StreamsResetter in project apache-kafka-on-k8s by banzaicloud.
the class AbstractResetIntegrationTest method cleanGlobal.
private void cleanGlobal(final boolean withIntermediateTopics, final String resetScenario, final String resetScenarioArg) throws Exception {
// leaving --zookeeper arg here to ensure tool works if users add it
final List<String> parameterList = new ArrayList<>(Arrays.asList("--application-id", appID, "--bootstrap-servers", cluster.bootstrapServers(), "--input-topics", INPUT_TOPIC, "--execute"));
if (withIntermediateTopics) {
parameterList.add("--intermediate-topics");
parameterList.add(INTERMEDIATE_USER_TOPIC);
}
final Map<String, Object> sslConfig = getClientSslConfig();
if (sslConfig != null) {
final File configFile = TestUtils.tempFile();
final BufferedWriter writer = new BufferedWriter(new FileWriter(configFile));
writer.write(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG + "=SSL\n");
writer.write(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG + "=" + sslConfig.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG) + "\n");
writer.write(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG + "=" + ((Password) sslConfig.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).value() + "\n");
writer.close();
parameterList.add("--config-file");
parameterList.add(configFile.getAbsolutePath());
}
if (resetScenario != null) {
parameterList.add(resetScenario);
}
if (resetScenarioArg != null) {
parameterList.add(resetScenarioArg);
}
final String[] parameters = parameterList.toArray(new String[parameterList.size()]);
final Properties cleanUpConfig = new Properties();
cleanUpConfig.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 100);
cleanUpConfig.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, "" + CLEANUP_CONSUMER_TIMEOUT);
final int exitCode = new StreamsResetter().run(parameters, cleanUpConfig);
Assert.assertEquals(0, exitCode);
}
use of kafka.tools.StreamsResetter in project kafka by apache.
the class AbstractResetIntegrationTest method tryCleanGlobal.
protected boolean tryCleanGlobal(final boolean withIntermediateTopics, final String resetScenario, final String resetScenarioArg, final String appID) throws Exception {
final List<String> parameterList = new ArrayList<>(Arrays.asList("--application-id", appID, "--bootstrap-servers", cluster.bootstrapServers(), "--input-topics", INPUT_TOPIC));
if (withIntermediateTopics) {
parameterList.add("--intermediate-topics");
parameterList.add(INTERMEDIATE_USER_TOPIC);
}
final Map<String, Object> sslConfig = getClientSslConfig();
if (sslConfig != null) {
final File configFile = TestUtils.tempFile();
final BufferedWriter writer = new BufferedWriter(new FileWriter(configFile));
writer.write(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG + "=SSL\n");
writer.write(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG + "=" + sslConfig.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG) + "\n");
writer.write(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG + "=" + ((Password) sslConfig.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).value() + "\n");
writer.close();
parameterList.add("--config-file");
parameterList.add(configFile.getAbsolutePath());
}
if (resetScenario != null) {
parameterList.add(resetScenario);
}
if (resetScenarioArg != null) {
parameterList.add(resetScenarioArg);
}
final String[] parameters = parameterList.toArray(new String[0]);
final Properties cleanUpConfig = new Properties();
cleanUpConfig.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 100);
cleanUpConfig.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, Integer.toString(CLEANUP_CONSUMER_TIMEOUT));
return new StreamsResetter().run(parameters, cleanUpConfig) == 0;
}
use of kafka.tools.StreamsResetter in project kafka by apache.
the class ResetIntegrationTest method shouldNotAllowToResetWhenInputTopicAbsent.
@Test
public void shouldNotAllowToResetWhenInputTopicAbsent() {
final String appID = IntegrationTestUtils.safeUniqueTestName(getClass(), testName);
final String[] parameters = new String[] { "--application-id", appID, "--bootstrap-servers", cluster.bootstrapServers(), "--input-topics", NON_EXISTING_TOPIC };
final Properties cleanUpConfig = new Properties();
cleanUpConfig.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 100);
cleanUpConfig.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, Integer.toString(CLEANUP_CONSUMER_TIMEOUT));
final int exitCode = new StreamsResetter().run(parameters, cleanUpConfig);
Assert.assertEquals(1, exitCode);
}
use of kafka.tools.StreamsResetter in project kafka by apache.
the class ResetIntegrationTest method shouldNotAllowToResetWhileStreamsIsRunning.
@Test
public void shouldNotAllowToResetWhileStreamsIsRunning() {
final String appID = IntegrationTestUtils.safeUniqueTestName(getClass(), testName);
final String[] parameters = new String[] { "--application-id", appID, "--bootstrap-servers", cluster.bootstrapServers(), "--input-topics", NON_EXISTING_TOPIC };
final Properties cleanUpConfig = new Properties();
cleanUpConfig.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 100);
cleanUpConfig.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, Integer.toString(CLEANUP_CONSUMER_TIMEOUT));
streamsConfig.put(StreamsConfig.APPLICATION_ID_CONFIG, appID);
// RUN
streams = new KafkaStreams(setupTopologyWithoutIntermediateUserTopic(), streamsConfig);
streams.start();
final int exitCode = new StreamsResetter().run(parameters, cleanUpConfig);
Assert.assertEquals(1, exitCode);
streams.close();
}
Aggregations