diff --git a/examples/tests/sdk_tests/queue/retention_period.main.w b/examples/tests/sdk_tests/queue/retention_period.main.w index 25dc96987f6..0c1c2dd798a 100644 --- a/examples/tests/sdk_tests/queue/retention_period.main.w +++ b/examples/tests/sdk_tests/queue/retention_period.main.w @@ -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"; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_compile_tf-aws.md index 274cd0395c2..70c4224a730 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_compile_tf-aws.md @@ -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); @@ -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)); } @@ -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 } } } @@ -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"))}, }) `; @@ -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); diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_test_sim.md index 0a9fc70e6ee..a46202c468b 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/retention_period.main.w_test_sim.md @@ -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)