Skip to content

Commit

Permalink
temp: run connection reuse test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Feb 24, 2025
1 parent f44f714 commit e90e255
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/core/src/test/shared/awsClientBuilderV3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
import sinon from 'sinon'
import assert from 'assert'
import http from 'http'
import { version } from 'vscode'
import { getClientId } from '../../shared/telemetry/util'
import { FakeMemento } from '../fakeExtensionContext'
Expand Down Expand Up @@ -32,6 +33,7 @@ import { Credentials, MetadataBearer, MiddlewareStack } from '@aws-sdk/types'
import { oneDay } from '../../shared/datetime'
import { ConfiguredRetryStrategy } from '@smithy/util-retry'
import { StandardRetryStrategy } from '@smithy/util-retry'
import { DescribeSessionsCommand, SSMClient } from '@aws-sdk/client-ssm'

describe('AwsClientBuilderV3', function () {
let builder: AWSClientBuilderV3
Expand Down Expand Up @@ -318,6 +320,38 @@ describe('recordErrorTelemetry', function () {
})
})

describe('connection reuse', function () {
it('reuses connections', async function () {
const port = 3000
const server = http.createServer((req, rsp) => {
rsp.writeHead(200, { 'Content-Type': 'application/json' })
rsp.end(JSON.stringify({ message: 'success' }))
})
try {
server.listen(port, () => {})
const config = {
region: 'us-east-1',
endpoint: `http://localhost:${port}`,
// requestHandler: new NodeHttpHandler({
// httpAgent: new Agent({ keepAlive: true }),
// }),
}
const client = new SSMClient(config)
const requests: http.IncomingMessage[] = []
server.on('request', (req) => {
requests.push(req)
})
await client.send(new DescribeSessionsCommand({ State: 'Active' }))
await client.send(new DescribeSessionsCommand({ State: 'Active' }))

assert.strictEqual(requests[0].headers.connection, 'keep-alive')
assert.strictEqual(requests.length, 1)
} finally {
server.close()
}
})
})

class MockCredentialsShim implements CredentialsShim {
public constructor(
public credentials: Credentials,
Expand Down

0 comments on commit e90e255

Please sign in to comment.