Skip to content

Commit

Permalink
test(NODE-5962): gossip cluster time in utr (#4019)
Browse files Browse the repository at this point in the history
  • Loading branch information
durran authored Mar 6, 2024
1 parent 057c223 commit 4ac9675
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';

const SKIPPED_TESTS = [
'callback succeeds after multiple connection errors',
'callback is not retried after non-transient error',
'callback is not retried after non-transient error (DuplicateKeyError)',
'withTransaction succeeds if callback aborts',
'unpin after transient error within a transaction',
'withTransaction succeeds if callback commits',
'withTransaction still succeeds if callback aborts and runs extra op',
'withTransaction still succeeds if callback commits and runs extra op',
'withTransaction commits after callback returns (second transaction)',
'withTransaction commits after callback returns',
'withTransaction and no transaction options set',
'withTransaction inherits transaction options from defaultTransactionOptions',
'withTransaction explicit transaction options override defaultTransactionOptions',
'withTransaction explicit transaction options'
'withTransaction succeeds if callback aborts'
];

describe('Transactions Convenient API Spec Unified Tests', function () {
Expand All @@ -33,7 +22,7 @@ describe('Transactions Convenient API Spec Unified Tests', function () {

runUnifiedSuite(loadSpecTests(path.join('transactions-convenient-api', 'unified')), test => {
return SKIPPED_TESTS.includes(test.description)
? 'TODO(NODE-5855/DRIVERS-2816): Skipping failing transaction tests'
? 'TODO(NODE-5855): Skipping failing transaction tests'
: false;
});
});
6 changes: 6 additions & 0 deletions test/tools/unified-spec-runner/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ChangeStream,
ClientEncryption,
ClientSession,
type ClusterTime,
Collection,
type CommandFailedEvent,
type CommandStartedEvent,
Expand Down Expand Up @@ -556,6 +557,7 @@ export class EntitiesMap<E = Entity> extends Map<string, E> {

static async createEntities(
config: TestConfiguration,
clusterTime: ClusterTime | null,
entities?: EntityDescription[],
entityMap?: EntitiesMap
): Promise<EntitiesMap> {
Expand Down Expand Up @@ -627,6 +629,10 @@ export class EntitiesMap<E = Entity> extends Map<string, E> {
}
}
const session = client.startSession(options);
// Advance the session cluster time. See DRIVERS-2816.
if (clusterTime) {
session.advanceClusterTime(clusterTime);
}
map.set(entity.session.id, session);
} else if ('bucket' in entity) {
const db = map.getEntity('db', entity.bucket.database);
Expand Down
2 changes: 1 addition & 1 deletion test/tools/unified-spec-runner/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ operations.set('createEntities', async ({ entities, operation, testConfig }) =>
if (!operation.arguments?.entities) {
throw new Error('encountered createEntities operation without entities argument');
}
await EntitiesMap.createEntities(testConfig, operation.arguments.entities!, entities);
await EntitiesMap.createEntities(testConfig, null, operation.arguments.entities!, entities);
});

operations.set('abortTransaction', async ({ entities, operation }) => {
Expand Down
9 changes: 8 additions & 1 deletion test/tools/unified-spec-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,15 @@ async function runUnifiedTest(
}
}

const ping = await utilClient.db().admin().command({ ping: 1 });
const clusterTime = ping.$clusterTime;

trace('createEntities');
entities = await EntitiesMap.createEntities(ctx.configuration, unifiedSuite.createEntities);
entities = await EntitiesMap.createEntities(
ctx.configuration,
clusterTime,
unifiedSuite.createEntities
);

// Workaround for SERVER-39704:
// test runners MUST execute a non-transactional distinct command on
Expand Down

0 comments on commit 4ac9675

Please sign in to comment.