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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ protected void KillAllSessions()
protected IClientSessionHandle StartSession(IMongoClient client, BsonDocument test, string sessionKey)
{
var options = ParseSessionOptions(test, sessionKey);
return client.StartSession(options);
var session = client.StartSession(options);
if (LastKnownClusterTime != null)
{
session.WrappedCoreSession.AdvanceClusterTime(LastKnownClusterTime);
}
return session;
}

// private methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public abstract class MongoClientJsonDrivenTestRunnerBase : LoggableTestClass

protected IServer _failPointServer = null;

protected BsonDocument LastKnownClusterTime { get; set; }

// public constructors
public MongoClientJsonDrivenTestRunnerBase(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
Expand Down Expand Up @@ -218,8 +220,11 @@ protected virtual void CreateCollection(IMongoClient client, string databaseName
{
Logger.LogDebug("Creating collection {0} in {1} db", databaseName, collectionName);

var session = client.StartSession();
var database = client.GetDatabase(databaseName).WithWriteConcern(WriteConcern.WMajority);
database.CreateCollection(collectionName);
database.CreateCollection(session, collectionName);

LastKnownClusterTime = session.ClusterTime;
}

protected virtual MongoClient CreateClientForTestSetup()
Expand Down Expand Up @@ -288,13 +293,21 @@ protected virtual void InsertData(IMongoClient client, string databaseName, stri

if (shared.Contains(DataKey))
{
BsonDocument lastServerTime = null;
var documents = shared[DataKey].AsBsonArray.Cast<BsonDocument>().ToList();

if (documents.Count > 0)
{
var session = client.StartSession();

var database = client.GetDatabase(databaseName);
var collection = database.GetCollection<BsonDocument>(collectionName).WithWriteConcern(WriteConcern.WMajority);
collection.InsertMany(documents);
collection.InsertMany(session, documents);

lastServerTime = session.ClusterTime;
}

LastKnownClusterTime = lastServerTime ?? LastKnownClusterTime;
}
}

Expand Down