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

Update unit test doc #5856

Merged
merged 2 commits into from
Jun 20, 2022
Merged

Update unit test doc #5856

merged 2 commits into from
Jun 20, 2022

Conversation

res-life
Copy link
Collaborator

Closes #5467

Problem

case 1

cd spark-rapids
mvn test

The aggregator is a shading module, there are no classes under the aggregator/target/Sparkxxx/classes/ path.
So Maven tries to find the aggregator jar from local or remote repositories.

case 2

cd spark-rapids/tests
mvn test

By default, Maven tries to find an aggregator jar from local or remote repositories.

Changes

Due to the limitation of Maven, should first install the aggregator jar to the local repository.
Only need to update the doc.

Other context

The aggregator jar is not published to Maven Central.

Signed-off-by: Chong Gao res_life@163.com

Signed-off-by: Chong Gao <res_life@163.com>
@res-life
Copy link
Collaborator Author

build

@res-life
Copy link
Collaborator Author

Made an example, b module depends on a module.
mvn test -X shows the following:

[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ b ---
...
[DEBUG] test classpath classpath:
[DEBUG]   .../test-java-projects/b/target/test-classes
[DEBUG]   .../test-java-projects/b/target/classes
[DEBUG]   .../test-java-projects/a/target/classes

mvn test under the root directory, MVN adds the <dependency_module>/target/classes to the test classpath.
For the shading module, there are no target/classes directory.

tests/README.md Outdated
Comment on lines 19 to 21
The `tests` module depends on the `aggregator` module which is shading the dependencies.
Should first `mvn install` the aggregator jar to local Maven repository due to a limitation of the shading system.
The steps to run the unit tests:
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tgravescs does this wording make sense?

Suggested change
The `tests` module depends on the `aggregator` module which is shading the dependencies.
Should first `mvn install` the aggregator jar to local Maven repository due to a limitation of the shading system.
The steps to run the unit tests:
The `tests` module depends on the `aggregator` module which shades dependencies. When running the
tests, make sure to do an install via `mvn install` for the aggregator jar to the local maven
repository.
The steps to run the unit tests:

Copy link
Collaborator

Choose a reason for hiding this comment

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

its close, we might add "When running the tests via 'mvn test', make...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Updating the suggestion:

Suggested change
The `tests` module depends on the `aggregator` module which is shading the dependencies.
Should first `mvn install` the aggregator jar to local Maven repository due to a limitation of the shading system.
The steps to run the unit tests:
The `tests` module depends on the `aggregator` module which shades dependencies. When running the
tests via `mvn test`, make sure to do an install via `mvn install` for the aggregator jar to the
local maven repository.
The steps to run the unit tests:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@res-life
Copy link
Collaborator Author

build

@tgravescs tgravescs added the documentation Improvements or additions to documentation label Jun 17, 2022
@tgravescs tgravescs added this to the Jun 6 - Jun 17 milestone Jun 17, 2022
@gerashegalov
Copy link
Collaborator

If we end up merely documenting the work around we should file another bug to actually make mvn test without workarounds possible

Ideally we should make test depend on dist, make sure that dist mimics the default maven phases correctly and customize test class path of the test module if necessary using additionalClassPathElements https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html

@res-life
Copy link
Collaborator Author

res-life commented Jun 20, 2022

If we end up merely documenting the work around we should file another bug to actually make mvn test without workarounds possible

Ideally we should make test depend on dist, make sure that dist mimics the default maven phases correctly and customize test class path of the test module if necessary using additionalClassPathElements https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html

Thanks, @gerashegalov
The link you provided is helpful, in the link:

The Surefire plugin builds the test classpath in the following order:
  1. The test-classes directory
  2. The classes directory
  3. The project dependencies
  4. Additional classpath elements

If test depends on dist, the dependency type is: 3. The project dependencies

Already had an issue to try to depend on dist: #3932.
This issue was closed without a fix, please see details in the issue.

@res-life res-life merged commit ba8c57b into NVIDIA:branch-22.08 Jun 20, 2022
@res-life res-life deleted the test-doc branch June 20, 2022 01:52
@gerashegalov
Copy link
Collaborator

Thanks for the reminder about #3192 @res-life.

In addition, another obstacle to making the test phase on the tests module working without a prior install is that the shade plugin only supports the package phase per https://maven.apache.org/plugins/maven-shade-plugin/

So there is no way to make the tests module run in the test phase using the aggregator jar produced only in the package phase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] mvn test -Dbuildver=330 fails
4 participants