-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[MINOR] Performance improvement of flink ITs with reused miniCluster #7151
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d411cae
[MINOR] Performance improvement of flink ITs with reused miniCluster
trushev fb4b561
[MINOR] Performance improvement of flink ITs with reused miniCluster
trushev 4851e5e
implement MiniCluster extension compatible with junit5
trushev db20736
add RAT
trushev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...ink-datasource/hudi-flink/src/test/java/org/apache/hudi/utils/AbstractHoodieTestBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hudi.utils; | ||
|
|
||
| import org.apache.hudi.exception.HoodieException; | ||
|
|
||
| import org.apache.flink.test.util.AbstractTestBase; | ||
| import org.apache.flink.test.util.MiniClusterWithClientResource; | ||
|
|
||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
|
|
||
| import java.lang.reflect.Field; | ||
| import java.util.Arrays; | ||
|
|
||
| import static java.lang.reflect.Modifier.isPublic; | ||
| import static java.lang.reflect.Modifier.isStatic; | ||
|
|
||
| /** | ||
| * Hoodie base class for tests that run multiple tests and want to reuse the same Flink cluster. | ||
| * Unlike {@link AbstractTestBase}, this class is designed to run with JUnit 5. | ||
| */ | ||
| public abstract class AbstractHoodieTestBase extends AbstractTestBase { | ||
|
|
||
| private static final MiniClusterWithClientResource MINI_CLUSTER_RESOURCE = getMiniClusterFromParentClass(); | ||
|
|
||
| @BeforeAll | ||
| public static void beforeAll() throws Exception { | ||
| MINI_CLUSTER_RESOURCE.before(); | ||
| } | ||
|
|
||
| @AfterAll | ||
| public static void afterAll() { | ||
| MINI_CLUSTER_RESOURCE.after(); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void afterEach() throws Exception { | ||
| cleanupRunningJobs(); | ||
| } | ||
|
|
||
| private static MiniClusterWithClientResource getMiniClusterFromParentClass() { | ||
| String fieldFlink114 = "miniClusterResource"; | ||
| String fieldFlink115 = "MINI_CLUSTER_RESOURCE"; | ||
| Field miniClusterField = Arrays.stream(AbstractTestBase.class.getDeclaredFields()) | ||
| .filter(f -> isPublic(f.getModifiers()) && isStatic(f.getModifiers())) | ||
| .filter(f -> fieldFlink114.equals(f.getName()) || fieldFlink115.equals(f.getName())) | ||
| .findAny() | ||
| .orElseThrow(() -> new NoSuchFieldError(String.format( | ||
| "%s not found in %s", | ||
| fieldFlink115, | ||
| AbstractTestBase.class.getName()))); | ||
| try { | ||
| return (MiniClusterWithClientResource) miniClusterField.get(null); | ||
| } catch (IllegalAccessException e) { | ||
| throw new HoodieException("Cannot access miniCluster field", e); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the Junit4
ClassRulecan not work correctly here ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
ClassRuledoes not workWe should call
MINI_CLUSTER_RESOURCE.before()andMINI_CLUSTER_RESOURCE.after()using JUnit 5There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some mvn bridge plugin for Junit4 and Junit5, did you try to use that ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially, we want to run junit5
org.junit.jupiter.api.Testtests in class inherited from class contained junit4org.junit.ClassRule. Pseudocode:I didn't find solution better than inroduced by this PR. Do you know mvn plugin that runs such tests?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the vintage engine work here:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there is annotation
@EnableRuleMigrationSupportfromand it works for
@Rulebut for some reason it does not work for
@ClassRule(our case)There is only
@Rulementioned in official docThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, some compatibility tools should be used here, or maybe we can implement a
AbstractTestBaseof our own for Junit5, there is no much code here BTW.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented as junit5 extension