File tree 3 files changed +21
-8
lines changed
helpers/integration-tests
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,9 @@ const runIntegrationTests = async () => {
8
8
9
9
try {
10
10
for ( const test of [ runStaticTests , runScannerTest ] ) {
11
- const errorFound = await test ( ) ;
11
+ const success = await test ( ) ;
12
12
13
- if ( errorFound ) {
13
+ if ( ! success ) {
14
14
error = true ;
15
15
}
16
16
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const runScannerTest = async () => {
22
22
} ! => Status: ${ response . status ( ) } `
23
23
) ;
24
24
25
- return response . status ( ) ! == 200 ;
25
+ return response . status ( ) = == 200 ;
26
26
} catch ( error ) {
27
27
console . error ( '🚨 Something went wrong while executing Puppeteer: ' , error ) ;
28
28
await browser . close ( ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ const staticURLsToVerify = [
7
7
'https://sonarwhal-staging.azurewebsites.net/docs/user-guide/hints/'
8
8
] ;
9
9
10
+ const backOffTime = 5000 ;
11
+ const maxRetries = 3 ;
12
+
13
+ const delay = ( ms ) => {
14
+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
15
+ } ;
16
+
10
17
const runPuppeteer = async ( url ) => {
11
18
const browser = await puppeteer . launch ( ) ;
12
19
@@ -32,17 +39,23 @@ const runPuppeteer = async (url) => {
32
39
} ;
33
40
34
41
const runStaticTests = async ( ) => {
35
- let errorFound = false ;
42
+ let success = true ;
43
+ let retryCount = 0 ;
44
+ let resultStatus = null ;
36
45
37
46
for ( const url of staticURLsToVerify ) {
38
- const resultStatus = await runPuppeteer ( url ) ;
47
+ resultStatus = await runPuppeteer ( url ) ;
39
48
40
- if ( resultStatus !== 200 ) {
41
- errorFound = true ;
49
+ while ( resultStatus !== 200 && retryCount < maxRetries ) {
50
+ console . log ( 'Test failed, retrying... Attempt #' + ( ++ retryCount ) ) ;
51
+ await delay ( backOffTime * retryCount ) ;
52
+ resultStatus = await runPuppeteer ( url ) ;
42
53
}
54
+
55
+ success = success && resultStatus === 200 ;
43
56
}
44
57
45
- return errorFound ;
58
+ return success ;
46
59
} ;
47
60
48
61
module . exports = { runStaticTests } ;
You can’t perform that action at this time.
0 commit comments