-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(NODE-6318): utf runner withTransaction callback propagates error…
…s from operations (#4193)
- Loading branch information
Showing
2 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
test/integration/unified-test-format/unified_test_format.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { type FailPoint, TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/utils'; | ||
|
||
describe('Unified Test Runner', () => { | ||
UnifiedTestSuiteBuilder.describe('withTransaction error propagation') | ||
.runOnRequirement({ topologies: ['replicaset'], minServerVersion: '4.4.0' }) | ||
.createEntities([ | ||
{ | ||
client: { | ||
id: 'client', | ||
useMultipleMongoses: true, | ||
uriOptions: { appName: 'bob' }, | ||
observeEvents: ['commandStartedEvent', 'commandSucceededEvent', 'commandFailedEvent'] | ||
} | ||
}, | ||
{ database: { id: 'database', client: 'client', databaseName: 'test' } }, | ||
{ collection: { id: 'collection', database: 'database', collectionName: 'coll' } }, | ||
{ session: { id: 'session', client: 'client' } }, | ||
|
||
{ client: { id: 'failPointClient', useMultipleMongoses: false } } | ||
]) | ||
.test( | ||
TestBuilder.it('should propagate the error to the withTransaction API') | ||
.operation({ | ||
name: 'failPoint', | ||
object: 'testRunner', | ||
arguments: { | ||
client: 'failPointClient', | ||
failPoint: { | ||
configureFailPoint: 'failCommand', | ||
mode: { times: 1 }, | ||
data: { failCommands: ['insert'], errorCode: 50, appName: 'bob' } | ||
} as FailPoint | ||
} | ||
}) | ||
.operation({ | ||
name: 'withTransaction', | ||
object: 'session', | ||
arguments: { | ||
callback: [ | ||
{ | ||
name: 'insertOne', | ||
object: 'collection', | ||
arguments: { session: 'session', document: { _id: 1 } }, | ||
expectError: { isClientError: false } | ||
} | ||
] | ||
}, | ||
expectError: { isClientError: false } | ||
}) | ||
.expectEvents({ | ||
client: 'client', | ||
events: [ | ||
{ | ||
commandStartedEvent: { | ||
commandName: 'insert', | ||
databaseName: 'test', | ||
command: { insert: 'coll' } | ||
} | ||
}, | ||
{ commandFailedEvent: { commandName: 'insert' } }, | ||
{ | ||
commandStartedEvent: { | ||
commandName: 'abortTransaction', | ||
databaseName: 'admin', | ||
command: { abortTransaction: 1 } | ||
} | ||
}, | ||
{ commandFailedEvent: { commandName: 'abortTransaction' } } | ||
] | ||
}) | ||
.toJSON() | ||
) | ||
.run(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters