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

[Bug report] TestHiveTableOperations can't be test alone #4851

Closed
LindaSummer opened this issue Sep 4, 2024 · 1 comment · Fixed by #4854
Closed

[Bug report] TestHiveTableOperations can't be test alone #4851

LindaSummer opened this issue Sep 4, 2024 · 1 comment · Fixed by #4854
Assignees
Labels
0.6.1 Release v0.6.1 0.7.0 Release v0.7.0 bug Something isn't working

Comments

@LindaSummer
Copy link
Contributor

Version

main branch

Describe what's wrong

When using this command line gradle :catalogs:catalog-hive:test --tests 'org.apache.gravitino.catalog.hive.TestHiveTableOperations', unit test will fail.

Error message and/or stacktrace

Here are logs of testing.

gradle :catalogs:catalog-hive:test --tests 'org.apache.gravitino.catalog.hive.TestHiveTableOperations'

> Configure project :
------------------ Check Docker environment ---------------------
Docker server status ............................................ [running]
Run test cases without `gravitino-docker-test` tag .............. [embedded test]
-----------------------------------------------------------------

> Task :catalogs:catalog-hive:test

TestHiveTableOperations > initializationError FAILED
    java.lang.NullPointerException
        at org.apache.gravitino.catalog.hive.TestHiveTable.initHiveSchema(TestHiveTable.java:90)
        at org.apache.gravitino.catalog.hive.TestHiveTableOperations.setup(TestHiveTableOperations.java:62)

1 test completed, 1 failed

> Task :catalogs:catalog-hive:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':catalogs:catalog-hive:test'.
> There were failing tests. See the report at: file:///home/ubuntu/opensource/gravitino/build/reports/index.html

* Try:
> Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.10/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 12s
30 actionable tasks: 4 executed, 26 up-to-date

How to reproduce

Gravitino version: main branch commit 03e2110.

Run this command: gradle :catalogs:catalog-hive:test --tests 'org.apache.gravitino.catalog.hive.TestHiveTableOperations'

Additional context

This issue only happens when TestHiveTable is not initialized.
It imports static variables TestHiveTable.hiveCatalogOperations.
So, when TestHiveTable class is not initialized with setup(), the imported variable is null.

I find this problem during check the coverage of TestHiveTableOperations on issue #2183.

@LindaSummer LindaSummer added the bug Something isn't working label Sep 4, 2024
@LindaSummer
Copy link
Contributor Author

Hi Team,

Please correct me if I misunderstand the problem or my way of usage is incorrect.

I will try to fix it first and then continue to check the coverage of TestHiveTableOperations.

Best Regards,
Edward

github-actions bot pushed a commit that referenced this issue Sep 5, 2024
<!--
1. Title: [#<issue>] <type>(<scope>): <subject>
   Examples:
     - "[#123] feat(operator): support xxx"
     - "[#233] fix: check null before access result in xxx"
     - "[MINOR] refactor: fix typo in variable name"
     - "[MINOR] docs: fix typo in README"
     - "[#255] test: fix flaky test NameOfTheTest"
   Reference: https://www.conventionalcommits.org/en/v1.0.0/
2. If the PR is unfinished, please mark this PR as draft.
-->

### What changes were proposed in this pull request?

`TestHiveTableOperations` can be tested before `TestHiveTable`
initialized.
Make `TestHiveTableOperations::steup()` run alone.

### Why are the changes needed?

When we try to just run `gradle :catalogs:catalog-hive:test --tests
'org.apache.gravitino.catalog.hive.TestHiveTableOperations'`,
`TestHiveTableOperations` needs static variables which must be
initialized ahead, and it can't be run alone.

Fix: #4851 

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Refactor of unit test setup, local unit tests have passed.
@mchades mchades added the 0.6.0 Release v0.6.0 label Sep 5, 2024
@jerryshao jerryshao added 0.6.1 Release v0.6.1 0.7.0 Release v0.7.0 and removed 0.6.0 Release v0.6.0 labels Sep 5, 2024
jerryshao pushed a commit that referenced this issue Sep 5, 2024
### What changes were proposed in this pull request?

`TestHiveTableOperations` can be tested before `TestHiveTable`
initialized.
Make `TestHiveTableOperations::steup()` run alone.

### Why are the changes needed?

When we try to just run `gradle :catalogs:catalog-hive:test --tests
'org.apache.gravitino.catalog.hive.TestHiveTableOperations'`,
`TestHiveTableOperations` needs static variables which must be
initialized ahead, and it can't be run alone.

Fix: #4851 

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Refactor of unit test setup, local unit tests have passed.

Co-authored-by: Edward Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.6.1 Release v0.6.1 0.7.0 Release v0.7.0 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants