Skip to content

Commit

Permalink
test: improve test case to inspect server connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Feb 24, 2025
1 parent 3ef7dd1 commit 015d8e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/testE2E/shared/awsClientBuilderV3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('AWSClientBuilderV3', function () {
const port = 3000
let server: http.Server
let requests: http.IncomingMessage[]
let activeConnections: number

before(function () {
server = http.createServer({ keepAlive: true }, (req, rsp) => {
Expand All @@ -23,10 +24,14 @@ describe('AWSClientBuilderV3', function () {
server.on('request', (req) => {
requests.push(req)
})
server.on('connection', (_req) => {
activeConnections++
})
})

beforeEach(function () {
requests = []
activeConnections = 0
})

after(function () {
Expand All @@ -42,11 +47,13 @@ describe('AWSClientBuilderV3', function () {
endpoint: `http://localhost:${port}`,
requestHandler: httpHandler,
})
assert.strictEqual(activeConnections, 0)
await client.send(new DescribeSessionsCommand({ State: 'Active' }))
assert.strictEqual(activeConnections, 1)
await client.send(new DescribeSessionsCommand({ State: 'Active' }))
assert.strictEqual(activeConnections, 1)

assert.strictEqual(requests[0].headers.connection, 'keep-alive')
assert.strictEqual(requests[1].headers.connection, 'keep-alive')
assert.strictEqual(server.connections, 1)
})
})

0 comments on commit 015d8e6

Please sign in to comment.