Copy latest video (#3248)

This commit is contained in:
Peter Hedenskog 2021-01-12 15:11:28 +01:00 committed by GitHub
parent c69010389f
commit bb8ec44a39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View File

@ -315,8 +315,9 @@ module.exports = {
run.errors = result[resultIndex].errors[runIndex];
run.screenshots =
run.screenshot =
result[resultIndex].files.screenshot[runIndex][resultIndex];
run.video = result[resultIndex].files.video[runIndex];
// calculate errors
for (let error of result[resultIndex].errors) {

View File

@ -27,16 +27,12 @@ module.exports = {
case 'browsertime.run': {
// Only use the first one for now
if (
message.iteration === 1 &&
this.options.copyLatestFilesToBase &&
this.useScreenshots
) {
if (message.iteration === 1 && this.options.copyLatestFilesToBase) {
const options = this.options;
const baseDir = this.storageManager.getBaseDir();
// Hack to get out of the date dir
const newPath = path.resolve(baseDir, '..');
const fullPath = path.join(baseDir, message.data.screenshots);
// This is a hack to get the same name as in Grafana, meaning we can
// generate the path to the URL there
const name = graphiteUtil.getURLAndGroup(
@ -46,10 +42,21 @@ module.exports = {
this.options.graphite.includeQueryParams,
this.alias
);
await this.storageManager.copyFileToDir(
fullPath,
newPath + '/' + name + '.' + this.screenshotType
);
if (this.useScreenshots) {
const imageFullPath = path.join(baseDir, message.data.screenshot);
await this.storageManager.copyFileToDir(
imageFullPath,
newPath + '/' + name + '.' + this.screenshotType
);
}
if (this.options.browsertime && this.options.browsertime.video) {
const videoFullPath = path.join(baseDir, message.data.video);
await this.storageManager.copyFileToDir(
videoFullPath,
newPath + '/' + name + '.mp4'
);
}
// Also store a JSON with data that we can use later
const json = {