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

[#4951] improvement(test): Reduce fields shares between different IT to make AbstractIT more independent. #4996

Merged
merged 21 commits into from
Oct 16, 2024

Conversation

yuqi1129
Copy link
Contributor

@yuqi1129 yuqi1129 commented Sep 23, 2024

What changes were proposed in this pull request?

Remove static fields of AbstractIT to make it more robust.

Why are the changes needed?

To make it more robut.

Fix: #4951

Does this PR introduce any user-facing change?

N/A

How was this patch tested?

The existing test.

@yuqi1129 yuqi1129 changed the title [#4951] improvement(test): Make AbstractIT more independent. [#4951] improvement(test): Make AbstractIT more independent to reduce fields shares between different IT. Sep 30, 2024
@yuqi1129 yuqi1129 changed the title [#4951] improvement(test): Make AbstractIT more independent to reduce fields shares between different IT. [#4951] improvement(test): Reduce fields shares between different IT to make AbstractIT more independent. Sep 30, 2024
@yuqi1129
Copy link
Contributor Author

yuqi1129 commented Oct 8, 2024

@mchades
Please help to review this PR, thanks.

@jerryshao
Copy link
Contributor

Ping @mchades .

Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

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

Sorry for the later response.

@yuqi1129 yuqi1129 self-assigned this Oct 11, 2024
@mchades mchades requested a review from diqiu50 October 12, 2024 02:28
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.shaded.org.awaitility.Awaitility;

@ExtendWith({PrintFuncNameExtension.class, CloseContainerExtension.class})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this annotation be inherited by subclasses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Please see SparkHiveCatalogIT33 and SparkHiveCatalogIT

Copy link
Contributor

Choose a reason for hiding this comment

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

If that, we call remove all the annotation like @TestInstance(TestInstance.Lifecycle.PER_CLASS) in the subclasses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I have removed the redundant annotations.

"embedded, kvBackend",
"deploy, jdbcBackend",
"deploy, kvBackend"
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Would removing these have no effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's pointless and won't actually happen.

diqiu50
diqiu50 previously approved these changes Oct 14, 2024
Copy link
Contributor

@diqiu50 diqiu50 left a comment

Choose a reason for hiding this comment

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

LGTM

private static BaseIT baseIT;

private void setEnv() throws Exception {
baseIT = new BaseIT();
Copy link
Contributor

Choose a reason for hiding this comment

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

How to use BaseIT? What is the difference between creating an instance and inheritance? Can we add an abstract modifier to baseIT for uniform usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the difference between creating an instance and inheritance

Some tests, for example, SparkQueryRunner just use BaseIT as a field to start the Gravitino server and run TPCDS query. Others just take it as the base test class.

Can we add an abstract modifier to baseIT for uniform usage?

it's beyond the scope of this PR scope and we can do the refacor later with the help of @FANNG1 @diqiu50 for the Spark and Trino related tests that use BaseIT as the class field.

Copy link
Contributor

Choose a reason for hiding this comment

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

BaseIT is actually a utility for starting the Gravitino server and Gravitino client for TrinoTesters.
In the TrinoQueryIT class, starting the Gravitino server is an option for running the tests.
Therefore, it is not appropriate for the TrinoQueryIT class to inherit from BaseIT

Copy link
Contributor

Choose a reason for hiding this comment

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

If refactoring is necessary, I think it would be better to move the logic for starting the Gravitino server out of BaseIT. In BaseIT, the automatic starting of the Gravitino server is implemented. Test classes that need to use the default method to start the Gravitino server should inherit from BaseIT

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me summarize the differences between the two usages:
Extending BaseIT automatically starts the Gravitino server and client before the test begins. If a developer wishes to start the Gravitino server manually, they should create a BaseIT instance, is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, refactoring this part will be another work for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

If that's the case, I believe adding comments to the class BaseIT is sufficient and there is no need to refactor it.

diqiu50
diqiu50 previously approved these changes Oct 15, 2024
@jerryshao
Copy link
Contributor

Please address the conflicts here.

Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

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

LGTM.

@yuqi1129 yuqi1129 merged commit b7f4e34 into apache:main Oct 16, 2024
26 checks passed
@yuqi1129 yuqi1129 deleted the issue_4951 branch October 16, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants