If we upload to s3/gcs then wait on sending budget message until data is uploaded (#3180)

* If we upload to s3/gcs then wait on sending budget message until data is uploaded.

* Fix uploading

* Also collect errors
This commit is contained in:
Peter Hedenskog 2020-11-03 13:34:48 +01:00 committed by GitHub
parent bfc81cb56c
commit a8e15f3d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 51 additions and 14 deletions

View File

@ -8,15 +8,17 @@ const cliUtil = require('../../cli/util');
const send = require('./send');
function getBrowserData(data) {
return `${data.browser.name} ${data.browser.version} ${get(
data,
'android.model',
''
)} ${get(data, 'android.androidVersion', '')} ${get(
data,
'android.id',
''
)} `;
if (data && data.browser) {
return `${data.browser.name} ${data.browser.version} ${get(
data,
'android.model',
''
)} ${get(data, 'android.androidVersion', '')} ${get(
data,
'android.id',
''
)} `;
} else return '';
}
module.exports = {
@ -33,6 +35,7 @@ module.exports = {
throwIfMissing(options.matrix, ['accessToken', 'host', 'room'], 'matrix');
this.resultUrls = context.resultUrls;
this.errorTexts = '';
this.waitForUpload = false;
},
async processMessage(message) {
const options = this.matrixOptions;
@ -41,7 +44,14 @@ module.exports = {
this.browserData = message.data;
break;
}
case 'render': {
case 'gcs.setup':
case 'ftp.setup':
case 's3.setup': {
this.waitForUpload = true;
break;
}
case 'sitespeedio.render': {
if (this.errorTexts !== '') {
const room = get(options, 'rooms.error', options.room);
try {
@ -98,15 +108,42 @@ module.exports = {
}
text += `</ul>`;
}
} else {
text += `<p><b>&#9888;&#65039; All (${
}
if (Object.keys(message.data.error).length > 0) {
const errorURLs = Object.keys(message.data.error);
text += `<h1>&#9888;&#65039; Budget errors testing ${
errorURLs.length
} URLs</h1>`;
for (let url of errorURLs) {
text += `<h5>&#10060; ${url}</h5>`;
text += `<pre>${message.data.error[url]}</pre>`;
}
}
if (
Object.keys(message.data.error).length === 0 &&
Object.keys(message.data.failing).length === 0
) {
text += `<p><b>&#127881; All (${
message.data.working.length
} URLs passed the budget. </b></p>`;
}) URLs passed the budget. </b></p>`;
text += `<p><b>${get(this.options, 'name', '') +
'</b> '}${getBrowserData(this.browserData)}</p>`;
}
if (!this.waitForUpload) {
const room = get(options, 'rooms.budget', options.room);
await send(options.host, room, options.accessToken, text);
} else {
this.budgetText = text;
}
}
break;
}
case 'gcs.finished':
case 'ftp.finished':
case 's3.finished': {
if (this.waitForUpload && options.messages.indexOf('budget') > -1) {
const room = get(options, 'rooms.budget', options.room);
await send(options.host, room, options.accessToken, text);
await send(options.host, room, options.accessToken, this.budgetText);
}
break;
}