mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-28 08:26:57 +00:00
Fix Test Database Cleanup Script (#497)
This commit is contained in:
parent
69975cd0e8
commit
45af1d7cf9
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -167,7 +167,6 @@ jobs:
|
|||||||
test-file:
|
test-file:
|
||||||
- ./test/cassandra/container.spec.ts
|
- ./test/cassandra/container.spec.ts
|
||||||
- ./test/mongo/mongoIndexPolicy.spec.ts
|
- ./test/mongo/mongoIndexPolicy.spec.ts
|
||||||
- ./test/mongo/openMongoAccount.spec.ts
|
|
||||||
- ./test/notebooks/uploadAndOpenNotebook.spec.ts
|
- ./test/notebooks/uploadAndOpenNotebook.spec.ts
|
||||||
- ./test/selfServe/selfServeExample.spec.ts
|
- ./test/selfServe/selfServeExample.spec.ts
|
||||||
- ./test/sql/container.spec.ts
|
- ./test/sql/container.spec.ts
|
||||||
|
26359
package-lock.json
generated
26359
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
|||||||
import { Frame } from "puppeteer";
|
|
||||||
import { ApiKind } from "../../src/Contracts/DataModels";
|
|
||||||
import { getTestExplorerFrame } from "../testExplorer/TestExplorerUtils";
|
|
||||||
|
|
||||||
jest.setTimeout(300000);
|
|
||||||
|
|
||||||
let frame: Frame;
|
|
||||||
|
|
||||||
describe("Mongo", () => {
|
|
||||||
it("Account opens", async () => {
|
|
||||||
try {
|
|
||||||
frame = await getTestExplorerFrame(ApiKind.MongoDB);
|
|
||||||
await frame.waitForSelector(".accordion");
|
|
||||||
} catch (error) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
const testName = (expect as any).getState().currentTestName;
|
|
||||||
await page.screenshot({ path: `failed-${testName}.jpg` });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
@ -20,23 +20,23 @@ async function main() {
|
|||||||
if (account.kind === "MongoDB") {
|
if (account.kind === "MongoDB") {
|
||||||
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
||||||
for (const database of mongoDatabases) {
|
for (const database of mongoDatabases) {
|
||||||
const timestamp = database.name.split("-")[1];
|
const timestamp = Number(database.name.split("-")[1]);
|
||||||
if (!timestamp || Number(timestamp) < twentyMinutesAgo) {
|
if (timestamp || timestamp < twentyMinutesAgo) {
|
||||||
await client.mongoDBResources.deleteMongoDBDatabase(resourceGroupName, account.name, database.name);
|
await client.mongoDBResources.deleteMongoDBDatabase(resourceGroupName, account.name, database.name);
|
||||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - Number(timestamp))}`);
|
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - Number(timestamp))}`);
|
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (account.kind === "GlobalDocumentDB") {
|
} else if (account.kind === "GlobalDocumentDB") {
|
||||||
const sqlDatabases = await client.sqlResources.listSqlDatabases(resourceGroupName, account.name);
|
const sqlDatabases = await client.sqlResources.listSqlDatabases(resourceGroupName, account.name);
|
||||||
for (const database of sqlDatabases) {
|
for (const database of sqlDatabases) {
|
||||||
const timestamp = database.name.split("-")[1];
|
const timestamp = Number(database.name.split("-")[1]);
|
||||||
if (!timestamp || Number(timestamp) < twentyMinutesAgo) {
|
if (timestamp || timestamp < twentyMinutesAgo) {
|
||||||
await client.sqlResources.deleteSqlDatabase(resourceGroupName, account.name, database.name);
|
await client.sqlResources.deleteSqlDatabase(resourceGroupName, account.name, database.name);
|
||||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - Number(timestamp))}`);
|
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - Number(timestamp))}`);
|
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,6 +49,7 @@ main()
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.log(err);
|
||||||
process.exit(1);
|
console.log("Cleanup failed! Exiting with success. Cleanup should always fail safe.");
|
||||||
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user