@@ -18,29 +18,33 @@ describe('test query timeout', () => {
18
18
await pgMeta . query ( 'DROP TABLE timeout_test;' )
19
19
} )
20
20
21
- test ( 'query timeout after 5s and connection cleanup' , async ( ) => {
22
- const query = `SELECT pg_sleep(10);`
23
- // Execute a query that will sleep for 10 seconds
24
- const res = await app . inject ( {
25
- method : 'POST' ,
26
- path : '/query' ,
27
- payload : {
28
- query,
29
- } ,
30
- } )
21
+ test (
22
+ 'query timeout after 3s and connection cleanup' ,
23
+ async ( ) => {
24
+ const query = `SELECT pg_sleep(10);`
25
+ // Execute a query that will sleep for 10 seconds
26
+ const res = await app . inject ( {
27
+ method : 'POST' ,
28
+ path : '/query' ,
29
+ payload : {
30
+ query,
31
+ } ,
32
+ } )
31
33
32
- // Check that we get the proper timeout error response
33
- expect ( res . statusCode ) . toBe ( 408 ) // Request Timeout
34
- expect ( res . json ( ) ) . toMatchObject ( {
35
- error : expect . stringContaining ( 'Query read timeout' ) ,
36
- } )
34
+ // Check that we get the proper timeout error response
35
+ expect ( res . statusCode ) . toBe ( 408 ) // Request Timeout
36
+ expect ( res . json ( ) ) . toMatchObject ( {
37
+ error : expect . stringContaining ( 'Query read timeout' ) ,
38
+ } )
37
39
38
- // Verify that the connection has been cleaned up by checking active connections
39
- const connectionsRes = await pgMeta . query ( `
40
+ // Verify that the connection has been cleaned up by checking active connections
41
+ const connectionsRes = await pgMeta . query ( `
40
42
SELECT * FROM pg_stat_activity where application_name = 'postgres-meta 0.0.0-automated' and query ILIKE '%${ query } %';
41
43
` )
42
44
43
- // Should have no active connections except for our current query
44
- expect ( connectionsRes . data ) . toHaveLength ( 0 )
45
- } )
45
+ // Should have no active connections except for our current query
46
+ expect ( connectionsRes . data ) . toHaveLength ( 0 )
47
+ } ,
48
+ { timeout : 5000 }
49
+ )
46
50
} )
0 commit comments