diff --git a/js/node-client/getNextTestInfo.js b/js/node-client/getNextTestInfo.js index c136332..a398d63 100644 --- a/js/node-client/getNextTestInfo.js +++ b/js/node-client/getNextTestInfo.js @@ -23,11 +23,17 @@ module.exports = async function( options ) { }, options ); - const response = await axios( `${options.serverURL}/aquaserver/next-test?old=${options.old}` ); + let response = {}; + try { + response = await axios( `${options.serverURL}/aquaserver/next-test?old=${options.old}` ); + } + catch( e ) { + throw new Error( `axios failure code ${e.response.status} getting next-test: ${e.message}` ); + } if ( response.status !== 200 ) { throw new Error( `nextTest request failed with status ${response.status} ${response}` ); } - return response.data; + return response.data || {}; }; \ No newline at end of file diff --git a/js/node-client/runNextTest.js b/js/node-client/runNextTest.js index 4fad855..48cbbf0 100644 --- a/js/node-client/runNextTest.js +++ b/js/node-client/runNextTest.js @@ -20,16 +20,18 @@ const winston = require( 'winston' ); */ module.exports = async function( options ) { - const testInfo = await getNextTestInfo( options ); - winston.info( 'testInfo', JSON.stringify( testInfo ) ); - const attemptCount = 3; let attemptsLeft = attemptCount; let lastFailure; + let testInfo = null; while ( attemptsLeft-- > 0 ) { try { + if ( !testInfo ) { + testInfo = await getNextTestInfo( options ); + winston.info( 'testInfo', JSON.stringify( testInfo ) ); + } await runTest( testInfo, options ); winston.debug( 'runTest completed' ); return;