Skip to content

Move initial data creation back to where it was #1320

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

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.bson.BsonValue;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -252,6 +253,10 @@ public MongoCollection<BsonDocument> getCollection(final String id) {
return getEntity(id, collections, "collection");
}

public Collection<ClientSession> getSessions() {
return sessions.values();
}

public ClientSession getSession(final String id) {
return getEntity(id, sessions, "session");
}
Expand Down Expand Up @@ -300,7 +305,6 @@ private <T> void putEntity(final String id, final T entity, final Map<String, T>
}

public void init(final BsonArray entitiesArray,
final BsonDocument startingClusterTime,
final boolean waitForPoolAsyncWorkManagerStart,
final Function<MongoClientSettings, MongoClient> mongoClientSupplier,
final Function<MongoDatabase, GridFSBucket> gridFSBucketSupplier,
Expand All @@ -325,7 +329,7 @@ public void init(final BsonArray entitiesArray,
break;
}
case "session": {
initSession(entity, id, startingClusterTime);
initSession(entity, id);
break;
}
case "bucket": {
Expand Down Expand Up @@ -597,7 +601,7 @@ private void initCollection(final BsonDocument entity, final String id) {
putEntity(id, collection, collections);
}

private void initSession(final BsonDocument entity, final String id, final BsonDocument startingClusterTime) {
private void initSession(final BsonDocument entity, final String id) {
MongoClient client = clients.get(entity.getString("client").getValue());
ClientSessionOptions.Builder optionsBuilder = ClientSessionOptions.builder();
if (entity.containsKey("sessionOptions")) {
Expand All @@ -615,7 +619,6 @@ private void initSession(final BsonDocument entity, final String id, final BsonD
}
}
ClientSession session = client.startSession(optionsBuilder.build());
session.advanceClusterTime(startingClusterTime);
putEntity(id, session, sessions);
putEntity(id + "-identifier", session.getServerSession().getIdentifier(), sessionIdentifiers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public abstract class UnifiedTest {
private final UnifiedClientEncryptionHelper clientEncryptionHelper = new UnifiedClientEncryptionHelper(entities);
private final List<FailPoint> failPoints = new ArrayList<>();
private final UnifiedTestContext rootContext = new UnifiedTestContext();
private BsonDocument startingClusterTime;

private class UnifiedTestContext {
private final AssertionContext context = new AssertionContext();
Expand Down Expand Up @@ -214,12 +213,19 @@ public void setUp() {
if (definition.containsKey("skipReason")) {
throw new AssumptionViolatedException(definition.getString("skipReason").getValue());
}
startingClusterTime = addInitialDataAndGetClusterTime();
entities.init(entitiesArray, startingClusterTime,

entities.init(entitiesArray,
fileDescription != null && PRESTART_POOL_ASYNC_WORK_MANAGER_FILE_DESCRIPTIONS.contains(fileDescription),
this::createMongoClient,
this::createGridFSBucket,
this::createClientEncryption);

BsonDocument startingClusterTime = addInitialDataAndGetClusterTime();

entities.getSessions().stream()
.forEach((ClientSession clientSession) -> {
clientSession.advanceClusterTime(startingClusterTime);
});
}

@After
Expand Down Expand Up @@ -563,7 +569,6 @@ protected boolean terminateLoop() {

private OperationResult executeCreateEntities(final BsonDocument operation) {
entities.init(operation.getDocument("arguments").getArray("entities"),
startingClusterTime,
false,
this::createMongoClient,
this::createGridFSBucket,
Expand Down