127 lines
4.4 KiB
Plaintext
127 lines
4.4 KiB
Plaintext
= Spring AOT Smoke Tests image:https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A["Revved up by Develocity", link="https://ge.spring.io/scans?search.rootProjectNames=spring-aot-smoke-tests"]
|
||
|
||
A suite of tests for applications using AOT on the JVM and in GraalVM native images.
|
||
There are two types of tests: unit tests and application tests.
|
||
|
||
Unit tests are processed ahead of time and are then either run on the JVM or as a native executable.
|
||
Unit tests can be run on the JVM using the `test` task and as a native executable using the `nativeTest` task.
|
||
|
||
Application tests are always executed on the JVM against an application that's running on the JVM or as a native executable.
|
||
The `appTest` task tests the application running on the JVM.The `nativeAppTest` task tests the application running as a native executable.
|
||
|
||
== Contributing
|
||
|
||
Please read and follow the link:CONTRIBUTING.adoc[contributing guide].
|
||
|
||
== Initial Setup
|
||
|
||
The smoke tests resolve commercial dependencies from https://repo.spring.io which requires authentication.
|
||
Use the `REPO_SPRING_IO_USERNAME` and `REPO_SPRING_IO_PASSWORD` environment variables to provide the necessary credentials.
|
||
|
||
== How to
|
||
|
||
=== Run all of a project's smoke tests
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :<name of the group>:<name of the smoke test>:build
|
||
----
|
||
|
||
for example
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :boot:actuator-webmvc:build
|
||
----
|
||
|
||
=== Run a specific type of tests for a project
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :<name of the group>:<name of the smoke test>:<test task name>
|
||
----
|
||
|
||
Valid test task names are:
|
||
|
||
1. `appTest` – tests the application running on the JVM
|
||
2. `nativeAppTest` – tests the application running as a native executable
|
||
3. `test` – executes the AOT-processed unit tests on the JVM
|
||
4. `nativeTest` – executes the AOT-processed unit tests in a native executable
|
||
|
||
for example
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :boot:actuator-webmvc:appTest
|
||
----
|
||
|
||
=== Add a new smoke test
|
||
|
||
1. Create a new directory for your smoke test in the appropriate group
|
||
2. Include the directory in `settings.gradle` (new groups only)
|
||
3. Consult the https://github.com/spring-projects/spring-aot-smoke-tests/tree/ci/README.adoc[README in the `ci` branch] to update the CI infrastructure
|
||
|
||
=== Test against local changes
|
||
|
||
==== Your project uses Gradle
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :<name of the group>:<name of the smoke test>:build --include-build /path/to/your/project
|
||
----
|
||
|
||
Gradle https://docs.gradle.org/current/userguide/composite_builds.html#command_line_composite[will then substitute the dependency] with your provided version.
|
||
|
||
_Hint: You can use `--include-build` multiple times._
|
||
|
||
==== Your project uses Maven or --include-build does not work
|
||
|
||
First, install the snapshots into your local Maven cache.
|
||
You can now consume those snapshots using `-PfromMavenLocal` which takes a comma-separated list of group IDs:
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :rest-template:build -PfromMavenLocal=org.springframework,org.springframework.data
|
||
----
|
||
|
||
The preceding example will run the `rest-template` smoke test, resolving Spring Framework and Spring Data modules from your local Maven cache.
|
||
|
||
=== Using snapshots
|
||
|
||
By default, the smoke tests will use snapshots of `org.springframework.*` dependencies.
|
||
Note that `org.springframework.boot` and `org.springframework.cloud` dependencies are not affected.
|
||
Their versions are controlled by the `springBootVersion` and `springCloudVersion` properties defined in `gradle.properties`.
|
||
|
||
For each eligible dependency, the snapshot version that is used is derived from the dependency's default version:
|
||
|
||
- `x.y.z-SNAPSHOT` is left as-is
|
||
- `x.y.z` is changed to `x.y.z+1-SNAPSHOT`
|
||
- `x.y.z-Mn` is changed to `x.y.z-SNAPSHOT`
|
||
- `x.y.z-RCn` is changed to `x.y.z-SNAPSHOT`
|
||
|
||
To disable this behavior, set the `forceSnapshots` property to `false`, as shown in the following example:
|
||
|
||
[source,]
|
||
----
|
||
./gradlew :boot:actuator-webmvc:build -PforceSnapshots=false
|
||
----
|
||
|
||
=== Override a dependency version
|
||
|
||
As the test doesn't use the Spring Dependency Management Plugin, you can't use the `ext['...'] = '...'` method.
|
||
|
||
Instead, use https://docs.gradle.org/current/userguide/dependency_constraints.html[Gradle dependency constraints].
|
||
Say, for example, you want to update the version of Spring Session JDBC to `3.0.0-SNAPSHOT`:
|
||
|
||
[source,]
|
||
----
|
||
dependencies {
|
||
// ...
|
||
constraints {
|
||
implementation('org.springframework.session:spring-session-jdbc:3.0.0-SNAPSHOT')
|
||
}
|
||
}
|
||
----
|
||
|
||
This works for direct and transitive dependencies.
|