Skip to content

Added mongodb/specifications as a git submodule #1670

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

Merged
merged 21 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update test runner and revert lookup test skipping
  • Loading branch information
rozza committed Apr 3, 2025
commit 7a139b1c5a920c03c958a605c3577d24049d8a7a
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ protected ClientEncryption createClientEncryption(final ClientEncryptionSettings

@BeforeEach
public void setUp() {
assumeFalse(() -> true); // https://jira.mongodb.org/browse/JAVA-5837
assumeFalse(isStandalone());
assumeTrue(serverVersionAtLeast(7, 0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ BsonDocument getOperationResults(final BsonDocument operation, @Nullable final C
case "assertIndexNotExists":
assertIndexExists(operation, false);
return new BsonDocument();
case "wait":
return executeWait(operation);
default:
try {
Method method = getClass().getDeclaredMethod(methodName, BsonDocument.class, BsonDocument.class, ClientSession.class);
Expand Down Expand Up @@ -246,6 +248,15 @@ BsonDocument toResult(@Nullable final BsonValue results) {
return new BsonDocument("result", results != null ? results : BsonNull.VALUE);
}

private BsonDocument executeWait(final BsonDocument operation) {
try {
Thread.sleep(operation.getDocument("arguments").getNumber("ms").longValue());
return new BsonDocument();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

private void assertCollectionExists(final BsonDocument operation, final boolean shouldExist) {
BsonDocument arguments = operation.getDocument("arguments", new BsonDocument());
String databaseName = arguments.getString("database").getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.bson.BsonInt32;
import org.bson.BsonString;
import org.bson.BsonValue;
import org.bson.assertions.Assertions;
import org.bson.codecs.BsonDocumentCodec;
import org.bson.diagnostics.Logger;
import org.bson.diagnostics.Loggers;
Expand All @@ -63,6 +64,7 @@

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand All @@ -85,6 +87,7 @@
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier;
import static com.mongodb.client.unified.UnifiedTestModifications.applyCustomizations;
import static com.mongodb.client.unified.UnifiedTestModifications.testDef;
import static java.lang.String.format;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -106,6 +109,11 @@ public abstract class UnifiedTest {
private static final Set<String> PRESTART_POOL_ASYNC_WORK_MANAGER_FILE_DESCRIPTIONS = Collections.singleton(
"wait queue timeout errors include details about checked out connections");

private static final String MAX_SUPPORTED_SCHEMA_VERSION = "1.21";
private static final List<Integer> MAX_SUPPORTED_SCHEMA_VERSION_COMPONENTS = Arrays.stream(MAX_SUPPORTED_SCHEMA_VERSION.split("\\."))
.map(Integer::parseInt)
.collect(Collectors.toList());

public static final int RETRY_ATTEMPTS = 3;
public static final int FORCE_FLAKY_ATTEMPTS = 10;
private static final Set<String> ATTEMPTED_TESTS_TO_HENCEFORTH_IGNORE = new HashSet<>();
Expand Down Expand Up @@ -256,30 +264,7 @@ public void setUp(
}
skips(fileDescription, testDescription);

assertTrue(
schemaVersion.equals("1.0")
|| schemaVersion.equals("1.1")
|| schemaVersion.equals("1.2")
|| schemaVersion.equals("1.3")
|| schemaVersion.equals("1.4")
|| schemaVersion.equals("1.5")
|| schemaVersion.equals("1.6")
|| schemaVersion.equals("1.7")
|| schemaVersion.equals("1.8")
|| schemaVersion.equals("1.9")
|| schemaVersion.equals("1.10")
|| schemaVersion.equals("1.11")
|| schemaVersion.equals("1.12")
|| schemaVersion.equals("1.13")
|| schemaVersion.equals("1.14")
|| schemaVersion.equals("1.15")
|| schemaVersion.equals("1.16")
|| schemaVersion.equals("1.17")
|| schemaVersion.equals("1.18")
|| schemaVersion.equals("1.19")
|| schemaVersion.equals("1.20")
|| schemaVersion.equals("1.21"),
String.format("Unsupported schema version %s", schemaVersion));
assumeTrue(isSupportedSchemaVersion(schemaVersion), format("Unsupported schema version %s", schemaVersion));
if (runOnRequirements != null) {
assumeTrue(runOnRequirementsMet(runOnRequirements, getMongoClientSettings(), getServerVersion()),
"Run-on requirements not met");
Expand Down Expand Up @@ -436,6 +421,25 @@ private void compareEvents(final UnifiedTestContext context, final BsonDocument
}
}

private boolean isSupportedSchemaVersion(final String schemaVersion) {
List<Integer> schemaVersionComponents = Arrays.stream(schemaVersion.split("\\."))
.map(Integer::parseInt)
.collect(Collectors.toList());

if (schemaVersionComponents.size() != 2) {
Assertions.fail("Unsupported schema version: " + schemaVersion);
}

for (int i = 0; i < 2; i++){
int schemaComponent = schemaVersionComponents.get(i);
int maxSupportedComponent = MAX_SUPPORTED_SCHEMA_VERSION_COMPONENTS.get(i);
if (schemaComponent > maxSupportedComponent) {
return false;
}
}
return true;
}

private void compareLogMessages(final UnifiedTestContext rootContext, final BsonDocument definition,
final Iterable<LogMatcher.Tweak> tweaks) {
for (BsonValue cur : definition.getArray("expectLogMessages")) {
Expand Down