Skip to content

Commit 888e503

Browse files
authored
Try to mitigate random crashes in the tests (#428)
* Try to mitigate random crashes in the tests * Use a delay * Removed debug code * Increase the number of test
1 parent 9f47296 commit 888e503

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tests/Integration/LambdaClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public function testInvokeWait(): void
6767

6868
$results = [];
6969
$expected = [];
70-
for ($i = 0; $i < 10; ++$i) {
70+
for ($i = 0; $i < 27; ++$i) {
7171
$expected[] = '"hello ' . $i . '"';
7272
$results[] = $client->Invoke(new InvocationRequest([
7373
'FunctionName' => 'Index',
74-
'Payload' => \json_encode(['name' => $i]),
74+
'Payload' => \json_encode(['name' => $i, 'delay' => 80 * ($i % 3)]),
7575
]));
7676
}
7777

tests/fixtures/lambda/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
exports.handler = async (event) => {
2-
return `hello ${event.name}`;
2+
function wait(event){
3+
return new Promise((resolve, reject) => {
4+
setTimeout(() => resolve(`hello ${event.name}`), event.delay)
5+
});
6+
}
7+
8+
if (typeof(event.delay) === "undefined" || event.delay < 1) {
9+
event.delay = 1;
10+
}
11+
12+
return wait(event);
313
};

0 commit comments

Comments
 (0)