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-33023][table-planner][JUnit5 Migration] Module: flink-table-planner (TableTestBase) #23349

Merged
merged 8 commits into from
Nov 10, 2023

Conversation

Jiabao-Sun
Copy link
Contributor

@Jiabao-Sun Jiabao-Sun commented Sep 4, 2023

What is the purpose of the change

[FLINK-33023][table-planner][JUnit5 Migration] Module: flink-table-planner (TableTestBase)

Brief change log

JUnit5 Migration Module: flink-table-planner (TableTestBase)

Verifying this change

This change is already covered by existing tests

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 4, 2023

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@Jiabao-Sun
Copy link
Contributor Author

Hi @leonardBang.
Would you mind to help review this PR when you have time?

@leonardBang leonardBang self-requested a review September 11, 2023 17:42
@Jiabao-Sun Jiabao-Sun force-pushed the junit5-table-test-base branch 2 times, most recently from 19b263b to c4202ee Compare September 14, 2023 12:45
@Jiabao-Sun
Copy link
Contributor Author

@flinkbot run azure

@Jiabao-Sun Jiabao-Sun force-pushed the junit5-table-test-base branch 3 times, most recently from fa07af0 to c59b139 Compare October 9, 2023 12:02
@leonardBang
Copy link
Contributor

@xuyangzhong Would you like to help review this PR?

Copy link
Contributor

@xuyangzhong xuyangzhong left a comment

Choose a reason for hiding this comment

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

Thank for your huge contribution about replacing junit4 with junit5 in table-planner module. The whole pr looks good to me. I mainly have two confusion.

  1. Is it a good time to remove the dependency in module table-planner to avoid other contributor continuing using junit4?
  2. I found that you spent some time to remove public for each test functions. But it is a weak constraint for contributor to following this implicit rule. How to make this rule more visible for contributor? (maybe using custom check style or something else)

"Logical plans do not match",
LogicalPlanFormatUtils.formatTempTableId(expectedString),
LogicalPlanFormatUtils.formatTempTableId(actualString))
assertThat(LogicalPlanFormatUtils.formatTempTableId(actualString))
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message seems to be lost. What about using org.junit.jupiter.api.Assertions#assertEquals?

@@ -621,8 +638,9 @@ abstract class TableTestUtilBase(test: TableTestBase, isStreamingMode: Boolean)
val optimizedRel = getPlanner.optimize(relNode)
val optimizedPlan = getOptimizedRelPlan(Array(optimizedRel), Array.empty, withRowType = false)
val result = notExpected.forall(!optimizedPlan.contains(_))
val message = s"\nactual plan:\n$optimizedPlan\nnot expected:\n${notExpected.mkString(", ")}"
assertTrue(message, result)
val message: String =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, revert this unnecessary changes.

@@ -835,28 +848,26 @@ abstract class TableTestUtilBase(test: TableTestBase, isStreamingMode: Boolean)
if (!file.exists() || "true".equalsIgnoreCase(System.getenv(PLAN_TEST_FORCE_OVERWRITE))) {
Files.deleteIfExists(path)
file.getParentFile.mkdirs()
assertTrue(file.createNewFile())
assertThat(file.createNewFile()).isTrue
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, use assertTrue(file.createNewFile()) since you have intruduced org.junit.jupiter.api.Assertions.assertTrue with junit5.

@@ -103,7 +103,7 @@ public void testCrossJoinOverrideParameters() {
}

@Test
public void testLeftOuterJoinWithLiteralTrue() {
void testLeftOuterJoinWithLiteralTrue() {
String sinkTableDdl =
"CREATE TABLE MySink (\n"
+ " a varchar,\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, also remove the public in function testJoinWithFilter() below.
BTW, maybe we need to consider how to make the weak constraint about removing public in test functions more conspicuous.


/** Test for {@link PushFilterIntoTableSourceScanRule}. */
public class PushFilterIntoTableSourceScanRuleTest
extends PushFilterIntoTableSourceScanRuleTestBase {
class PushFilterIntoTableSourceScanRuleTest extends PushFilterIntoTableSourceScanRuleTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto, this class only has some unresolved test cases where the 'public' need to be removed.

@Jiabao-Sun
Copy link
Contributor Author

Thank for your huge contribution about replacing junit4 with junit5 in table-planner module. The whole pr looks good to me. I mainly have two confusion.

  1. Is it a good time to remove the dependency in module table-planner to avoid other contributor continuing using junit4?
  2. I found that you spent some time to remove public for each test functions. But it is a weak constraint for contributor to following this implicit rule. How to make this rule more visible for contributor? (maybe using custom check style or something else)

Thanks @xuyangzhong for the hard review.

  1. Currently we can't remove junit4 dependencies from table-planner, because there are still some tests using Junit4 and have not been migrated to complete. After all the tests are migrated by Junit5, we can do this.
  2. I think we can add this check to ARCH Tests, but it may still need to wait until Junit5 is fully migrated.

Please help check it again when you have time.
Thanks again.

@xuyangzhong
Copy link
Contributor

LGTM. cc @leonardBang for the final check.

Copy link
Contributor

@leonardBang leonardBang left a comment

Choose a reason for hiding this comment

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

Thanks @Jiabao-Sun for the contribution and @xuyangzhong for the review work, LGTM

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.

4 participants