1
1
import { expect } from 'chai' ;
2
+ import * as semver from 'semver' ;
2
3
3
- const metadata = {
4
- requires : {
5
- mongodb : '>=4.2.0' ,
6
- topology : [ 'replicaset' , 'sharded' , 'load-balanced' ]
7
- }
8
- } ;
4
+ import { TopologyType } from '../../../src' ;
9
5
10
- describe ( 'Transactions (prose)' , metadata , function ( ) {
6
+ const VALID_TOPOLOGIES = [
7
+ TopologyType . ReplicaSetWithPrimary ,
8
+ TopologyType . Sharded ,
9
+ TopologyType . LoadBalanced
10
+ ] ;
11
+
12
+ describe ( 'Transactions (prose)' , function ( ) {
11
13
const dbName = 'retryable-handshake-tests' ;
12
14
const collName = 'coll' ;
13
15
const docs = [ { _id : 1 , x : 11 } ] ;
@@ -16,18 +18,26 @@ describe('Transactions (prose)', metadata, function () {
16
18
let coll ;
17
19
18
20
beforeEach ( function ( ) {
21
+ if (
22
+ semver . lt ( this . configuration . buildInfo . version , '4.2.0' ) ||
23
+ ! VALID_TOPOLOGIES . includes ( this . configuration . topologyType )
24
+ ) {
25
+ this . currentTest . skipReason =
26
+ 'Transaction tests require MongoDB 4.2 and higher and no standalone' ;
27
+ this . skip ( ) ;
28
+ }
19
29
client = this . configuration . newClient ( { } ) ;
20
30
db = client . db ( dbName ) ;
21
31
coll = db . collection ( collName ) ;
22
32
} ) ;
23
33
24
34
afterEach ( async function ( ) {
25
- await db . admin ( ) . command ( {
35
+ await db ? .admin ( ) . command ( {
26
36
configureFailPoint : 'failCommand' ,
27
37
mode : 'off'
28
38
} ) ;
29
- await coll . drop ( ) ;
30
- await client . close ( ) ;
39
+ await coll ? .drop ( ) ;
40
+ await client ? .close ( ) ;
31
41
} ) ;
32
42
33
43
context ( 'when the handshake fails with a network error' , function ( ) {
@@ -42,7 +52,7 @@ describe('Transactions (prose)', metadata, function () {
42
52
data : {
43
53
failCommands : [ 'saslContinue' , 'ping' ] ,
44
54
closeConnection : true
45
- } ,
55
+ }
46
56
} ) ;
47
57
await coll . insertOne ( { _id : 2 , x : 22 } , { session } ) ;
48
58
await session . abortTransaction ( ) ;
0 commit comments