mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ci/screenshots] enable discovering truncated screenshot names (#133950)
This commit is contained in:
parent
bc591aedfa
commit
42ba236b8e
2 changed files with 12 additions and 6 deletions
|
@ -96,7 +96,10 @@ export function reportFailuresToFile(
|
|||
);
|
||||
|
||||
let screenshot = '';
|
||||
const screenshotName = `${failure.name.replace(/([^ a-zA-Z0-9-]+)/g, '_')}`;
|
||||
const truncatedName = failure.name.replace(/([^ a-zA-Z0-9-]+)/g, '_').slice(0, 80);
|
||||
const failureNameHash = createHash('sha256').update(failure.name).digest('hex');
|
||||
const screenshotName = `${truncatedName}-${failureNameHash}`;
|
||||
|
||||
if (screenshotsByName[screenshotName]) {
|
||||
try {
|
||||
screenshot = readFileSync(screenshotsByName[screenshotName]).toString('base64');
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import { resolve } from 'path';
|
||||
import { writeFile, mkdir } from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import Uuid from 'uuid';
|
||||
import { createHash } from 'crypto';
|
||||
|
||||
import del from 'del';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
@ -49,11 +49,14 @@ export async function FailureDebuggingProvider({ getService }: FtrProviderContex
|
|||
}
|
||||
|
||||
async function onFailure(_: any, test: Test) {
|
||||
const fullName = test.fullTitle();
|
||||
|
||||
// include a hash of the full title of the test in the filename so that even with truncation filenames are
|
||||
// always unique and deterministic based on the test title
|
||||
const hash = createHash('sha256').update(fullName).digest('hex');
|
||||
|
||||
// Replace characters in test names which can't be used in filenames, like *
|
||||
let name = test.fullTitle().replace(/([^ a-zA-Z0-9-]+)/g, '_');
|
||||
if (name.length > 100) {
|
||||
name = `truncated-${name.slice(-100)}-${Uuid.v4()}`;
|
||||
}
|
||||
const name = `${fullName.replace(/([^ a-zA-Z0-9-]+)/g, '_').slice(0, 80)}-${hash}`;
|
||||
|
||||
await Promise.all([screenshots.takeForFailure(name), logCurrentUrl(), savePageHtml(name)]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue