MCPcopy
hub / github.com/mongodb/node-mongodb-native / runTestSuiteTest

Function runTestSuiteTest

test/tools/spec-runner/index.js:345–419  ·  view source on GitHub ↗
(configuration, spec, context)

Source from the content-addressed store, hash-verified

343const CMAP_EVENTS = new Set(SOURCE_CMAP_EVENTS);
344
345function runTestSuiteTest(configuration, spec, context) {
346 context.commandEvents = [];
347 const clientOptions = translateClientOptions({
348 heartbeatFrequencyMS: 100,
349 minHeartbeatFrequencyMS: 100,
350 monitorCommands: true,
351 ...spec.clientOptions,
352 __skipPingOnConnect: true
353 });
354
355 if (context.requiresCSFLE) {
356 clientOptions.promoteValues = false;
357 clientOptions.promoteLongs = false;
358 }
359
360 const url = resolveConnectionString(configuration, spec, context);
361 const client = configuration.newClient(url, clientOptions);
362 CMAP_EVENTS.forEach(eventName => client.on(eventName, event => context.cmapEvents.push(event)));
363 SDAM_EVENTS.forEach(eventName => client.on(eventName, event => context.sdamEvents.push(event)));
364
365 client.on('commandStarted', event => {
366 if (!IGNORED_COMMANDS.has(event.commandName)) {
367 context.commandEvents.push(event);
368 }
369 });
370
371 return client.connect().then(client => {
372 context.testClient = client;
373 const sessionOptions = Object.assign({}, spec.transactionOptions);
374
375 spec.sessionOptions = spec.sessionOptions || {};
376 const database = client.db(context.dbName);
377
378 let session0, session1;
379 let savedSessionData;
380
381 if (context.useSessions) {
382 try {
383 session0 = client.startSession(
384 Object.assign({}, sessionOptions, parseSessionOptions(spec.sessionOptions.session0))
385 );
386 session1 = client.startSession(
387 Object.assign({}, sessionOptions, parseSessionOptions(spec.sessionOptions.session1))
388 );
389
390 savedSessionData = {
391 session0: JSON.parse(EJSON.stringify(session0.id)),
392 session1: JSON.parse(EJSON.stringify(session1.id))
393 };
394 } catch {
395 // ignore
396 }
397 }
398
399 const operationContext = {
400 client,
401 database,
402 collectionName: context.collectionName,

Callers 1

generateTopologyTestsFunction · 0.85

Calls 14

translateClientOptionsFunction · 0.85
resolveConnectionStringFunction · 0.85
parseSessionOptionsFunction · 0.85
testOperationsFunction · 0.85
validateExpectationsFunction · 0.85
onMethod · 0.80
startSessionMethod · 0.80
endSessionMethod · 0.80
newClientMethod · 0.45
pushMethod · 0.45
hasMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected