Skip to content

Commit b646da2

Browse files
Document how to run tests & our test configurations (#3843)
This adds documentation about the different configurations, and how to run our tests. In writing this, I noticed that the gradle config refernces a `Random` tag, but we didn't have such a tag in `Tags`, so I added one. I didn't see any references to that as a literal in any tests. I also added a couple comments to the gradle config to remind us to maintain this section of the contributing document. --------- Co-authored-by: ohadzeliger <[email protected]>
1 parent 61175b3 commit b646da2

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

CONTRIBUTING.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The following guide outlines the basics of how to get involved.
1313
* [Issues to Track Changes](#issues-to-track-changes)
1414
* [Opening a Pull Request](#opening-a-pull-request)
1515
* [Reporting Issues](#reporting-issues)
16+
* [Running tests](#running-tests)
1617
* [Project Communication](#project-communication)
1718
* [Community Forums](#community-forums)
1819
* [Using GitHub Issues and Community Forums](#using-github-issues-and-community-forums)
@@ -115,6 +116,75 @@ To report a security issue, please **DO NOT** start by filing a public issue
115116
or posting to the forums; instead send a private email to
116117
117118

119+
### Running tests
120+
121+
We have a variety of different testing configurations:
122+
123+
#### test
124+
125+
Standard test target for the majority of our tests; and the standard way of running tests
126+
in gradle `./gradlew test`
127+
128+
#### destructiveTest
129+
130+
Some tests have to work with global state in FDB, and need to wipe the entire database
131+
while running (or in `@Before*`/`@After*`). Those tests are annotated with `@Tag(Tags.WipesFDB)`,
132+
and are only run when you do `./gradlew destructiveTest`
133+
134+
#### performanceTest
135+
136+
For tests that gather performance numbers, and aren't focused on correctness.
137+
We don't currently run these in any sort of regular cadence, or automatically, but once written,
138+
it's valuable to keep the code, and run again if you touch the associated production code. These tests are annotated
139+
with `@Tag(Tags.Performance)` and can be run with `./gradlew performanceTest`.
140+
141+
#### quickTest
142+
143+
For tests that use `@YamlTest`, they generally run with a mixture of different configurations
144+
(e.g. force continuations / external servers). The `quickTest` target runs just the embedded
145+
configuration, and is most useful when you are developing new features & tests to make sure
146+
it works in an `Embedded` configuration without having to run the failing test a bunch of times for the other configurations.
147+
This can be run with `./gradlew quickTest`
148+
149+
#### rpcTest
150+
151+
Similar to `quickTest` above, except instead of running with an
152+
`EmbeddedRelationalConnection` it runs against JDBC-In-Process, which can be helpful if
153+
you are working on an aspect of the RPC protocol. This can be run with `./gradlew rpcTest`
154+
155+
#### singleVersionTest
156+
157+
For tests that use `@YamlTest`, this will run all the tests with the test connecting just
158+
to multiple external servers of the same version (unlike its normal behavior which is to alternate between the
159+
external server and the current embedded connection).
160+
This can be run with `./gradlew singleVersionTest`
161+
162+
#### Nightly
163+
164+
We have a [nightly action](https://github.com/FoundationDB/fdb-record-layer/actions/workflows/nightly.yml)
165+
that we run every night, and include tests that are exceptionally slow (annotated with `@SuperSlow`) or have
166+
randomness (ideally using `RandomizedTestUtils`).
167+
168+
To mimic the test run in our nightly GitHub action you'll need to attach the following properties, but
169+
you don't always need all of them. You can add this to a standard `./gradlew test` run.
170+
171+
- `-Ptests.nightly`:
172+
- It will gnore failures (since these tests are more likely to be flaky, we want to make sure we run all tests in all
173+
sub modules, and not abort if an early one fails.
174+
- It will run tests that are annotated with `@SuperSlow`, which have a higher timeout of 20 minutes.
175+
- It will run test parameters that are wrapped in `TestConfigurationUtils.onlyNightly`
176+
- `-Ptests.includeRandom`:
177+
- It will include tests tagged with `@Tag(Tags.Random)`
178+
- It will set the system locale to a randomly chosen one (to help catch issues where we assume the default locale is
179+
`en-US`)
180+
- `-Ptests.iterations=2`: For tests using `RandomizedTestUtils` to generate random seeds, this specifies the number of
181+
seeds to use. If `-Ptests.includeRandom` is not set, it still won't add any random seeds. This defaults to `0`.
182+
183+
184+
Note: We also utilize the `lucene-test-framework` to get additional coverage of our file format extensions and directory.
185+
Those tests have randomness, but also use JUnit4, unlike all of our tests which use JUnit5. We translate the randomness
186+
controls above into the appropriate properties so that it has matching behavior.
187+
118188
## Project Communication
119189

120190
### Community Forums

fdb-test-utils/src/main/java/com/apple/test/Tags.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public final class Tags {
4747
* Tests that wipe the entire FDB cluster during their run.
4848
*/
4949
public static final String WipesFDB = "WipesFDB";
50+
/**
51+
* Tests that are inherently random, and thus could be flaky.
52+
* See also {@link RandomizedTestUtils}.
53+
*/
54+
public static final String Random = "Random";
5055

5156
private Tags() {
5257
}

gradle/testing.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jacoco {
2727
toolVersion = libs.versions.jacoco.get()
2828
}
2929

30+
// if you add to or modify these testing configurations, make sure to update the CONTRIBUTING.md to include any updates
3031
test {
3132
useJUnitPlatform {
3233
excludeTags 'WipesFDB'
@@ -74,6 +75,8 @@ task singleVersionTest(type: Test) {
7475
}
7576
}
7677

78+
// if you add to or modify these testing configurations, make sure to update the CONTRIBUTING.md to include any updates
79+
7780
def getMixedModeVersion(descriptor) {
7881
while (descriptor != null) {
7982
// don't display this or any of the parents. Let's assume that nobody ever

0 commit comments

Comments
 (0)