jerrypeng commented on code in PR #52729: URL: https://github.com/apache/spark/pull/52729#discussion_r2482494798
########## connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaRealTimeIntegrationSuite.scala: ########## @@ -0,0 +1,293 @@ +/* + * 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.spark.sql.kafka010 + +import java.nio.file.Files +import java.util.Properties + +import scala.collection.mutable +import scala.collection.mutable.ListBuffer + +import org.apache.kafka.clients.producer.{KafkaProducer, Producer, ProducerRecord} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.time.SpanSugar._ + +import org.apache.spark.{SparkContext, ThreadAudit} +import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema +import org.apache.spark.sql.execution.streaming.RealTimeTrigger +import org.apache.spark.sql.functions._ +import org.apache.spark.sql.streaming.{OutputMode, ResultsCollector, StreamingQuery, StreamRealTimeModeE2ESuiteBase, StreamRealTimeModeSuiteBase} +import org.apache.spark.sql.test.TestSparkSession +import org.apache.spark.sql.types.{StringType, StructField, StructType} + +class KafkaRealTimeModeE2ESuite extends KafkaSourceTest with StreamRealTimeModeE2ESuiteBase { + + override protected val defaultTrigger: RealTimeTrigger = RealTimeTrigger.apply("5 seconds") + + override protected def createSparkSession = + new TestSparkSession( + new SparkContext( + "local[15]", + "streaming-key-cuj" + ) + ) + + override def beforeEach(): Unit = { + super[KafkaSourceTest].beforeEach() + super[StreamRealTimeModeE2ESuiteBase].beforeEach() + } + + def getKafkaConsumerProperties: Properties = { + val props: Properties = new Properties() + props.put("bootstrap.servers", testUtils.brokerAddress) + props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer") + props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer") + props.put("compression.type", "snappy") + + props + } + + test("Union two kafka streams, for each write to sink") { Review Comment: There is some difference. KafkaRealTimeModeSuite only has tests that uses StreamTest framework that allows us to perform step wise testing that writes to a memory sink. KafkaRealTimeIntegrationSuite and KafkaRealTimeModeE2ESuite are more E2E in a more realistic setting. KafkaRealTimeIntegrationSuite deploys a multiple worker cluster to run tests. KafkaRealTimeModeE2ESuite deploys a local in process cluster to test s foreach use case. The reason we are not consolidating the two is because it is easier to retrieve results from foreach sink writer if it is in process. Though we can consolidate the two by creating a kafka producer in foreach sink to write to results to kafka. Perhaps as a follow up item I can look into consolidating KafkaRealTimeModeE2ESuite and KafkaRealTimeIntegrationSuite? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
