Compare commits

...

3 Commits

Author SHA1 Message Date
Asier Isayas
43b407a190 nit 2026-01-21 07:29:53 -08:00
Asier Isayas
dd93b70a61 dont delete database 2026-01-21 06:51:26 -08:00
Asier Isayas
4270151e97 add second github sql account 2026-01-21 06:40:26 -08:00
10 changed files with 73 additions and 34 deletions

View File

@@ -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

View File

@@ -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, string> = {
[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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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 }) => {
@@ -22,9 +24,12 @@ test.describe("Computed Properties", () => {
await computedPropertiesTab.click();
});
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
}
test("Add valid computed property", async ({ page }) => {
await clearComputedPropertiesTextBoxContent({ page });

View File

@@ -19,7 +19,7 @@ test.describe("Settings under Scale & Settings", () => {
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
}

View File

@@ -7,16 +7,21 @@ 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 }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
});
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
}
test("Add, execute, and delete stored procedure", async ({ page }, testInfo) => {
void page;

View File

@@ -19,15 +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);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
});
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
}

View File

@@ -12,15 +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);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
});
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
}

View File

@@ -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<string> => {
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
@@ -155,20 +151,21 @@ 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);
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<string> => {
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
@@ -252,3 +249,16 @@ export async function retry<T>(fn: () => Promise<T>, 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;
}
}