Skip to content

Commit

Permalink
Ensure JavaScript Ice/ami test awaits all requests - Fix #3130 (#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone authored Nov 12, 2024
1 parent c7a7cc7 commit 4a8cd91
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions js/test/Ice/ami/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,29 +159,29 @@ export class Client extends TestHelper {
// Safari WebSocket implementation accepts lots of data before apply back-pressure
// making this test very slow.
await testController.holdAdapter();
const requests: Ice.AsyncResult<void>[] = [];
try {
r1 = p.op();
const seq = new Uint8Array(100000);
while (true) {
r2 = p.opWithPayload(seq);
requests.push(r2);
if (r2.sentSynchronously()) {
await Ice.Promise.delay(0);
} else {
break;
}
}

if ((await p.ice_getConnection()) !== null) {
test(
(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted()) ||
(!r1.sentSynchronously() && !r1.isCompleted()),
);
test(
(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted()) ||
(!r1.sentSynchronously() && !r1.isCompleted()),
);

test(!r2.sentSynchronously() && !r2.isCompleted());
test(!r2.sentSynchronously() && !r2.isCompleted());

test(!r1.isCompleted());
test(!r2.isCompleted());
}
test(!r1.isCompleted());
test(!r2.isCompleted());
} finally {
await testController.resumeAdapter();
}
Expand All @@ -194,6 +194,8 @@ export class Client extends TestHelper {
test(r2.isSent());
test(r2.isCompleted());

await Promise.all(requests);

test(r1.operation == "op");
test(r2.operation == "opWithPayload");
}
Expand Down Expand Up @@ -243,8 +245,10 @@ export class Client extends TestHelper {
await testController.holdAdapter();
const seq = new Uint8Array(new Array(100000));
let r;
let requests: Ice.AsyncResult<void>[] = [];
while (true) {
r = p.opWithPayload(seq);
requests.push(r);
if (r.sentSynchronously()) {
await Ice.Promise.delay(0);
} else {
Expand All @@ -270,7 +274,7 @@ export class Client extends TestHelper {
r2.cancel();

await testController.resumeAdapter();
await r;
await Promise.all(requests);

test(!r1.isSent() && r1.isCompleted());
test(!r2.isSent() && r2.isCompleted());
Expand Down

0 comments on commit 4a8cd91

Please sign in to comment.