forked from apache/kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MINOR: Remove sleep calls and ignore annotation from streams upgrade …
…test (apache#6046) The StreamsUpgradeTest::test_upgrade_downgrade_brokers used sleep calls in the test which led to flaky test performance and as a result, we placed an @ignore annotation on the test. This PR uses log events instead of the sleep calls hence we can now remove the @ignore setting. Reviewers: Ewen Cheslack-Postava <[email protected]>, Matthias J. Sax <[email protected]>, Guozhang Wang <[email protected]>
- Loading branch information
1 parent
1f3cb6c
commit 404bdef
Showing
8 changed files
with
185 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...rade-system-tests-21/src/test/java/org/apache/kafka/streams/tests/StreamsUpgradeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.kafka.streams.tests; | ||
|
||
import java.util.Properties; | ||
import org.apache.kafka.common.utils.Utils; | ||
import org.apache.kafka.streams.KafkaStreams; | ||
import org.apache.kafka.streams.StreamsBuilder; | ||
import org.apache.kafka.streams.StreamsConfig; | ||
import org.apache.kafka.streams.kstream.KStream; | ||
import org.apache.kafka.streams.processor.AbstractProcessor; | ||
import org.apache.kafka.streams.processor.Processor; | ||
import org.apache.kafka.streams.processor.ProcessorContext; | ||
import org.apache.kafka.streams.processor.ProcessorSupplier; | ||
|
||
public class StreamsUpgradeTest { | ||
|
||
|
||
@SuppressWarnings("unchecked") | ||
public static void main(final String[] args) throws Exception { | ||
if (args.length < 2) { | ||
System.err.println("StreamsUpgradeTest requires three argument (kafka-url, properties-file) but only " + args.length + " provided: " | ||
+ (args.length > 0 ? args[0] : "")); | ||
} | ||
final String kafka = args[0]; | ||
final String propFileName = args.length > 1 ? args[1] : null; | ||
|
||
final Properties streamsProperties = Utils.loadProps(propFileName); | ||
|
||
System.out.println("StreamsTest instance started (StreamsUpgradeTest v2.1)"); | ||
System.out.println("kafka=" + kafka); | ||
System.out.println("props=" + streamsProperties); | ||
|
||
final StreamsBuilder builder = new StreamsBuilder(); | ||
final KStream dataStream = builder.stream("data"); | ||
dataStream.process(printProcessorSupplier()); | ||
dataStream.to("echo"); | ||
|
||
final Properties config = new Properties(); | ||
config.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, "StreamsUpgradeTest"); | ||
config.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, kafka); | ||
config.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, 1000); | ||
config.putAll(streamsProperties); | ||
|
||
final KafkaStreams streams = new KafkaStreams(builder.build(), config); | ||
streams.start(); | ||
|
||
Runtime.getRuntime().addShutdownHook(new Thread() { | ||
@Override | ||
public void run() { | ||
streams.close(); | ||
System.out.println("UPGRADE-TEST-CLIENT-CLOSED"); | ||
System.out.flush(); | ||
} | ||
}); | ||
} | ||
|
||
private static <K, V> ProcessorSupplier<K, V> printProcessorSupplier() { | ||
return new ProcessorSupplier<K, V>() { | ||
public Processor<K, V> get() { | ||
return new AbstractProcessor<K, V>() { | ||
private int numRecordsProcessed = 0; | ||
|
||
@Override | ||
public void init(final ProcessorContext context) { | ||
System.out.println("initializing processor: topic=data taskId=" + context.taskId()); | ||
numRecordsProcessed = 0; | ||
} | ||
|
||
@Override | ||
public void process(final K key, final V value) { | ||
numRecordsProcessed++; | ||
if (numRecordsProcessed % 100 == 0) { | ||
System.out.println("processed " + numRecordsProcessed + " records from topic=data"); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() {} | ||
}; | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.