This is an automated email from the ASF dual-hosted git repository. aljoscha pushed a commit to branch release-1.11 in repository https://gitbox.apache.org/repos/asf/flink.git
commit 33135677c4349c4cb62eab50fc8f08fb4a4031d6 Author: klion26 <[email protected]> AuthorDate: Wed Feb 19 21:03:34 2020 +0800 [FLINK-13632] Port CompositeSerializer upgrade test to TypeSerializerUpgradeTestBase --- ...mpositeTypeSerializerSnapshotMigrationTest.java | 63 --------- .../CompositeTypeSerializerUpgradeTest.java | 147 +++++++++++++++++++++ .../resources/flink-1.6-either-serializer-data | Bin 42 -> 0 bytes .../resources/flink-1.6-either-serializer-snapshot | Bin 1365 -> 0 bytes .../flink-1.6-generic-array-serializer-data | Bin 90 -> 0 bytes .../flink-1.6-generic-array-serializer-snapshot | Bin 1007 -> 0 bytes .../resources/flink-1.7-either-serializer-data | 1 - .../resources/flink-1.7-either-serializer-snapshot | Bin 383 -> 0 bytes .../flink-1.7-generic-array-serializer-data | Bin 280 -> 0 bytes .../flink-1.7-generic-array-serializer-snapshot | Bin 270 -> 0 bytes 10 files changed, 147 insertions(+), 64 deletions(-) diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerSnapshotMigrationTest.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerSnapshotMigrationTest.java deleted file mode 100644 index 6294bef..0000000 --- a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerSnapshotMigrationTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.api.common.typeutils; - -import org.apache.flink.api.common.typeutils.base.GenericArraySerializer; -import org.apache.flink.api.common.typeutils.base.GenericArraySerializerSnapshot; -import org.apache.flink.api.common.typeutils.base.IntSerializer; -import org.apache.flink.api.common.typeutils.base.StringSerializer; -import org.apache.flink.api.java.typeutils.runtime.EitherSerializer; -import org.apache.flink.api.java.typeutils.runtime.JavaEitherSerializerSnapshot; -import org.apache.flink.testutils.migration.MigrationVersion; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Collection; - -/** - * Migration tests for Composite Types. - */ -@RunWith(Parameterized.class) -public class CompositeTypeSerializerSnapshotMigrationTest extends TypeSerializerSnapshotMigrationTestBase<Object> { - - public CompositeTypeSerializerSnapshotMigrationTest(TestSpecification<Object> testSpecification) { - super(testSpecification); - } - - @SuppressWarnings("unchecked") - @Parameterized.Parameters(name = "Test Specification = {0}") - public static Collection<TestSpecification<?>> testSpecifications() { - - final TestSpecifications testSpecifications = new TestSpecifications(MigrationVersion.v1_6, MigrationVersion.v1_7); - - testSpecifications.add( - "either-serializer", - EitherSerializer.class, - JavaEitherSerializerSnapshot.class, - () -> new EitherSerializer<>(StringSerializer.INSTANCE, IntSerializer.INSTANCE)); - testSpecifications.add( - "generic-array-serializer", - GenericArraySerializer.class, - GenericArraySerializerSnapshot.class, - () -> new GenericArraySerializer<>(String.class, StringSerializer.INSTANCE)); - - return testSpecifications.get(); - } -} diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerUpgradeTest.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerUpgradeTest.java new file mode 100644 index 0000000..a82ec29 --- /dev/null +++ b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerUpgradeTest.java @@ -0,0 +1,147 @@ +/* + * 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.api.common.typeutils; + +import org.apache.flink.api.common.typeutils.base.GenericArraySerializer; +import org.apache.flink.api.common.typeutils.base.IntSerializer; +import org.apache.flink.api.common.typeutils.base.StringSerializer; +import org.apache.flink.api.java.typeutils.runtime.EitherSerializer; +import org.apache.flink.testutils.migration.MigrationVersion; +import org.apache.flink.types.Either; + +import org.hamcrest.Matcher; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.ArrayList; +import java.util.Collection; + +import static org.hamcrest.Matchers.is; + +/** + * A {@link TypeSerializerUpgradeTestBase} for {@link GenericArraySerializer}. + */ +@RunWith(Parameterized.class) +public class CompositeTypeSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> { + + public CompositeTypeSerializerUpgradeTest(TestSpecification<Object, Object> testSpecification) { + super(testSpecification); + } + + @Parameterized.Parameters(name = "Test Specification = {0}") + public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception { + + ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>(); + for (MigrationVersion migrationVersion : MIGRATION_VERSIONS) { + testSpecifications.add( + new TestSpecification<>( + "either-serializer", + migrationVersion, + EitherSerializerSetup.class, + EitherSerializerVerifier.class)); + testSpecifications.add( + new TestSpecification<>( + "generic-array-serializer", + migrationVersion, + GenericArraySerializerSetup.class, + GenericArraySerializerVerifier.class)); + } + return testSpecifications; + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "either-serializer" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class EitherSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<Either<String, Integer>> { + @Override + public TypeSerializer<Either<String, Integer>> createPriorSerializer() { + return new EitherSerializer<>(StringSerializer.INSTANCE, IntSerializer.INSTANCE); + } + + @Override + public Either<String, Integer> createTestData() { + return new Either.Left<>("ApacheFlink"); + } + } + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class EitherSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<Either<String, Integer>> { + @Override + public TypeSerializer<Either<String, Integer>> createUpgradedSerializer() { + return new EitherSerializer<>(StringSerializer.INSTANCE, IntSerializer.INSTANCE); + } + + @Override + public Matcher<Either<String, Integer>> testDataMatcher() { + return is(new Either.Left<>("ApacheFlink")); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<Either<String, Integer>>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "generic-array-serializer" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class GenericArraySerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<String[]> { + @Override + public TypeSerializer<String[]> createPriorSerializer() { + return new GenericArraySerializer<>(String.class, StringSerializer.INSTANCE); + } + + @Override + public String[] createTestData() { + String[] data = {"Apache", "Flink"}; + return data; + } + } + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class GenericArraySerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<String[]> { + @Override + public TypeSerializer<String[]> createUpgradedSerializer() { + return new GenericArraySerializer<>(String.class, StringSerializer.INSTANCE); + } + + @Override + public Matcher<String[]> testDataMatcher() { + String[] data = {"Apache", "Flink"}; + return is(data); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<String[]>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } +} diff --git a/flink-core/src/test/resources/flink-1.6-either-serializer-data b/flink-core/src/test/resources/flink-1.6-either-serializer-data deleted file mode 100644 index 619dc59..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-either-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.6-either-serializer-snapshot b/flink-core/src/test/resources/flink-1.6-either-serializer-snapshot deleted file mode 100644 index ed2e378..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-either-serializer-snapshot and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.6-generic-array-serializer-data b/flink-core/src/test/resources/flink-1.6-generic-array-serializer-data deleted file mode 100644 index 47ac459..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-generic-array-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.6-generic-array-serializer-snapshot b/flink-core/src/test/resources/flink-1.6-generic-array-serializer-snapshot deleted file mode 100644 index 100eef0..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-generic-array-serializer-snapshot and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-either-serializer-data b/flink-core/src/test/resources/flink-1.7-either-serializer-data deleted file mode 100644 index 3aabc0b..0000000 --- a/flink-core/src/test/resources/flink-1.7-either-serializer-data +++ /dev/null @@ -1 +0,0 @@ -hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world \ No newline at end of file diff --git a/flink-core/src/test/resources/flink-1.7-either-serializer-snapshot b/flink-core/src/test/resources/flink-1.7-either-serializer-snapshot deleted file mode 100644 index 16242c0..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-either-serializer-snapshot and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-generic-array-serializer-data b/flink-core/src/test/resources/flink-1.7-generic-array-serializer-data deleted file mode 100644 index e2d6a23..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-generic-array-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-generic-array-serializer-snapshot b/flink-core/src/test/resources/flink-1.7-generic-array-serializer-snapshot deleted file mode 100644 index 9ace763..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-generic-array-serializer-snapshot and /dev/null differ
