mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
chore(ci): release database after closed (#4819)
* chore(ci): release database after closed * chore: clean database * chore: test
This commit is contained in:
parent
88519c9c8f
commit
7084e8d35f
2
.github/workflows/nocobase-test-backend.yml
vendored
2
.github/workflows/nocobase-test-backend.yml
vendored
@ -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:
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user