guozhangwang commented on code in PR #12644: URL: https://github.com/apache/kafka/pull/12644#discussion_r981685201
########## streams/src/test/java/org/apache/kafka/streams/kstream/internals/KStreamKStreamSelfJoinTest.java: ########## @@ -0,0 +1,341 @@ +/* + * 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.kstream.internals; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; + +import java.util.List; +import java.util.Properties; +import org.apache.kafka.common.serialization.Serdes; +import org.apache.kafka.common.serialization.StringSerializer; +import org.apache.kafka.streams.KeyValueTimestamp; +import org.apache.kafka.streams.StreamsBuilder; +import org.apache.kafka.streams.StreamsConfig; +import org.apache.kafka.streams.TestInputTopic; +import org.apache.kafka.streams.Topology; +import org.apache.kafka.streams.TopologyTestDriver; +import org.apache.kafka.streams.kstream.Consumed; +import org.apache.kafka.streams.kstream.JoinWindows; +import org.apache.kafka.streams.kstream.KStream; +import org.apache.kafka.streams.kstream.StreamJoined; +import org.apache.kafka.streams.kstream.ValueJoiner; +import org.apache.kafka.test.MockApiProcessor; +import org.apache.kafka.test.MockApiProcessorSupplier; +import org.apache.kafka.test.StreamsTestUtils; +import org.junit.Test; + +public class KStreamKStreamSelfJoinTest { + private final String topic1 = "topic1"; + private final String topic2 = "topic2"; + private final Properties props = StreamsTestUtils.getStreamsConfig(Serdes.String(), Serdes.String()); + + @Test + public void shouldMatchInnerJoinWithSelfJoinWithSingleStream() { + props.setProperty(StreamsConfig.BUILT_IN_METRICS_VERSION_CONFIG, StreamsConfig.METRICS_LATEST); + props.put(StreamsConfig.TOPOLOGY_OPTIMIZATION_CONFIG, StreamsConfig.OPTIMIZE); + final ValueJoiner<String, String, String> valueJoiner = (v, v2) -> v + v2; + final List<KeyValueTimestamp<String, String>> expected; Review Comment: Thanks for the thoughtful tests comparing the optimized topology with non-optimized topology, really like it! Just one thought: it seems we do not need to create the `StreamsBuilder` twice, but instead we can just create it once from the same topic (since they get the same data as well), and then call `build` twice each different `props` to generate two topologies with different client ids so that they will re-run from the beginning of the input topic for the test driver, is that doable? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
