Make playwright test environment more dynamic (#2532)

* Update Az CLI to use new secrets.

* Add test step for Az login

* Remove test step. Fix up account names in test code.

* Fix the account prefix env. variable.

* Fix it in the CI config as well.

* Try to fix the CI config for some tests

* Clean up access tokens for NoSQL.

* Disable most tests while sorting out account setup. Add debug tracing.

* Comment out most tests.

* Set RG Name var in CI config.

* Fix up tenant id.

* Enable other API tests

* e-enable more tests.

* Re-enable remaining tests.

* Remove all of the test.skip() calls.

* Remove debug traces.

* Remove function to retrieve SQL RBAC token, this is handled by the CI config now.

* Fix rbac token detection for table and resource token tests.

* Minor cleanup and fixing the cleanup config.

* Preview site and storage changes. Cleanup script changes.

* Clean up before PR.

* Fix resource group name in test results email.
This commit is contained in:
jawelton74
2026-07-20 08:00:29 -07:00
committed by GitHub
parent cdc5569a34
commit e3b77ec1f2
10 changed files with 74 additions and 205 deletions
+21 -12
View File
@@ -1,7 +1,6 @@
import { DefaultAzureCredential } from "@azure/identity";
import { Frame, Locator, Page, expect } from "@playwright/test";
import crypto from "crypto";
import { getNoSqlRbacToken } from "./NoSqlTestSetup";
import { TestContainerContext } from "./testData";
const RETRY_COUNT = 3;
@@ -45,29 +44,34 @@ export enum TestAccount {
}
export function getDefaultAccountName(accountType: TestAccount): string {
const accountNamePrefix = process.env.DE_ACCOUNT_PREFIX;
if (!accountNamePrefix) {
throw new Error("DE_ACCOUNT_PREFIX is not set");
}
switch (accountType) {
case TestAccount.Tables:
return "github-e2etests-tables";
return `${accountNamePrefix}-de-test-table-1`;
case TestAccount.Cassandra:
return "github-e2etests-cassandra";
return `${accountNamePrefix}-de-test-cassandra-1`;
case TestAccount.Gremlin:
return "github-e2etests-gremlin";
return `${accountNamePrefix}-de-test-gremlin-1`;
case TestAccount.Mongo:
return "github-e2etests-mongo";
return `${accountNamePrefix}-de-test-mongo-1`;
case TestAccount.MongoReadonly:
return "github-e2etests-mongo-readonly";
return `${accountNamePrefix}-de-test-mongo-readonly`;
case TestAccount.Mongo32:
return "github-e2etests-mongo32";
return `${accountNamePrefix}-de-test-mongo32-1`;
case TestAccount.SQLReadOnly:
return "github-e2etests-sql-readonly";
return `${accountNamePrefix}-de-test-sql-readonly`;
case TestAccount.SQLContainerCopyOnly:
return "github-e2etests-sql-containercopyonly";
return `${accountNamePrefix}-de-test-sql-containercopy`;
case TestAccount.SQL: {
const shardIndex = process.env.PLAYWRIGHT_SHARD_INDEX ?? "";
if (!shardIndex) {
throw new Error("PLAYWRIGHT_SHARD_INDEX is not set");
}
return "github-e2etests-sql-" + shardIndex;
return `${accountNamePrefix}-de-test-sql-${shardIndex}`;
}
default:
throw new Error(`No default account name defined for account type ${accountType}`);
@@ -75,7 +79,7 @@ export function getDefaultAccountName(accountType: TestAccount): string {
}
export const resourceGroupName = process.env.DE_TEST_RESOURCE_GROUP ?? "de-e2e-tests";
export const subscriptionId = process.env.DE_TEST_SUBSCRIPTION_ID ?? "69e02f2d-f059-4409-9eac-97e8a276ae2c";
export const subscriptionId = process.env.DE_TEST_SUBSCRIPTION_ID ?? process.env.AZURE_SUBSCRIPTION_ID ?? "";
export const TEST_AUTOSCALE_THROUGHPUT_RU = 1000;
export const TEST_MANUAL_THROUGHPUT_RU = 800;
export const TEST_AUTOSCALE_MAX_THROUGHPUT_RU_2K = 2000;
@@ -117,11 +121,16 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes
params.set("subscriptionId", subscriptionId);
params.set("token", token);
const tenantId = process.env.AZURE_TENANT_ID;
if (tenantId) {
params.set("tenantId", tenantId);
}
// There seem to be occasional CORS issues with calling the copilot APIs (/api/tokens/sampledataconnection/v2, for example)
// For now, since we don't test copilot, we can disable the copilot APIs by setting the feature flag to false.
params.set("feature.enableCopilot", "false");
const nosqlRbacToken = getNoSqlRbacToken();
const nosqlRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN;
const nosqlReadOnlyRbacToken = process.env.NOSQL_READONLY_TESTACCOUNT_TOKEN;
const nosqlContainerCopyRbacToken = process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN;