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 7f03c876f887e53fb8c67b46872e087ba751759c Author: klion26 <[email protected]> AuthorDate: Wed Feb 19 21:25:45 2020 +0800 [FLINK-13632] Port ArrayListSerializer upgrade test to TypeSerializerUpgradeTestBase --- .../state/ArrayListSerializerMigrationTest.java | 57 ----------- .../state/ArrayListSerializerUpgradeTest.java | 107 +++++++++++++++++++++ .../resources/flink-1.6-arraylist-serializer-data | Bin 240 -> 0 bytes .../flink-1.6-arraylist-serializer-snapshot | Bin 881 -> 0 bytes .../resources/flink-1.7-arraylist-serializer-data | Bin 240 -> 0 bytes .../flink-1.7-arraylist-serializer-snapshot | Bin 231 -> 0 bytes 6 files changed, 107 insertions(+), 57 deletions(-) diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/state/ArrayListSerializerMigrationTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/state/ArrayListSerializerMigrationTest.java deleted file mode 100644 index 91b9658..0000000 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/state/ArrayListSerializerMigrationTest.java +++ /dev/null @@ -1,57 +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.runtime.state; - -import org.apache.flink.api.common.typeutils.TypeSerializerSnapshotMigrationTestBase; -import org.apache.flink.api.common.typeutils.base.StringSerializer; -import org.apache.flink.testutils.migration.MigrationVersion; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Migration test for the {@link ArrayListSerializerSnapshot}. - */ -@RunWith(Parameterized.class) -public class ArrayListSerializerMigrationTest extends TypeSerializerSnapshotMigrationTestBase<ArrayList<String>> { - - private static final String SPEC_NAME = "arraylist-serializer"; - - public ArrayListSerializerMigrationTest(TestSpecification<ArrayList<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, - ArrayListSerializer.class, - ArrayListSerializerSnapshot.class, - () -> new ArrayListSerializer<>(StringSerializer.INSTANCE)); - - return testSpecifications.get(); - } -} diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/state/ArrayListSerializerUpgradeTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/state/ArrayListSerializerUpgradeTest.java new file mode 100644 index 0000000..5cba5af --- /dev/null +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/state/ArrayListSerializerUpgradeTest.java @@ -0,0 +1,107 @@ +/* + * 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.runtime.state; + +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.api.common.typeutils.base.StringSerializer; +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 static org.hamcrest.Matchers.is; + +/** + * A {@link TypeSerializerUpgradeTestBase} for {@link ArrayListSerializerSnapshot}. + */ +@RunWith(Parameterized.class) +public class ArrayListSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<ArrayList<String>, ArrayList<String>> { + + private static final String SPEC_NAME = "arraylist-serializer"; + + public ArrayListSerializerUpgradeTest(TestSpecification<ArrayList<String>, ArrayList<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, + ArrayListSerializerSetup.class, + ArrayListSerializerVerifier.class)); + } + return testSpecifications; + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "arraylist-serializer" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class ArrayListSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<ArrayList<String>> { + @Override + public TypeSerializer<ArrayList<String>> createPriorSerializer() { + return new ArrayListSerializer<>(StringSerializer.INSTANCE); + } + + @Override + public ArrayList<String> createTestData() { + ArrayList<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 ArrayListSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<ArrayList<String>> { + @Override + public TypeSerializer<ArrayList<String>> createUpgradedSerializer() { + return new ArrayListSerializer<>(StringSerializer.INSTANCE); + } + + @Override + public Matcher<ArrayList<String>> testDataMatcher() { + ArrayList<String> data = new ArrayList<>(2); + data.add("Apache"); + data.add("Flink"); + return is(data); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<ArrayList<String>>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } +} diff --git a/flink-runtime/src/test/resources/flink-1.6-arraylist-serializer-data b/flink-runtime/src/test/resources/flink-1.6-arraylist-serializer-data deleted file mode 100644 index 7b6c68a..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.6-arraylist-serializer-data and /dev/null differ diff --git a/flink-runtime/src/test/resources/flink-1.6-arraylist-serializer-snapshot b/flink-runtime/src/test/resources/flink-1.6-arraylist-serializer-snapshot deleted file mode 100644 index f6486ae..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.6-arraylist-serializer-snapshot and /dev/null differ diff --git a/flink-runtime/src/test/resources/flink-1.7-arraylist-serializer-data b/flink-runtime/src/test/resources/flink-1.7-arraylist-serializer-data deleted file mode 100644 index 7b6c68a..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.7-arraylist-serializer-data and /dev/null differ diff --git a/flink-runtime/src/test/resources/flink-1.7-arraylist-serializer-snapshot b/flink-runtime/src/test/resources/flink-1.7-arraylist-serializer-snapshot deleted file mode 100644 index cf43209..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.7-arraylist-serializer-snapshot and /dev/null differ
