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 a8abbbc9b4d3e88ce216f0cfbf20639c83a11020 Author: klion26 <[email protected]> AuthorDate: Wed Feb 19 20:48:59 2020 +0800 [FLINK-13632] Port MapSerializer upgrade test to TypeSerializerUpgradeTestBase --- .../base/MapSerializerSnapshotMigrationTest.java | 56 ----------- .../typeutils/base/MapSerializerUpgradeTest.java | 111 +++++++++++++++++++++ .../test/resources/flink-1.6-map-serializer-data | Bin 440 -> 0 bytes .../resources/flink-1.6-map-serializer-snapshot | Bin 1356 -> 0 bytes .../test/resources/flink-1.7-map-serializer-data | Bin 390 -> 0 bytes .../resources/flink-1.7-map-serializer-snapshot | Bin 379 -> 0 bytes 6 files changed, 111 insertions(+), 56 deletions(-) diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/MapSerializerSnapshotMigrationTest.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/MapSerializerSnapshotMigrationTest.java deleted file mode 100644 index 804eac4..0000000 --- a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/MapSerializerSnapshotMigrationTest.java +++ /dev/null @@ -1,56 +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.Map; - -/** - * Migration test for the {@link MapSerializerSnapshot}. - */ -@RunWith(Parameterized.class) -public class MapSerializerSnapshotMigrationTest extends TypeSerializerSnapshotMigrationTestBase<Map<Integer, String>> { - - private static final String SPEC_NAME = "map-serializer"; - - public MapSerializerSnapshotMigrationTest(TestSpecification<Map<Integer, 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, - MapSerializer.class, - MapSerializerSnapshot.class, - () -> new MapSerializer<>(IntSerializer.INSTANCE, StringSerializer.INSTANCE)); - - return testSpecifications.get(); - } -} diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/MapSerializerUpgradeTest.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/MapSerializerUpgradeTest.java new file mode 100644 index 0000000..e3d84b4 --- /dev/null +++ b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/MapSerializerUpgradeTest.java @@ -0,0 +1,111 @@ +/* + * 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.HashMap; +import java.util.Map; + +import static org.hamcrest.Matchers.is; + +/** + * A {@link TypeSerializerUpgradeTestBase} for {@link MapSerializerSnapshot}. + */ +@RunWith(Parameterized.class) +public class MapSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Map<Integer, String>, Map<Integer, String>> { + + private static final String SPEC_NAME = "map-serializer"; + + public MapSerializerUpgradeTest(TestSpecification<Map<Integer, String>, Map<Integer, 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, + MapSerializerSetup.class, + MapSerializerVerifier.class)); + } + return testSpecifications; + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "map-serializer" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class MapSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<Map<Integer, String>> { + @Override + public TypeSerializer<Map<Integer, String>> createPriorSerializer() { + return new MapSerializer<>(IntSerializer.INSTANCE, StringSerializer.INSTANCE); + } + + @Override + public Map<Integer, String> createTestData() { + Map<Integer, String> data = new HashMap<>(3); + for (int i = 0; i < 3; ++i) { + data.put(i, String.valueOf(i)); + } + return data; + } + } + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class MapSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<Map<Integer, String>> { + @Override + public TypeSerializer<Map<Integer, String>> createUpgradedSerializer() { + return new MapSerializer<>(IntSerializer.INSTANCE, StringSerializer.INSTANCE); + } + + @Override + public Matcher<Map<Integer, String>> testDataMatcher() { + Map<Integer, String> data = new HashMap<>(3); + for (int i = 0; i < 3; ++i) { + data.put(i, String.valueOf(i)); + } + return is(data); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<Map<Integer, String>>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } +} diff --git a/flink-core/src/test/resources/flink-1.6-map-serializer-data b/flink-core/src/test/resources/flink-1.6-map-serializer-data deleted file mode 100644 index 8f8011b..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-map-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.6-map-serializer-snapshot b/flink-core/src/test/resources/flink-1.6-map-serializer-snapshot deleted file mode 100644 index a192ba3..0000000 Binary files a/flink-core/src/test/resources/flink-1.6-map-serializer-snapshot and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-map-serializer-data b/flink-core/src/test/resources/flink-1.7-map-serializer-data deleted file mode 100644 index 4d7334a..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-map-serializer-data and /dev/null differ diff --git a/flink-core/src/test/resources/flink-1.7-map-serializer-snapshot b/flink-core/src/test/resources/flink-1.7-map-serializer-snapshot deleted file mode 100644 index 2d5f1f0..0000000 Binary files a/flink-core/src/test/resources/flink-1.7-map-serializer-snapshot and /dev/null differ
