@ -350,60 +350,60 @@ module.exports.tests.success = (test, common) => {
} ;
module . exports . tests . service _errors = ( test , common ) => {
test ( 'default # of request timeout retries should be 3', ( t ) => {
// test for 1 initial search service, 3 retries, 1 log messages, 1 req, and 1 res
t . plan ( 1 + 3 + 1 + 2 ) ;
const logger = mocklogger ( ) ;
const config = {
indexName : 'indexName value'
} ;
const esclient = 'this is the esclient' ;
const query = ( ) => ( {
body : 'this is the query body' ,
} ) ;
const timeoutError = {
status : 408 ,
displayName : 'RequestTimeout' ,
message : 'Request Timeout after 17ms'
} ;
// a controller that validates that the search service was called
const controller = proxyquire ( '../../../controller/search_with_ids' , {
'../service/search' : ( esclient , cmd , callback ) => {
// note that the searchService got called
t . pass ( 'search service was called' ) ;
callback ( timeoutError ) ;
} ,
'pelias-logger' : logger
} ) ( config , esclient , query , ( ) => true ) ;
const req = { clean : { } , errors : [ ] , warnings : [ ] } ;
const res = { } ;
const next = ( ) => {
t . deepEqual ( logger . getInfoMessages ( ) , [
'[req] endpoint=undefined {}' ,
'request timed out on attempt 1, retrying',
'request timed out on attempt 2, retrying',
'request timed out on attempt 3, retrying'
] ) ;
t . deepEqual ( req , {
clean : { } ,
errors : [ timeoutError . message ] ,
warnings : [ ]
} ) ;
t . deepEqual ( res , { } ) ;
t . end ( ) ;
} ;
controller ( req , res , next ) ;
} ) ;
//test( 'default # of request timeout retries should be 3', (t) => {
//// test for 1 initial search service, 3 retries, 1 log messages, 1 req, and 1 res
//t.plan(1 + 3 + 1 + 2);
//const logger = mocklogger();
//const config = {
//indexName: 'indexName value'
//};
//const esclient = 'this is the esclient';
//const query = () => ({
//body: 'this is the query body',
//});
//const timeoutError = {
//status: 408,
//displayName: 'RequestTimeout',
//message: 'Request Timeout after 17ms'
//};
//// a controller that validates that the search service was called
//const controller = proxyquire('../../../controller/search_with_ids', {
//'../service/search': (esclient, cmd, callback) => {
//// note that the searchService got called
//t.pass('search service was called');
//callback(timeoutError);
//},
//'pelias-logger': logger
//})(config, esclient, query, () => true );
//const req = { clean: { }, errors: [], warnings: [] };
//const res = {};
//const next = () => {
//t.deepEqual(logger.getInfoMessages(), [
//'[req] endpoint=undefined {}',
// 'request timed out on attempt 1, retrying',
// 'request timed out on attempt 2, retrying',
// 'request timed out on attempt 3, retrying'
//]);
//t.deepEqual(req, {
//clean: {},
//errors: [timeoutError.message],
//warnings: []
//});
//t.deepEqual(res, {});
//t.end();
//};
//controller(req, res, next);
//});
test ( 'explicit apiConfig.requestRetries should retry that many times' , ( t ) => {
t . plan ( 1 + 17 ) ; // test for initial search service call and 17 retries