@@ -18,6 +18,7 @@ import {
1818 LOG_PATH ,
1919 removeUserDataDir ,
2020 updateMongoDBServerInfo ,
21+ ATLAS_DOMAIN ,
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 ( ! ATLAS_DOMAIN ) {
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
@@ -118,8 +121,10 @@ async function setup() {
118121
119122 fs . mkdirSync ( LOG_PATH , { recursive : true } ) ;
120123
121- debug ( 'Getting mongodb server info' ) ;
122- updateMongoDBServerInfo ( ) ;
124+ if ( ! ATLAS_DOMAIN ) {
125+ debug ( 'Getting mongodb server info' ) ;
126+ updateMongoDBServerInfo ( ) ;
127+ }
123128}
124129
125130function getResources ( ) {
@@ -139,34 +144,36 @@ function cleanup() {
139144 const disableStartStop = process . argv . includes ( '--disable-start-stop' ) ;
140145 const shouldTestCompassWeb = process . argv . includes ( '--test-compass-web' ) ;
141146
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' ) ;
147+ if ( ! ATLAS_DOMAIN ) {
148+ if ( ! disableStartStop ) {
149+ if ( shouldTestCompassWeb ) {
150+ debug ( 'Stopping compass-web' ) ;
151+ try {
152+ if ( compassWeb . pid ) {
153+ debug ( `killing compass-web [${ compassWeb . pid } ]` ) ;
154+ kill ( compassWeb . pid , 'SIGINT' ) ;
155+ } else {
156+ debug ( 'no pid for compass-web' ) ;
157+ }
158+ } catch ( e ) {
159+ debug ( 'Failed to stop compass-web' , e ) ;
151160 }
152- } catch ( e ) {
153- debug ( 'Failed to stop compass-web' , e ) ;
154161 }
155- }
156162
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 ) ;
163+ debug ( 'Stopping MongoDB server' ) ;
164+ try {
165+ crossSpawn . sync ( 'npm' , [ 'run' , 'stop-servers' ] , {
166+ // If it's taking too long we might as well kill the process and move on,
167+ // mongodb-runner is flaky sometimes and in ci `posttest-ci` script will
168+ // take care of additional clean up anyway
169+ timeout : 120_000 ,
170+ stdio : 'inherit' ,
171+ } ) ;
172+ } catch ( e ) {
173+ debug ( 'Failed to stop MongoDB Server' , e ) ;
174+ }
175+ debug ( 'Done stopping' ) ;
168176 }
169- debug ( 'Done stopping' ) ;
170177 }
171178
172179 // Since the webdriverio update something is messing with the terminal's
@@ -258,9 +265,10 @@ async function main() {
258265
259266 const e2eTestGroupsAmount = parseInt ( process . env . E2E_TEST_GROUPS || '1' ) ;
260267 const e2eTestGroup = parseInt ( process . env . E2E_TEST_GROUP || '1' ) ;
268+ const e2eTestFilter = process . env . E2E_TEST_FILTER || '*' ;
261269
262- const rawTests = (
263- await glob ( ' tests/**/* .{test,spec}.ts' , {
270+ let tests = (
271+ await glob ( ` tests/**/${ e2eTestFilter } .{test,spec}.ts` , {
264272 cwd : __dirname ,
265273 } )
266274 ) . filter ( ( value , index , array ) => {
@@ -271,15 +279,20 @@ async function main() {
271279 return index >= minGroupIndex && index <= maxGroupIndex ;
272280 } ) ;
273281
274- console . info ( 'Test files:' , rawTests ) ;
282+ console . info ( 'Test files:' , tests ) ;
275283
276284 // The only test file that's interested in the first-run experience (at the
277285 // time of writing) is time-to-first-query.ts and that happens to be
278286 // alphabetically right at the end. Which is fine, but the first test to run
279287 // will also get the slow first run experience for no good reason unless it is
280288 // the time-to-first-query.ts test.
281289 // So yeah.. this is a bit of a micro optimisation.
282- const tests = [ FIRST_TEST , ...rawTests . filter ( ( t ) => t !== FIRST_TEST ) ] ;
290+ for ( let i = 0 ; i < tests . length ; ++ i ) {
291+ if ( tests [ i ] === FIRST_TEST ) {
292+ [ tests [ i ] , tests [ 0 ] ] = [ tests [ 0 ] , tests [ i ] ] ;
293+ break ;
294+ }
295+ }
283296
284297 // Ensure the insert-data mocha hooks are run.
285298 tests . unshift ( path . join ( 'helpers' , 'insert-data.ts' ) ) ;
0 commit comments