Skip to content

Commit

Permalink
chore: queue retention time in spec test is too short (#4287)
Browse files Browse the repository at this point in the history
Looks like the minimum is 60 seconds

See https://github.com/winglang/wing/actions/runs/6314317373/job/17144314958

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
MarkMcCulloh authored Sep 27, 2023
1 parent d6fb4d0 commit 3a84b1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
10 changes: 6 additions & 4 deletions examples/tests/sdk_tests/queue/retention_period.main.w
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
bring cloud;
bring util;

let var timeout = 100ms;
let var retentionPeriod = 1s;
let var timeout = 30s;
let var retentionPeriod = 60s;

let q = new cloud.Queue(timeout: timeout, retentionPeriod: retentionPeriod);

test "retentionPeriod" {
new std.Test(inflight () => {
q.push("hello", "world");

util.sleep(retentionPeriod);

assert(util.waitUntil(() => {
return q.approxSize() == 0;
}));
}
}, timeout: 2m) as "retentionPeriod";
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## inflight.$Closure1-1.js
```js
module.exports = function({ $q, $util_Util }) {
module.exports = function({ $q, $retentionPeriod, $util_Util }) {
class $Closure1 {
constructor({ }) {
const $obj = (...args) => this.handle(...args);
Expand All @@ -11,6 +11,7 @@ module.exports = function({ $q, $util_Util }) {
}
async handle() {
(await $q.push("hello","world"));
(await $util_Util.sleep($retentionPeriod));
{((cond) => {if (!cond) throw new Error("assertion failed: util.waitUntil(() => {\n return q.approxSize() == 0;\n })")})((await $util_Util.waitUntil(async () => {
return (((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await $q.approxSize()),0));
}
Expand Down Expand Up @@ -60,9 +61,9 @@ module.exports = function({ $q, $util_Util }) {
"uniqueId": "cloudQueue"
}
},
"message_retention_seconds": 1,
"message_retention_seconds": 60,
"name": "cloud-Queue-c86e03d8",
"visibility_timeout_seconds": 0.1
"visibility_timeout_seconds": 30
}
}
}
Expand Down Expand Up @@ -90,6 +91,7 @@ class $Root extends $stdlib.std.Resource {
return `
require("./inflight.$Closure1-1.js")({
$q: ${context._lift(q)},
$retentionPeriod: ${context._lift(retentionPeriod)},
$util_Util: ${context._lift($stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"))},
})
`;
Expand All @@ -111,14 +113,15 @@ class $Root extends $stdlib.std.Resource {
_registerBind(host, ops) {
if (ops.includes("handle")) {
$Closure1._registerBindObject(q, host, ["approxSize", "push"]);
$Closure1._registerBindObject(retentionPeriod, host, []);
}
super._registerBind(host, ops);
}
}
let timeout = (std.Duration.fromSeconds(0.1));
let retentionPeriod = (std.Duration.fromSeconds(1));
let timeout = (std.Duration.fromSeconds(30));
let retentionPeriod = (std.Duration.fromSeconds(60));
const q = this.node.root.newAbstract("@winglang/sdk.cloud.Queue",this,"cloud.Queue",{ timeout: timeout, retentionPeriod: retentionPeriod });
this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:retentionPeriod",new $Closure1(this,"$Closure1"));
this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"retentionPeriod",new $Closure1(this,"$Closure1"),{ timeout: (std.Duration.fromSeconds(120)) });
}
}
const $App = $stdlib.core.App.for(process.env.WING_TARGET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## stdout.log
```log
pass ─ retention_period.main.wsim » root/env0/test:retentionPeriod
pass ─ retention_period.main.wsim » root/env0/retentionPeriod
Tests 1 passed (1)
Expand Down

0 comments on commit 3a84b1c

Please sign in to comment.