|
|
@ -15,7 +15,7 @@ module.exports.tests.interface = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
module.exports.tests.success = (test, common) => { |
|
|
|
module.exports.tests.success = (test, common) => { |
|
|
|
test('successful request to search service should replace data and meta', (t) => { |
|
|
|
test('successful request to search service should replace data and meta', (t) => { |
|
|
|
t.plan(5); |
|
|
|
t.plan(4); |
|
|
|
|
|
|
|
|
|
|
|
const logger = mocklogger(); |
|
|
|
const logger = mocklogger(); |
|
|
|
|
|
|
|
|
|
|
@ -77,8 +77,6 @@ module.exports.tests.success = (test, common) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
t.ok(logger.isInfoMessage('[controller:search] [queryType:this is the query type] [es_result_count:2]')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -146,7 +144,7 @@ module.exports.tests.success = (test, common) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('undefined docs in response should not overwrite existing results', (t) => { |
|
|
|
test('undefined docs in response should not overwrite existing results', (t) => { |
|
|
|
t.plan(1+3); // ensures that search service was called, then req+res+logger tests
|
|
|
|
t.plan(1+2); // ensures that search service was called, then req+res tests
|
|
|
|
|
|
|
|
|
|
|
|
const logger = mocklogger(); |
|
|
|
const logger = mocklogger(); |
|
|
|
|
|
|
|
|
|
|
@ -196,8 +194,6 @@ module.exports.tests.success = (test, common) => { |
|
|
|
meta: { key: 'value' } |
|
|
|
meta: { key: 'value' } |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
t.notOk(logger.isInfoMessage(/[controller:search] [queryType:this is the query type] [es_result_count:0]/)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -206,7 +202,7 @@ module.exports.tests.success = (test, common) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('empty docs in response should not overwrite existing results', (t) => { |
|
|
|
test('empty docs in response should not overwrite existing results', (t) => { |
|
|
|
t.plan(4); |
|
|
|
t.plan(3); |
|
|
|
|
|
|
|
|
|
|
|
const logger = mocklogger(); |
|
|
|
const logger = mocklogger(); |
|
|
|
|
|
|
|
|
|
|
@ -255,8 +251,6 @@ module.exports.tests.success = (test, common) => { |
|
|
|
meta: { key: 'value' } |
|
|
|
meta: { key: 'value' } |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
t.notOk(logger.isInfoMessage(/[controller:search] [queryType:this is the query type] [es_result_count:0]/)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -265,7 +259,7 @@ module.exports.tests.success = (test, common) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('successful request on retry to search service should log info message', (t) => { |
|
|
|
test('successful request on retry to search service should log info message', (t) => { |
|
|
|
t.plan(3+2+2); // 3 search service calls, 2 log messages, 1 req, 1 res
|
|
|
|
t.plan(3+2); // 3 search service calls, 1 req, 1 res
|
|
|
|
|
|
|
|
|
|
|
|
const logger = mocklogger(); |
|
|
|
const logger = mocklogger(); |
|
|
|
|
|
|
|
|
|
|
@ -337,9 +331,6 @@ module.exports.tests.success = (test, common) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
t.ok(logger.isInfoMessage('[controller:search] [queryType:this is the query type] [es_result_count:2]')); |
|
|
|
|
|
|
|
t.ok(logger.isInfoMessage('succeeded on retry 2')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -351,8 +342,8 @@ 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 req, and 1 res
|
|
|
|
t.plan(1 + 3 + 1 + 2); |
|
|
|
t.plan(1 + 3 + 2); |
|
|
|
|
|
|
|
|
|
|
|
const logger = mocklogger(); |
|
|
|
const logger = mocklogger(); |
|
|
|
|
|
|
|
|
|
|
@ -385,13 +376,6 @@ module.exports.tests.service_errors = (test, common) => { |
|
|
|
const res = {}; |
|
|
|
const res = {}; |
|
|
|
|
|
|
|
|
|
|
|
const next = () => { |
|
|
|
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, { |
|
|
|
t.deepEqual(req, { |
|
|
|
clean: {}, |
|
|
|
clean: {}, |
|
|
|
errors: [timeoutError.message], |
|
|
|
errors: [timeoutError.message], |
|
|
|