mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-13 16:07:26 +01:00
add second github sql account
This commit is contained in:
@@ -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)
|
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 "::add-mask::$NOSQL_TESTACCOUNT_TOKEN"
|
||||||
echo NOSQL_TESTACCOUNT_TOKEN=$NOSQL_TESTACCOUNT_TOKEN >> $GITHUB_ENV
|
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)
|
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 "::add-mask::$NOSQL_READONLY_TESTACCOUNT_TOKEN"
|
||||||
echo NOSQL_READONLY_TESTACCOUNT_TOKEN=$NOSQL_READONLY_TESTACCOUNT_TOKEN >> $GITHUB_ENV
|
echo NOSQL_READONLY_TESTACCOUNT_TOKEN=$NOSQL_READONLY_TESTACCOUNT_TOKEN >> $GITHUB_ENV
|
||||||
|
|||||||
+12
-1
@@ -39,6 +39,7 @@ export enum TestAccount {
|
|||||||
MongoReadonly = "MongoReadOnly",
|
MongoReadonly = "MongoReadOnly",
|
||||||
Mongo32 = "Mongo32",
|
Mongo32 = "Mongo32",
|
||||||
SQL = "SQL",
|
SQL = "SQL",
|
||||||
|
SQL2 = "SQL2",
|
||||||
SQLReadOnly = "SQLReadOnly",
|
SQLReadOnly = "SQLReadOnly",
|
||||||
SQLContainerCopyOnly = "SQLContainerCopyOnly",
|
SQLContainerCopyOnly = "SQLContainerCopyOnly",
|
||||||
}
|
}
|
||||||
@@ -51,6 +52,7 @@ export const defaultAccounts: Record<TestAccount, string> = {
|
|||||||
[TestAccount.MongoReadonly]: "github-e2etests-mongo-readonly",
|
[TestAccount.MongoReadonly]: "github-e2etests-mongo-readonly",
|
||||||
[TestAccount.Mongo32]: "github-e2etests-mongo32",
|
[TestAccount.Mongo32]: "github-e2etests-mongo32",
|
||||||
[TestAccount.SQL]: "github-e2etests-sql",
|
[TestAccount.SQL]: "github-e2etests-sql",
|
||||||
|
[TestAccount.SQL2]: "github-e2etests-sql-2",
|
||||||
[TestAccount.SQLReadOnly]: "github-e2etests-sql-readonly",
|
[TestAccount.SQLReadOnly]: "github-e2etests-sql-readonly",
|
||||||
[TestAccount.SQLContainerCopyOnly]: "github-e2etests-sql-containercopyonly",
|
[TestAccount.SQLContainerCopyOnly]: "github-e2etests-sql-containercopyonly",
|
||||||
};
|
};
|
||||||
@@ -72,6 +74,9 @@ function tryGetStandardName(accountType: TestAccount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getAccountName(accountType: TestAccount) {
|
export function getAccountName(accountType: TestAccount) {
|
||||||
|
if (accountType === TestAccount.SQL2 && !process.env.CI) {
|
||||||
|
accountType = TestAccount.SQL;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
process.env[`DE_TEST_ACCOUNT_NAME_${accountType.toLocaleUpperCase()}`] ??
|
process.env[`DE_TEST_ACCOUNT_NAME_${accountType.toLocaleUpperCase()}`] ??
|
||||||
tryGetStandardName(accountType) ??
|
tryGetStandardName(accountType) ??
|
||||||
@@ -101,6 +106,7 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes
|
|||||||
params.set("feature.enableCopilot", "false");
|
params.set("feature.enableCopilot", "false");
|
||||||
|
|
||||||
const nosqlRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN;
|
const nosqlRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN;
|
||||||
|
const nosql2RbacToken = process.env.NOSQL2_TESTACCOUNT_TOKEN;
|
||||||
const nosqlReadOnlyRbacToken = process.env.NOSQL_READONLY_TESTACCOUNT_TOKEN;
|
const nosqlReadOnlyRbacToken = process.env.NOSQL_READONLY_TESTACCOUNT_TOKEN;
|
||||||
const nosqlContainerCopyRbacToken = process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN;
|
const nosqlContainerCopyRbacToken = process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN;
|
||||||
const tableRbacToken = process.env.TABLE_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");
|
params.set("enableaaddataplane", "true");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TestAccount.SQL2:
|
||||||
|
if (nosql2RbacToken) {
|
||||||
|
params.set("nosql2RbacToken", nosql2RbacToken);
|
||||||
|
params.set("enableaaddataplane", "true");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case TestAccount.SQLContainerCopyOnly:
|
case TestAccount.SQLContainerCopyOnly:
|
||||||
if (nosqlContainerCopyRbacToken) {
|
if (nosqlContainerCopyRbacToken) {
|
||||||
params.set("nosqlRbacToken", nosqlContainerCopyRbacToken);
|
params.set("nosqlRbacToken", nosqlContainerCopyRbacToken);
|
||||||
|
|||||||
@@ -136,9 +136,7 @@ test.describe.serial("Upload Item", () => {
|
|||||||
if (existsSync(uploadDocumentDirPath)) {
|
if (existsSync(uploadDocumentDirPath)) {
|
||||||
rmdirSync(uploadDocumentDirPath);
|
rmdirSync(uploadDocumentDirPath);
|
||||||
}
|
}
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach("Close Upload Items panel if still open", async () => {
|
test.afterEach("Close Upload Items panel if still open", async () => {
|
||||||
|
|||||||
@@ -30,12 +30,9 @@ test.beforeEach("Open new query tab", async ({ page }) => {
|
|||||||
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete database only if not running in CI
|
test.afterAll("Delete Test Database", async () => {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
test.afterAll("Delete Test Database", async () => {
|
});
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Query results", async () => {
|
test("Query results", async () => {
|
||||||
// Run the query and verify the results
|
// Run the query and verify the results
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ test.describe("Change Partition Key", () => {
|
|||||||
let previousJobName: string | undefined;
|
let previousJobName: string | undefined;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer();
|
context = await createTestSQLContainer({
|
||||||
|
testAccount: TestAccount.SQL2,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open container settings", async ({ page }) => {
|
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
|
// Click Scale & Settings and open Partition Key tab
|
||||||
await explorer.openScaleAndSettings(context);
|
await explorer.openScaleAndSettings(context);
|
||||||
@@ -23,12 +25,9 @@ test.describe("Change Partition Key", () => {
|
|||||||
await PartitionKeyTab.click();
|
await PartitionKeyTab.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete database only if not running in CI
|
test.afterEach("Delete Test Database", async () => {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
test.afterEach("Delete Test Database", async () => {
|
});
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Change partition key path", async ({ page }) => {
|
test("Change partition key path", async ({ page }) => {
|
||||||
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
|
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ test.describe("Computed Properties", () => {
|
|||||||
let explorer: DataExplorer = null!;
|
let explorer: DataExplorer = null!;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
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 }) => {
|
test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => {
|
||||||
|
|||||||
@@ -118,7 +118,5 @@ async function openScaleTab(browser: Browser): Promise<SetupResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function cleanup({ context }: Partial<SetupResult>) {
|
async function cleanup({ context }: Partial<SetupResult>) {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,9 @@ test.describe("Settings under Scale & Settings", () => {
|
|||||||
await settingsTab.click();
|
await settingsTab.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete database only if not running in CI
|
test.afterAll("Delete Test Database", async () => {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
test.afterAll("Delete Test Database", async () => {
|
});
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Update TTL to On (no default)", async () => {
|
test("Update TTL to On (no default)", async () => {
|
||||||
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ test.describe("Stored Procedures", () => {
|
|||||||
let explorer: DataExplorer = null!;
|
let explorer: DataExplorer = null!;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer();
|
context = await createTestSQLContainer({
|
||||||
|
testAccount: TestAccount.SQL2,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open container", async ({ page }) => {
|
test.beforeEach("Open container", async ({ page }) => {
|
||||||
|
|||||||
@@ -19,18 +19,18 @@ test.describe("Triggers", () => {
|
|||||||
request.setBody(itemToCreate);
|
request.setBody(itemToCreate);
|
||||||
}`;
|
}`;
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer();
|
context = await createTestSQLContainer({
|
||||||
|
testAccount: TestAccount.SQL2,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open container", async ({ page }) => {
|
test.beforeEach("Open container", async ({ page }) => {
|
||||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!process.env.CI) {
|
test.afterAll("Delete Test Database", async () => {
|
||||||
test.afterAll("Delete Test Database", async () => {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Add and delete trigger", async ({ page }, testInfo) => {
|
test("Add and delete trigger", async ({ page }, testInfo) => {
|
||||||
// Open container context menu and click New Trigger
|
// Open container context menu and click New Trigger
|
||||||
|
|||||||
@@ -12,18 +12,18 @@ test.describe("User Defined Functions", () => {
|
|||||||
}`;
|
}`;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer();
|
context = await createTestSQLContainer({
|
||||||
|
testAccount: TestAccount.SQL2,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open container", async ({ page }) => {
|
test.beforeEach("Open container", async ({ page }) => {
|
||||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!process.env.CI) {
|
test.afterAll("Delete Test Database", async () => {
|
||||||
test.afterAll("Delete Test Database", async () => {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Add, execute, and delete user defined function", async ({ page }, testInfo) => {
|
test("Add, execute, and delete user defined function", async ({ page }, testInfo) => {
|
||||||
// Open container context menu and click New UDF
|
// Open container context menu and click New UDF
|
||||||
|
|||||||
+20
-9
@@ -86,13 +86,14 @@ type createTestSqlContainerConfig = {
|
|||||||
includeTestData?: boolean;
|
includeTestData?: boolean;
|
||||||
partitionKey?: string;
|
partitionKey?: string;
|
||||||
databaseName?: string;
|
databaseName?: string;
|
||||||
|
testAccount?: TestAccount;
|
||||||
};
|
};
|
||||||
|
|
||||||
type createMultipleTestSqlContainerConfig = {
|
type createMultipleTestSqlContainerConfig = {
|
||||||
containerCount?: number;
|
containerCount?: number;
|
||||||
partitionKey?: string;
|
partitionKey?: string;
|
||||||
databaseName?: string;
|
databaseName?: string;
|
||||||
accountType: TestAccount.SQLContainerCopyOnly | TestAccount.SQL;
|
accountType: TestAccount.SQLContainerCopyOnly | TestAccount.SQL | TestAccount.SQL2;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function createMultipleTestContainers({
|
export async function createMultipleTestContainers({
|
||||||
@@ -114,12 +115,7 @@ export async function createMultipleTestContainers({
|
|||||||
endpoint: account.documentEndpoint!,
|
endpoint: account.documentEndpoint!,
|
||||||
};
|
};
|
||||||
|
|
||||||
const rbacToken =
|
const rbacToken = getRbacToken(accountType);
|
||||||
accountType === TestAccount.SQL
|
|
||||||
? process.env.NOSQL_TESTACCOUNT_TOKEN
|
|
||||||
: accountType === TestAccount.SQLContainerCopyOnly
|
|
||||||
? process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN
|
|
||||||
: "";
|
|
||||||
if (rbacToken) {
|
if (rbacToken) {
|
||||||
clientOptions.tokenProvider = async (): Promise<string> => {
|
clientOptions.tokenProvider = async (): Promise<string> => {
|
||||||
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
||||||
@@ -155,20 +151,22 @@ export async function createTestSQLContainer({
|
|||||||
includeTestData = false,
|
includeTestData = false,
|
||||||
partitionKey = "/partitionKey",
|
partitionKey = "/partitionKey",
|
||||||
databaseName = "",
|
databaseName = "",
|
||||||
|
testAccount = TestAccount.SQL,
|
||||||
}: createTestSqlContainerConfig = {}) {
|
}: createTestSqlContainerConfig = {}) {
|
||||||
const databaseId = databaseName ? databaseName : generateUniqueName("db");
|
const databaseId = databaseName ? databaseName : generateUniqueName("db");
|
||||||
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
|
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
|
||||||
const credentials = getAzureCLICredentials();
|
const credentials = getAzureCLICredentials();
|
||||||
const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials);
|
const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials);
|
||||||
const armClient = new CosmosDBManagementClient(adaptedCredentials, subscriptionId);
|
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 account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||||
|
|
||||||
const clientOptions: CosmosClientOptions = {
|
const clientOptions: CosmosClientOptions = {
|
||||||
endpoint: account.documentEndpoint!,
|
endpoint: account.documentEndpoint!,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nosqlAccountRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN;
|
const nosqlAccountRbacToken = getRbacToken(testAccount);
|
||||||
if (nosqlAccountRbacToken) {
|
if (nosqlAccountRbacToken) {
|
||||||
clientOptions.tokenProvider = async (): Promise<string> => {
|
clientOptions.tokenProvider = async (): Promise<string> => {
|
||||||
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
||||||
@@ -252,3 +250,16 @@ export async function retry<T>(fn: () => Promise<T>, retries = 3, delayMs = 1000
|
|||||||
}
|
}
|
||||||
throw lastError;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user