From 9973553da4b4d8cf6f35780a8b987f804d2ab621 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Tue, 17 Mar 2020 12:50:07 -0700 Subject: [PATCH] test: add sample test debugging (#385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First attempt did not work out. Console output wasn't captured in the logs because `execSync` threw. Hoping it's better this time 🤞 --- monitoring/snippets/metrics.js | 3 +++ monitoring/snippets/test/metrics.test.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/monitoring/snippets/metrics.js b/monitoring/snippets/metrics.js index e6b87e40f5..8f9760fe09 100644 --- a/monitoring/snippets/metrics.js +++ b/monitoring/snippets/metrics.js @@ -324,6 +324,9 @@ async function readTimeSeriesAggregate(projectId) { console.log('CPU utilization:'); timeSeries.forEach(data => { console.log(data); + for (const point of data.points) { + console.log(point); + } console.log(data.metric.labels.instance_name); console.log(` Now: ${data.points[0].value.doubleValue}`); console.log(` 10 min ago: ${data.points[1].value.doubleValue}`); diff --git a/monitoring/snippets/test/metrics.test.js b/monitoring/snippets/test/metrics.test.js index a8cf0d5fe2..4a0b1e44d1 100644 --- a/monitoring/snippets/test/metrics.test.js +++ b/monitoring/snippets/test/metrics.test.js @@ -151,7 +151,13 @@ describe('metrics', () => { perSeriesAligner: `ALIGN_MEAN`, }, }); - const output = execSync(`${cmd} read-aggregate`); + let output; + try { + output = execSync(`${cmd} read-aggregate`); + } catch (e) { + console.error(e); + throw e; + } assert.include(output, 'CPU utilization:'); timeSeries.forEach(data => { assert.include(output, data.metric.labels.instance_name);