Skip to content

Commit

Permalink
fixes to benchmark scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers committed Nov 7, 2024
1 parent c7fddcf commit 5b28c3c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/aws-device-farm/device-farm-client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import {
} from "@aws-sdk/client-device-farm";

export function getDeviceFarmClient() {
return new DeviceFarmClient({ region: "us-west-2" });
return new DeviceFarmClient({ region: "us-west-2", retryMode: "adaptive", maxAttempts: 10 });
}
2 changes: 1 addition & 1 deletion scripts/aws-device-farm/plot-android-benchmark-results.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

# Define the colors for each renderer
colors = {'legacy': 'gray', 'drawable': 'blue', 'vulkan': 'red'}
renderer_order = ['drawable', 'vulkan']
renderer_order = ['legacy', 'drawable', 'vulkan']

legend_names = {'legacy': 'Legacy', 'drawable': 'OpenGL', 'vulkan': 'Vulkan'}

Expand Down
57 changes: 30 additions & 27 deletions scripts/aws-device-farm/store-test-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ function getArgs() {
type: "string",
},
runArn: {
type: "string"
type: "string",
multiple: true
},
testsSuite: {
type: "boolean"
type: "boolean"
},
customerArtifacts: {
type: "boolean"
Expand All @@ -42,7 +43,7 @@ function getArgs() {
const { outputDir, runArn } = values;
if (typeof outputDir !== 'string') usage();

if (typeof runArn !== 'string') usage();
if (!runArn || !runArn.length) usage();

function suitesFilter() {
const names = new Set();
Expand Down Expand Up @@ -82,34 +83,36 @@ await storeRunArtifacts(runArn, outputDir);
/**
* Looks for the run with the provided ARN and returns the test spec output.
*
* @param {string} arn
* @param {string[]} arnArr
* @param {string} outputDir
* @returns string
*/
async function storeRunArtifacts(arn, outputDir) {
const jobs = await deviceFarmClient.send(new ListJobsCommand({
arn
}));

await Promise.all((jobs.jobs || []).map(async (job) => {
const suites = await deviceFarmClient.send(new ListSuitesCommand({arn: job.arn}));
await Promise.all((suites.suites || []).filter(suitesFilter).map(async (suite) => {
const artifacts = await deviceFarmClient.send(new ListArtifactsCommand({
arn: suite.arn,
type: 'FILE'
}));
await Promise.all((artifacts.artifacts || []).map(async (artifact) => {
if (!artifact.name || !artifact.url || !artifact.type) return;
if (artifactsToDownload.includes(artifact.type)) {
const filename = `${artifact.name.replaceAll(' ', '_')}-${crypto.randomBytes(10).toString('hex')}.${artifact.extension}`;
const res = await fetch(artifact.url);
if (!res.ok || !res.body) return;
const destination = path.resolve(outputDir, filename);
const fileStream = fs.createWriteStream(destination, { flags: 'wx' });
await finished(Readable.fromWeb(/** @type {any} **/ (res.body)).pipe(fileStream));
}
async function storeRunArtifacts(arnArr, outputDir) {
for (const arn of arnArr) {
const jobs = await deviceFarmClient.send(new ListJobsCommand({
arn
}));

await Promise.all((jobs.jobs || []).map(async (job) => {
const suites = await deviceFarmClient.send(new ListSuitesCommand({ arn: job.arn }));
await Promise.all((suites.suites || []).filter(suitesFilter).map(async (suite) => {
const artifacts = await deviceFarmClient.send(new ListArtifactsCommand({
arn: suite.arn,
type: 'FILE'
}));
await Promise.all((artifacts.artifacts || []).map(async (artifact) => {
if (!artifact.name || !artifact.url || !artifact.type) return;
if (artifactsToDownload.includes(artifact.type)) {
const filename = `${artifact.name.replaceAll(' ', '_')}-${crypto.randomBytes(10).toString('hex')}.${artifact.extension}`;
const res = await fetch(artifact.url);
if (!res.ok || !res.body) return;
const destination = path.resolve(outputDir, filename);
const fileStream = fs.createWriteStream(destination, { flags: 'wx' });
await finished(Readable.fromWeb(/** @type {any} **/(res.body)).pipe(fileStream));
}
}));
}));
}));
}));
}
console.log(`Wrote run artifacts to ${outputDir}`)
}

0 comments on commit 5b28c3c

Please sign in to comment.