Skip to content

Commit

Permalink
test: add sample test debugging (#385)
Browse files Browse the repository at this point in the history
First attempt did not work out.  Console output wasn't captured in the logs because `execSync` threw.  Hoping it's better this time 🤞
  • Loading branch information
JustinBeckwith authored Mar 17, 2020
1 parent ebfa69e commit 9973553
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions monitoring/snippets/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
8 changes: 7 additions & 1 deletion monitoring/snippets/test/metrics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9973553

Please sign in to comment.