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 893f3220bf35d62f819fcd62810b9d618c4411ae Author: klion26 <qcx978132...@gmail.com> AuthorDate: Wed Feb 19 21:12:17 2020 +0800 [FLINK-13632] Port ListSerializer upgrade test to TypeSerializerUpgradeTestBase --- .../base/ListSerializerSnapshotMigrationTest.java | 55 ----------- .../typeutils/base/ListSerializerUpgradeTest.java | 109 +++++++++++++++++++++ .../test/resources/flink-1.6-list-serializer-data | Bin 240 -> 0 bytes .../resources/flink-1.6-list-serializer-snapshot | Bin 888 -> 0 bytes .../test/resources/flink-1.7-list-serializer-data | Bin 240 -> 0 bytes .../resources/flink-1.7-list-serializer-snapshot | Bin 238 -> 0 bytes 6 files changed, 109 insertions(+), 55 deletions(-) diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/ListSerializerSnapshotMigrationTest.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/ListSerializerSnapshotMigrationTest.java deleted file mode 100644 index f3662c6..0000000 --- a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/ListSerializerSnapshotMigrationTest.java +++ /dev/null @@ -1,55 +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.base; - -import org.apache.flink.api.common.typeutils.TypeSerializerSnapshotMigrationTestBase; -import org.apache.flink.testutils.migration.MigrationVersion; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Collection; -import java.util.List; - -/** - * Migration test for the {@link ListSerializerSnapshot}. - */ -@RunWith(Parameterized.class) -public class ListSerializerSnapshotMigrationTest extends TypeSerializerSnapshotMigrationTestBase<List<String>> { - - private static final String SPEC_NAME = "list-serializer"; - - public ListSerializerSnapshotMigrationTest(TestSpecification<List<String>> 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( - SPEC_NAME, - ListSerializer.class, - ListSerializerSnapshot.class, - () -> new ListSerializer<>(StringSerializer.INSTANCE)); - - return testSpecifications.get(); - } -} diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/ListSerializerUpgradeTest.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/ListSerializerUpgradeTest.java new file mode 100644 index 0000000..1892989 --- /dev/null +++ b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/ListSerializerUpgradeTest.java @@ -0,0 +1,109 @@ +/* + * 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.base; + +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.api.common.typeutils.TypeSerializerMatchers; +import org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility; +import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase; +import org.apache.flink.testutils.migration.MigrationVersion; + +import org.hamcrest.Matcher; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.hamcrest.Matchers.is; + +/** + * A {@link TypeSerializerUpgradeTestBase} for {@link ListSerializerSnapshot}. + */ +@RunWith(Parameterized.class) +public class ListSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<List<String>, List<String>> { + + private static final String SPEC_NAME = "list-serializer"; + + public ListSerializerUpgradeTest(TestSpecification<List<String>, List<String>> 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<>( + SPEC_NAME, + migrationVersion, + ListSerializerSetup.class, + ListSerializerVerifier.class)); + } + + return testSpecifications; + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "list-serializer" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class ListSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<List<String>> { + @Override + public TypeSerializer<List<String>> createPriorSerializer() { + return new ListSerializer<>(StringSerializer.INSTANCE); + } + + @Override + public List<String> createTestData() { + List<String> data = new ArrayList<>(2); + data.add("Apache"); + data.add("Flink"); + return data; + } + } + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class ListSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<List<String>> { + @Override + public TypeSerializer<List<String>> createUpgradedSerializer() { + return new ListSerializer<>(StringSerializer.INSTANCE); + } + + @Override + public Matcher<List<String>> testDataMatcher() { + List<String> data = new ArrayList<>(2); + data.add("Apache"); + data.add("Flink"); + return is(data); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<List<String>>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } +} diff --git a/flink-core/src/test/resources/flink-1.6-list-serializer-data b/flink-core/src/test/resources/flink-1.6-list-serializer-data deleted file mode 100644 index 7b6c68a..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-list-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.6-list-serializer-snapshot b/flink-core/src/test/resources/flink-1.6-list-serializer-snapshot deleted file mode 100644 index 8bb94b4..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-list-serializer-snapshot and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-list-serializer-data b/flink-core/src/test/resources/flink-1.7-list-serializer-data deleted file mode 100644 index 7b6c68a..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-list-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-list-serializer-snapshot b/flink-core/src/test/resources/flink-1.7-list-serializer-snapshot deleted file mode 100644 index a8efd3a..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-list-serializer-snapshot and /dev/null differ