File tree Expand file tree Collapse file tree 6 files changed +72
-58
lines changed Expand file tree Collapse file tree 6 files changed +72
-58
lines changed Original file line number Diff line number Diff line change @@ -154,14 +154,23 @@ functions:
154
154
- command : shell.exec
155
155
type : test
156
156
params :
157
- working_dir : src
158
157
silent : true
159
- script : >
160
- # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
158
+ working_dir : src
159
+ script : |
160
+ cat <<EOT > prepare_atlas_connectivity.sh
161
+ export ATLAS_CONNECTIVITY='${ATLAS_CONNECTIVITY}'
162
+ EOT
163
+ - command : shell.exec
164
+ type : test
165
+ params :
166
+ working_dir : src
167
+ script : |
168
+ # Disable xtrace (just in case it was accidentally set).
169
+ set +x
170
+ . ./prepare_atlas_connectivity.sh
171
+ rm -f ./prepare_atlas_connectivity.sh
161
172
162
- NODE_LTS_NAME='${NODE_LTS_NAME}' ATLAS_REPL='${atlas_repl}' ATLAS_SHRD='${atlas_shrd}'
163
- ATLAS_FREE='${atlas_free}' ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' bash
164
- ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
173
+ NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
165
174
pre :
166
175
- func : fetch source
167
176
- func : prepare resources
Original file line number Diff line number Diff line change @@ -189,11 +189,23 @@ functions:
189
189
- command: shell.exec
190
190
type: test
191
191
params:
192
- working_dir: "src"
193
192
silent: true
193
+ working_dir: "src"
194
194
script: |
195
- # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
196
- NODE_LTS_NAME='${NODE_LTS_NAME}' ATLAS_REPL='${atlas_repl}' ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
195
+ cat <<EOT > prepare_atlas_connectivity.sh
196
+ export ATLAS_CONNECTIVITY='${ATLAS_CONNECTIVITY}'
197
+ EOT
198
+ - command: shell.exec
199
+ type: test
200
+ params:
201
+ working_dir: "src"
202
+ script: |
203
+ # Disable xtrace (just in case it was accidentally set).
204
+ set +x
205
+ . ./prepare_atlas_connectivity.sh
206
+ rm -f ./prepare_atlas_connectivity.sh
207
+
208
+ NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
197
209
198
210
pre:
199
211
- func: "fetch source"
Original file line number Diff line number Diff line change @@ -7,4 +7,4 @@ NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
7
7
export NVM_DIR=" ${NODE_ARTIFACTS_PATH} /nvm"
8
8
[ -s " $NVM_DIR /nvm.sh" ] && \. " $NVM_DIR /nvm.sh"
9
9
10
- ATLAS_REPL= " $ATLAS_REPL " ATLAS_SHRD= " $ATLAS_SHRD " ATLAS_FREE= " $ATLAS_FREE " ATLAS_TLS11= " $ATLAS_TLS11 " ATLAS_TLS12= " $ATLAS_TLS12 " npm run atlas
10
+ npm run atlas
Original file line number Diff line number Diff line change 64
64
"url" : " https://github.com/mongodb/node-mongodb-native/issues"
65
65
},
66
66
"scripts" : {
67
- "atlas" : " node ./test/tools/atlas_connectivity_tests .js" ,
67
+ "atlas" : " mocha --opts '{}' ./test/manual/atlas_connectivity.test .js" ,
68
68
"test" : " npm run lint && mocha --recursive test/functional test/unit test/core" ,
69
69
"test-nolint" : " mocha --recursive test/functional test/unit test/core" ,
70
70
"coverage" : " istanbul cover mongodb-test-runner -- -t 60000 test/core test/unit test/functional" ,
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const MongoClient = require ( '../..' ) . MongoClient ;
3
+
4
+ describe ( 'Atlas Connectivity' , function ( ) {
5
+ if ( process . env . ATLAS_CONNECTIVITY == null ) {
6
+ console . log (
7
+ 'skipping atlas connectivity tests, ATLAS_CONNECTIVITY environment variable is not defined'
8
+ ) ;
9
+
10
+ return ;
11
+ }
12
+
13
+ const CONFIGS = JSON . parse ( process . env . ATLAS_CONNECTIVITY ) ;
14
+ Object . keys ( CONFIGS ) . forEach ( configName => {
15
+ context ( configName , function ( ) {
16
+ CONFIGS [ configName ] . forEach ( connectionString => {
17
+ const name = connectionString . indexOf ( 'mongodb+srv' ) >= 0 ? 'mongodb+srv' : 'normal' ;
18
+ it ( `${ name } (unified)` , makeConnectionTest ( connectionString , { useUnifiedTopology : true } ) ) ;
19
+ it ( `${ name } (legacy)` , makeConnectionTest ( connectionString , { useUnifiedTopology : false } ) ) ;
20
+ } ) ;
21
+ } ) ;
22
+ } ) ;
23
+ } ) ;
24
+
25
+ function makeConnectionTest ( connectionString , clientOptions ) {
26
+ return function ( ) {
27
+ const client = new MongoClient ( connectionString , clientOptions ) ;
28
+
29
+ return client
30
+ . connect ( )
31
+ . then ( ( ) => client . db ( 'admin' ) . command ( { ismaster : 1 } ) )
32
+ . then ( ( ) =>
33
+ client
34
+ . db ( 'test' )
35
+ . collection ( 'test' )
36
+ . findOne ( { } )
37
+ )
38
+ . then ( ( ) => client . close ( ) ) ;
39
+ } ;
40
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments