From 4270151e9783594ce4b524595607c43c5a5f30a1 Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Wed, 21 Jan 2026 06:40:26 -0800 Subject: [PATCH] add second github sql account --- .github/workflows/ci.yml | 3 ++ test/fx.ts | 13 ++++++++- test/sql/document.spec.ts | 4 +-- test/sql/query.spec.ts | 9 ++---- .../changePartitionKey.spec.ts | 15 +++++----- .../computedProperties.spec.ts | 4 ++- test/sql/scaleAndSettings/scale.spec.ts | 4 +-- test/sql/scaleAndSettings/settings.spec.ts | 9 ++---- test/sql/scripts/storedProcedure.spec.ts | 4 ++- test/sql/scripts/trigger.spec.ts | 12 ++++---- test/sql/scripts/userDefinedFunction.spec.ts | 12 ++++---- test/testData.ts | 29 +++++++++++++------ 12 files changed, 68 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d91f15973..1f5ffcb65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -189,6 +189,9 @@ jobs: NOSQL_TESTACCOUNT_TOKEN=$(az account get-access-token --scope "https://github-e2etests-sql.documents.azure.com/.default" -o tsv --query accessToken) echo "::add-mask::$NOSQL_TESTACCOUNT_TOKEN" echo NOSQL_TESTACCOUNT_TOKEN=$NOSQL_TESTACCOUNT_TOKEN >> $GITHUB_ENV + NOSQL2_TESTACCOUNT_TOKEN=$(az account get-access-token --scope "https://github-e2etests-sql-2.documents.azure.com/.default" -o tsv --query accessToken) + echo "::add-mask::$NOSQL2_TESTACCOUNT_TOKEN" + echo NOSQL2_TESTACCOUNT_TOKEN=$NOSQL2_TESTACCOUNT_TOKEN >> $GITHUB_ENV NOSQL_READONLY_TESTACCOUNT_TOKEN=$(az account get-access-token --scope "https://github-e2etests-sql-readonly.documents.azure.com/.default" -o tsv --query accessToken) echo "::add-mask::$NOSQL_READONLY_TESTACCOUNT_TOKEN" echo NOSQL_READONLY_TESTACCOUNT_TOKEN=$NOSQL_READONLY_TESTACCOUNT_TOKEN >> $GITHUB_ENV diff --git a/test/fx.ts b/test/fx.ts index 1de8be90d..e5b63c02c 100644 --- a/test/fx.ts +++ b/test/fx.ts @@ -39,6 +39,7 @@ export enum TestAccount { MongoReadonly = "MongoReadOnly", Mongo32 = "Mongo32", SQL = "SQL", + SQL2 = "SQL2", SQLReadOnly = "SQLReadOnly", SQLContainerCopyOnly = "SQLContainerCopyOnly", } @@ -51,6 +52,7 @@ export const defaultAccounts: Record = { [TestAccount.MongoReadonly]: "github-e2etests-mongo-readonly", [TestAccount.Mongo32]: "github-e2etests-mongo32", [TestAccount.SQL]: "github-e2etests-sql", + [TestAccount.SQL2]: "github-e2etests-sql-2", [TestAccount.SQLReadOnly]: "github-e2etests-sql-readonly", [TestAccount.SQLContainerCopyOnly]: "github-e2etests-sql-containercopyonly", }; @@ -72,6 +74,9 @@ function tryGetStandardName(accountType: TestAccount) { } export function getAccountName(accountType: TestAccount) { + if (accountType === TestAccount.SQL2 && !process.env.CI) { + accountType = TestAccount.SQL; + } return ( process.env[`DE_TEST_ACCOUNT_NAME_${accountType.toLocaleUpperCase()}`] ?? tryGetStandardName(accountType) ?? @@ -101,6 +106,7 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes params.set("feature.enableCopilot", "false"); const nosqlRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN; + const nosql2RbacToken = process.env.NOSQL2_TESTACCOUNT_TOKEN; const nosqlReadOnlyRbacToken = process.env.NOSQL_READONLY_TESTACCOUNT_TOKEN; const nosqlContainerCopyRbacToken = process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN; const tableRbacToken = process.env.TABLE_TESTACCOUNT_TOKEN; @@ -117,7 +123,12 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes params.set("enableaaddataplane", "true"); } break; - + case TestAccount.SQL2: + if (nosql2RbacToken) { + params.set("nosql2RbacToken", nosql2RbacToken); + params.set("enableaaddataplane", "true"); + } + break; case TestAccount.SQLContainerCopyOnly: if (nosqlContainerCopyRbacToken) { params.set("nosqlRbacToken", nosqlContainerCopyRbacToken); diff --git a/test/sql/document.spec.ts b/test/sql/document.spec.ts index 5d17c22c3..a093da376 100644 --- a/test/sql/document.spec.ts +++ b/test/sql/document.spec.ts @@ -136,9 +136,7 @@ test.describe.serial("Upload Item", () => { if (existsSync(uploadDocumentDirPath)) { rmdirSync(uploadDocumentDirPath); } - if (!process.env.CI) { - await context?.dispose(); - } + await context?.dispose(); }); test.afterEach("Close Upload Items panel if still open", async () => { diff --git a/test/sql/query.spec.ts b/test/sql/query.spec.ts index f9dfc80f9..6368c4327 100644 --- a/test/sql/query.spec.ts +++ b/test/sql/query.spec.ts @@ -30,12 +30,9 @@ test.beforeEach("Open new query tab", async ({ page }) => { await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor(); }); -// Delete database only if not running in CI -if (!process.env.CI) { - test.afterAll("Delete Test Database", async () => { - await context?.dispose(); - }); -} +test.afterAll("Delete Test Database", async () => { + await context?.dispose(); +}); test("Query results", async () => { // Run the query and verify the results diff --git a/test/sql/scaleAndSettings/changePartitionKey.spec.ts b/test/sql/scaleAndSettings/changePartitionKey.spec.ts index 1f23d3154..e8c9b1aab 100644 --- a/test/sql/scaleAndSettings/changePartitionKey.spec.ts +++ b/test/sql/scaleAndSettings/changePartitionKey.spec.ts @@ -10,11 +10,13 @@ test.describe("Change Partition Key", () => { let previousJobName: string | undefined; test.beforeAll("Create Test Database", async () => { - context = await createTestSQLContainer(); + context = await createTestSQLContainer({ + testAccount: TestAccount.SQL2, + }); }); test.beforeEach("Open container settings", async ({ page }) => { - explorer = await DataExplorer.open(page, TestAccount.SQL); + explorer = await DataExplorer.open(page, TestAccount.SQL2); // Click Scale & Settings and open Partition Key tab await explorer.openScaleAndSettings(context); @@ -23,12 +25,9 @@ test.describe("Change Partition Key", () => { await PartitionKeyTab.click(); }); - // Delete database only if not running in CI - if (!process.env.CI) { - test.afterEach("Delete Test Database", async () => { - await context?.dispose(); - }); - } + test.afterEach("Delete Test Database", async () => { + await context?.dispose(); + }); test("Change partition key path", async ({ page }) => { await expect(explorer.frame.getByText("/partitionKey")).toBeVisible(); diff --git a/test/sql/scaleAndSettings/computedProperties.spec.ts b/test/sql/scaleAndSettings/computedProperties.spec.ts index d1f95e53e..2ee1576fd 100644 --- a/test/sql/scaleAndSettings/computedProperties.spec.ts +++ b/test/sql/scaleAndSettings/computedProperties.spec.ts @@ -8,7 +8,9 @@ test.describe("Computed Properties", () => { let explorer: DataExplorer = null!; test.beforeAll("Create Test Database", async () => { - context = await createTestSQLContainer(); + context = await createTestSQLContainer({ + testAccount: TestAccount.SQL2, + }); }); test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => { diff --git a/test/sql/scaleAndSettings/scale.spec.ts b/test/sql/scaleAndSettings/scale.spec.ts index d12db999c..d886b2def 100644 --- a/test/sql/scaleAndSettings/scale.spec.ts +++ b/test/sql/scaleAndSettings/scale.spec.ts @@ -118,7 +118,5 @@ async function openScaleTab(browser: Browser): Promise { } async function cleanup({ context }: Partial) { - if (!process.env.CI) { - await context?.dispose(); - } + await context?.dispose(); } diff --git a/test/sql/scaleAndSettings/settings.spec.ts b/test/sql/scaleAndSettings/settings.spec.ts index 3f14422eb..f60889574 100644 --- a/test/sql/scaleAndSettings/settings.spec.ts +++ b/test/sql/scaleAndSettings/settings.spec.ts @@ -17,12 +17,9 @@ test.describe("Settings under Scale & Settings", () => { await settingsTab.click(); }); - // Delete database only if not running in CI - if (!process.env.CI) { - test.afterAll("Delete Test Database", async () => { - await context?.dispose(); - }); - } + test.afterAll("Delete Test Database", async () => { + await context?.dispose(); + }); test("Update TTL to On (no default)", async () => { const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" }); diff --git a/test/sql/scripts/storedProcedure.spec.ts b/test/sql/scripts/storedProcedure.spec.ts index 35fb4e0f8..c4084423a 100644 --- a/test/sql/scripts/storedProcedure.spec.ts +++ b/test/sql/scripts/storedProcedure.spec.ts @@ -7,7 +7,9 @@ test.describe("Stored Procedures", () => { let explorer: DataExplorer = null!; test.beforeAll("Create Test Database", async () => { - context = await createTestSQLContainer(); + context = await createTestSQLContainer({ + testAccount: TestAccount.SQL2, + }); }); test.beforeEach("Open container", async ({ page }) => { diff --git a/test/sql/scripts/trigger.spec.ts b/test/sql/scripts/trigger.spec.ts index 6874c2aac..f233f54ea 100644 --- a/test/sql/scripts/trigger.spec.ts +++ b/test/sql/scripts/trigger.spec.ts @@ -19,18 +19,18 @@ test.describe("Triggers", () => { request.setBody(itemToCreate); }`; test.beforeAll("Create Test Database", async () => { - context = await createTestSQLContainer(); + context = await createTestSQLContainer({ + testAccount: TestAccount.SQL2, + }); }); test.beforeEach("Open container", async ({ page }) => { explorer = await DataExplorer.open(page, TestAccount.SQL); }); - if (!process.env.CI) { - test.afterAll("Delete Test Database", async () => { - await context?.dispose(); - }); - } + test.afterAll("Delete Test Database", async () => { + await context?.dispose(); + }); test("Add and delete trigger", async ({ page }, testInfo) => { // Open container context menu and click New Trigger diff --git a/test/sql/scripts/userDefinedFunction.spec.ts b/test/sql/scripts/userDefinedFunction.spec.ts index 911b1f4ce..4dc4c3c7c 100644 --- a/test/sql/scripts/userDefinedFunction.spec.ts +++ b/test/sql/scripts/userDefinedFunction.spec.ts @@ -12,18 +12,18 @@ test.describe("User Defined Functions", () => { }`; test.beforeAll("Create Test Database", async () => { - context = await createTestSQLContainer(); + context = await createTestSQLContainer({ + testAccount: TestAccount.SQL2, + }); }); test.beforeEach("Open container", async ({ page }) => { explorer = await DataExplorer.open(page, TestAccount.SQL); }); - if (!process.env.CI) { - test.afterAll("Delete Test Database", async () => { - await context?.dispose(); - }); - } + test.afterAll("Delete Test Database", async () => { + await context?.dispose(); + }); test("Add, execute, and delete user defined function", async ({ page }, testInfo) => { // Open container context menu and click New UDF diff --git a/test/testData.ts b/test/testData.ts index 7e5a1f26c..47165786b 100644 --- a/test/testData.ts +++ b/test/testData.ts @@ -86,13 +86,14 @@ type createTestSqlContainerConfig = { includeTestData?: boolean; partitionKey?: string; databaseName?: string; + testAccount?: TestAccount; }; type createMultipleTestSqlContainerConfig = { containerCount?: number; partitionKey?: string; databaseName?: string; - accountType: TestAccount.SQLContainerCopyOnly | TestAccount.SQL; + accountType: TestAccount.SQLContainerCopyOnly | TestAccount.SQL | TestAccount.SQL2; }; export async function createMultipleTestContainers({ @@ -114,12 +115,7 @@ export async function createMultipleTestContainers({ endpoint: account.documentEndpoint!, }; - const rbacToken = - accountType === TestAccount.SQL - ? process.env.NOSQL_TESTACCOUNT_TOKEN - : accountType === TestAccount.SQLContainerCopyOnly - ? process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN - : ""; + const rbacToken = getRbacToken(accountType); if (rbacToken) { clientOptions.tokenProvider = async (): Promise => { const AUTH_PREFIX = `type=aad&ver=1.0&sig=`; @@ -155,20 +151,22 @@ export async function createTestSQLContainer({ includeTestData = false, partitionKey = "/partitionKey", databaseName = "", + testAccount = TestAccount.SQL, }: createTestSqlContainerConfig = {}) { const databaseId = databaseName ? databaseName : generateUniqueName("db"); const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique const credentials = getAzureCLICredentials(); const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials); const armClient = new CosmosDBManagementClient(adaptedCredentials, subscriptionId); - const accountName = getAccountName(TestAccount.SQL); + const accountName = getAccountName(testAccount); + console.log(accountName); const account = await armClient.databaseAccounts.get(resourceGroupName, accountName); const clientOptions: CosmosClientOptions = { endpoint: account.documentEndpoint!, }; - const nosqlAccountRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN; + const nosqlAccountRbacToken = getRbacToken(testAccount); if (nosqlAccountRbacToken) { clientOptions.tokenProvider = async (): Promise => { const AUTH_PREFIX = `type=aad&ver=1.0&sig=`; @@ -252,3 +250,16 @@ export async function retry(fn: () => Promise, retries = 3, delayMs = 1000 } throw lastError; } + +function getRbacToken(accountType: TestAccount): string | undefined { + switch (accountType) { + case TestAccount.SQL: + return process.env.NOSQL_TESTACCOUNT_TOKEN; + case TestAccount.SQL2: + return process.env.NOSQL2_TESTACCOUNT_TOKEN; + case TestAccount.SQLContainerCopyOnly: + return process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN; + default: + return undefined; + } +}