Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: queue retention time in spec test is too short #4287

Merged
merged 7 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}));
MarkMcCulloh marked this conversation as resolved.
Show resolved Hide resolved
}
}, 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
Loading