mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-19 11:47:31 +01:00
dependabot security alerts + delete containers after each migration e2e test (#2384)
* dependabot security alerts + delete containers after each migration e2e test * catch error --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com>
This commit is contained in:
@@ -9,9 +9,10 @@ import {
|
||||
TestAccount,
|
||||
waitForApiResponse,
|
||||
} from "../../fx";
|
||||
import { createMultipleTestContainers } from "../../testData";
|
||||
import { createMultipleTestContainers, TestContainerContext } from "../../testData";
|
||||
|
||||
test.describe("Container Copy - Offline Migration", () => {
|
||||
let contexts: TestContainerContext[];
|
||||
let page: Page;
|
||||
let wrapper: Locator;
|
||||
let panel: Locator;
|
||||
@@ -22,7 +23,7 @@ test.describe("Container Copy - Offline Migration", () => {
|
||||
let expectedCopyJobNameInitial: string;
|
||||
|
||||
test.beforeEach("Setup for offline migration test", async ({ browser }) => {
|
||||
await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
|
||||
contexts = await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
|
||||
|
||||
page = await browser.newPage();
|
||||
({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
|
||||
@@ -33,6 +34,7 @@ test.describe("Container Copy - Offline Migration", () => {
|
||||
test.afterEach("Cleanup after offline migration test", async () => {
|
||||
await page.unroute(/.*/, (route) => route.continue());
|
||||
await page.close();
|
||||
await Promise.all(contexts.map((context) => context?.dispose()));
|
||||
});
|
||||
|
||||
test("Successfully create and manage offline migration copy job", async () => {
|
||||
|
||||
@@ -7,9 +7,10 @@ import {
|
||||
TestAccount,
|
||||
waitForApiResponse,
|
||||
} from "../../fx";
|
||||
import { createMultipleTestContainers } from "../../testData";
|
||||
import { createMultipleTestContainers, TestContainerContext } from "../../testData";
|
||||
|
||||
test.describe("Container Copy - Online Migration", () => {
|
||||
let contexts: TestContainerContext[];
|
||||
let page: Page;
|
||||
let wrapper: Locator;
|
||||
let panel: Locator;
|
||||
@@ -17,7 +18,7 @@ test.describe("Container Copy - Online Migration", () => {
|
||||
let targetAccountName: string;
|
||||
|
||||
test.beforeEach("Setup for online migration test", async ({ browser }) => {
|
||||
await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
|
||||
contexts = await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
|
||||
|
||||
page = await browser.newPage();
|
||||
({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
|
||||
@@ -27,6 +28,7 @@ test.describe("Container Copy - Online Migration", () => {
|
||||
test.afterEach("Cleanup after online migration test", async () => {
|
||||
await page.unroute(/.*/, (route) => route.continue());
|
||||
await page.close();
|
||||
await Promise.all(contexts.map((context) => context?.dispose()));
|
||||
});
|
||||
|
||||
test("Successfully create and manage online migration copy job", async () => {
|
||||
|
||||
+17
-2
@@ -1,5 +1,13 @@
|
||||
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||
import { BulkOperationType, Container, CosmosClient, CosmosClientOptions, Database, JSONObject } from "@azure/cosmos";
|
||||
import {
|
||||
BulkOperationType,
|
||||
Container,
|
||||
CosmosClient,
|
||||
CosmosClientOptions,
|
||||
Database,
|
||||
ErrorResponse,
|
||||
JSONObject,
|
||||
} from "@azure/cosmos";
|
||||
import { Buffer } from "node:buffer";
|
||||
import { webcrypto } from "node:crypto";
|
||||
import {
|
||||
@@ -78,7 +86,14 @@ export class TestContainerContext {
|
||||
) {}
|
||||
|
||||
async dispose() {
|
||||
await this.database.delete();
|
||||
try {
|
||||
await this.database.delete();
|
||||
} catch (error) {
|
||||
if (error instanceof ErrorResponse && error.code === 404) {
|
||||
return; // Resource already deleted, ignore
|
||||
}
|
||||
throw error; // Re-throw other errors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user