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

[Improvement-12333][Test] Migrate all UT cases from jUnit 4 to jUnit 5 in microbench and e2e module #12348

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

rickchengx
Copy link
Contributor

Purpose of the pull request

Brief change log

Migrate all UT cases from jUnit 4 to jUnit 5 in microbench and e2e module

Verify this pull request

@github-actions github-actions bot added the e2e e2e test label Oct 13, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2022

Codecov Report

Merging #12348 (3bef85f) into dev (ac84504) will increase coverage by 0.28%.
The diff coverage is 29.16%.

❗ Current head 3bef85f differs from pull request most recent head 4836073. Consider uploading reports for the commit 4836073 to get more accurate results

@@             Coverage Diff              @@
##                dev   #12348      +/-   ##
============================================
+ Coverage     38.93%   39.22%   +0.28%     
- Complexity     4177     4211      +34     
============================================
  Files          1040     1040              
  Lines         38797    38794       -3     
  Branches       4460     4460              
============================================
+ Hits          15105    15216     +111     
+ Misses        21923    21806     -117     
- Partials       1769     1772       +3     
Impacted Files Coverage Δ
.../org/apache/dolphinscheduler/api/enums/Status.java 100.00% <ø> (ø)
...api/service/impl/ProcessDefinitionServiceImpl.java 34.83% <0.00%> (+0.11%) ⬆️
...inscheduler/service/expand/CuringGlobalParams.java 31.11% <0.00%> (ø)
...olphinscheduler/plugin/task/api/TaskConstants.java 0.00% <ø> (ø)
...lphinscheduler/plugin/task/api/utils/K8sUtils.java 3.50% <0.00%> (-0.34%) ⬇️
...dolphinscheduler/plugin/task/datax/DataxUtils.java 0.00% <0.00%> (ø)
.../dolphinscheduler/plugin/task/datax/DataxTask.java 36.77% <63.63%> (+36.77%) ⬆️
...org/apache/dolphinscheduler/remote/utils/Host.java 42.55% <0.00%> (-2.13%) ⬇️
...e/dolphinscheduler/remote/NettyRemotingClient.java 51.42% <0.00%> (-0.72%) ⬇️
...r/plugin/task/datax/DataxTaskExecutionContext.java 5.00% <0.00%> (+5.00%) ⬆️
... and 2 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rickchengx
Copy link
Contributor Author

Hi, @kezhenxu94 , could you please help me with this e2e problem?

This PR wants to remove the junit4 api in the e2e module. But in dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java, we cannot just remove or replace the junit4 api since org.testcontainers.containers.Network is used.

截屏2022-10-13 14 22 18

It seems that Testcontainers is tightly coupled with the JUnit 4.x rule API, and here is the limitation of Testcontainers from the article below:
截屏2022-10-13 14 32 59

If we want to migrate all UT cases from jUnit4 to Junit5 here, do we need to refactor the tests in e2e module.
Note: Testcontainers is also used in dolphinscheduler-api-test module.

cc @EricGao888

@kezhenxu94
Copy link
Member

kezhenxu94 commented Oct 14, 2022

From the doc of testcontainers it seems impossible to remove junit4 from test classpath. But since we have spotless check to forbid usage of junit4 classes we can avoid direct use of junit4 in our codebase. Right?

Is your question about the failed tests, then?

@rickchengx
Copy link
Contributor Author

@kezhenxu94 Thanks a lot for the comment, I agree with you. So we need to avoid the junit 4 api in our codebase.

截屏2022-10-13 14 22 18

As for the CI e2e failure, this is because I usenetwork = Network.newNetWork() instead of network = new NetWork() and override the methods of getId(), close() and apply().

The reason I made this change was to avoid the import of org.junit.runner.Description and org.junit.runners.model.Statement. But network = Network.newNetWork() now cannot return the networkId and cause the CI failure.

Now I have tried to use network = Network.builder().id(networkId).build();. I am not sure whether this could pass the CI.

Maybe we could wait for the CI results before deciding what to do next.

@EricGao888 EricGao888 added this to the 3.2.0 milestone Oct 14, 2022
@rickchengx
Copy link
Contributor Author

rickchengx commented Oct 14, 2022

Hi @kezhenxu94 It seems that the CI cannot pass because of the network below, would you please help me with this CI failure?

截屏2022-10-14 14 26 35

image

@rickchengx rickchengx force-pushed the Improvement-12333 branch 2 times, most recently from 76d5e7e to 5f4179f Compare October 14, 2022 11:44
@rickchengx
Copy link
Contributor Author

I have a clue, WIP

@EricGao888
Copy link
Member

@rickchengx FYI, we also have a junit import in microbench module, see:

@rickchengx
Copy link
Contributor Author

@rickchengx FYI, we also have a junit import in microbench module, see:

Hi @EricGao888 Thanks for the comment. I've noticed this.
image

@sonarcloud
Copy link

sonarcloud bot commented Oct 18, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rickchengx
Copy link
Contributor Author

Hi, @EricGao888 , I have refactored DolphinschedulerExtension in e2e module to remove the junit4 api and It seems that the CI is passed, : )

cc @kezhenxu94

@EricGao888 EricGao888 added the improvement make more easy to user or prompt friendly label Oct 19, 2022
@EricGao888
Copy link
Member

Seems good to me. But I'm not familiar with this module. Could u plz take a look when available? @kezhenxu94 @SbloodyS ? Thanks~

@zhongjiajie
Copy link
Member

zhongjiajie commented Oct 19, 2022

LGTM, BTW can you also fix the number format error?
image

@EricGao888
Copy link
Member

EricGao888 commented Oct 19, 2022

LGTM, BTW can you also fix the number format error? image

@zhongjiajie Thanks for pointing this out. I will submit a follow-up PR to this issue to fix this, as well as remove junit4 check exclusions for these two modules.

dolphinscheduler/pom.xml

Lines 642 to 647 in a11892a

<java>
<!--TODO: Remove the following excludes section when junit4 removed from e2e and microbench module-->
<excludes>
<exclude>**/e2e/**/*.java</exclude>
<exclude>**/microbench/**/*.java</exclude>
</excludes>

@EricGao888
Copy link
Member

LGTM, BTW can you also fix the number format error? image

@zhongjiajie I've done it in #12450, please take a look when available, thanks : )

Chris-Arith pushed a commit to Chris-Arith/dolphinscheduler that referenced this pull request Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e e2e test improvement make more easy to user or prompt friendly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Migration][Test] Migrate all UT cases from jUnit 4 to jUnit 5 in microbench and e2e module
5 participants