Test E2E resource naming

This commit is contained in:
Vsevolod Kukol
2026-09-11 22:58:07 +02:00
parent 2ff1308a6e
commit 1f8fe0acdf
4 changed files with 72 additions and 12 deletions
+3 -11
View File
@@ -1,6 +1,7 @@
import { DefaultAzureCredential } from "@azure/identity";
import { Frame, Locator, Page, expect } from "@playwright/test";
import crypto, { webcrypto } from "crypto";
import { webcrypto } from "crypto";
import { generateUniqueName as generateUniqueResourceName } from "../utils/testResourceName";
import { TestContainerContext } from "./testData";
// The @azure/cosmos client signs requests with globalThis.crypto (Web Crypto API).
@@ -19,16 +20,7 @@ export interface TestNameOptions {
}
export function generateUniqueName(baseName: string, options?: TestNameOptions): string {
const length = options?.length ?? 1;
const timestamp = options?.timestampped === undefined ? true : options.timestampped;
const prefixed = options?.prefixed === undefined ? true : options.prefixed;
const runId = process.env.GITHUB_RUN_ID;
const runAttempt = process.env.GITHUB_RUN_ATTEMPT ?? "1";
const runPrefix = runId ? `${runId}_${runAttempt}_` : "";
const prefix = prefixed ? `t_${runPrefix}` : "";
const suffix = timestamp ? `_${Date.now()}` : "";
return `${prefix}${baseName}${crypto.randomBytes(length).toString("hex")}${suffix}`;
return generateUniqueResourceName(baseName, options, process.env);
}
export function getAzureCLICredentials(): DefaultAzureCredential {