Skip to content
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actions/gradle-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ runs:
- name: Copy Test Reports
shell: bash
if: always()
run: mkdir -p test-reports && for d in fdb-java-annotations fdb-extensions fdb-record-layer-core fdb-record-layer-icu fdb-record-layer-spatial fdb-record-layer-lucene fdb-record-layer-jmh examples fdb-relational-api fdb-relational-core fdb-relational-cli fdb-relational-grpc fdb-relational-jdbc fdb-relational-server yaml-tests; do ln -s ../$d/.out/reports test-reports/$d; done
run: mkdir -p test-reports && for d in fdb-java-annotations fdb-extensions fdb-test-utils fdb-record-layer-core fdb-record-layer-icu fdb-record-layer-spatial fdb-record-layer-lucene fdb-record-layer-jmh examples fdb-relational-api fdb-relational-core fdb-relational-cli fdb-relational-grpc fdb-relational-jdbc fdb-relational-server yaml-tests; do ln -s ../$d/.out/reports test-reports/$d; done
1 change: 1 addition & 0 deletions fdb-extensions/fdb-extensions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation(libs.slf4j.api)
compileOnly(libs.jsr305)

testImplementation project(':fdb-test-utils')
testImplementation(libs.bundles.test.impl)
testRuntimeOnly(libs.bundles.test.runtime)
testCompileOnly(libs.bundles.test.compileOnly)
Expand Down
2 changes: 1 addition & 1 deletion fdb-record-layer-core/fdb-record-layer-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
compileOnly(libs.autoService)
annotationProcessor(libs.autoService)

testImplementation testFixtures(project(':fdb-extensions'))
testImplementation project(':fdb-test-utils')
testImplementation(libs.bundles.test.impl)
testRuntimeOnly(libs.bundles.test.runtime)
testCompileOnly(libs.bundles.test.compileOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static FDB getInitedFDB() {
synchronized (FDBDatabaseExtension.class) {
if (fdb == null) {
// Note: in some ways, this mirrors the TestDatabaseExtension abstraction in the
// fdb-extensions project. We could re-use this here, except that if we did, we'd
// fdb-test-utils project. We could re-use this here, except that if we did, we'd
// never test the FDBDatabaseFactory's methods for initializing FDB
FDBDatabaseFactory baseFactory = FDBDatabaseFactory.instance();
if (TRACE) {
Expand Down
2 changes: 1 addition & 1 deletion fdb-record-layer-icu/fdb-record-layer-icu.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
compileOnly(libs.autoService)
annotationProcessor(libs.autoService)

testImplementation testFixtures(project(':fdb-extensions'))
testImplementation project(':fdb-test-utils')
testImplementation project(path: coreProject, configuration: 'tests')
testImplementation(libs.bundles.test.impl)
testRuntimeOnly(libs.bundles.test.runtime)
Expand Down
2 changes: 1 addition & 1 deletion fdb-record-layer-lucene/fdb-record-layer-lucene.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
compileOnly(libs.autoService)
annotationProcessor(libs.autoService)

testImplementation testFixtures(project(':fdb-extensions'))
testImplementation project(':fdb-test-utils')
testImplementation project(path: coreProject, configuration: 'tests')
testImplementation(libs.bundles.test.impl)
testImplementation(libs.lucene.testFramework)
Expand Down
2 changes: 1 addition & 1 deletion fdb-record-layer-spatial/fdb-record-layer-spatial.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
testImplementation(libs.bundles.test.impl)
testRuntimeOnly(libs.bundles.test.runtime)
testCompileOnly(libs.bundles.test.compileOnly)
testImplementation testFixtures(project(':fdb-extensions'))
testImplementation project(':fdb-test-utils')
testImplementation project(path: coreProject, configuration: 'tests')
}

Expand Down
45 changes: 45 additions & 0 deletions fdb-test-utils/fdb-test-utils.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* fdb-test-utils.gradle
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2025 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply from: rootProject.file('gradle/publishing.gradle')

dependencies {
api(libs.bundles.test.impl)
api(libs.slf4j.api)
compileOnly(libs.bundles.test.compileOnly)
compileOnly(libs.jsr305)
annotationProcessor(libs.autoService)
implementation(libs.fdbJava)

testImplementation(libs.bundles.test.impl)
testRuntimeOnly(libs.bundles.test.runtime)
testCompileOnly(libs.bundles.test.compileOnly)
testAnnotationProcessor(libs.autoService)
}

publishing {
publications {
library(MavenPublication) {
pom {
description = 'Test utilities for FoundationDB Record Layer projects.'
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
* create an instance of this as static member variable and then register the class as an extension so
* that the callbacks associated with this extension are executed. Like so:
*
* <pre>{@code
* @RegisterExtension
* static final TestDatabaseExtension dbExtension = new TestDatabaseExtension();
* }</pre>
* <pre>
* &#64;RegisterExtension
* static final TestDatabaseExtension dbExtension = new TestDatabaseExtension();
* </pre>
*
* <p>
* The user can then call {@link #getDatabase() dbExtension.getDatabase()} to get an actual FDB handle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
/**
* Executors to use during testing.
*/
public class TestExecutors {
public final class TestExecutors {
@Nonnull
private static final Executor DEFAULT_THREAD_POOL = newThreadPool("fdb-unit-test");

private TestExecutors() {
}

/**
* Thread factory for creating threads used by test thread pools.
*/
Expand All @@ -51,9 +57,6 @@ public Thread newThread(final Runnable r) {
}
}

@Nonnull
private static final Executor DEFAULT_THREAD_POOL = newThreadPool("fdb-unit-test");

public static Executor newThreadPool(@Nonnull String namePrefix) {
return Executors.newCachedThreadPool(new TestThreadFactory(namePrefix));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.apple.foundationdb.Range;
import com.apple.foundationdb.directory.DirectoryLayer;
import com.apple.foundationdb.subspace.Subspace;
import com.apple.foundationdb.tuple.ByteArrayUtil2;
import com.apple.foundationdb.tuple.Tuple;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand All @@ -40,12 +39,12 @@
* will be cleared out during the {@link AfterEachCallback} for this extension. To use, create a member variable
* of the test and register the extension:
*
* <pre>{@code
* @RegisterExtension
* static final TestDatabaseExtension dbExtension = new TestDatabaseExtension();
* @RegisterExtension
* TestSubspaceExtension subspaceExtension = new TestSubspaceExtension(dbExtension);
* }</pre>
* <pre>
* &#64;RegisterExtension
* static final TestDatabaseExtension dbExtension = new TestDatabaseExtension();
* &#64;RegisterExtension
* TestSubspaceExtension subspaceExtension = new TestSubspaceExtension(dbExtension);
* </pre>
*
* <p>
* Within the test, call {@link #getSubspace()} to get the test's allocated exception. As long as all usage
Expand All @@ -72,7 +71,7 @@ public Subspace getSubspace() {
.thenApply(directorySubspace -> directorySubspace.subspace(Tuple.from(UUID.randomUUID())))
).join();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("created test subspace subspace=\"{}\"", ByteArrayUtil2.loggable(subspace.getKey()));
LOGGER.debug("created test subspace subspace=\"{}\"", subspace);
}
}
return subspace;
Expand All @@ -82,7 +81,7 @@ public Subspace getSubspace() {
public void afterEach(final ExtensionContext extensionContext) {
if (subspace != null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("clearing test subspace subspace=\"{}\"", ByteArrayUtil2.loggable(subspace.getKey()));
LOGGER.debug("clearing test subspace subspace=\"{}\"", subspace);
}
dbExtension.getDatabase().run(tx -> {
tx.clear(Range.startsWith(subspace.pack()));
Expand Down
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TeamScale is complaining that we should not use varargs for cartesianProduct.
I think this is a valid usage of varargs, as per the explanation of the issue:

Varargs methods are a convenient way to define methods that require a variable number of arguments, but they should not be overused. They can produce confusing results if used inappropriately.

I think we should tolerate this usage and leave it as-is, but wanted am commenting here as a place for discussion.

I will note that cartesianProduct does have a private overload that takes and returns an incompatible type from the public method.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
/**
* Helper utility class for interacting with {@link org.junit.jupiter.params.ParameterizedTest}s.
*/
public class ParameterizedTestUtils {
public final class ParameterizedTestUtils {

private ParameterizedTestUtils() {
}

/**
* Provides a stream of boolean, named arguments.
Expand Down
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TeamScale is complaining that we should not use varargs for randomSeeds.
I think this is a valid usage of varargs, as per the explanation of the issue:

Varargs methods are a convenient way to define methods that require a variable number of arguments, but they should not be overused. They can produce confusing results if used inappropriately.

I think we should tolerate this usage and leave it as-is, but wanted am commenting here as a place for discussion.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
/**
* Annotation {@link org.junit.jupiter.api.Tag}s for Record Layer tests.
*/
public class Tags {
@SuppressWarnings("PMD.FieldNamingConventions")
public final class Tags {
/**
* Tests that require FoundationDB to be available.
*/
Expand All @@ -46,4 +47,8 @@ public class Tags {
* Tests that wipe the entire FDB cluster during their run.
*/
public static final String WipesFDB = "WipesFDB";

private Tags() {
}

}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rootProject.name='fdb-record-layer'

include 'fdb-java-annotations'
include 'fdb-extensions'
include 'fdb-test-utils'
include 'fdb-record-layer-core'
include 'fdb-record-layer-core-shaded'
include 'fdb-record-layer-icu'
Expand Down
Loading