@@ -18,6 +18,7 @@ import {
1818 LOG_PATH ,
1919 removeUserDataDir ,
2020 updateMongoDBServerInfo ,
21+ TEST_ATLAS_CLOUD_EXTERNAL_URL ,
2122} from './helpers/compass' ;
2223import ResultLogger from './helpers/result-logger' ;
2324
@@ -60,52 +61,54 @@ async function setup() {
6061 const disableStartStop = process . argv . includes ( '--disable-start-stop' ) ;
6162 const shouldTestCompassWeb = process . argv . includes ( '--test-compass-web' ) ;
6263
63- // When working on the tests it is faster to just keep the server running.
64- if ( ! disableStartStop ) {
65- debug ( 'Starting MongoDB server' ) ;
66- crossSpawn . sync ( 'npm' , [ 'run' , 'start-servers' ] , { stdio : 'inherit' } ) ;
67-
68- if ( shouldTestCompassWeb ) {
69- debug ( 'Starting Compass Web' ) ;
70- compassWeb = crossSpawn . spawn (
71- 'npm' ,
72- [ 'run' , '--unsafe-perm' , 'start-web' ] ,
73- {
74- cwd : path . resolve ( __dirname , '..' , '..' ) ,
75- env : {
76- ...process . env ,
77- OPEN_BROWSER : 'false' , // tell webpack dev server not to open the default browser
78- DISABLE_DEVSERVER_OVERLAY : 'true' ,
79- APP_ENV : 'webdriverio' ,
80- } ,
64+ if ( ! TEST_ATLAS_CLOUD_EXTERNAL_URL ) {
65+ // When working on the tests it is faster to just keep the server running.
66+ if ( ! disableStartStop ) {
67+ debug ( 'Starting MongoDB server' ) ;
68+ crossSpawn . sync ( 'npm' , [ 'run' , 'start-servers' ] , { stdio : 'inherit' } ) ;
69+
70+ if ( shouldTestCompassWeb ) {
71+ debug ( 'Starting Compass Web' ) ;
72+ compassWeb = crossSpawn . spawn (
73+ 'npm' ,
74+ [ 'run' , '--unsafe-perm' , 'start-web' ] ,
75+ {
76+ cwd : path . resolve ( __dirname , '..' , '..' ) ,
77+ env : {
78+ ...process . env ,
79+ OPEN_BROWSER : 'false' , // tell webpack dev server not to open the default browser
80+ DISABLE_DEVSERVER_OVERLAY : 'true' ,
81+ APP_ENV : 'webdriverio' ,
82+ } ,
83+ }
84+ ) ;
85+
86+ compassWeb . stdout . pipe ( process . stdout ) ;
87+ compassWeb . stderr . pipe ( process . stderr ) ;
88+
89+ let serverReady = false ;
90+ const start = Date . now ( ) ;
91+ while ( ! serverReady ) {
92+ if ( Date . now ( ) - start >= 120_000 ) {
93+ throw new Error (
94+ 'The compass-web sandbox is still not running after 120000ms'
95+ ) ;
96+ }
97+ try {
98+ const res = await fetch ( 'http://localhost:7777' ) ;
99+ serverReady = res . ok ;
100+ debug ( 'Web server ready: %s' , serverReady ) ;
101+ } catch ( err ) {
102+ debug ( 'Failed to connect to dev server: %s' , ( err as any ) . message ) ;
103+ }
104+ await wait ( 1000 ) ;
81105 }
82- ) ;
83-
84- compassWeb . stdout . pipe ( process . stdout ) ;
85- compassWeb . stderr . pipe ( process . stderr ) ;
86-
87- let serverReady = false ;
88- const start = Date . now ( ) ;
89- while ( ! serverReady ) {
90- if ( Date . now ( ) - start >= 120_000 ) {
91- throw new Error (
92- 'The compass-web sandbox is still not running after 120000ms'
93- ) ;
94- }
95- try {
96- const res = await fetch ( 'http://localhost:7777' ) ;
97- serverReady = res . ok ;
98- debug ( 'Web server ready: %s' , serverReady ) ;
99- } catch ( err ) {
100- debug ( 'Failed to connect to dev server: %s' , ( err as any ) . message ) ;
101- }
102- await wait ( 1000 ) ;
106+ } else {
107+ debug ( 'Writing electron-versions.json' ) ;
108+ crossSpawn . sync ( 'scripts/write-electron-versions.sh' , [ ] , {
109+ stdio : 'inherit' ,
110+ } ) ;
103111 }
104- } else {
105- debug ( 'Writing electron-versions.json' ) ;
106- crossSpawn . sync ( 'scripts/write-electron-versions.sh' , [ ] , {
107- stdio : 'inherit' ,
108- } ) ;
109112 }
110113 }
111114
@@ -139,34 +142,36 @@ function cleanup() {
139142 const disableStartStop = process . argv . includes ( '--disable-start-stop' ) ;
140143 const shouldTestCompassWeb = process . argv . includes ( '--test-compass-web' ) ;
141144
142- if ( ! disableStartStop ) {
143- if ( shouldTestCompassWeb ) {
144- debug ( 'Stopping compass-web' ) ;
145- try {
146- if ( compassWeb . pid ) {
147- debug ( `killing compass-web [${ compassWeb . pid } ]` ) ;
148- kill ( compassWeb . pid , 'SIGINT' ) ;
149- } else {
150- debug ( 'no pid for compass-web' ) ;
145+ if ( ! TEST_ATLAS_CLOUD_EXTERNAL_URL ) {
146+ if ( ! disableStartStop ) {
147+ if ( shouldTestCompassWeb ) {
148+ debug ( 'Stopping compass-web' ) ;
149+ try {
150+ if ( compassWeb . pid ) {
151+ debug ( `killing compass-web [${ compassWeb . pid } ]` ) ;
152+ kill ( compassWeb . pid , 'SIGINT' ) ;
153+ } else {
154+ debug ( 'no pid for compass-web' ) ;
155+ }
156+ } catch ( e ) {
157+ debug ( 'Failed to stop compass-web' , e ) ;
151158 }
152- } catch ( e ) {
153- debug ( 'Failed to stop compass-web' , e ) ;
154159 }
155- }
156160
157- debug ( 'Stopping MongoDB server' ) ;
158- try {
159- crossSpawn . sync ( 'npm' , [ 'run' , 'stop-servers' ] , {
160- // If it's taking too long we might as well kill the process and move on,
161- // mongodb-runner is flaky sometimes and in ci `posttest-ci` script will
162- // take care of additional clean up anyway
163- timeout : 120_000 ,
164- stdio : 'inherit' ,
165- } ) ;
166- } catch ( e ) {
167- debug ( 'Failed to stop MongoDB Server' , e ) ;
161+ debug ( 'Stopping MongoDB server' ) ;
162+ try {
163+ crossSpawn . sync ( 'npm' , [ 'run' , 'stop-servers' ] , {
164+ // If it's taking too long we might as well kill the process and move on,
165+ // mongodb-runner is flaky sometimes and in ci `posttest-ci` script will
166+ // take care of additional clean up anyway
167+ timeout : 120_000 ,
168+ stdio : 'inherit' ,
169+ } ) ;
170+ } catch ( e ) {
171+ debug ( 'Failed to stop MongoDB Server' , e ) ;
172+ }
173+ debug ( 'Done stopping' ) ;
168174 }
169- debug ( 'Done stopping' ) ;
170175 }
171176
172177 // Since the webdriverio update something is messing with the terminal's
@@ -258,9 +263,10 @@ async function main() {
258263
259264 const e2eTestGroupsAmount = parseInt ( process . env . E2E_TEST_GROUPS || '1' ) ;
260265 const e2eTestGroup = parseInt ( process . env . E2E_TEST_GROUP || '1' ) ;
266+ const e2eTestFilter = process . env . E2E_TEST_FILTER || '*' ;
261267
262- const rawTests = (
263- await glob ( ' tests/**/* .{test,spec}.ts' , {
268+ const tests = (
269+ await glob ( ` tests/**/${ e2eTestFilter } .{test,spec}.ts` , {
264270 cwd : __dirname ,
265271 } )
266272 ) . filter ( ( value , index , array ) => {
@@ -271,15 +277,19 @@ async function main() {
271277 return index >= minGroupIndex && index <= maxGroupIndex ;
272278 } ) ;
273279
274- console . info ( 'Test files:' , rawTests ) ;
280+ console . info ( 'Test files:' , tests ) ;
275281
276282 // The only test file that's interested in the first-run experience (at the
277283 // time of writing) is time-to-first-query.ts and that happens to be
278284 // alphabetically right at the end. Which is fine, but the first test to run
279285 // will also get the slow first run experience for no good reason unless it is
280286 // the time-to-first-query.ts test.
281287 // So yeah.. this is a bit of a micro optimisation.
282- const tests = [ FIRST_TEST , ...rawTests . filter ( ( t ) => t !== FIRST_TEST ) ] ;
288+ tests . sort ( ( a , b ) => {
289+ if ( a === FIRST_TEST ) return - 1 ;
290+ else if ( b === FIRST_TEST ) return 1 ;
291+ else return 0 ;
292+ } ) ;
283293
284294 // Ensure the insert-data mocha hooks are run.
285295 tests . unshift ( path . join ( 'helpers' , 'insert-data.ts' ) ) ;
0 commit comments