@@ -210,6 +210,51 @@ describe("gateway concurrency benchmark script", () => {
210210 }
211211 } ) ;
212212
213+ it ( "reuses one connection for sequential successful HTTP samples" , async ( ) => {
214+ let connectionCount = 0 ;
215+ const server = createHttpServer ( ( request , response ) => {
216+ response . setHeader (
217+ "content-type" ,
218+ request . url === "/readyz" ? "application/json" : "text/html" ,
219+ ) ;
220+ response . end ( request . url === "/readyz" ? '{"status":"ok"}' : "<html></html>" ) ;
221+ } ) ;
222+ server . on ( "connection" , ( ) => {
223+ connectionCount += 1 ;
224+ } ) ;
225+ await new Promise < void > ( ( resolve , reject ) => {
226+ server . once ( "error" , reject ) ;
227+ server . listen ( 0 , "127.0.0.1" , resolve ) ;
228+ } ) ;
229+ try {
230+ const address = server . address ( ) ;
231+ if ( ! address || typeof address === "string" ) {
232+ throw new Error ( "expected HTTP test server address" ) ;
233+ }
234+ const deadlineAt = performance . now ( ) + 5_000 ;
235+
236+ await testing . requestHttp ( {
237+ accept : "application/json" ,
238+ deadlineAt,
239+ path : "/readyz" ,
240+ port : address . port ,
241+ } ) ;
242+ await testing . requestHttp ( {
243+ accept : "text/html" ,
244+ deadlineAt,
245+ path : "/" ,
246+ port : address . port ,
247+ } ) ;
248+
249+ expect ( connectionCount ) . toBe ( 1 ) ;
250+ } finally {
251+ server . closeAllConnections ( ) ;
252+ await new Promise < void > ( ( resolve , reject ) => {
253+ server . close ( ( error ) => ( error ? reject ( error ) : resolve ( ) ) ) ;
254+ } ) ;
255+ }
256+ } ) ;
257+
213258 it ( "loads through native Node TypeScript stripping" , ( ) => {
214259 const result = spawnSync ( process . execPath , [ "scripts/bench-gateway-concurrency.ts" , "--help" ] , {
215260 cwd : process . cwd ( ) ,
0 commit comments