Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flink v1.16: Switch Flink v1.16 tests to Junit5 (Part 1) #9565

Closed
wants to merge 15 commits into from
Closed

Flink v1.16: Switch Flink v1.16 tests to Junit5 (Part 1) #9565

wants to merge 15 commits into from

Conversation

ilyasahsan123
Copy link

Issue: #9087

@nastra
Copy link
Contributor

nastra commented Jan 29, 2024

@ilyasahsan123 we typically apply such changes on the latest version first (1.18) and then backport them in a separate PR. Could you apply these changes to Flink 1.18 first please?

@ilyasahsan123
Copy link
Author

Sure, I will do it. Thanks

@ilyasahsan123
Copy link
Author

hi @nastra , I've addressed your suggestion. Could you please take another look? Thanks

@@ -22,6 +22,10 @@ String scalaVersion = System.getProperty("scalaVersion") != null ? System.getPro

project(":iceberg-flink:iceberg-flink-${flinkMajorVersion}") {

test {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already set in L127, so it's not needed here


int expectedMilliseconds = (int) ((long) expected / 1000_000);
int actualMilliseconds = (int) ((long) actual / 1000_000);
Assert.assertEquals(message, expectedMilliseconds, actualMilliseconds);
assertThat(expectedMilliseconds).as(message).isEqualTo(actualMilliseconds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the actual/expected is the wrong way around. It should be assertThat(actualMilliseconds).isEqualTo(expectedMilliseconds)

@@ -75,8 +75,8 @@ protected void generateAndValidate(Schema schema, RecordWrapperTest.AssertMethod
StructLikeWrapper actualWrapper = StructLikeWrapper.forType(schema.asStruct());
StructLikeWrapper expectedWrapper = StructLikeWrapper.forType(schema.asStruct());
for (int i = 0; i < numRecords; i++) {
Assert.assertTrue("Should have more records", actual.hasNext());
Assert.assertTrue("Should have more RowData", expected.hasNext());
assertThat(actual.hasNext()).as("Should have more records").isTrue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertThat(actual.hasNext()).as("Should have more records").isTrue();
assertThat(actual).as("Should have more records").hasNext();

same for the other places that use a similar pattern. We want to avoid using isTrue/isFalse as much as possible, because we want to get rich context from AssertJ when the assertion ever fails

@@ -22,7 +22,7 @@
import org.apache.iceberg.flink.DataGenerator;
import org.apache.iceberg.flink.DataGenerators;
import org.apache.iceberg.flink.TestHelpers;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestStructRowData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not also include the other files from the data package in this PR?

@@ -18,10 +18,11 @@
*/
package org.apache.iceberg.flink.sink;

import static org.junit.jupiter.api.Assertions.assertEquals;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong import. We should be using AssertJ assertions instead of the JUnit ones

@@ -18,10 +18,11 @@
*/
package org.apache.iceberg.flink.sink;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected to include other test files from the sink package here is well, but just picking 2 files seems quite random to me. I'd suggest to focus on one or more packages per PR (depending on how big the changes are) instead of just randomly picking files across the codebase


String expectedStr = row.isNullAt(1) ? null : row.getString(1).toString();
Assert.assertEquals(expectedStr, partitionKey.get(0, String.class));
assertThat(expectedStr).isEqualTo(partitionKey.get(0, String.class));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ordering of actual/expected needs to be fixed here

// recordOffset points to the position after this one
Assert.assertEquals(startingRecordOffset + i + 1, recAndPos.recordOffset());
assertThat(elements[i]).isEqualTo(recAndPos.record());
assertThat(fileOffset).isEqualTo(recAndPos.fileOffset());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think actual/expected are in the wrong order here as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants