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 acbdbceda70eecb98007224bbc4bda62692e14dc Author: Aljoscha Krettek <aljos...@apache.org> AuthorDate: Wed May 27 08:52:40 2020 +0200 [FLINK-13632] Update TypeSerializerUpgradeTestBase for Flink 1.11 We change MIGRATION_VERSIONS to only test versions > 1.11 because that's when we're adding the tests. We make an exception for PojoSerializerUpgradeTest and RowSerializerUpgradeTest, for which we have earlier snapshots. This also changes the test base to only generate snapshots for the CURRENT_VERSION when we generateTestSetupFiles(). --- .../typeutils/TypeSerializerUpgradeTestBase.java | 38 +++++++++++++++++----- .../runtime/PojoSerializerUpgradeTest.java | 13 +++++++- .../runtime/RowSerializerUpgradeTest.java | 10 +++++- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/TypeSerializerUpgradeTestBase.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/TypeSerializerUpgradeTestBase.java index fe94ee9..ec77e7b 100644 --- a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/TypeSerializerUpgradeTestBase.java +++ b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/TypeSerializerUpgradeTestBase.java @@ -50,11 +50,10 @@ import static org.junit.Assume.assumeThat; */ public abstract class TypeSerializerUpgradeTestBase<PreviousElementT, UpgradedElementT> extends TestLogger { - public static final MigrationVersion[] MIGRATION_VERSIONS = new MigrationVersion[]{ - MigrationVersion.v1_7, - MigrationVersion.v1_8, - MigrationVersion.v1_9, - }; + public static final MigrationVersion[] MIGRATION_VERSIONS = + MigrationVersion.v1_11.orHigher().toArray(new MigrationVersion[0]); + + public static final MigrationVersion CURRENT_VERSION = MigrationVersion.v1_11; private final TestSpecification<PreviousElementT, UpgradedElementT> testSpecification; @@ -235,8 +234,8 @@ public abstract class TypeSerializerUpgradeTestBase<PreviousElementT, UpgradedEl * generating the test files, e.g. to generate test files for {@link MigrationVersion#v1_8}, you * should be under the release-1.8 branch. */ - @Ignore @Test + @Ignore public void generateTestSetupFiles() throws Exception { Files.createDirectories(getSerializerSnapshotFilePath().getParent()); @@ -248,7 +247,7 @@ public abstract class TypeSerializerUpgradeTestBase<PreviousElementT, UpgradedEl // mutates only after being used for serialization (e.g. dynamic type registrations for Pojo / Kryo) DataOutputSerializer testDataOut = new DataOutputSerializer(INITIAL_OUTPUT_BUFFER_SIZE); priorSerializer.serialize(testSpecification.setup.createTestData(), testDataOut); - writeContentsTo(getTestDataFilePath(), testDataOut.getCopyOfBuffer()); + writeContentsTo(getGenerateDataFilePath(), testDataOut.getCopyOfBuffer()); // ... then write the serializer snapshot DataOutputSerializer serializerSnapshotOut = new DataOutputSerializer( @@ -256,9 +255,9 @@ public abstract class TypeSerializerUpgradeTestBase<PreviousElementT, UpgradedEl writeSerializerSnapshot( serializerSnapshotOut, priorSerializer, - testSpecification.migrationVersion); + CURRENT_VERSION); writeContentsTo( - getSerializerSnapshotFilePath(), + getGenerateSerializerSnapshotFilePath(), serializerSnapshotOut.getCopyOfBuffer()); } } @@ -412,6 +411,27 @@ public abstract class TypeSerializerUpgradeTestBase<PreviousElementT, UpgradedEl // Utilities // ------------------------------------------------------------------------------ + /** + * Paths to use during snapshot generation, which should only use the CURRENT_VERSION. + */ + private Path getGenerateSerializerSnapshotFilePath() { + return Paths.get(getGenerateResourceDirectory() + "/serializer-snapshot"); + } + + /** + * Paths to use during snapshot generation, which should only use the CURRENT_VERSION. + */ + private Path getGenerateDataFilePath() { + return Paths.get(getGenerateResourceDirectory() + "/test-data"); + } + + /** + * Paths to use during snapshot generation, which should only use the CURRENT_VERSION. + */ + private String getGenerateResourceDirectory() { + return System.getProperty("user.dir") + "/src/test/resources/" + testSpecification.name + "-" + CURRENT_VERSION; + } + private Path getSerializerSnapshotFilePath() { return Paths.get(getTestResourceDirectory() + "/serializer-snapshot"); } diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerUpgradeTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerUpgradeTest.java index fac1bde..ce90dd6 100644 --- a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerUpgradeTest.java +++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerUpgradeTest.java @@ -25,7 +25,9 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.List; /** * A {@link TypeSerializerUpgradeTestBase} for the {@link PojoSerializer}. @@ -40,7 +42,16 @@ public class PojoSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Obj @Parameterized.Parameters(name = "Test Specification = {0}") public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception { ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>(); - for (MigrationVersion migrationVersion : MIGRATION_VERSIONS) { + // for PojoSerializer we also test against 1.7, 1.8, and 1.9 because we have snapshots + // for this which go beyond what we have for the usual subclasses of + // TypeSerializerUpgradeTestBase. We don't have snapshot data for 1.10, but the + // PojoSerializer has not been changed in quite a while anyways. + List<MigrationVersion> testVersions = new ArrayList<>(); + testVersions.add(MigrationVersion.v1_7); + testVersions.add(MigrationVersion.v1_8); + testVersions.add(MigrationVersion.v1_9); + testVersions.addAll(Arrays.asList(MIGRATION_VERSIONS)); + for (MigrationVersion migrationVersion : testVersions) { testSpecifications.add( new TestSpecification<>( "pojo-serializer-identical-schema", diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/RowSerializerUpgradeTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/RowSerializerUpgradeTest.java index f30893c..7d72809 100644 --- a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/RowSerializerUpgradeTest.java +++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/RowSerializerUpgradeTest.java @@ -34,7 +34,9 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.List; import static org.hamcrest.Matchers.is; @@ -51,7 +53,13 @@ public class RowSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Row, @Parameterized.Parameters(name = "Test Specification = {0}") public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception { ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>(); - for (MigrationVersion migrationVersion : MigrationVersion.v1_10.orHigher()) { + // for RowSerializer we also test against 1.10 and newer because we have snapshots + // for this which go beyond what we have for the usual subclasses of + // TypeSerializerUpgradeTestBase + List<MigrationVersion> testVersions = new ArrayList<>(); + testVersions.add(MigrationVersion.v1_10); + testVersions.addAll(Arrays.asList(MIGRATION_VERSIONS)); + for (MigrationVersion migrationVersion : testVersions) { testSpecifications.add( new TestSpecification<>( "row-serializer",