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 6453161580da55be04b2907b9ef7cb59642dcab7 Author: klion26 <[email protected]> AuthorDate: Fri Jan 31 12:52:24 2020 +0800 [FLINK-13632] Port VoidNamespaceSerializer upgrade test to TypeSerializerUpgradeTestBase --- .../state/VoidNamespaceSerializerUpgradeTest.java | 102 +++++++++++++++++++++ ...dNamespacieSerializerSnapshotMigrationTest.java | 55 ----------- .../flink-1.6-void-namespace-serializer-data | Bin 10 -> 0 bytes .../flink-1.6-void-namespace-serializer-snapshot | Bin 384 -> 0 bytes .../flink-1.7-void-namespace-serializer-data | Bin 10 -> 0 bytes .../flink-1.7-void-namespace-serializer-snapshot | Bin 372 -> 0 bytes 6 files changed, 102 insertions(+), 55 deletions(-) diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/state/VoidNamespaceSerializerUpgradeTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/state/VoidNamespaceSerializerUpgradeTest.java new file mode 100644 index 0000000..747bd6d --- /dev/null +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/state/VoidNamespaceSerializerUpgradeTest.java @@ -0,0 +1,102 @@ +/* + * 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.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 VoidNamespaceSerializer}. + */ +@RunWith(Parameterized.class) +public class VoidNamespaceSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<VoidNamespace, VoidNamespace> { + + private static final String SPEC_NAME = "void-namespace-serializer"; + + public VoidNamespaceSerializerUpgradeTest(TestSpecification<VoidNamespace, VoidNamespace> 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, + VoidNamespaceSerializerSetup.class, + VoidNamespaceSerializerVerifier.class)); + } + return testSpecifications; + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "voidnamespace-serializer" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class VoidNamespaceSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<VoidNamespace> { + @Override + public TypeSerializer<VoidNamespace> createPriorSerializer() { + return VoidNamespaceSerializer.INSTANCE; + } + + @Override + public VoidNamespace createTestData() { + return VoidNamespace.INSTANCE; + } + } + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class VoidNamespaceSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<VoidNamespace> { + @Override + public TypeSerializer<VoidNamespace> createUpgradedSerializer() { + return VoidNamespaceSerializer.INSTANCE; + } + + @Override + public Matcher<VoidNamespace> testDataMatcher() { + return is(VoidNamespace.INSTANCE); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<VoidNamespace>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } + +} diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/state/VoidNamespacieSerializerSnapshotMigrationTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/state/VoidNamespacieSerializerSnapshotMigrationTest.java deleted file mode 100644 index ac5d69e..0000000 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/state/VoidNamespacieSerializerSnapshotMigrationTest.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.runtime.state; - -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; - -/** - * Migration test for the {@link VoidNamespaceSerializer}. - */ -@RunWith(Parameterized.class) -public class VoidNamespacieSerializerSnapshotMigrationTest extends TypeSerializerSnapshotMigrationTestBase<VoidNamespace> { - - private static final String SPEC_NAME = "void-namespace-serializer"; - - public VoidNamespacieSerializerSnapshotMigrationTest(TestSpecification<VoidNamespace> 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, - VoidNamespaceSerializer.class, - VoidNamespaceSerializer.VoidNamespaceSerializerSnapshot.class, - () -> VoidNamespaceSerializer.INSTANCE); - - return testSpecifications.get(); - } -} diff --git a/flink-runtime/src/test/resources/flink-1.6-void-namespace-serializer-data b/flink-runtime/src/test/resources/flink-1.6-void-namespace-serializer-data deleted file mode 100644 index cb43b5c..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.6-void-namespace-serializer-data and /dev/null differ diff --git a/flink-runtime/src/test/resources/flink-1.6-void-namespace-serializer-snapshot b/flink-runtime/src/test/resources/flink-1.6-void-namespace-serializer-snapshot deleted file mode 100644 index be8d4f4..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.6-void-namespace-serializer-snapshot and /dev/null differ diff --git a/flink-runtime/src/test/resources/flink-1.7-void-namespace-serializer-data b/flink-runtime/src/test/resources/flink-1.7-void-namespace-serializer-data deleted file mode 100644 index cb43b5c..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.7-void-namespace-serializer-data and /dev/null differ diff --git a/flink-runtime/src/test/resources/flink-1.7-void-namespace-serializer-snapshot b/flink-runtime/src/test/resources/flink-1.7-void-namespace-serializer-snapshot deleted file mode 100644 index a12698d..0000000 Binary files a/flink-runtime/src/test/resources/flink-1.7-void-namespace-serializer-snapshot and /dev/null differ
