pnowojski commented on a change in pull request #7677: [FLINK-11249][kafka] Add 
migration tests for FlinkKafkaProdcuer and FlinkKafkaProducer011
URL: https://github.com/apache/flink/pull/7677#discussion_r276125674
 
 

 ##########
 File path: 
flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/streaming/connectors/kafka/KafkaMigrationTestBase.java
 ##########
 @@ -0,0 +1,171 @@
+/*
+ * 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.flink.streaming.connectors.kafka;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import 
org.apache.flink.api.common.serialization.TypeInformationSerializationSchema;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.runtime.checkpoint.OperatorSubtaskState;
+import 
org.apache.flink.streaming.connectors.kafka.internals.KeyedSerializationSchemaWrapper;
+import org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness;
+import org.apache.flink.streaming.util.OperatorSnapshotUtil;
+import org.apache.flink.streaming.util.serialization.KeyedSerializationSchema;
+import org.apache.flink.testutils.migration.MigrationVersion;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.Properties;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * The base class with migration tests for the Kafka Exactly-Once Producer.
+ */
+@SuppressWarnings("serial")
+public abstract class KafkaMigrationTestBase extends KafkaTestBase {
+
+       protected static final Logger LOG = 
LoggerFactory.getLogger(KafkaMigrationTestBase.class);
+       protected static final String TOPIC = 
"flink-kafka-producer-migration-test";
+
+       protected final MigrationVersion testMigrateVersion;
+       protected final TypeInformationSerializationSchema<Integer> 
integerSerializationSchema =
+               new 
TypeInformationSerializationSchema<>(BasicTypeInfo.INT_TYPE_INFO, new 
ExecutionConfig());
+       protected final KeyedSerializationSchema<Integer> 
integerKeyedSerializationSchema =
+               new 
KeyedSerializationSchemaWrapper<>(integerSerializationSchema);
+
+       /**
+        * TODO change this to the corresponding savepoint version to be 
written (e.g. {@link MigrationVersion#v1_3} for 1.3)
+        * TODO and remove all @Ignore annotations on write*Snapshot() methods 
to generate savepoints
+        * TODO Note: You should generate the savepoint based on the release 
branch instead of the master.
+        */
+       protected final Optional<MigrationVersion> 
flinkGenerateSavepointVersion = Optional.empty();
+
+       public KafkaMigrationTestBase(MigrationVersion testMigrateVersion) {
+               this.testMigrateVersion = checkNotNull(testMigrateVersion);
+       }
+
+       public String getOperatorSnapshotPath() {
+               return getOperatorSnapshotPath(testMigrateVersion);
+       }
+
+       public String getOperatorSnapshotPath(MigrationVersion version) {
+               return 
"src/test/resources/kafka-migration-kafka-producer-flink-" + version + 
"-snapshot";
+       }
+
+       /**
+        * Override {@link KafkaTestBase}. Kafka Migration Tests are starting 
up Kafka/ZooKeeper cluster manually
+        */
+       @BeforeClass
+       public static void prepare() throws Exception {
 
 Review comment:
   This not using Java mechanism, but relays on [JUnit's 
functionality](https://junit.org/junit4/javadoc/latest/org/junit/BeforeClass.html):
   
   > The @BeforeClass methods of superclasses will be run before those of the 
current class, **unless they are shadowed in the current class.**
   
   And explained for [example here](https://stackoverflow.com/a/2132896/8149051)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to