Skip to content

Commit 8ff7e5a

Browse files
committed
test(sagemaker): add HyperPod integration tests and WriteQueue unit test
Integration tests cover: - Deeplink connection flow (prepare → launch IDE) - Side panel (LC) connection flow - Space lifecycle (start/stop/connect-to-stopped) - Server routes with real HTTP (/get_hyperpod_session, /get_hyperpod_session_async) - Multi-IDE support (VS Code, Cursor, Kiro) Unit test added for WriteQueue sequential write serialization.
1 parent 3aa0591 commit 8ff7e5a

2 files changed

Lines changed: 566 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import assert from 'assert'
7+
import { WriteQueue } from '../../../../awsService/sagemaker/detached-server/writeQueue'
8+
9+
describe('WriteQueue', function () {
10+
it('processes operations sequentially', async function () {
11+
const queue = new WriteQueue()
12+
const order: number[] = []
13+
14+
queue.push(async () => {
15+
await new Promise((r) => setTimeout(r, 10))
16+
order.push(1)
17+
})
18+
queue.push(async () => {
19+
order.push(2)
20+
})
21+
queue.push(async () => {
22+
order.push(3)
23+
})
24+
25+
await queue.process()
26+
27+
assert.deepStrictEqual(order, [1, 2, 3])
28+
})
29+
30+
it('concurrent process() calls do not duplicate work', async function () {
31+
const queue = new WriteQueue()
32+
let count = 0
33+
34+
queue.push(async () => {
35+
await new Promise((r) => setTimeout(r, 10))
36+
count++
37+
})
38+
39+
// Call process twice simultaneously
40+
await Promise.all([queue.process(), queue.process()])
41+
42+
assert.strictEqual(count, 1)
43+
})
44+
45+
it('can enqueue after previous batch completes', async function () {
46+
const queue = new WriteQueue()
47+
const results: string[] = []
48+
49+
queue.push(async () => {
50+
results.push('first')
51+
})
52+
await queue.process()
53+
54+
queue.push(async () => {
55+
results.push('second')
56+
})
57+
await queue.process()
58+
59+
assert.deepStrictEqual(results, ['first', 'second'])
60+
})
61+
})

0 commit comments

Comments
 (0)