Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ All notable changes to this project are documented in this file.
- Added structured runtime logging contract (`onLog`, `logFormat`) with expanded log levels (`error`/`warn`/`info`/`debug`).

### Fixed
- Fixed insert parity for documents missing `_id` by assigning an `ObjectId` before unique-index validation.
- Fixed release-gate runOn lanes to keep `mongos-unpin` and `client-bulkWrite-errors*` suites gated until their exact differential contracts are implemented.
- Fixed deterministic R3 parity mismatches for dollar-prefixed `_id` subfields, replacement-style `updateMany`, and `createIndexes` inside transactions.
- Fixed upsert seed extraction to honor equality clauses nested inside `$and`, restoring duplicate-key behavior for `findOneAndUpdate` lock-style filters.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ public synchronized void insertMany(List<Document> documents) {
if (document == null) {
throw new IllegalArgumentException("documents must not contain null");
}
copiedDocuments.add(DocumentCopies.copy(document));
final Document copiedDocument = DocumentCopies.copy(document);
if (!copiedDocument.containsKey("_id")) {
copiedDocument.put("_id", new ObjectId());
}
copiedDocuments.add(copiedDocument);
}

List<Document> candidateDocuments = new ArrayList<>(this.documents.size() + copiedDocuments.size());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jongodb/testkit/UnifiedSpecImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,6 @@ private static boolean isMongosPinAutoLaneSourcePath(final String sourcePath) {

private static boolean isMongosTopologyLaneSourcePath(final String sourcePath) {
return matchesSpecPathWithSupportedExtensions(sourcePath, "transactions/tests/unified/pin-mongos")
|| matchesSpecPathWithSupportedExtensions(sourcePath, "transactions/tests/unified/mongos-unpin")
|| matchesSpecPathWithSupportedExtensions(sourcePath, "transactions/tests/unified/mongos-recovery-token");
}

Expand Down Expand Up @@ -1262,7 +1261,8 @@ private static boolean isClientBulkWriteVersionLaneSourcePath(final String sourc
if (!clientBulkWriteSource) {
return false;
}
return !sourcePath.contains("client-bulkWrite-errorResponse");
return !sourcePath.contains("client-bulkWrite-errors")
&& !sourcePath.contains("client-bulkWrite-errorResponse");
}

private static boolean isSnapshotSessionsNotSupportedClientErrorLaneSourcePath(final String sourcePath) {
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/org/jongodb/engine/InMemoryCollectionStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Date;
import java.util.List;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.junit.jupiter.api.Test;

class InMemoryCollectionStoreTest {
Expand All @@ -30,6 +31,20 @@ void insertManyAndFindAllReturnsInsertedDocuments() {
assertEquals("Linus", found.get(1).getString("name"));
}

@Test
void insertManyAssignsObjectIdWhenIdIsMissing() {
CollectionStore store = new InMemoryCollectionStore();
final Document source = new Document("name", "Ada");

store.insertMany(List.of(source));

final List<Document> found = store.findAll();
assertEquals(1, found.size());
assertFalse(source.containsKey("_id"));
assertTrue(found.get(0).get("_id") instanceof ObjectId);
assertEquals("Ada", found.get(0).getString("name"));
}

@Test
void findSupportsSimpleEqualityFilter() {
CollectionStore store = new InMemoryCollectionStore();
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/org/jongodb/testkit/UnifiedSpecImporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void appliesMongosTopologyLaneOverrideForPinMongosYamlSourcePath() throws IOExce
}

@Test
void appliesMongosTopologyLaneOverrideForMongosUnpinSourcePath() throws IOException {
void keepsRunOnTopologyChecksForMongosUnpinSourcePath() throws IOException {
final Path suiteRoot = tempDir.resolve("transactions/tests/unified");
Files.createDirectories(suiteRoot);
Files.writeString(
Expand All @@ -408,9 +408,9 @@ void appliesMongosTopologyLaneOverrideForMongosUnpinSourcePath() throws IOExcept
tempDir,
UnifiedSpecImporter.RunOnContext.evaluated("7.0.25", "replicaset", false, false));

assertEquals(1, result.importedCount());
assertEquals(0, result.skippedCount());
assertEquals(0, result.unsupportedCount());
assertEquals(0, result.importedCount());
assertEquals(1, result.skippedCount());
assertTrue(result.skippedCases().get(0).reason().contains("runOnRequirements not satisfied"));
}

@Test
Expand Down Expand Up @@ -606,7 +606,7 @@ void keepsRunOnVersionChecksForNonClientBulkWriteLaneFiles() throws IOException
}

@Test
void appliesRunOnVersionLaneForClientBulkWriteErrorsFiles() throws IOException {
void keepsRunOnVersionChecksForClientBulkWriteErrorsFiles() throws IOException {
final Path suiteRoot = tempDir.resolve("crud/tests/unified");
Files.createDirectories(suiteRoot);
Files.writeString(
Expand All @@ -617,7 +617,7 @@ void appliesRunOnVersionLaneForClientBulkWriteErrorsFiles() throws IOException {
"collection_name": "users",
"tests": [
{
"description": "errors lane included",
"description": "errors lane excluded",
"runOnRequirements": [{"minServerVersion": "8.0"}],
"operations": [
{"name": "find", "arguments": {"filter": {"_id": 1}}}
Expand All @@ -632,9 +632,9 @@ void appliesRunOnVersionLaneForClientBulkWriteErrorsFiles() throws IOException {
tempDir,
UnifiedSpecImporter.RunOnContext.evaluated("7.0.25", "replicaset", false, false));

assertEquals(1, result.importedCount());
assertEquals(0, result.skippedCount());
assertEquals(0, result.unsupportedCount());
assertEquals(0, result.importedCount());
assertEquals(1, result.skippedCount());
assertTrue(result.skippedCases().get(0).reason().contains("runOnRequirements not satisfied"));
}

@Test
Expand Down
Loading