[FLINK-39772][tests][JUnit5 migration] Module: flink-fs-tests#28497
[FLINK-39772][tests][JUnit5 migration] Module: flink-fs-tests#28497spuru9 wants to merge 1 commit into
Conversation
621df3c to
ee5bd24
Compare
ee5bd24 to
8ea2fa1
Compare
|
cc: @raminqaf @snuyanzin Can you review this PR as well on JUnit5 migration. |
| monitoringFunction.run(context); | ||
|
|
||
| Assert.assertArrayEquals(filesKept.toArray(), context.getSeenFiles().toArray()); | ||
| assertThat(context.getSeenFiles().toArray()).isEqualTo(filesKept.toArray()); |
There was a problem hiding this comment.
why do we need conversion to array here?
There was a problem hiding this comment.
Have done for 1x1 replacement so had it, also the same for isTrue and some others. Will add it my learning for the PR for other submodules.
| assertThat(initTestInstance.getOutput().contains(new StreamRecord<>(fsSplit1))).isTrue(); | ||
| assertThat(initTestInstance.getOutput().contains(new StreamRecord<>(fsSplit2))).isTrue(); | ||
| assertThat(initTestInstance.getOutput().contains(new StreamRecord<>(fsSplit3))).isTrue(); | ||
| assertThat(initTestInstance.getOutput().contains(new StreamRecord<>(fsSplit4))).isTrue(); |
There was a problem hiding this comment.
assert has contains method, so no need for isTrue
|
|
||
| Assert.assertArrayEquals( | ||
| initTestInstance.getOutput().toArray(), restoredTestInstance.getOutput().toArray()); | ||
| assertThat(restoredTestInstance.getOutput().toArray()) |
There was a problem hiding this comment.
what is the reason to convert to array here?
| cntntStr.append(line); | ||
| } | ||
| Assert.assertEquals(expectedFileContents.get(fileIdx), cntntStr.toString()); | ||
| assertThat(cntntStr.toString()).isEqualTo(expectedFileContents.get(fileIdx)); |
There was a problem hiding this comment.
assertJ has hasToString()
| // of the input stream. | ||
|
|
||
| Assert.assertEquals(NO_OF_FILES * LINES_PER_FILE + 1, tester.getOutput().size()); | ||
| assertThat(tester.getOutput().size()).isEqualTo(NO_OF_FILES * LINES_PER_FILE + 1); |
| import static org.assertj.core.api.Assertions.fail; | ||
| import static org.junit.jupiter.api.Assumptions.assumeTrue; |
There was a problem hiding this comment.
I'm not sure it is a good idea to mix assertj and junit5
let's use assumptions from assertj
| private static int getLineNo(String line) { | ||
| String[] tkns = line.split("\\s"); | ||
| Assert.assertEquals(6, tkns.length); | ||
| assertThat(tkns.length).isEqualTo(6); |
| t.join(); | ||
|
|
||
| Assert.assertArrayEquals(filesToBeRead.toArray(), context.getSeenFiles().toArray()); | ||
| assertThat(context.getSeenFiles().toArray()).isEqualTo(filesToBeRead.toArray()); |
There was a problem hiding this comment.
why do we need to transform to array?
What is the purpose of the change
Migrate the remaining JUnit 4 tests in
flink-fs-teststo JUnit 5 (Jupiter). After this PR the module has zero JUnit 4 imports. Part of the umbrella JUnit 4 → 5 migration.JIRA: FLINK-39772 (sub-task of FLINK-25325)
Brief change log
Five test classes migrated (all under
org.apache.flink.hdfstests):HDFSTest—@Rule/@ClassRule TemporaryFolder→@TempDir,@Before*/@After*→@BeforeEach/@AfterEach/@BeforeAll,Assume.assumeTrue→Assumptions.assumeTrue(arg order swapped).DistributedCacheDfsTest— droppedextends TestLogger;@ClassRule MiniClusterWithClientResource→@RegisterExtension static MiniClusterExtension;@ClassRule TemporaryFolder→@TempDir.ContinuousFileProcessingITCase—extends AbstractTestBaseJUnit4→extends AbstractTestBase(the JUnit 5 sibling); lifecycle annotations.ContinuousFileProcessingTest— lifecycle annotations,@ClassRule TemporaryFolder→@TempDir(+TempDirUtils).ContinuousFileProcessingMigrationTest(parameterized) —@RunWith(Parameterized.class)→@ExtendWith(ParameterizedTestExtension.class)with@Parameterfield injection and@TestTemplate;@SnapshotsGeneratormethods keptpublic(the migration framework discovers them viaClass#getMethods()).org.junit.*imports removed;publicdropped from test classes/methods per the Flink JUnit 5 Migration Guide.One assertion in
testReaderSnapshotRestorekeepsCollection#contains(...)(rather than AssertJ'sassertThat(coll).contains(...)) on purpose:FileInputSplit#equalsis asymmetric with itsTimestampedFileInputSplitsubclass, and AssertJ reverses theequalsdirection. A comment documents this.No production code is touched.
Verifying this change
This change is a test-only migration covered by the existing tests it migrates:
Result: 50 tests run, 0 failures, 0 errors, 0 skipped, matching the pre-migration baseline.
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation
Was generative AI tooling used to co-author this PR?