chore(ci): release database after closed (#4819)
Some checks are pending
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase Backend Test / sqlite-test (20, false) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, false) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, true) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, false) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, true) (push) Waiting to run
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run

* chore(ci): release database after closed

* chore: clean database

* chore: test
This commit is contained in:
ChengLei Shao 2024-07-04 21:48:51 +08:00 committed by GitHub
parent 88519c9c8f
commit 7084e8d35f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -111,7 +111,7 @@ jobs:
DB_SCHEMA: ${{ matrix.schema }}
COLLECTION_MANAGER_SCHEMA: ${{ matrix.collection_schema }}
DB_TEST_DISTRIBUTOR_PORT: 23450
DB_TEST_PREFIX: test_
DB_TEST_PREFIX: test
timeout-minutes: 60
mysql-test:

View File

@ -36,6 +36,11 @@ abstract class BaseClient<Client> {
await this._createDB(name);
this.createdDBs.add(name);
// remove db after 3 minutes
setTimeout(async () => {
await this.removeDB(name);
}, 3 * 60 * 1000);
}
async releaseAll() {
@ -51,6 +56,16 @@ abstract class BaseClient<Client> {
this.createdDBs.delete(name);
}
}
async removeDB(name: string) {
if (!this._client) {
return;
}
if (this.createdDBs.has(name)) {
await this._removeDB(name);
this.createdDBs.delete(name);
}
}
}
class PostgresClient extends BaseClient<pg.Client> {
@ -156,8 +171,9 @@ const server = http.createServer((req, res) => {
res.end(JSON.stringify({ error }));
});
} else if (trimmedPath === 'release') {
const name = parsedUrl.query.name as string | undefined;
dbClient
.releaseAll()
.removeDB(name)
.then(() => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end();