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