Skip to content

Commit

Permalink
refactor: update constants
Browse files Browse the repository at this point in the history
  • Loading branch information
dariakp committed Jul 20, 2022
1 parent 2633e68 commit c675992
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/cmap/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MongoDriverError } from '../error';
import { MongoDriverError, MongoNetworkError } from '../error';
import type { ConnectionPool } from './connection_pool';

/**
Expand All @@ -23,7 +23,7 @@ export class PoolClosedError extends MongoDriverError {
* An error indicating a connection pool is currently paused
* @category Error
*/
export class PoolClearedError extends MongoDriverError {
export class PoolClearedError extends MongoNetworkError {
// TODO: needs to extend RetryableError or be marked retryable in some other way per spec
/** The address of the connection pool */
address: string;
Expand Down
5 changes: 3 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ export const HEARTBEAT_EVENTS = Object.freeze([
/** @public */
export const CMAP_EVENTS = Object.freeze([
CONNECTION_POOL_CREATED,
CONNECTION_POOL_READY,
CONNECTION_POOL_CLEARED,
CONNECTION_POOL_CLOSED,
CONNECTION_CREATED,
CONNECTION_READY,
CONNECTION_CLOSED,
CONNECTION_CHECK_OUT_STARTED,
CONNECTION_CHECK_OUT_FAILED,
CONNECTION_CHECKED_OUT,
CONNECTION_CHECKED_IN,
CONNECTION_POOL_CLEARED
CONNECTION_CHECKED_IN
] as const);

/** @public */
Expand Down
15 changes: 2 additions & 13 deletions test/tools/cmap_spec_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { promisify } from 'util';

import { Connection, HostAddress, MongoClient } from '../../src';
import { ConnectionPool, ConnectionPoolOptions } from '../../src/cmap/connection_pool';
import { CMAP_EVENTS } from '../../src/constants';
import { makeClientMetadata, shuffle } from '../../src/utils';
import { isAnyRequirementSatisfied } from './unified-spec-runner/unified-utils';
import { FailPoint, sleep } from './utils';
Expand Down Expand Up @@ -80,19 +81,7 @@ export type CmapTest = {
failPoint?: FailPoint;
};

const ALL_POOL_EVENTS = new Set([
ConnectionPool.CONNECTION_POOL_CREATED,
ConnectionPool.CONNECTION_POOL_CLOSED,
ConnectionPool.CONNECTION_POOL_CLEARED,
ConnectionPool.CONNECTION_POOL_READY,
ConnectionPool.CONNECTION_CREATED,
ConnectionPool.CONNECTION_READY,
ConnectionPool.CONNECTION_CLOSED,
ConnectionPool.CONNECTION_CHECK_OUT_STARTED,
ConnectionPool.CONNECTION_CHECK_OUT_FAILED,
ConnectionPool.CONNECTION_CHECKED_OUT,
ConnectionPool.CONNECTION_CHECKED_IN
]);
const ALL_POOL_EVENTS = new Set(CMAP_EVENTS);

function getEventType(event) {
const eventName = event.constructor.name;
Expand Down
51 changes: 19 additions & 32 deletions test/tools/spec-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ const { EJSON } = require('bson');
const { isRecord } = require('../../../src/utils');
const TestRunnerContext = require('./context').TestRunnerContext;
const resolveConnectionString = require('./utils').resolveConnectionString;
const { LEGACY_HELLO_COMMAND } = require('../../../src/constants');
const {
LEGACY_HELLO_COMMAND,
CMAP_EVENTS: SOURCE_CMAP_EVENTS,
TOPOLOGY_EVENTS,
HEARTBEAT_EVENTS
} = require('../../../src/constants');
const { isAnyRequirementSatisfied } = require('../unified-spec-runner/unified-utils');
const ClientSideEncryptionFilter = require('../runner/filters/client_encryption_filter');

Expand Down Expand Up @@ -158,16 +163,16 @@ function generateTopologyTests(testSuites, testContext, filter) {

const { spec } = this.currentTest;

if (
shouldRun &&
spec.operations.some(
op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
)
) {
this.currentTest.skipReason =
'TODO(NODE-2994): Connection storms work will add new events to connection pool';
shouldRun = false;
}
// if (
// shouldRun &&
// spec.operations.some(
// op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
// )
// ) {
// this.currentTest.skipReason =
// 'TODO(NODE-2994): Connection storms work will add new events to connection pool';
// shouldRun = false;
// }

if (shouldRun && spec.skipReason) {
this.currentTest.skipReason = spec.skipReason;
Expand Down Expand Up @@ -329,29 +334,11 @@ function parseSessionOptions(options) {

const IGNORED_COMMANDS = new Set([LEGACY_HELLO_COMMAND, 'configureFailPoint', 'endSessions']);
const SDAM_EVENTS = new Set([
'serverOpening',
'serverClosed',
'serverDescriptionChanged',
'topologyOpening',
'topologyClosed',
'topologyDescriptionChanged',
'serverHeartbeatStarted',
'serverHeartbeatSucceeded',
'serverHeartbeatFailed'
...TOPOLOGY_EVENTS.filter(ev => !['error', 'timeout', 'close'].includes(ev)),
...HEARTBEAT_EVENTS
]);

const CMAP_EVENTS = new Set([
'connectionPoolCreated',
'connectionPoolClosed',
'connectionCreated',
'connectionReady',
'connectionClosed',
'connectionCheckOutStarted',
'connectionCheckOutFailed',
'connectionCheckedOut',
'connectionCheckedIn',
'connectionPoolCleared'
]);
const CMAP_EVENTS = new Set(SOURCE_CMAP_EVENTS);

function runTestSuiteTest(configuration, spec, context) {
context.commandEvents = [];
Expand Down

0 comments on commit c675992

Please sign in to comment.