Android Instrumentation Tests Improvements (#2321)
This commit is contained in:
7
scripts/aws-device-farm/device-farm-client.mjs
Normal file
7
scripts/aws-device-farm/device-farm-client.mjs
Normal file
@@ -0,0 +1,7 @@
|
||||
import {
|
||||
DeviceFarmClient,
|
||||
} from "@aws-sdk/client-device-farm";
|
||||
|
||||
export function getDeviceFarmClient() {
|
||||
return new DeviceFarmClient({ region: "us-west-2" });
|
||||
}
|
||||
@@ -6,11 +6,12 @@ import https from "node:https";
|
||||
import readline from "node:readline";
|
||||
|
||||
import {
|
||||
DeviceFarmClient,
|
||||
ListJobsCommand,
|
||||
ListArtifactsCommand,
|
||||
} from "@aws-sdk/client-device-farm";
|
||||
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { getDeviceFarmClient } from "./device-farm-client.mjs";
|
||||
import { getS3Client } from "./s3-client.mjs";
|
||||
|
||||
/**
|
||||
* Retrieves a log file and looks for the line that includes the benchmark results.
|
||||
@@ -46,7 +47,7 @@ function usage() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const deviceFarmClient = new DeviceFarmClient({ region: "us-west-2" });
|
||||
const deviceFarmClient = getDeviceFarmClient();
|
||||
|
||||
if (process.argv.length !== 3) usage();
|
||||
|
||||
@@ -103,9 +104,7 @@ const benchmarkResults = benchmarkResultLogLines
|
||||
.filter((line) => !!line)
|
||||
.map((jsonVal) => JSON.parse(jsonVal));
|
||||
|
||||
const s3Client = new S3Client({
|
||||
region: "eu-central-1",
|
||||
});
|
||||
const s3Client = getS3Client();
|
||||
|
||||
// store benchmark results as JSON files on S3
|
||||
await Promise.all(
|
||||
|
||||
47
scripts/aws-device-farm/log-test-spec-output.mjs
Normal file
47
scripts/aws-device-farm/log-test-spec-output.mjs
Normal file
@@ -0,0 +1,47 @@
|
||||
import { ListArtifactsCommand } from "@aws-sdk/client-device-farm";
|
||||
import { getDeviceFarmClient } from "./device-farm-client.mjs";
|
||||
|
||||
/**
|
||||
* @returns {never}
|
||||
*/
|
||||
function usage() {
|
||||
console.error("Logs test spec output from AWS Device Farm");
|
||||
console.error(`Usage: node ${process.argv.at(1)} RUN_ARN`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.argv.length !== 3) usage();
|
||||
|
||||
const arn = process.argv.at(2);
|
||||
|
||||
if (typeof arn !== 'string') usage();
|
||||
|
||||
const deviceFarmClient = getDeviceFarmClient();
|
||||
|
||||
/**
|
||||
* Looks for the run with the provided ARN and returns the test spec output.
|
||||
*
|
||||
* @param {string} arn
|
||||
* @returns string
|
||||
*/
|
||||
async function getTestSpecOutput(arn) {
|
||||
const logs = await deviceFarmClient.send(new ListArtifactsCommand({
|
||||
arn,
|
||||
type: 'FILE'
|
||||
}));
|
||||
for (const artifact of logs.artifacts || []) {
|
||||
if (artifact.type === 'TESTSPEC_OUTPUT' && artifact.url) {
|
||||
return await (await fetch(artifact.url)).text();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
const testSpecOutput = await getTestSpecOutput(arn);
|
||||
|
||||
if (!testSpecOutput) {
|
||||
console.error(`Test spec output for run '${arn}' not found`);
|
||||
}
|
||||
|
||||
console.log(testSpecOutput);
|
||||
|
||||
7
scripts/aws-device-farm/s3-client.mjs
Normal file
7
scripts/aws-device-farm/s3-client.mjs
Normal file
@@ -0,0 +1,7 @@
|
||||
import { S3Client } from "@aws-sdk/client-s3";
|
||||
|
||||
export function getS3Client() {
|
||||
return new S3Client({
|
||||
region: "eu-central-1",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user