From b21fd7d886623db80a8d052b10085ff308e390fe Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 6 Dec 2018 16:20:51 -0700 Subject: [PATCH 1/3] [Reporting] Test logging --- x-pack/plugins/reporting/server/routes/jobs.js | 10 ++++++++++ x-pack/test/reporting/configs/api.js | 1 + x-pack/test/reporting/configs/chromium_api.js | 1 - x-pack/test/reporting/configs/functional.js | 12 ++++++++++-- x-pack/test/reporting/configs/phantom_functional.js | 1 - 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/reporting/server/routes/jobs.js b/x-pack/plugins/reporting/server/routes/jobs.js index 2639fc103bbde..afbdb9cc7e213 100644 --- a/x-pack/plugins/reporting/server/routes/jobs.js +++ b/x-pack/plugins/reporting/server/routes/jobs.js @@ -124,6 +124,16 @@ export function jobs(server) { const { docId } = request.params; let response = await jobResponseHandler(request.pre.management.jobTypes, request.pre.user, h, { docId }); + const { statusCode } = response; + + if (statusCode !== 200) { + const logLevel = statusCode === 500 ? 'error' : 'debug'; + server.log( + [logLevel, "reporting", "download"], + `Report ${docId} has non-OK status: [${statusCode}] Reason: [${JSON.stringify(response.source)}]` + ); + } + if (!response.isBoom) { response = response.header('accept-ranges', 'none'); } diff --git a/x-pack/test/reporting/configs/api.js b/x-pack/test/reporting/configs/api.js index 3723390c971b0..7c30f299f3f46 100644 --- a/x-pack/test/reporting/configs/api.js +++ b/x-pack/test/reporting/configs/api.js @@ -30,6 +30,7 @@ export async function getReportingApiConfig({ readConfigFile }) { serverArgs: [ ...apiConfig.get('kbnTestServer.serverArgs'), `--optimize.enabled=true`, + '--logging.events.log', JSON.stringify(['info', 'warning', 'error', 'fatal', 'optimize', 'reporting']) ], }, }; diff --git a/x-pack/test/reporting/configs/chromium_api.js b/x-pack/test/reporting/configs/chromium_api.js index 1d643c4d359df..461c6c0df5271 100644 --- a/x-pack/test/reporting/configs/chromium_api.js +++ b/x-pack/test/reporting/configs/chromium_api.js @@ -22,7 +22,6 @@ export default async function ({ readConfigFile }) { ...reportingApiConfig.kbnTestServer.serverArgs, `--xpack.reporting.capture.browser.type=chromium`, `--xpack.spaces.enabled=false`, - `--logging.verbose=true`, ], }, }; diff --git a/x-pack/test/reporting/configs/functional.js b/x-pack/test/reporting/configs/functional.js index 82d38ccde3119..89085c8b07ab6 100644 --- a/x-pack/test/reporting/configs/functional.js +++ b/x-pack/test/reporting/configs/functional.js @@ -21,9 +21,17 @@ export async function getFunctionalConfig({ readConfigFile }) { junit: { reportName: 'X-Pack Reporting Functional Tests', }, - kbnTestServer: xPackFunctionalTestsConfig.get('kbnTestServer'), + kbnTestServer: { + ...xPackFunctionalTestsConfig.get('kbnTestServer'), + serverArgs: [ + ...xPackFunctionalTestsConfig.get('kbnTestServer.serverArgs'), + '--logging.events.log', JSON.stringify(['info', 'warning', 'error', 'fatal', 'optimize', 'reporting']) + ], + }, testFiles: [require.resolve('../functional')], }; } -export default getFunctionalConfig; \ No newline at end of file +export default getFunctionalConfig; + + diff --git a/x-pack/test/reporting/configs/phantom_functional.js b/x-pack/test/reporting/configs/phantom_functional.js index e9a61ee813cf2..b0e7ba6f29ce7 100644 --- a/x-pack/test/reporting/configs/phantom_functional.js +++ b/x-pack/test/reporting/configs/phantom_functional.js @@ -21,7 +21,6 @@ export default async function ({ readConfigFile }) { serverArgs: [ ...functionalConfig.kbnTestServer.serverArgs, `--xpack.reporting.capture.browser.type=phantom`, - `--logging.verbose=true`, ], }, }; From d2400f0e8077ee2d9d70fefd29a9ac29a5012b06 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 6 Dec 2018 16:21:36 -0700 Subject: [PATCH 2/3] chromium api tests fixed --- x-pack/scripts/functional_tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/scripts/functional_tests.js b/x-pack/scripts/functional_tests.js index a9192077791f4..fe070c3445a68 100644 --- a/x-pack/scripts/functional_tests.js +++ b/x-pack/scripts/functional_tests.js @@ -6,7 +6,7 @@ require('@kbn/plugin-helpers').babelRegister(); require('@kbn/test').runTestsCli([ - // require.resolve('../test/reporting/configs/chromium_api.js'), + require.resolve('../test/reporting/configs/chromium_api.js'), // require.resolve('../test/reporting/configs/chromium_functional.js'), // require.resolve('../test/reporting/configs/phantom_api.js'), // require.resolve('../test/reporting/configs/phantom_functional.js'), From e134bb0d3b68d453bca1b489c9fa4f1b354bf968 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 6 Dec 2018 16:38:56 -0700 Subject: [PATCH 3/3] whitespace --- x-pack/test/reporting/configs/functional.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/test/reporting/configs/functional.js b/x-pack/test/reporting/configs/functional.js index 89085c8b07ab6..4eafa10369e93 100644 --- a/x-pack/test/reporting/configs/functional.js +++ b/x-pack/test/reporting/configs/functional.js @@ -33,5 +33,3 @@ export async function getFunctionalConfig({ readConfigFile }) { } export default getFunctionalConfig; - -