Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(control-api): close the administrative pool in a guaranteed finally

Alfredo Lopez3ac6836f9682
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index aa6d7ce06..6094a5ab6 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.718",
+ "version": "0.1.719",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.718",
+ "version": "0.1.719",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --git a/control-api/package.json b/control-api/package.json
index ad822f2bb..c12af00a3 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.718",
+ "version": "0.1.719",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/llmProviderAttemptAuthorizer.cancellation.realPostgres.integration.test.ts b/control-api/test/llmProviderAttemptAuthorizer.cancellation.realPostgres.integration.test.ts
index 1db5d7fd5..41df0e9f8 100644
--- a/control-api/test/llmProviderAttemptAuthorizer.cancellation.realPostgres.integration.test.ts
+++ b/control-api/test/llmProviderAttemptAuthorizer.cancellation.realPostgres.integration.test.ts
@@ -87,11 +87,12 @@ realPostgres('scoped transaction cancellation mechanism and durable outcome', ()
}, 60_000)
afterAll(async () => {
- await endPoolAndWaitForClients(pool)
- await endPoolAndWaitForClients(observer)
- if (admin) {
- await admin.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await endPoolAndWaitForClients(admin)
+ try {
+ await endPoolAndWaitForClients(pool)
+ await endPoolAndWaitForClients(observer)
+ if (admin) await admin.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await admin?.end()
}
})
diff --git a/control-api/test/services.llmProviderAttemptAuthorization.realPostgres.integration.test.ts b/control-api/test/services.llmProviderAttemptAuthorization.realPostgres.integration.test.ts
index 4db9ef17f..5b14e80d3 100644
--- a/control-api/test/services.llmProviderAttemptAuthorization.realPostgres.integration.test.ts
+++ b/control-api/test/services.llmProviderAttemptAuthorization.realPostgres.integration.test.ts
@@ -1,4 +1,4 @@
-import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import * as k8s from '@kubernetes/client-node'
import { randomBytes, randomUUID } from 'node:crypto'
import { once } from 'node:events'
@@ -927,7 +927,6 @@ describeRealPostgres('Codex provider-attempt authorization on real PostgreSQL',
}
beforeAll(async () => {
- config.grokSubscriptionEnabled = true
const created = await insertInitialGrokSubscriptionConnection(
pool,
KEY,
@@ -949,7 +948,13 @@ describeRealPostgres('Codex provider-attempt authorization on real PostgreSQL',
)
})
- afterAll(() => {
+ // Per-test flag and tap state: the file's only afterAll owns the
+ // administrative pool close (realPostgresAdminCleanup.guard.test.ts).
+ beforeEach(() => {
+ config.grokSubscriptionEnabled = true
+ })
+
+ afterEach(() => {
config.grokSubscriptionEnabled = previousGrokFlag
grokTicketTap.afterIssue = null
})