rivetkit 2.1.5 → 2.1.6-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.d.ts +593 -588
- package/dist/browser/client.js +215 -35
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +109 -10
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/inspector.tar.gz +0 -0
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/{actor-router-consts-D29T1Z-K.d.cts → actor-router-consts-DU-1IdQj.d.cts} +1 -1
- package/dist/tsup/{actor-router-consts-D29T1Z-K.d.ts → actor-router-consts-DU-1IdQj.d.ts} +1 -1
- package/dist/tsup/chunk-2ELYUO6C.cjs +112 -0
- package/dist/tsup/chunk-2ELYUO6C.cjs.map +1 -0
- package/dist/tsup/chunk-2LY7RW3Y.cjs +2316 -0
- package/dist/tsup/chunk-2LY7RW3Y.cjs.map +1 -0
- package/dist/tsup/{chunk-L47L3ZWJ.cjs → chunk-6G7ZNM27.cjs} +11 -6
- package/dist/tsup/chunk-6G7ZNM27.cjs.map +1 -0
- package/dist/tsup/{chunk-PB5AEMKQ.cjs → chunk-A4KEUCB6.cjs} +84 -34
- package/dist/tsup/chunk-A4KEUCB6.cjs.map +1 -0
- package/dist/tsup/{chunk-7HTNH26M.js → chunk-AKUJ5OTO.js} +11 -6
- package/dist/tsup/chunk-AKUJ5OTO.js.map +1 -0
- package/dist/tsup/{chunk-TADUYCHF.js → chunk-C22JYHVT.js} +77 -27
- package/dist/tsup/chunk-C22JYHVT.js.map +1 -0
- package/dist/tsup/chunk-C4EB42ET.js +1459 -0
- package/dist/tsup/chunk-C4EB42ET.js.map +1 -0
- package/dist/tsup/chunk-CGGGBIDP.cjs +1459 -0
- package/dist/tsup/chunk-CGGGBIDP.cjs.map +1 -0
- package/dist/tsup/chunk-CMQPDBBR.cjs +1486 -0
- package/dist/tsup/chunk-CMQPDBBR.cjs.map +1 -0
- package/dist/tsup/{chunk-GQGRQDRL.cjs → chunk-DH6UINWA.cjs} +4 -4
- package/dist/tsup/{chunk-GQGRQDRL.cjs.map → chunk-DH6UINWA.cjs.map} +1 -1
- package/dist/tsup/chunk-DK46YYCJ.js +1486 -0
- package/dist/tsup/chunk-DK46YYCJ.js.map +1 -0
- package/dist/tsup/chunk-EGWXXBZV.js +2316 -0
- package/dist/tsup/chunk-EGWXXBZV.js.map +1 -0
- package/dist/tsup/{chunk-S662Y6ZU.js → chunk-EONWXYMN.js} +2 -2
- package/dist/tsup/{chunk-N4KRDJ56.js → chunk-GFGRBYO2.js} +35 -6
- package/dist/tsup/chunk-GFGRBYO2.js.map +1 -0
- package/dist/tsup/{chunk-IIJNPVPQ.cjs → chunk-GUHXWPGB.cjs} +1515 -1479
- package/dist/tsup/chunk-GUHXWPGB.cjs.map +1 -0
- package/dist/tsup/{chunk-TI5PXQGG.cjs → chunk-HNE2AK6C.cjs} +2375 -3713
- package/dist/tsup/chunk-HNE2AK6C.cjs.map +1 -0
- package/dist/tsup/{chunk-2OK7S6QF.js → chunk-I5I6OALK.js} +2 -2
- package/dist/tsup/chunk-IHQAF2HV.cjs +23 -0
- package/dist/tsup/chunk-IHQAF2HV.cjs.map +1 -0
- package/dist/tsup/{chunk-U5SMSA27.cjs → chunk-JJNZQDUN.cjs} +667 -2517
- package/dist/tsup/chunk-JJNZQDUN.cjs.map +1 -0
- package/dist/tsup/{chunk-ZPWOYQHN.js → chunk-JJSPHLJN.js} +219 -287
- package/dist/tsup/chunk-JJSPHLJN.js.map +1 -0
- package/dist/tsup/chunk-JRKPV5NJ.js +481 -0
- package/dist/tsup/chunk-JRKPV5NJ.js.map +1 -0
- package/dist/tsup/{chunk-VKVNIQRQ.js → chunk-K7MVU5SI.js} +36 -41
- package/dist/tsup/chunk-K7MVU5SI.js.map +1 -0
- package/dist/tsup/{chunk-KJSYAUOM.js → chunk-MLK3GY6P.js} +43 -27
- package/dist/tsup/chunk-MLK3GY6P.js.map +1 -0
- package/dist/tsup/{chunk-HYPIHCDT.cjs → chunk-MPLMTJY5.cjs} +123 -23
- package/dist/tsup/chunk-MPLMTJY5.cjs.map +1 -0
- package/dist/tsup/{chunk-MIX2KB6U.js → chunk-PQWI44WD.js} +1755 -3093
- package/dist/tsup/chunk-PQWI44WD.js.map +1 -0
- package/dist/tsup/{chunk-SR3KQE7Q.cjs → chunk-SQFCIDCG.cjs} +35 -6
- package/dist/tsup/chunk-SQFCIDCG.cjs.map +1 -0
- package/dist/tsup/{chunk-WY2SHWXQ.js → chunk-SVHJSM2E.js} +110 -24
- package/dist/tsup/chunk-SVHJSM2E.js.map +1 -0
- package/dist/tsup/chunk-T5KYKM6R.js +49 -0
- package/dist/tsup/chunk-T5KYKM6R.js.map +1 -0
- package/dist/tsup/{chunk-7WF2QSIC.cjs → chunk-TJ7DKW6F.cjs} +123 -37
- package/dist/tsup/chunk-TJ7DKW6F.cjs.map +1 -0
- package/dist/tsup/chunk-UQZRMTM3.js +23 -0
- package/dist/tsup/chunk-UQZRMTM3.js.map +1 -0
- package/dist/tsup/{chunk-JC6BEPE7.cjs → chunk-V3JSZR5P.cjs} +3 -3
- package/dist/tsup/{chunk-JC6BEPE7.cjs.map → chunk-V3JSZR5P.cjs.map} +1 -1
- package/dist/tsup/{chunk-OAXJWGMU.cjs → chunk-VBR35EQF.cjs} +271 -339
- package/dist/tsup/chunk-VBR35EQF.cjs.map +1 -0
- package/dist/tsup/{chunk-EIATSBYZ.js → chunk-VWYO36X4.js} +117 -17
- package/dist/tsup/chunk-VWYO36X4.js.map +1 -0
- package/dist/tsup/{chunk-JPXO2H55.js → chunk-WW27B6DM.js} +1452 -1416
- package/dist/tsup/chunk-WW27B6DM.js.map +1 -0
- package/dist/tsup/chunk-YAE3MEJM.cjs +49 -0
- package/dist/tsup/chunk-YAE3MEJM.cjs.map +1 -0
- package/dist/tsup/{chunk-SRIM3GHD.js → chunk-YGYGANCA.js} +473 -2323
- package/dist/tsup/chunk-YGYGANCA.js.map +1 -0
- package/dist/tsup/chunk-YZJWZBY5.cjs +481 -0
- package/dist/tsup/chunk-YZJWZBY5.cjs.map +1 -0
- package/dist/tsup/{chunk-ZFY5J2EP.cjs → chunk-ZZLJ5TSM.cjs} +39 -44
- package/dist/tsup/chunk-ZZLJ5TSM.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +10 -7
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +6 -6
- package/dist/tsup/client/mod.d.ts +6 -6
- package/dist/tsup/client/mod.js +11 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-Qj-zLJPc.d.ts → config-C2Wwnc69.d.ts} +142 -208
- package/dist/tsup/{config-BiNoIHRs.d.ts → config-DROwzBLT.d.cts} +82 -6
- package/dist/tsup/{config-BiNoIHRs.d.cts → config-DROwzBLT.d.ts} +82 -6
- package/dist/tsup/{config-iPj5l1bL.d.cts → config-ehT-_3BB.d.cts} +142 -208
- package/dist/tsup/{context-DzvH1PBK.d.cts → context-DGMJuAyc.d.ts} +16 -3
- package/dist/tsup/{context-CQCMuHND.d.ts → context-Dpp2RJbW.d.cts} +16 -3
- package/dist/tsup/db/drizzle/mod.cjs +3 -3
- package/dist/tsup/db/drizzle/mod.d.cts +1 -1
- package/dist/tsup/db/drizzle/mod.d.ts +1 -1
- package/dist/tsup/db/drizzle/mod.js +2 -2
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.d.cts +1 -1
- package/dist/tsup/db/mod.d.ts +1 -1
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/{driver-Jo8v-kbU.d.ts → driver-CYZP9QYo.d.ts} +1 -1
- package/dist/tsup/{driver-iV8J-WMv.d.cts → driver-CoTFpipv.d.cts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +7 -5
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +17 -18
- package/dist/tsup/driver-helpers/mod.d.ts +17 -18
- package/dist/tsup/driver-helpers/mod.js +11 -9
- package/dist/tsup/driver-test-suite/mod.cjs +1275 -228
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +6 -5
- package/dist/tsup/driver-test-suite/mod.d.ts +6 -5
- package/dist/tsup/driver-test-suite/mod.js +1581 -534
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +4 -4
- package/dist/tsup/inspector/mod.js +3 -3
- package/dist/tsup/mod.cjs +15 -9
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +9 -9
- package/dist/tsup/mod.d.ts +9 -9
- package/dist/tsup/mod.js +19 -13
- package/dist/tsup/sandbox/client.cjs +28 -0
- package/dist/tsup/sandbox/client.cjs.map +1 -0
- package/dist/tsup/sandbox/client.d.cts +88 -0
- package/dist/tsup/sandbox/client.d.ts +88 -0
- package/dist/tsup/sandbox/client.js +28 -0
- package/dist/tsup/sandbox/client.js.map +1 -0
- package/dist/tsup/sandbox/index.cjs +761 -0
- package/dist/tsup/sandbox/index.cjs.map +1 -0
- package/dist/tsup/sandbox/index.d.cts +120 -0
- package/dist/tsup/sandbox/index.d.ts +120 -0
- package/dist/tsup/sandbox/index.js +761 -0
- package/dist/tsup/sandbox/index.js.map +1 -0
- package/dist/tsup/sandbox/providers/computesdk.cjs +3 -0
- package/dist/tsup/sandbox/providers/computesdk.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/computesdk.d.cts +7 -0
- package/dist/tsup/sandbox/providers/computesdk.d.ts +7 -0
- package/dist/tsup/sandbox/providers/computesdk.js +3 -0
- package/dist/tsup/sandbox/providers/computesdk.js.map +1 -0
- package/dist/tsup/sandbox/providers/daytona.cjs +3 -0
- package/dist/tsup/sandbox/providers/daytona.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/daytona.d.cts +1 -0
- package/dist/tsup/sandbox/providers/daytona.d.ts +1 -0
- package/dist/tsup/sandbox/providers/daytona.js +3 -0
- package/dist/tsup/sandbox/providers/daytona.js.map +1 -0
- package/dist/tsup/sandbox/providers/docker.cjs +3 -0
- package/dist/tsup/sandbox/providers/docker.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/docker.d.cts +1 -0
- package/dist/tsup/sandbox/providers/docker.d.ts +1 -0
- package/dist/tsup/sandbox/providers/docker.js +3 -0
- package/dist/tsup/sandbox/providers/docker.js.map +1 -0
- package/dist/tsup/sandbox/providers/e2b.cjs +3 -0
- package/dist/tsup/sandbox/providers/e2b.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/e2b.d.cts +1 -0
- package/dist/tsup/sandbox/providers/e2b.d.ts +1 -0
- package/dist/tsup/sandbox/providers/e2b.js +3 -0
- package/dist/tsup/sandbox/providers/e2b.js.map +1 -0
- package/dist/tsup/sandbox/providers/local.cjs +3 -0
- package/dist/tsup/sandbox/providers/local.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/local.d.cts +1 -0
- package/dist/tsup/sandbox/providers/local.d.ts +1 -0
- package/dist/tsup/sandbox/providers/local.js +3 -0
- package/dist/tsup/sandbox/providers/local.js.map +1 -0
- package/dist/tsup/sandbox/providers/modal.cjs +3 -0
- package/dist/tsup/sandbox/providers/modal.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/modal.d.cts +1 -0
- package/dist/tsup/sandbox/providers/modal.d.ts +1 -0
- package/dist/tsup/sandbox/providers/modal.js +3 -0
- package/dist/tsup/sandbox/providers/modal.js.map +1 -0
- package/dist/tsup/sandbox/providers/vercel.cjs +3 -0
- package/dist/tsup/sandbox/providers/vercel.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/vercel.d.cts +1 -0
- package/dist/tsup/sandbox/providers/vercel.d.ts +1 -0
- package/dist/tsup/sandbox/providers/vercel.js +3 -0
- package/dist/tsup/sandbox/providers/vercel.js.map +1 -0
- package/dist/tsup/serve-test-suite/mod.cjs +451 -327
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +362 -238
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +17 -14
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +14 -11
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +6 -6
- package/dist/tsup/workflow/mod.d.cts +13 -9
- package/dist/tsup/workflow/mod.d.ts +13 -9
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +114 -15
- package/src/actor/config.ts +94 -88
- package/src/actor/conn/drivers/websocket.ts +2 -1
- package/src/actor/contexts/base/actor.ts +27 -4
- package/src/actor/database.ts +6 -1
- package/src/actor/driver.ts +27 -8
- package/src/actor/errors.ts +10 -5
- package/src/actor/instance/connection-manager.ts +4 -3
- package/src/actor/instance/kv.ts +52 -9
- package/src/actor/instance/mod.ts +135 -84
- package/src/actor/instance/queue-manager.ts +2 -5
- package/src/actor/instance/queue.ts +31 -29
- package/src/actor/instance/state-manager.ts +7 -1
- package/src/actor/instance/traces-driver.ts +34 -36
- package/src/actor/metrics.ts +137 -0
- package/src/actor/protocol/old.ts +9 -12
- package/src/actor/router-websocket-endpoints.ts +12 -6
- package/src/actor/router.ts +46 -9
- package/src/actor/schema.ts +14 -22
- package/src/client/actor-common.ts +65 -0
- package/src/client/actor-conn.ts +71 -9
- package/src/client/actor-handle.ts +22 -5
- package/src/client/client.ts +32 -6
- package/src/client/config.ts +18 -21
- package/src/client/mod.ts +1 -0
- package/src/client/queue.ts +8 -6
- package/src/common/inline-websocket-adapter.ts +8 -2
- package/src/common/router.ts +1 -4
- package/src/common/utils.ts +2 -5
- package/src/db/config.ts +10 -5
- package/src/db/drizzle/mod.ts +51 -41
- package/src/db/mod.ts +54 -29
- package/src/db/shared.ts +42 -8
- package/src/driver-helpers/mod.ts +2 -1
- package/src/driver-helpers/sqlite-pool.ts +42 -0
- package/src/driver-helpers/utils.ts +0 -20
- package/src/driver-test-suite/mod.ts +11 -1
- package/src/driver-test-suite/tests/access-control.ts +19 -12
- package/src/driver-test-suite/tests/action-features.ts +20 -8
- package/src/driver-test-suite/tests/actor-conn.ts +94 -8
- package/src/driver-test-suite/tests/actor-db-kv-stats.ts +282 -0
- package/src/driver-test-suite/tests/actor-db-raw.ts +6 -2
- package/src/driver-test-suite/tests/actor-db.ts +101 -31
- package/src/driver-test-suite/tests/actor-inspector.ts +174 -32
- package/src/driver-test-suite/tests/actor-kv.ts +79 -33
- package/src/driver-test-suite/tests/actor-lifecycle.ts +4 -12
- package/src/driver-test-suite/tests/actor-queue.ts +125 -17
- package/src/driver-test-suite/tests/actor-run.ts +59 -55
- package/src/driver-test-suite/tests/actor-sandbox.ts +78 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +1 -4
- package/src/driver-test-suite/tests/actor-sleep.ts +111 -0
- package/src/driver-test-suite/tests/actor-workflow.ts +387 -3
- package/src/driver-test-suite/tests/conn-error-serialization.ts +3 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +5 -1
- package/src/drivers/default.ts +1 -3
- package/src/drivers/engine/actor-driver.ts +94 -21
- package/src/drivers/engine/config.ts +4 -12
- package/src/drivers/engine/mod.ts +1 -5
- package/src/drivers/file-system/actor.ts +43 -8
- package/src/drivers/file-system/global-state.ts +180 -64
- package/src/drivers/file-system/kv-limits.ts +1 -1
- package/src/drivers/file-system/sqlite-runtime.ts +13 -4
- package/src/engine-process/mod.ts +5 -1
- package/src/inspector/actor-inspector.ts +47 -21
- package/src/inspector/config.ts +1 -4
- package/src/inspector/mod.browser.ts +2 -2
- package/src/inspector/mod.ts +4 -1
- package/src/inspector/serve-ui.ts +0 -1
- package/src/inspector/workflow-history-json.ts +309 -0
- package/src/manager/gateway.ts +6 -2
- package/src/manager/router.ts +3 -3
- package/src/registry/config/index.ts +65 -12
- package/src/registry/config/runner.ts +19 -4
- package/src/registry/index.ts +42 -89
- package/src/sandbox/actor/db.ts +36 -0
- package/src/sandbox/actor/index.ts +476 -0
- package/src/sandbox/actor/session.ts +350 -0
- package/src/sandbox/actor.test.ts +36 -0
- package/src/sandbox/client.test.ts +484 -0
- package/src/sandbox/client.ts +707 -0
- package/src/sandbox/config.ts +151 -0
- package/src/sandbox/index.ts +41 -0
- package/src/sandbox/providers/computesdk.ts +1 -0
- package/src/sandbox/providers/daytona.ts +1 -0
- package/src/sandbox/providers/docker.ts +1 -0
- package/src/sandbox/providers/e2b.ts +1 -0
- package/src/sandbox/providers/local.ts +1 -0
- package/src/sandbox/providers/modal.ts +1 -0
- package/src/sandbox/providers/vercel.ts +1 -0
- package/src/sandbox/session-persist-driver.ts +180 -0
- package/src/sandbox/types.ts +138 -0
- package/src/serverless/configure.ts +5 -3
- package/src/serverless/router.test.ts +17 -9
- package/src/serverless/router.ts +20 -13
- package/src/test/mod.ts +3 -4
- package/src/utils/endpoint-parser.test.ts +6 -2
- package/src/utils/endpoint-parser.ts +6 -2
- package/src/utils/env-vars.ts +0 -2
- package/src/utils/node.ts +1 -1
- package/src/utils/serve.ts +10 -5
- package/src/utils.ts +6 -1
- package/src/workflow/constants.ts +1 -2
- package/src/workflow/context.ts +42 -9
- package/src/workflow/driver.ts +57 -23
- package/src/workflow/inspector.ts +7 -13
- package/src/workflow/mod.ts +91 -4
- package/dist/tsup/chunk-6LJAZ5R4.cjs +0 -96
- package/dist/tsup/chunk-6LJAZ5R4.cjs.map +0 -1
- package/dist/tsup/chunk-7HTNH26M.js.map +0 -1
- package/dist/tsup/chunk-7WF2QSIC.cjs.map +0 -1
- package/dist/tsup/chunk-D2SPAJVT.cjs +0 -645
- package/dist/tsup/chunk-D2SPAJVT.cjs.map +0 -1
- package/dist/tsup/chunk-EIATSBYZ.js.map +0 -1
- package/dist/tsup/chunk-HYPIHCDT.cjs.map +0 -1
- package/dist/tsup/chunk-IIJNPVPQ.cjs.map +0 -1
- package/dist/tsup/chunk-JPXO2H55.js.map +0 -1
- package/dist/tsup/chunk-KJSYAUOM.js.map +0 -1
- package/dist/tsup/chunk-L47L3ZWJ.cjs.map +0 -1
- package/dist/tsup/chunk-MIX2KB6U.js.map +0 -1
- package/dist/tsup/chunk-N4KRDJ56.js.map +0 -1
- package/dist/tsup/chunk-OAXJWGMU.cjs.map +0 -1
- package/dist/tsup/chunk-PB5AEMKQ.cjs.map +0 -1
- package/dist/tsup/chunk-R5OQUSLN.js +0 -645
- package/dist/tsup/chunk-R5OQUSLN.js.map +0 -1
- package/dist/tsup/chunk-SR3KQE7Q.cjs.map +0 -1
- package/dist/tsup/chunk-SRIM3GHD.js.map +0 -1
- package/dist/tsup/chunk-TADUYCHF.js.map +0 -1
- package/dist/tsup/chunk-TI5PXQGG.cjs.map +0 -1
- package/dist/tsup/chunk-U5SMSA27.cjs.map +0 -1
- package/dist/tsup/chunk-VKVNIQRQ.js.map +0 -1
- package/dist/tsup/chunk-WY2SHWXQ.js.map +0 -1
- package/dist/tsup/chunk-ZFY5J2EP.cjs.map +0 -1
- package/dist/tsup/chunk-ZPWOYQHN.js.map +0 -1
- package/src/db/sqlite-vfs.ts +0 -12
- /package/dist/tsup/{chunk-S662Y6ZU.js.map → chunk-EONWXYMN.js.map} +0 -0
- /package/dist/tsup/{chunk-2OK7S6QF.js.map → chunk-I5I6OALK.js.map} +0 -0
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HIBERNATION_SLEEP_TIMEOUT,
|
|
3
|
+
MANY_QUEUE_NAMES,
|
|
3
4
|
RUN_SLEEP_TIMEOUT,
|
|
4
5
|
SLEEP_TIMEOUT,
|
|
6
|
+
WORKFLOW_NESTED_QUEUE_NAME,
|
|
5
7
|
WORKFLOW_QUEUE_NAME,
|
|
6
8
|
logger
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-DK46YYCJ.js";
|
|
10
|
+
import "../chunk-SVHJSM2E.js";
|
|
11
|
+
import "../chunk-JJSPHLJN.js";
|
|
12
|
+
import "../chunk-UQZRMTM3.js";
|
|
13
|
+
import "../chunk-EGWXXBZV.js";
|
|
14
|
+
import "../chunk-YGYGANCA.js";
|
|
15
|
+
import "../chunk-EONWXYMN.js";
|
|
16
|
+
import {
|
|
17
|
+
createClient
|
|
18
|
+
} from "../chunk-T5KYKM6R.js";
|
|
12
19
|
import {
|
|
13
20
|
ActorError,
|
|
14
21
|
ClientConfigSchema,
|
|
15
|
-
createClient,
|
|
16
22
|
createClientWithDriver
|
|
17
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-WW27B6DM.js";
|
|
18
24
|
import {
|
|
19
25
|
importWebSocket
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
26
|
+
} from "../chunk-I5I6OALK.js";
|
|
27
|
+
import "../chunk-MLK3GY6P.js";
|
|
28
|
+
import "../chunk-GFGRBYO2.js";
|
|
29
|
+
import {
|
|
30
|
+
buildManagerRouter
|
|
31
|
+
} from "../chunk-C4EB42ET.js";
|
|
23
32
|
import {
|
|
24
33
|
HEADER_ACTOR_ID,
|
|
25
34
|
WS_PROTOCOL_ACTOR,
|
|
@@ -27,27 +36,26 @@ import {
|
|
|
27
36
|
WS_PROTOCOL_ENCODING,
|
|
28
37
|
WS_PROTOCOL_STANDARD,
|
|
29
38
|
WS_PROTOCOL_TARGET,
|
|
30
|
-
WS_TEST_PROTOCOL_PATH
|
|
31
|
-
|
|
32
|
-
} from "../chunk-MIX2KB6U.js";
|
|
39
|
+
WS_TEST_PROTOCOL_PATH
|
|
40
|
+
} from "../chunk-PQWI44WD.js";
|
|
33
41
|
import "../chunk-LXUQ667X.js";
|
|
34
42
|
import {
|
|
35
43
|
assertUnreachable
|
|
36
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-C22JYHVT.js";
|
|
37
45
|
import {
|
|
38
46
|
noopNext
|
|
39
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-VWYO36X4.js";
|
|
40
48
|
import {
|
|
41
49
|
INTERNAL_ERROR_CODE,
|
|
42
50
|
INTERNAL_ERROR_DESCRIPTION
|
|
43
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-AKUJ5OTO.js";
|
|
44
52
|
import "../chunk-424PT5DM.js";
|
|
45
53
|
|
|
46
54
|
// src/driver-test-suite/mod.ts
|
|
47
55
|
import { serve as honoServe } from "@hono/node-server";
|
|
48
56
|
import { createNodeWebSocket } from "@hono/node-ws";
|
|
49
57
|
import invariant2 from "invariant";
|
|
50
|
-
import { describe as
|
|
58
|
+
import { describe as describe33 } from "vitest";
|
|
51
59
|
|
|
52
60
|
// src/driver-test-suite/tests/action-features.ts
|
|
53
61
|
import { describe, expect, test } from "vitest";
|
|
@@ -372,19 +380,27 @@ function runActionFeaturesTests(driverTestConfig) {
|
|
|
372
380
|
const instance = client.largePayloadActor.getOrCreate();
|
|
373
381
|
const items = [];
|
|
374
382
|
for (let i = 0; i < 800; i++) {
|
|
375
|
-
items.push(
|
|
383
|
+
items.push(
|
|
384
|
+
`Item ${i} with some additional text to increase size`
|
|
385
|
+
);
|
|
376
386
|
}
|
|
377
387
|
const result = await instance.processLargeRequest({ items });
|
|
378
388
|
expect(result.itemCount).toBe(800);
|
|
379
|
-
expect(result.firstItem).toBe(
|
|
380
|
-
|
|
389
|
+
expect(result.firstItem).toBe(
|
|
390
|
+
"Item 0 with some additional text to increase size"
|
|
391
|
+
);
|
|
392
|
+
expect(result.lastItem).toBe(
|
|
393
|
+
"Item 799 with some additional text to increase size"
|
|
394
|
+
);
|
|
381
395
|
});
|
|
382
396
|
test("should reject request exceeding maxIncomingMessageSize", async (c) => {
|
|
383
397
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
384
398
|
const instance = client.largePayloadActor.getOrCreate();
|
|
385
399
|
const items = [];
|
|
386
400
|
for (let i = 0; i < 1500; i++) {
|
|
387
|
-
items.push(
|
|
401
|
+
items.push(
|
|
402
|
+
`Item ${i} with some additional text to increase size`
|
|
403
|
+
);
|
|
388
404
|
}
|
|
389
405
|
await expect(
|
|
390
406
|
instance.processLargeRequest({ items })
|
|
@@ -395,8 +411,12 @@ function runActionFeaturesTests(driverTestConfig) {
|
|
|
395
411
|
const instance = client.largePayloadActor.getOrCreate();
|
|
396
412
|
const result = await instance.getLargeResponse(800);
|
|
397
413
|
expect(result.items).toHaveLength(800);
|
|
398
|
-
expect(result.items[0]).toBe(
|
|
399
|
-
|
|
414
|
+
expect(result.items[0]).toBe(
|
|
415
|
+
"Item 0 with some additional text to increase size"
|
|
416
|
+
);
|
|
417
|
+
expect(result.items[799]).toBe(
|
|
418
|
+
"Item 799 with some additional text to increase size"
|
|
419
|
+
);
|
|
400
420
|
});
|
|
401
421
|
test("should reject response exceeding maxOutgoingMessageSize", async (c) => {
|
|
402
422
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
@@ -421,7 +441,9 @@ function runAccessControlTests(driverTestConfig) {
|
|
|
421
441
|
});
|
|
422
442
|
test2("passes connection id into canPublish context", async (c) => {
|
|
423
443
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
424
|
-
const handle = client.accessControlActor.getOrCreate([
|
|
444
|
+
const handle = client.accessControlActor.getOrCreate([
|
|
445
|
+
"publish-ctx"
|
|
446
|
+
]);
|
|
425
447
|
await handle.send("allowedQueue", { value: "one" });
|
|
426
448
|
const connId = await handle.allowedGetLastCanPublishConnId();
|
|
427
449
|
expect2(typeof connId).toBe("string");
|
|
@@ -512,16 +534,21 @@ function runAccessControlTests(driverTestConfig) {
|
|
|
512
534
|
"undefined-event"
|
|
513
535
|
]);
|
|
514
536
|
const conn = handle.connect();
|
|
515
|
-
const eventPromise = new Promise(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
537
|
+
const eventPromise = new Promise(
|
|
538
|
+
(resolve, reject) => {
|
|
539
|
+
const unsubscribeError = conn.onError((error) => {
|
|
540
|
+
reject(error);
|
|
541
|
+
});
|
|
542
|
+
const unsubscribeEvent = conn.on(
|
|
543
|
+
"undefinedEvent",
|
|
544
|
+
(payload) => {
|
|
545
|
+
unsubscribeError();
|
|
546
|
+
unsubscribeEvent();
|
|
547
|
+
resolve(payload);
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
);
|
|
525
552
|
await conn.allowedAction("undefined-subscribe-ready");
|
|
526
553
|
await conn.allowedBroadcastUndefinedEvent("wildcard");
|
|
527
554
|
expect2(await eventPromise).toEqual({ value: "wildcard" });
|
|
@@ -745,6 +772,65 @@ function runActorConnTests(driverTestConfig) {
|
|
|
745
772
|
await conn1.dispose();
|
|
746
773
|
await conn2.dispose();
|
|
747
774
|
});
|
|
775
|
+
test3("should call getParams for each connection", async (c) => {
|
|
776
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
777
|
+
let connectionCount = 0;
|
|
778
|
+
const handle = client.counterWithParams.getOrCreate(
|
|
779
|
+
["test-get-params"],
|
|
780
|
+
{
|
|
781
|
+
getParams: async () => ({
|
|
782
|
+
name: `user${++connectionCount}`
|
|
783
|
+
})
|
|
784
|
+
}
|
|
785
|
+
);
|
|
786
|
+
const conn1 = handle.connect();
|
|
787
|
+
await conn1.getInitializers();
|
|
788
|
+
await conn1.dispose();
|
|
789
|
+
const conn2 = handle.connect();
|
|
790
|
+
const initializers = await conn2.getInitializers();
|
|
791
|
+
expect3(initializers).toEqual(["user1", "user2"]);
|
|
792
|
+
expect3(connectionCount).toBe(2);
|
|
793
|
+
await conn2.dispose();
|
|
794
|
+
});
|
|
795
|
+
test3("should surface getParams errors and retry connection setup", async (c) => {
|
|
796
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
797
|
+
let attempts = 0;
|
|
798
|
+
const handle = client.counterWithParams.getOrCreate(
|
|
799
|
+
["test-get-params-retry"],
|
|
800
|
+
{
|
|
801
|
+
getParams: async () => {
|
|
802
|
+
attempts++;
|
|
803
|
+
if (attempts === 1) {
|
|
804
|
+
throw new Error("token unavailable");
|
|
805
|
+
}
|
|
806
|
+
return { name: "user1" };
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
const conn = handle.connect();
|
|
811
|
+
const receivedErrors = [];
|
|
812
|
+
conn.onError((error) => {
|
|
813
|
+
receivedErrors.push({
|
|
814
|
+
group: error.group,
|
|
815
|
+
code: error.code
|
|
816
|
+
});
|
|
817
|
+
});
|
|
818
|
+
await expect3(conn.getInitializers()).rejects.toMatchObject({
|
|
819
|
+
group: "client",
|
|
820
|
+
code: "get_params_failed"
|
|
821
|
+
});
|
|
822
|
+
await vi2.waitFor(
|
|
823
|
+
async () => {
|
|
824
|
+
expect3(await conn.getInitializers()).toEqual(["user1"]);
|
|
825
|
+
},
|
|
826
|
+
{ timeout: 1e4 }
|
|
827
|
+
);
|
|
828
|
+
expect3(receivedErrors).toEqual([
|
|
829
|
+
{ group: "client", code: "get_params_failed" }
|
|
830
|
+
]);
|
|
831
|
+
expect3(attempts).toBeGreaterThanOrEqual(2);
|
|
832
|
+
await conn.dispose();
|
|
833
|
+
});
|
|
748
834
|
});
|
|
749
835
|
describe3("Lifecycle Hooks", () => {
|
|
750
836
|
test3("should trigger lifecycle hooks", async (c) => {
|
|
@@ -922,12 +1008,18 @@ function runActorConnTests(driverTestConfig) {
|
|
|
922
1008
|
const connection = handle.connect();
|
|
923
1009
|
const items = [];
|
|
924
1010
|
for (let i = 0; i < 800; i++) {
|
|
925
|
-
items.push(
|
|
1011
|
+
items.push(
|
|
1012
|
+
`Item ${i} with some additional text to increase size`
|
|
1013
|
+
);
|
|
926
1014
|
}
|
|
927
1015
|
const result = await connection.processLargeRequest({ items });
|
|
928
1016
|
expect3(result.itemCount).toBe(800);
|
|
929
|
-
expect3(result.firstItem).toBe(
|
|
930
|
-
|
|
1017
|
+
expect3(result.firstItem).toBe(
|
|
1018
|
+
"Item 0 with some additional text to increase size"
|
|
1019
|
+
);
|
|
1020
|
+
expect3(result.lastItem).toBe(
|
|
1021
|
+
"Item 799 with some additional text to increase size"
|
|
1022
|
+
);
|
|
931
1023
|
const lastRequestSize = await connection.getLastRequestSize();
|
|
932
1024
|
expect3(lastRequestSize).toBe(800);
|
|
933
1025
|
await connection.dispose();
|
|
@@ -940,7 +1032,9 @@ function runActorConnTests(driverTestConfig) {
|
|
|
940
1032
|
const connection = handle.connect();
|
|
941
1033
|
const items = [];
|
|
942
1034
|
for (let i = 0; i < 1500; i++) {
|
|
943
|
-
items.push(
|
|
1035
|
+
items.push(
|
|
1036
|
+
`Item ${i} with some additional text to increase size`
|
|
1037
|
+
);
|
|
944
1038
|
}
|
|
945
1039
|
await expect3(
|
|
946
1040
|
connection.processLargeRequest({ items })
|
|
@@ -955,8 +1049,12 @@ function runActorConnTests(driverTestConfig) {
|
|
|
955
1049
|
const connection = handle.connect();
|
|
956
1050
|
const result = await connection.getLargeResponse(800);
|
|
957
1051
|
expect3(result.items).toHaveLength(800);
|
|
958
|
-
expect3(result.items[0]).toBe(
|
|
959
|
-
|
|
1052
|
+
expect3(result.items[0]).toBe(
|
|
1053
|
+
"Item 0 with some additional text to increase size"
|
|
1054
|
+
);
|
|
1055
|
+
expect3(result.items[799]).toBe(
|
|
1056
|
+
"Item 799 with some additional text to increase size"
|
|
1057
|
+
);
|
|
960
1058
|
await connection.dispose();
|
|
961
1059
|
});
|
|
962
1060
|
test3("should reject response exceeding maxOutgoingMessageSize", async (c) => {
|
|
@@ -1279,7 +1377,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1279
1377
|
test6(
|
|
1280
1378
|
"bootstraps schema on startup",
|
|
1281
1379
|
async (c) => {
|
|
1282
|
-
const { client } = await setupDriverTest(
|
|
1380
|
+
const { client } = await setupDriverTest(
|
|
1381
|
+
c,
|
|
1382
|
+
driverTestConfig
|
|
1383
|
+
);
|
|
1283
1384
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1284
1385
|
`db-${variant}-bootstrap-${crypto.randomUUID()}`
|
|
1285
1386
|
]);
|
|
@@ -1291,7 +1392,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1291
1392
|
test6(
|
|
1292
1393
|
"supports CRUD, raw SQL, and multi-statement exec",
|
|
1293
1394
|
async (c) => {
|
|
1294
|
-
const { client } = await setupDriverTest(
|
|
1395
|
+
const { client } = await setupDriverTest(
|
|
1396
|
+
c,
|
|
1397
|
+
driverTestConfig
|
|
1398
|
+
);
|
|
1295
1399
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1296
1400
|
`db-${variant}-crud-${crypto.randomUUID()}`
|
|
1297
1401
|
]);
|
|
@@ -1300,8 +1404,12 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1300
1404
|
const second = await actor.insertValue("beta");
|
|
1301
1405
|
const values = await actor.getValues();
|
|
1302
1406
|
expect6(values.length).toBeGreaterThanOrEqual(2);
|
|
1303
|
-
expect6(
|
|
1304
|
-
|
|
1407
|
+
expect6(
|
|
1408
|
+
values.some((row) => row.value === "alpha")
|
|
1409
|
+
).toBeTruthy();
|
|
1410
|
+
expect6(
|
|
1411
|
+
values.some((row) => row.value === "beta")
|
|
1412
|
+
).toBeTruthy();
|
|
1305
1413
|
await actor.updateValue(first.id, "alpha-updated");
|
|
1306
1414
|
const updated = await actor.getValue(first.id);
|
|
1307
1415
|
expect6(updated).toBe("alpha-updated");
|
|
@@ -1326,7 +1434,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1326
1434
|
test6(
|
|
1327
1435
|
"handles transactions",
|
|
1328
1436
|
async (c) => {
|
|
1329
|
-
const { client } = await setupDriverTest(
|
|
1437
|
+
const { client } = await setupDriverTest(
|
|
1438
|
+
c,
|
|
1439
|
+
driverTestConfig
|
|
1440
|
+
);
|
|
1330
1441
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1331
1442
|
`db-${variant}-tx-${crypto.randomUUID()}`
|
|
1332
1443
|
]);
|
|
@@ -1341,7 +1452,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1341
1452
|
test6(
|
|
1342
1453
|
"persists across sleep and wake cycles",
|
|
1343
1454
|
async (c) => {
|
|
1344
|
-
const { client } = await setupDriverTest(
|
|
1455
|
+
const { client } = await setupDriverTest(
|
|
1456
|
+
c,
|
|
1457
|
+
driverTestConfig
|
|
1458
|
+
);
|
|
1345
1459
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1346
1460
|
`db-${variant}-sleep-${crypto.randomUUID()}`
|
|
1347
1461
|
]);
|
|
@@ -1360,9 +1474,14 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1360
1474
|
test6(
|
|
1361
1475
|
"completes onDisconnect DB writes before sleeping",
|
|
1362
1476
|
async (c) => {
|
|
1363
|
-
const { client } = await setupDriverTest(
|
|
1477
|
+
const { client } = await setupDriverTest(
|
|
1478
|
+
c,
|
|
1479
|
+
driverTestConfig
|
|
1480
|
+
);
|
|
1364
1481
|
const key = `db-${variant}-disconnect-${crypto.randomUUID()}`;
|
|
1365
|
-
const actor = getDbActor(client, variant).getOrCreate([
|
|
1482
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1483
|
+
key
|
|
1484
|
+
]);
|
|
1366
1485
|
await actor.reset();
|
|
1367
1486
|
await actor.configureDisconnectInsert(true, 250);
|
|
1368
1487
|
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 250);
|
|
@@ -1374,7 +1493,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1374
1493
|
test6(
|
|
1375
1494
|
"handles high-volume inserts",
|
|
1376
1495
|
async (c) => {
|
|
1377
|
-
const { client } = await setupDriverTest(
|
|
1496
|
+
const { client } = await setupDriverTest(
|
|
1497
|
+
c,
|
|
1498
|
+
driverTestConfig
|
|
1499
|
+
);
|
|
1378
1500
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1379
1501
|
`db-${variant}-high-volume-${crypto.randomUUID()}`
|
|
1380
1502
|
]);
|
|
@@ -1392,7 +1514,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1392
1514
|
test6(
|
|
1393
1515
|
"handles payloads across chunk boundaries",
|
|
1394
1516
|
async (c) => {
|
|
1395
|
-
const { client } = await setupDriverTest(
|
|
1517
|
+
const { client } = await setupDriverTest(
|
|
1518
|
+
c,
|
|
1519
|
+
driverTestConfig
|
|
1520
|
+
);
|
|
1396
1521
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1397
1522
|
`db-${variant}-chunk-${crypto.randomUUID()}`
|
|
1398
1523
|
]);
|
|
@@ -1408,7 +1533,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1408
1533
|
test6(
|
|
1409
1534
|
"handles large payloads",
|
|
1410
1535
|
async (c) => {
|
|
1411
|
-
const { client } = await setupDriverTest(
|
|
1536
|
+
const { client } = await setupDriverTest(
|
|
1537
|
+
c,
|
|
1538
|
+
driverTestConfig
|
|
1539
|
+
);
|
|
1412
1540
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1413
1541
|
`db-${variant}-large-${crypto.randomUUID()}`
|
|
1414
1542
|
]);
|
|
@@ -1422,7 +1550,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1422
1550
|
test6(
|
|
1423
1551
|
"supports shrink and regrow workloads with vacuum",
|
|
1424
1552
|
async (c) => {
|
|
1425
|
-
const { client } = await setupDriverTest(
|
|
1553
|
+
const { client } = await setupDriverTest(
|
|
1554
|
+
c,
|
|
1555
|
+
driverTestConfig
|
|
1556
|
+
);
|
|
1426
1557
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1427
1558
|
`db-${variant}-shrink-regrow-${crypto.randomUUID()}`
|
|
1428
1559
|
]);
|
|
@@ -1451,7 +1582,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1451
1582
|
test6(
|
|
1452
1583
|
"handles repeated updates to the same row",
|
|
1453
1584
|
async (c) => {
|
|
1454
|
-
const { client } = await setupDriverTest(
|
|
1585
|
+
const { client } = await setupDriverTest(
|
|
1586
|
+
c,
|
|
1587
|
+
driverTestConfig
|
|
1588
|
+
);
|
|
1455
1589
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1456
1590
|
`db-${variant}-updates-${crypto.randomUUID()}`
|
|
1457
1591
|
]);
|
|
@@ -1480,7 +1614,10 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1480
1614
|
test6(
|
|
1481
1615
|
"passes integrity checks after mixed workload and sleep",
|
|
1482
1616
|
async (c) => {
|
|
1483
|
-
const { client } = await setupDriverTest(
|
|
1617
|
+
const { client } = await setupDriverTest(
|
|
1618
|
+
c,
|
|
1619
|
+
driverTestConfig
|
|
1620
|
+
);
|
|
1484
1621
|
const actor = getDbActor(client, variant).getOrCreate([
|
|
1485
1622
|
`db-${variant}-integrity-${crypto.randomUUID()}`
|
|
1486
1623
|
]);
|
|
@@ -1489,10 +1626,14 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1489
1626
|
INTEGRITY_SEED_COUNT,
|
|
1490
1627
|
INTEGRITY_CHURN_COUNT
|
|
1491
1628
|
);
|
|
1492
|
-
expect6((await actor.integrityCheck()).toLowerCase()).toBe(
|
|
1629
|
+
expect6((await actor.integrityCheck()).toLowerCase()).toBe(
|
|
1630
|
+
"ok"
|
|
1631
|
+
);
|
|
1493
1632
|
await actor.triggerSleep();
|
|
1494
1633
|
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1495
|
-
expect6((await actor.integrityCheck()).toLowerCase()).toBe(
|
|
1634
|
+
expect6((await actor.integrityCheck()).toLowerCase()).toBe(
|
|
1635
|
+
"ok"
|
|
1636
|
+
);
|
|
1496
1637
|
},
|
|
1497
1638
|
dbTestTimeout
|
|
1498
1639
|
);
|
|
@@ -1503,7 +1644,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1503
1644
|
"runs db provider cleanup on sleep",
|
|
1504
1645
|
async (c) => {
|
|
1505
1646
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1506
|
-
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1647
|
+
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1648
|
+
"observer"
|
|
1649
|
+
]);
|
|
1507
1650
|
const lifecycle = client.dbLifecycle.getOrCreate([
|
|
1508
1651
|
`db-lifecycle-sleep-${crypto.randomUUID()}`
|
|
1509
1652
|
]);
|
|
@@ -1523,7 +1666,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1523
1666
|
}
|
|
1524
1667
|
expect6(after.create).toBeGreaterThanOrEqual(before.create);
|
|
1525
1668
|
expect6(after.migrate).toBeGreaterThanOrEqual(before.migrate);
|
|
1526
|
-
expect6(after.cleanup).toBeGreaterThanOrEqual(
|
|
1669
|
+
expect6(after.cleanup).toBeGreaterThanOrEqual(
|
|
1670
|
+
before.cleanup + 1
|
|
1671
|
+
);
|
|
1527
1672
|
},
|
|
1528
1673
|
lifecycleTestTimeout
|
|
1529
1674
|
);
|
|
@@ -1531,7 +1676,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1531
1676
|
"runs db provider cleanup on destroy",
|
|
1532
1677
|
async (c) => {
|
|
1533
1678
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1534
|
-
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1679
|
+
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1680
|
+
"observer"
|
|
1681
|
+
]);
|
|
1535
1682
|
const lifecycle = client.dbLifecycle.getOrCreate([
|
|
1536
1683
|
`db-lifecycle-destroy-${crypto.randomUUID()}`
|
|
1537
1684
|
]);
|
|
@@ -1557,7 +1704,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1557
1704
|
"runs db provider cleanup when migration fails",
|
|
1558
1705
|
async (c) => {
|
|
1559
1706
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1560
|
-
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1707
|
+
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1708
|
+
"observer"
|
|
1709
|
+
]);
|
|
1561
1710
|
const beforeTotalCleanup = await observer.getTotalCleanupCount();
|
|
1562
1711
|
const key = `db-lifecycle-migrate-failure-${crypto.randomUUID()}`;
|
|
1563
1712
|
const lifecycle = client.dbLifecycleFailing.getOrCreate([key]);
|
|
@@ -1576,7 +1725,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1576
1725
|
}
|
|
1577
1726
|
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1578
1727
|
}
|
|
1579
|
-
expect6(cleanupCount).toBeGreaterThanOrEqual(
|
|
1728
|
+
expect6(cleanupCount).toBeGreaterThanOrEqual(
|
|
1729
|
+
beforeTotalCleanup + 1
|
|
1730
|
+
);
|
|
1580
1731
|
},
|
|
1581
1732
|
lifecycleTestTimeout
|
|
1582
1733
|
);
|
|
@@ -1584,7 +1735,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1584
1735
|
"handles parallel actor lifecycle churn",
|
|
1585
1736
|
async (c) => {
|
|
1586
1737
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1587
|
-
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1738
|
+
const observer = client.dbLifecycleObserver.getOrCreate([
|
|
1739
|
+
"observer"
|
|
1740
|
+
]);
|
|
1588
1741
|
const actorHandles = Array.from(
|
|
1589
1742
|
{ length: 12 },
|
|
1590
1743
|
(_, i) => client.dbLifecycle.getOrCreate([
|
|
@@ -1595,17 +1748,27 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1595
1748
|
actorHandles.map((handle) => handle.getActorId())
|
|
1596
1749
|
);
|
|
1597
1750
|
await Promise.all(
|
|
1598
|
-
actorHandles.map(
|
|
1751
|
+
actorHandles.map(
|
|
1752
|
+
(handle, i) => handle.insertValue(`phase-1-${i}`)
|
|
1753
|
+
)
|
|
1754
|
+
);
|
|
1755
|
+
await Promise.all(
|
|
1756
|
+
actorHandles.map((handle) => handle.triggerSleep())
|
|
1599
1757
|
);
|
|
1600
|
-
await Promise.all(actorHandles.map((handle) => handle.triggerSleep()));
|
|
1601
1758
|
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1602
1759
|
await Promise.all(
|
|
1603
|
-
actorHandles.map(
|
|
1760
|
+
actorHandles.map(
|
|
1761
|
+
(handle, i) => handle.insertValue(`phase-2-${i}`)
|
|
1762
|
+
)
|
|
1604
1763
|
);
|
|
1605
1764
|
const survivors = actorHandles.slice(0, 6);
|
|
1606
1765
|
const destroyed = actorHandles.slice(6);
|
|
1607
|
-
await Promise.all(
|
|
1608
|
-
|
|
1766
|
+
await Promise.all(
|
|
1767
|
+
destroyed.map((handle) => handle.triggerDestroy())
|
|
1768
|
+
);
|
|
1769
|
+
await Promise.all(
|
|
1770
|
+
survivors.map((handle) => handle.triggerSleep())
|
|
1771
|
+
);
|
|
1609
1772
|
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1610
1773
|
await Promise.all(survivors.map((handle) => handle.ping()));
|
|
1611
1774
|
const survivorCounts = await Promise.all(
|
|
@@ -1634,7 +1797,9 @@ function runActorDbTests(driverTestConfig) {
|
|
|
1634
1797
|
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1635
1798
|
}
|
|
1636
1799
|
for (const actorId of actorIds) {
|
|
1637
|
-
expect6(
|
|
1800
|
+
expect6(
|
|
1801
|
+
lifecycleCleanup.get(actorId) ?? 0
|
|
1802
|
+
).toBeGreaterThanOrEqual(1);
|
|
1638
1803
|
}
|
|
1639
1804
|
},
|
|
1640
1805
|
lifecycleTestTimeout
|
|
@@ -1896,9 +2061,7 @@ function runActorLifecycleTests(driverTestConfig) {
|
|
|
1896
2061
|
const actorKey = `test-stop-before-instantiation-${Date.now()}`;
|
|
1897
2062
|
const actors = Array.from(
|
|
1898
2063
|
{ length: 5 },
|
|
1899
|
-
(_, i) => client.startStopRaceActor.getOrCreate([
|
|
1900
|
-
`${actorKey}-${i}`
|
|
1901
|
-
])
|
|
2064
|
+
(_, i) => client.startStopRaceActor.getOrCreate([`${actorKey}-${i}`])
|
|
1902
2065
|
);
|
|
1903
2066
|
const ids = await Promise.all(actors.map((a) => a.resolve()));
|
|
1904
2067
|
await Promise.all(actors.map((a) => a.destroy()));
|
|
@@ -1911,9 +2074,7 @@ function runActorLifecycleTests(driverTestConfig) {
|
|
|
1911
2074
|
expect9(err.group).toBe("actor");
|
|
1912
2075
|
expect9(err.code).toBe("not_found");
|
|
1913
2076
|
}
|
|
1914
|
-
expect9(destroyed, `actor ${id} should be destroyed`).toBe(
|
|
1915
|
-
true
|
|
1916
|
-
);
|
|
2077
|
+
expect9(destroyed, `actor ${id} should be destroyed`).toBe(true);
|
|
1917
2078
|
}
|
|
1918
2079
|
});
|
|
1919
2080
|
test9("onBeforeActorStart completes before stop proceeds", async (c) => {
|
|
@@ -1930,9 +2091,7 @@ function runActorLifecycleTests(driverTestConfig) {
|
|
|
1930
2091
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1931
2092
|
for (let i = 0; i < 10; i++) {
|
|
1932
2093
|
const actorKey = `test-rapid-cycle-${Date.now()}-${i}`;
|
|
1933
|
-
const actor = client.startStopRaceActor.getOrCreate([
|
|
1934
|
-
actorKey
|
|
1935
|
-
]);
|
|
2094
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1936
2095
|
const resolvePromise = actor.resolve();
|
|
1937
2096
|
const destroyPromise = actor.destroy();
|
|
1938
2097
|
await Promise.all([resolvePromise, destroyPromise]);
|
|
@@ -1945,9 +2104,7 @@ function runActorLifecycleTests(driverTestConfig) {
|
|
|
1945
2104
|
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1946
2105
|
const id = await actor.resolve();
|
|
1947
2106
|
await actor.destroy();
|
|
1948
|
-
const newActor = client.startStopRaceActor.getOrCreate([
|
|
1949
|
-
actorKey
|
|
1950
|
-
]);
|
|
2107
|
+
const newActor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1951
2108
|
const result = await newActor.ping();
|
|
1952
2109
|
expect9(result).toBe("pong");
|
|
1953
2110
|
await newActor.destroy();
|
|
@@ -2014,10 +2171,7 @@ function runActorScheduleTests(driverTestConfig) {
|
|
|
2014
2171
|
expect10(history1[0]).toBe("first");
|
|
2015
2172
|
await waitFor(driverTestConfig, 500);
|
|
2016
2173
|
const history2 = await scheduled.getTaskHistory();
|
|
2017
|
-
expect10(history2.slice(0, 2)).toEqual([
|
|
2018
|
-
"first",
|
|
2019
|
-
"second"
|
|
2020
|
-
]);
|
|
2174
|
+
expect10(history2.slice(0, 2)).toEqual(["first", "second"]);
|
|
2021
2175
|
await waitFor(driverTestConfig, 500);
|
|
2022
2176
|
const history3 = await scheduled.getTaskHistory();
|
|
2023
2177
|
expect10(history3).toEqual(["first", "second", "third"]);
|
|
@@ -2098,6 +2252,28 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
2098
2252
|
expect11(startCount).toBe(2);
|
|
2099
2253
|
}
|
|
2100
2254
|
});
|
|
2255
|
+
test11("waitUntil can broadcast before sleep disconnect", async (c) => {
|
|
2256
|
+
var _a2;
|
|
2257
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2258
|
+
const sleepActor = client.sleepWithWaitUntilMessage.getOrCreate().connect();
|
|
2259
|
+
const receivedMessages = [];
|
|
2260
|
+
sleepActor.once("sleeping", (message) => {
|
|
2261
|
+
receivedMessages.push(message);
|
|
2262
|
+
});
|
|
2263
|
+
await sleepActor.triggerSleep();
|
|
2264
|
+
await waitFor(driverTestConfig, 250);
|
|
2265
|
+
expect11(receivedMessages).toHaveLength(1);
|
|
2266
|
+
expect11((_a2 = receivedMessages[0]) == null ? void 0 : _a2.startCount).toBe(1);
|
|
2267
|
+
await sleepActor.dispose();
|
|
2268
|
+
await waitFor(driverTestConfig, 250);
|
|
2269
|
+
const sleepActor2 = client.sleepWithWaitUntilMessage.getOrCreate();
|
|
2270
|
+
{
|
|
2271
|
+
const { startCount, sleepCount, waitUntilMessageCount } = await sleepActor2.getCounts();
|
|
2272
|
+
expect11(waitUntilMessageCount).toBe(1);
|
|
2273
|
+
expect11(sleepCount).toBe(1);
|
|
2274
|
+
expect11(startCount).toBe(2);
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2101
2277
|
test11("rpc calls keep actor awake", async (c) => {
|
|
2102
2278
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2103
2279
|
const sleepActor = client.sleep.getOrCreate();
|
|
@@ -2283,6 +2459,64 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
2283
2459
|
expect11(startCount).toBe(1);
|
|
2284
2460
|
}
|
|
2285
2461
|
});
|
|
2462
|
+
test11("preventSleep blocks auto sleep until cleared", async (c) => {
|
|
2463
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2464
|
+
const sleepActor = client.sleepWithPreventSleep.getOrCreate();
|
|
2465
|
+
{
|
|
2466
|
+
const status = await sleepActor.getStatus();
|
|
2467
|
+
expect11(status.sleepCount).toBe(0);
|
|
2468
|
+
expect11(status.startCount).toBe(1);
|
|
2469
|
+
expect11(status.preventSleep).toBe(false);
|
|
2470
|
+
expect11(status.preventSleepOnWake).toBe(false);
|
|
2471
|
+
}
|
|
2472
|
+
expect11(await sleepActor.setPreventSleep(true)).toBe(true);
|
|
2473
|
+
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
2474
|
+
{
|
|
2475
|
+
const status = await sleepActor.getStatus();
|
|
2476
|
+
expect11(status.sleepCount).toBe(0);
|
|
2477
|
+
expect11(status.startCount).toBe(1);
|
|
2478
|
+
expect11(status.preventSleep).toBe(true);
|
|
2479
|
+
}
|
|
2480
|
+
expect11(await sleepActor.setPreventSleep(false)).toBe(false);
|
|
2481
|
+
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
2482
|
+
{
|
|
2483
|
+
const status = await sleepActor.getStatus();
|
|
2484
|
+
expect11(status.sleepCount).toBe(1);
|
|
2485
|
+
expect11(status.startCount).toBe(2);
|
|
2486
|
+
expect11(status.preventSleep).toBe(false);
|
|
2487
|
+
}
|
|
2488
|
+
});
|
|
2489
|
+
test11("preventSleep can be restored during onWake", async (c) => {
|
|
2490
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2491
|
+
const sleepActor = client.sleepWithPreventSleep.getOrCreate();
|
|
2492
|
+
expect11(await sleepActor.setPreventSleepOnWake(true)).toBe(true);
|
|
2493
|
+
await sleepActor.triggerSleep();
|
|
2494
|
+
await waitFor(driverTestConfig, 250);
|
|
2495
|
+
{
|
|
2496
|
+
const status = await sleepActor.getStatus();
|
|
2497
|
+
expect11(status.sleepCount).toBe(1);
|
|
2498
|
+
expect11(status.startCount).toBe(2);
|
|
2499
|
+
expect11(status.preventSleep).toBe(true);
|
|
2500
|
+
expect11(status.preventSleepOnWake).toBe(true);
|
|
2501
|
+
}
|
|
2502
|
+
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
2503
|
+
{
|
|
2504
|
+
const status = await sleepActor.getStatus();
|
|
2505
|
+
expect11(status.sleepCount).toBe(1);
|
|
2506
|
+
expect11(status.startCount).toBe(2);
|
|
2507
|
+
expect11(status.preventSleep).toBe(true);
|
|
2508
|
+
}
|
|
2509
|
+
expect11(await sleepActor.setPreventSleepOnWake(false)).toBe(false);
|
|
2510
|
+
expect11(await sleepActor.setPreventSleep(false)).toBe(false);
|
|
2511
|
+
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
2512
|
+
{
|
|
2513
|
+
const status = await sleepActor.getStatus();
|
|
2514
|
+
expect11(status.sleepCount).toBe(2);
|
|
2515
|
+
expect11(status.startCount).toBe(3);
|
|
2516
|
+
expect11(status.preventSleep).toBe(false);
|
|
2517
|
+
expect11(status.preventSleepOnWake).toBe(false);
|
|
2518
|
+
}
|
|
2519
|
+
});
|
|
2286
2520
|
});
|
|
2287
2521
|
}
|
|
2288
2522
|
|
|
@@ -2745,26 +2979,24 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2745
2979
|
});
|
|
2746
2980
|
expect16(response.status).toBe(200);
|
|
2747
2981
|
const data = await response.json();
|
|
2748
|
-
expect16(data).toEqual({
|
|
2982
|
+
expect16(data).toEqual({
|
|
2983
|
+
state: { count: 5 },
|
|
2984
|
+
isStateEnabled: true
|
|
2985
|
+
});
|
|
2749
2986
|
});
|
|
2750
2987
|
test16("PATCH /inspector/state updates actor state", async (c) => {
|
|
2751
2988
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2752
|
-
const handle = client.counter.getOrCreate([
|
|
2753
|
-
"inspector-set-state"
|
|
2754
|
-
]);
|
|
2989
|
+
const handle = client.counter.getOrCreate(["inspector-set-state"]);
|
|
2755
2990
|
await handle.increment(5);
|
|
2756
2991
|
const gatewayUrl = await handle.getGatewayUrl();
|
|
2757
|
-
const patchResponse = await fetch(
|
|
2758
|
-
|
|
2759
|
-
{
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
body: JSON.stringify({ state: { count: 42 } })
|
|
2766
|
-
}
|
|
2767
|
-
);
|
|
2992
|
+
const patchResponse = await fetch(`${gatewayUrl}/inspector/state`, {
|
|
2993
|
+
method: "PATCH",
|
|
2994
|
+
headers: {
|
|
2995
|
+
"Content-Type": "application/json",
|
|
2996
|
+
Authorization: "Bearer token"
|
|
2997
|
+
},
|
|
2998
|
+
body: JSON.stringify({ state: { count: 42 } })
|
|
2999
|
+
});
|
|
2768
3000
|
expect16(patchResponse.status).toBe(200);
|
|
2769
3001
|
const patchData = await patchResponse.json();
|
|
2770
3002
|
expect16(patchData).toEqual({ ok: true });
|
|
@@ -2806,9 +3038,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2806
3038
|
});
|
|
2807
3039
|
test16("POST /inspector/action/:name executes an action", async (c) => {
|
|
2808
3040
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2809
|
-
const handle = client.counter.getOrCreate([
|
|
2810
|
-
"inspector-action"
|
|
2811
|
-
]);
|
|
3041
|
+
const handle = client.counter.getOrCreate(["inspector-action"]);
|
|
2812
3042
|
await handle.increment(10);
|
|
2813
3043
|
const gatewayUrl = await handle.getGatewayUrl();
|
|
2814
3044
|
const response = await fetch(
|
|
@@ -2852,9 +3082,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2852
3082
|
});
|
|
2853
3083
|
test16("GET /inspector/traces returns trace data", async (c) => {
|
|
2854
3084
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2855
|
-
const handle = client.counter.getOrCreate([
|
|
2856
|
-
"inspector-traces"
|
|
2857
|
-
]);
|
|
3085
|
+
const handle = client.counter.getOrCreate(["inspector-traces"]);
|
|
2858
3086
|
await handle.increment(1);
|
|
2859
3087
|
const gatewayUrl = await handle.getGatewayUrl();
|
|
2860
3088
|
const response = await fetch(
|
|
@@ -2871,9 +3099,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2871
3099
|
});
|
|
2872
3100
|
test16("GET /inspector/workflow-history returns workflow status", async (c) => {
|
|
2873
3101
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2874
|
-
const handle = client.counter.getOrCreate([
|
|
2875
|
-
"inspector-workflow"
|
|
2876
|
-
]);
|
|
3102
|
+
const handle = client.counter.getOrCreate(["inspector-workflow"]);
|
|
2877
3103
|
await handle.increment(0);
|
|
2878
3104
|
const gatewayUrl = await handle.getGatewayUrl();
|
|
2879
3105
|
const response = await fetch(
|
|
@@ -2889,21 +3115,97 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2889
3115
|
expect16(data.isWorkflowEnabled).toBe(false);
|
|
2890
3116
|
expect16(data.history).toBeNull();
|
|
2891
3117
|
});
|
|
2892
|
-
test16("GET /inspector/
|
|
3118
|
+
test16("GET /inspector/database/schema returns SQLite schema", async (c) => {
|
|
2893
3119
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2894
|
-
const handle = client.
|
|
2895
|
-
|
|
3120
|
+
const handle = client.dbActorRaw.getOrCreate([
|
|
3121
|
+
`inspector-database-schema-${crypto.randomUUID()}`
|
|
2896
3122
|
]);
|
|
2897
|
-
await handle.
|
|
3123
|
+
await handle.insertValue("Alice");
|
|
3124
|
+
await handle.insertValue("Bob");
|
|
3125
|
+
const gatewayUrl = await handle.getGatewayUrl();
|
|
3126
|
+
const response = await fetch(
|
|
3127
|
+
`${gatewayUrl}/inspector/database/schema`,
|
|
3128
|
+
{
|
|
3129
|
+
headers: { Authorization: "Bearer token" }
|
|
3130
|
+
}
|
|
3131
|
+
);
|
|
3132
|
+
expect16(response.status).toBe(200);
|
|
3133
|
+
const data = await response.json();
|
|
3134
|
+
expect16(Array.isArray(data.schema.tables)).toBe(true);
|
|
3135
|
+
const testDataTable = data.schema.tables.find(
|
|
3136
|
+
(table) => table.table.name === "test_data"
|
|
3137
|
+
);
|
|
3138
|
+
expect16(testDataTable).toBeDefined();
|
|
3139
|
+
expect16(testDataTable == null ? void 0 : testDataTable.table.schema).toBe("main");
|
|
3140
|
+
expect16(testDataTable == null ? void 0 : testDataTable.table.type).toBe("table");
|
|
3141
|
+
expect16(testDataTable == null ? void 0 : testDataTable.records).toBe(2);
|
|
3142
|
+
expect16(testDataTable == null ? void 0 : testDataTable.columns.map((column) => column.name)).toEqual(
|
|
3143
|
+
["id", "value", "payload", "created_at"]
|
|
3144
|
+
);
|
|
3145
|
+
});
|
|
3146
|
+
test16("GET /inspector/workflow-history returns populated history for active workflows", async (c) => {
|
|
3147
|
+
var _a, _b, _c;
|
|
3148
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3149
|
+
const handle = client.workflowCounterActor.getOrCreate([
|
|
3150
|
+
"inspector-workflow-active"
|
|
3151
|
+
]);
|
|
3152
|
+
let state = await handle.getState();
|
|
3153
|
+
for (let i = 0; i < 40 && (state.runCount === 0 || state.history.length === 0); i++) {
|
|
3154
|
+
await waitFor(driverTestConfig, 50);
|
|
3155
|
+
state = await handle.getState();
|
|
3156
|
+
}
|
|
3157
|
+
expect16(state.runCount).toBeGreaterThan(0);
|
|
3158
|
+
expect16(state.history.length).toBeGreaterThan(0);
|
|
3159
|
+
const gatewayUrl = await handle.getGatewayUrl();
|
|
3160
|
+
const response = await fetch(
|
|
3161
|
+
`${gatewayUrl}/inspector/workflow-history`,
|
|
3162
|
+
{
|
|
3163
|
+
headers: { Authorization: "Bearer token" }
|
|
3164
|
+
}
|
|
3165
|
+
);
|
|
3166
|
+
expect16(response.status).toBe(200);
|
|
3167
|
+
const data = await response.json();
|
|
3168
|
+
expect16(data.isWorkflowEnabled).toBe(true);
|
|
3169
|
+
expect16(data.history).not.toBeNull();
|
|
3170
|
+
expect16((_a = data.history) == null ? void 0 : _a.nameRegistry.length).toBeGreaterThan(0);
|
|
3171
|
+
expect16((_b = data.history) == null ? void 0 : _b.entries.length).toBeGreaterThan(0);
|
|
3172
|
+
expect16(
|
|
3173
|
+
Object.keys(((_c = data.history) == null ? void 0 : _c.entryMetadata) ?? {}).length
|
|
3174
|
+
).toBeGreaterThan(0);
|
|
3175
|
+
});
|
|
3176
|
+
test16("GET /inspector/database/rows returns SQLite rows", async (c) => {
|
|
3177
|
+
var _a, _b, _c, _d;
|
|
3178
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3179
|
+
const handle = client.dbActorRaw.getOrCreate([
|
|
3180
|
+
`inspector-database-rows-${crypto.randomUUID()}`
|
|
3181
|
+
]);
|
|
3182
|
+
await handle.insertValue("Alice");
|
|
3183
|
+
await handle.insertValue("Bob");
|
|
2898
3184
|
const gatewayUrl = await handle.getGatewayUrl();
|
|
2899
3185
|
const response = await fetch(
|
|
2900
|
-
`${gatewayUrl}/inspector/
|
|
3186
|
+
`${gatewayUrl}/inspector/database/rows?table=test_data&limit=1&offset=1`,
|
|
2901
3187
|
{
|
|
2902
3188
|
headers: { Authorization: "Bearer token" }
|
|
2903
3189
|
}
|
|
2904
3190
|
);
|
|
2905
3191
|
expect16(response.status).toBe(200);
|
|
2906
3192
|
const data = await response.json();
|
|
3193
|
+
expect16(data.rows).toHaveLength(1);
|
|
3194
|
+
expect16((_a = data.rows[0]) == null ? void 0 : _a.id).toBe(2);
|
|
3195
|
+
expect16((_b = data.rows[0]) == null ? void 0 : _b.value).toBe("Bob");
|
|
3196
|
+
expect16((_c = data.rows[0]) == null ? void 0 : _c.payload).toBe("");
|
|
3197
|
+
expect16(typeof ((_d = data.rows[0]) == null ? void 0 : _d.created_at)).toBe("number");
|
|
3198
|
+
});
|
|
3199
|
+
test16("GET /inspector/summary returns full actor snapshot", async (c) => {
|
|
3200
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3201
|
+
const handle = client.counter.getOrCreate(["inspector-summary"]);
|
|
3202
|
+
await handle.increment(7);
|
|
3203
|
+
const gatewayUrl = await handle.getGatewayUrl();
|
|
3204
|
+
const response = await fetch(`${gatewayUrl}/inspector/summary`, {
|
|
3205
|
+
headers: { Authorization: "Bearer token" }
|
|
3206
|
+
});
|
|
3207
|
+
expect16(response.status).toBe(200);
|
|
3208
|
+
const data = await response.json();
|
|
2907
3209
|
expect16(data.state).toEqual({ count: 7 });
|
|
2908
3210
|
expect16(Array.isArray(data.connections)).toBe(true);
|
|
2909
3211
|
expect16(data.rpcs).toContain("increment");
|
|
@@ -2913,11 +3215,34 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2913
3215
|
expect16(data.isWorkflowEnabled).toBe(false);
|
|
2914
3216
|
expect16(data.workflowHistory).toBeNull();
|
|
2915
3217
|
});
|
|
2916
|
-
test16("inspector
|
|
3218
|
+
test16("GET /inspector/summary returns populated workflow history for active workflows", async (c) => {
|
|
3219
|
+
var _a, _b, _c;
|
|
2917
3220
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2918
|
-
const handle = client.
|
|
2919
|
-
"inspector-
|
|
3221
|
+
const handle = client.workflowCounterActor.getOrCreate([
|
|
3222
|
+
"inspector-summary-workflow"
|
|
2920
3223
|
]);
|
|
3224
|
+
let state = await handle.getState();
|
|
3225
|
+
for (let i = 0; i < 40 && (state.runCount === 0 || state.history.length === 0); i++) {
|
|
3226
|
+
await waitFor(driverTestConfig, 50);
|
|
3227
|
+
state = await handle.getState();
|
|
3228
|
+
}
|
|
3229
|
+
const gatewayUrl = await handle.getGatewayUrl();
|
|
3230
|
+
const response = await fetch(`${gatewayUrl}/inspector/summary`, {
|
|
3231
|
+
headers: { Authorization: "Bearer token" }
|
|
3232
|
+
});
|
|
3233
|
+
expect16(response.status).toBe(200);
|
|
3234
|
+
const data = await response.json();
|
|
3235
|
+
expect16(data.isWorkflowEnabled).toBe(true);
|
|
3236
|
+
expect16(data.workflowHistory).not.toBeNull();
|
|
3237
|
+
expect16((_a = data.workflowHistory) == null ? void 0 : _a.nameRegistry.length).toBeGreaterThan(0);
|
|
3238
|
+
expect16((_b = data.workflowHistory) == null ? void 0 : _b.entries.length).toBeGreaterThan(0);
|
|
3239
|
+
expect16(
|
|
3240
|
+
Object.keys(((_c = data.workflowHistory) == null ? void 0 : _c.entryMetadata) ?? {}).length
|
|
3241
|
+
).toBeGreaterThan(0);
|
|
3242
|
+
});
|
|
3243
|
+
test16("inspector endpoints require auth in non-dev mode", async (c) => {
|
|
3244
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3245
|
+
const handle = client.counter.getOrCreate(["inspector-auth"]);
|
|
2921
3246
|
await handle.increment(0);
|
|
2922
3247
|
const gatewayUrl = await handle.getGatewayUrl();
|
|
2923
3248
|
const response = await fetch(`${gatewayUrl}/inspector/state`, {
|
|
@@ -2938,7 +3263,9 @@ function runActorKvTests(driverTestConfig) {
|
|
|
2938
3263
|
driverTestConfig
|
|
2939
3264
|
);
|
|
2940
3265
|
const client = rawClient;
|
|
2941
|
-
const kvHandle = client.kvActor.getOrCreate([
|
|
3266
|
+
const kvHandle = client.kvActor.getOrCreate([
|
|
3267
|
+
"kv-text"
|
|
3268
|
+
]);
|
|
2942
3269
|
await kvHandle.putText("greeting", "hello");
|
|
2943
3270
|
const value = await kvHandle.getText("greeting");
|
|
2944
3271
|
expect17(value).toBe("hello");
|
|
@@ -2951,46 +3278,72 @@ function runActorKvTests(driverTestConfig) {
|
|
|
2951
3278
|
{ key: "prefix-b", value: "beta" }
|
|
2952
3279
|
]);
|
|
2953
3280
|
});
|
|
2954
|
-
test17(
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
}
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
3281
|
+
test17("supports range scans and range deletes", async (c) => {
|
|
3282
|
+
const { client: rawClient } = await setupDriverTest(
|
|
3283
|
+
c,
|
|
3284
|
+
driverTestConfig
|
|
3285
|
+
);
|
|
3286
|
+
const client = rawClient;
|
|
3287
|
+
const kvHandle = client.kvActor.getOrCreate([
|
|
3288
|
+
"kv-range"
|
|
3289
|
+
]);
|
|
3290
|
+
await kvHandle.putText("a", "alpha");
|
|
3291
|
+
await kvHandle.putText("b", "bravo");
|
|
3292
|
+
await kvHandle.putText("c", "charlie");
|
|
3293
|
+
await kvHandle.putText("d", "delta");
|
|
3294
|
+
const range = await kvHandle.listTextRange("b", "d");
|
|
3295
|
+
expect17(range).toEqual([
|
|
3296
|
+
{ key: "b", value: "bravo" },
|
|
3297
|
+
{ key: "c", value: "charlie" }
|
|
3298
|
+
]);
|
|
3299
|
+
const reversed = await kvHandle.listTextRange("a", "d", {
|
|
3300
|
+
reverse: true,
|
|
3301
|
+
limit: 2
|
|
3302
|
+
});
|
|
3303
|
+
expect17(reversed).toEqual([
|
|
3304
|
+
{ key: "c", value: "charlie" },
|
|
3305
|
+
{ key: "b", value: "bravo" }
|
|
3306
|
+
]);
|
|
3307
|
+
await kvHandle.deleteTextRange("b", "d");
|
|
3308
|
+
const remaining = await kvHandle.listText("");
|
|
3309
|
+
expect17(remaining).toEqual([
|
|
3310
|
+
{ key: "a", value: "alpha" },
|
|
3311
|
+
{ key: "d", value: "delta" }
|
|
3312
|
+
]);
|
|
3313
|
+
});
|
|
3314
|
+
test17("supports arrayBuffer encoding and decoding", async (c) => {
|
|
3315
|
+
const { client: rawClient } = await setupDriverTest(
|
|
3316
|
+
c,
|
|
3317
|
+
driverTestConfig
|
|
3318
|
+
);
|
|
3319
|
+
const client = rawClient;
|
|
3320
|
+
const kvHandle = client.kvActor.getOrCreate([
|
|
3321
|
+
"kv-array-buffer"
|
|
3322
|
+
]);
|
|
3323
|
+
const values = await kvHandle.roundtripArrayBuffer(
|
|
3324
|
+
"bytes",
|
|
3325
|
+
[4, 8, 15, 16, 23, 42]
|
|
3326
|
+
);
|
|
3327
|
+
expect17(values).toEqual([4, 8, 15, 16, 23, 42]);
|
|
3328
|
+
});
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
// src/driver-test-suite/tests/actor-metadata.ts
|
|
3333
|
+
import { describe as describe19, expect as expect18, test as test18 } from "vitest";
|
|
3334
|
+
function runActorMetadataTests(driverTestConfig) {
|
|
3335
|
+
describe19("Actor Metadata Tests", () => {
|
|
3336
|
+
describe19("Actor Name", () => {
|
|
3337
|
+
test18("should provide access to actor name", async (c) => {
|
|
3338
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3339
|
+
const handle = client.metadataActor.getOrCreate();
|
|
3340
|
+
const actorName = await handle.getActorName();
|
|
3341
|
+
expect18(actorName).toBe("metadataActor");
|
|
3342
|
+
});
|
|
3343
|
+
test18("should preserve actor name in state during onWake", async (c) => {
|
|
3344
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3345
|
+
const handle = client.metadataActor.getOrCreate();
|
|
3346
|
+
const storedName = await handle.getStoredActorName();
|
|
2994
3347
|
expect18(storedName).toBe("metadataActor");
|
|
2995
3348
|
});
|
|
2996
3349
|
});
|
|
@@ -3110,6 +3463,49 @@ function runActorOnStateChangeTests(driverTestConfig) {
|
|
|
3110
3463
|
import { describe as describe21, expect as expect20, test as test20 } from "vitest";
|
|
3111
3464
|
function runActorQueueTests(driverTestConfig) {
|
|
3112
3465
|
describe21("Actor Queue Tests", () => {
|
|
3466
|
+
async function expectManyQueueChildToDrain(handle, key) {
|
|
3467
|
+
const child = handle.getOrCreate([key]);
|
|
3468
|
+
const conn = child.connect();
|
|
3469
|
+
const messageCount = MANY_QUEUE_NAMES.length * 4;
|
|
3470
|
+
try {
|
|
3471
|
+
expect20(await conn.ping()).toEqual(
|
|
3472
|
+
expect20.objectContaining({
|
|
3473
|
+
pong: true
|
|
3474
|
+
})
|
|
3475
|
+
);
|
|
3476
|
+
await Promise.all(
|
|
3477
|
+
Array.from(
|
|
3478
|
+
{ length: messageCount },
|
|
3479
|
+
(_, index) => child.send(
|
|
3480
|
+
MANY_QUEUE_NAMES[index % MANY_QUEUE_NAMES.length],
|
|
3481
|
+
{ index }
|
|
3482
|
+
)
|
|
3483
|
+
)
|
|
3484
|
+
);
|
|
3485
|
+
let snapshot = await child.getSnapshot();
|
|
3486
|
+
for (let i = 0; i < 60 && snapshot.processed.length < messageCount; i++) {
|
|
3487
|
+
await waitFor(driverTestConfig, 100);
|
|
3488
|
+
snapshot = await child.getSnapshot();
|
|
3489
|
+
}
|
|
3490
|
+
expect20(snapshot.started).toBe(true);
|
|
3491
|
+
expect20(snapshot.processed).toHaveLength(messageCount);
|
|
3492
|
+
expect20(new Set(snapshot.processed)).toEqual(
|
|
3493
|
+
new Set(MANY_QUEUE_NAMES)
|
|
3494
|
+
);
|
|
3495
|
+
expect20(
|
|
3496
|
+
await child.send(
|
|
3497
|
+
MANY_QUEUE_NAMES[0],
|
|
3498
|
+
{ index: messageCount },
|
|
3499
|
+
{ wait: true, timeout: 1e3 }
|
|
3500
|
+
)
|
|
3501
|
+
).toEqual({
|
|
3502
|
+
status: "completed",
|
|
3503
|
+
response: { ok: true, index: messageCount }
|
|
3504
|
+
});
|
|
3505
|
+
} finally {
|
|
3506
|
+
await conn.dispose().catch(() => void 0);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3113
3509
|
test20("client can send to actor queue", async (c) => {
|
|
3114
3510
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3115
3511
|
const handle = client.queueActor.getOrCreate(["client-send"]);
|
|
@@ -3282,6 +3678,44 @@ function runActorQueueTests(driverTestConfig) {
|
|
|
3282
3678
|
const result = await resultPromise;
|
|
3283
3679
|
expect20(result.status).toBe("timedOut");
|
|
3284
3680
|
});
|
|
3681
|
+
test20(
|
|
3682
|
+
"drains many-queue child actors created from actions while connected",
|
|
3683
|
+
async (c) => {
|
|
3684
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3685
|
+
const parent = client.manyQueueActionParentActor.getOrCreate([
|
|
3686
|
+
"many-action-parent"
|
|
3687
|
+
]);
|
|
3688
|
+
expect20(await parent.spawnChild("many-action-child")).toEqual({
|
|
3689
|
+
key: "many-action-child"
|
|
3690
|
+
});
|
|
3691
|
+
await expectManyQueueChildToDrain(
|
|
3692
|
+
client.manyQueueChildActor,
|
|
3693
|
+
"many-action-child"
|
|
3694
|
+
);
|
|
3695
|
+
}
|
|
3696
|
+
);
|
|
3697
|
+
test20(
|
|
3698
|
+
"drains many-queue child actors created from run handlers while connected",
|
|
3699
|
+
async (c) => {
|
|
3700
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3701
|
+
const parent = client.manyQueueRunParentActor.getOrCreate([
|
|
3702
|
+
"many-run-parent"
|
|
3703
|
+
]);
|
|
3704
|
+
expect20(await parent.queueSpawn("many-run-child")).toEqual({
|
|
3705
|
+
queued: true
|
|
3706
|
+
});
|
|
3707
|
+
let spawned = await parent.getSpawned();
|
|
3708
|
+
for (let i = 0; i < 30 && !spawned.includes("many-run-child"); i++) {
|
|
3709
|
+
await waitFor(driverTestConfig, 100);
|
|
3710
|
+
spawned = await parent.getSpawned();
|
|
3711
|
+
}
|
|
3712
|
+
expect20(spawned).toContain("many-run-child");
|
|
3713
|
+
await expectManyQueueChildToDrain(
|
|
3714
|
+
client.manyQueueChildActor,
|
|
3715
|
+
"many-run-child"
|
|
3716
|
+
);
|
|
3717
|
+
}
|
|
3718
|
+
);
|
|
3285
3719
|
test20("manual receive retries message when not completed", async (c) => {
|
|
3286
3720
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3287
3721
|
const handle = client.queueActor.getOrCreate([
|
|
@@ -3290,7 +3724,9 @@ function runActorQueueTests(driverTestConfig) {
|
|
|
3290
3724
|
await handle.send("tasks", { value: 789 });
|
|
3291
3725
|
const first = await handle.receiveWithoutComplete("tasks");
|
|
3292
3726
|
expect20(first).toEqual({ name: "tasks", body: { value: 789 } });
|
|
3293
|
-
const retried = await handle.receiveOne("tasks", {
|
|
3727
|
+
const retried = await handle.receiveOne("tasks", {
|
|
3728
|
+
timeout: 1e3
|
|
3729
|
+
});
|
|
3294
3730
|
expect20(retried).toEqual({ name: "tasks", body: { value: 789 } });
|
|
3295
3731
|
});
|
|
3296
3732
|
test20("next throws when previous manual message is not completed", async (c) => {
|
|
@@ -3299,9 +3735,7 @@ function runActorQueueTests(driverTestConfig) {
|
|
|
3299
3735
|
"manual-next-requires-complete"
|
|
3300
3736
|
]);
|
|
3301
3737
|
await handle.send("tasks", { value: 111 });
|
|
3302
|
-
const result = await handle.receiveManualThenNextWithoutComplete(
|
|
3303
|
-
"tasks"
|
|
3304
|
-
);
|
|
3738
|
+
const result = await handle.receiveManualThenNextWithoutComplete("tasks");
|
|
3305
3739
|
expect20(result).toEqual({
|
|
3306
3740
|
group: "queue",
|
|
3307
3741
|
code: "previous_message_not_completed"
|
|
@@ -3331,9 +3765,7 @@ function runActorQueueTests(driverTestConfig) {
|
|
|
3331
3765
|
});
|
|
3332
3766
|
test20("complete throws when called twice", async (c) => {
|
|
3333
3767
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3334
|
-
const handle = client.queueActor.getOrCreate([
|
|
3335
|
-
"complete-twice"
|
|
3336
|
-
]);
|
|
3768
|
+
const handle = client.queueActor.getOrCreate(["complete-twice"]);
|
|
3337
3769
|
await handle.send("twice", { value: "test" });
|
|
3338
3770
|
const result = await handle.receiveAndCompleteTwice("twice");
|
|
3339
3771
|
expect20(result).toEqual({
|
|
@@ -3398,9 +3830,7 @@ function runActorRunTests(driverTestConfig) {
|
|
|
3398
3830
|
});
|
|
3399
3831
|
test21("active run handler keeps actor awake past sleep timeout", async (c) => {
|
|
3400
3832
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3401
|
-
const actor = client.runWithTicks.getOrCreate([
|
|
3402
|
-
"run-stays-awake"
|
|
3403
|
-
]);
|
|
3833
|
+
const actor = client.runWithTicks.getOrCreate(["run-stays-awake"]);
|
|
3404
3834
|
await waitFor(driverTestConfig, 100);
|
|
3405
3835
|
const state1 = await actor.getState();
|
|
3406
3836
|
expect21(state1.runStarted).toBe(true);
|
|
@@ -3460,100 +3890,184 @@ function runActorRunTests(driverTestConfig) {
|
|
|
3460
3890
|
const state2 = await actor.getState();
|
|
3461
3891
|
expect21(state2.wakeCount).toBeGreaterThan(state1.wakeCount);
|
|
3462
3892
|
});
|
|
3463
|
-
test21("run handler that exits early
|
|
3893
|
+
test21("run handler that exits early sleeps instead of destroying", async (c) => {
|
|
3894
|
+
var _a2;
|
|
3464
3895
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3465
3896
|
const actor = client.runWithEarlyExit.getOrCreate(["early-exit"]);
|
|
3466
3897
|
await waitFor(driverTestConfig, 100);
|
|
3467
3898
|
const state1 = await actor.getState();
|
|
3468
3899
|
expect21(state1.runStarted).toBe(true);
|
|
3469
|
-
await waitFor(driverTestConfig,
|
|
3470
|
-
const
|
|
3471
|
-
"early-exit-fresh"
|
|
3472
|
-
]);
|
|
3473
|
-
const state2 = await actor2.getState();
|
|
3900
|
+
await waitFor(driverTestConfig, RUN_SLEEP_TIMEOUT + 400);
|
|
3901
|
+
const state2 = await actor.getState();
|
|
3474
3902
|
expect21(state2.runStarted).toBe(true);
|
|
3903
|
+
expect21(state2.destroyCalled).toBe(false);
|
|
3904
|
+
if ((_a2 = driverTestConfig.skip) == null ? void 0 : _a2.sleep) {
|
|
3905
|
+
expect21(state2.sleepCount).toBe(0);
|
|
3906
|
+
expect21(state2.wakeCount).toBe(1);
|
|
3907
|
+
} else {
|
|
3908
|
+
expect21(state2.sleepCount).toBeGreaterThan(0);
|
|
3909
|
+
expect21(state2.wakeCount).toBeGreaterThan(1);
|
|
3910
|
+
}
|
|
3475
3911
|
});
|
|
3476
|
-
test21("run handler that throws error
|
|
3912
|
+
test21("run handler that throws error sleeps instead of destroying", async (c) => {
|
|
3913
|
+
var _a2;
|
|
3477
3914
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3478
3915
|
const actor = client.runWithError.getOrCreate(["run-error"]);
|
|
3479
3916
|
await waitFor(driverTestConfig, 100);
|
|
3480
3917
|
const state1 = await actor.getState();
|
|
3481
3918
|
expect21(state1.runStarted).toBe(true);
|
|
3482
|
-
await waitFor(driverTestConfig,
|
|
3483
|
-
const
|
|
3484
|
-
const state2 = await actor2.getState();
|
|
3919
|
+
await waitFor(driverTestConfig, RUN_SLEEP_TIMEOUT + 400);
|
|
3920
|
+
const state2 = await actor.getState();
|
|
3485
3921
|
expect21(state2.runStarted).toBe(true);
|
|
3922
|
+
expect21(state2.destroyCalled).toBe(false);
|
|
3923
|
+
if ((_a2 = driverTestConfig.skip) == null ? void 0 : _a2.sleep) {
|
|
3924
|
+
expect21(state2.sleepCount).toBe(0);
|
|
3925
|
+
expect21(state2.wakeCount).toBe(1);
|
|
3926
|
+
} else {
|
|
3927
|
+
expect21(state2.sleepCount).toBeGreaterThan(0);
|
|
3928
|
+
expect21(state2.wakeCount).toBeGreaterThan(1);
|
|
3929
|
+
}
|
|
3486
3930
|
});
|
|
3487
3931
|
});
|
|
3488
3932
|
}
|
|
3489
3933
|
|
|
3934
|
+
// src/driver-test-suite/tests/actor-sandbox.ts
|
|
3935
|
+
import { describe as describe23, expect as expect22, test as test22, vi as vi6 } from "vitest";
|
|
3936
|
+
function runActorSandboxTests(driverTestConfig) {
|
|
3937
|
+
var _a;
|
|
3938
|
+
describe23.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.sandbox)("Actor Sandbox Tests", () => {
|
|
3939
|
+
test22("supports sandbox actions through the actor runtime", async (c) => {
|
|
3940
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3941
|
+
const sandbox = client.dockerSandboxActor.getOrCreate([
|
|
3942
|
+
`sandbox-${crypto.randomUUID()}`
|
|
3943
|
+
]);
|
|
3944
|
+
const decoder = new TextDecoder();
|
|
3945
|
+
const health = await vi6.waitFor(
|
|
3946
|
+
async () => {
|
|
3947
|
+
return await sandbox.getHealth();
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
timeout: 12e4,
|
|
3951
|
+
interval: 500
|
|
3952
|
+
}
|
|
3953
|
+
);
|
|
3954
|
+
expect22(typeof health.status).toBe("string");
|
|
3955
|
+
const { url } = await sandbox.getSandboxUrl();
|
|
3956
|
+
expect22(url).toMatch(/^https?:\/\//);
|
|
3957
|
+
await sandbox.mkdirFs({ path: "/root/tmp" });
|
|
3958
|
+
await sandbox.writeFsFile(
|
|
3959
|
+
{ path: "/root/tmp/hello.txt" },
|
|
3960
|
+
"sandbox actor driver test"
|
|
3961
|
+
);
|
|
3962
|
+
expect22(
|
|
3963
|
+
decoder.decode(
|
|
3964
|
+
await sandbox.readFsFile({ path: "/root/tmp/hello.txt" })
|
|
3965
|
+
)
|
|
3966
|
+
).toBe("sandbox actor driver test");
|
|
3967
|
+
const stat = await sandbox.statFs({ path: "/root/tmp/hello.txt" });
|
|
3968
|
+
expect22(stat.entryType).toBe("file");
|
|
3969
|
+
await sandbox.moveFs({
|
|
3970
|
+
from: "/root/tmp/hello.txt",
|
|
3971
|
+
to: "/root/tmp/renamed.txt"
|
|
3972
|
+
});
|
|
3973
|
+
expect22(
|
|
3974
|
+
(await sandbox.listFsEntries({ path: "/root/tmp" })).map(
|
|
3975
|
+
(entry) => entry.name
|
|
3976
|
+
)
|
|
3977
|
+
).toContain("renamed.txt");
|
|
3978
|
+
await sandbox.dispose();
|
|
3979
|
+
const healthAfterDispose = await vi6.waitFor(
|
|
3980
|
+
async () => {
|
|
3981
|
+
return await sandbox.getHealth();
|
|
3982
|
+
},
|
|
3983
|
+
{
|
|
3984
|
+
timeout: 12e4,
|
|
3985
|
+
interval: 500
|
|
3986
|
+
}
|
|
3987
|
+
);
|
|
3988
|
+
expect22(typeof healthAfterDispose.status).toBe("string");
|
|
3989
|
+
expect22(
|
|
3990
|
+
decoder.decode(
|
|
3991
|
+
await sandbox.readFsFile({ path: "/root/tmp/renamed.txt" })
|
|
3992
|
+
)
|
|
3993
|
+
).toBe("sandbox actor driver test");
|
|
3994
|
+
await sandbox.deleteFsEntry({ path: "/root/tmp", recursive: true });
|
|
3995
|
+
expect22(await sandbox.listFsEntries({ path: "/root" })).not.toEqual(
|
|
3996
|
+
expect22.arrayContaining([
|
|
3997
|
+
expect22.objectContaining({ name: "tmp" })
|
|
3998
|
+
])
|
|
3999
|
+
);
|
|
4000
|
+
}, 18e4);
|
|
4001
|
+
});
|
|
4002
|
+
}
|
|
4003
|
+
|
|
3490
4004
|
// src/driver-test-suite/tests/actor-stateless.ts
|
|
3491
|
-
import { describe as
|
|
4005
|
+
import { describe as describe24, expect as expect23, test as test23 } from "vitest";
|
|
3492
4006
|
function runActorStatelessTests(driverTestConfig) {
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
4007
|
+
describe24("Actor Stateless Tests", () => {
|
|
4008
|
+
describe24("Stateless Actor Operations", () => {
|
|
4009
|
+
test23("can call actions on stateless actor", async (c) => {
|
|
3496
4010
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3497
4011
|
const instance = client.statelessActor.getOrCreate();
|
|
3498
4012
|
const result = await instance.ping();
|
|
3499
|
-
|
|
4013
|
+
expect23(result).toBe("pong");
|
|
3500
4014
|
});
|
|
3501
|
-
|
|
4015
|
+
test23("can echo messages", async (c) => {
|
|
3502
4016
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3503
4017
|
const instance = client.statelessActor.getOrCreate();
|
|
3504
4018
|
const message = "Hello, World!";
|
|
3505
4019
|
const result = await instance.echo(message);
|
|
3506
|
-
|
|
4020
|
+
expect23(result).toBe(message);
|
|
3507
4021
|
});
|
|
3508
|
-
|
|
4022
|
+
test23("can access actorId", async (c) => {
|
|
3509
4023
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3510
4024
|
const instance = client.statelessActor.getOrCreate(["test-id"]);
|
|
3511
4025
|
const actorId = await instance.getActorId();
|
|
3512
|
-
|
|
3513
|
-
|
|
4026
|
+
expect23(actorId).toBeDefined();
|
|
4027
|
+
expect23(typeof actorId).toBe("string");
|
|
3514
4028
|
});
|
|
3515
|
-
|
|
4029
|
+
test23("accessing state throws StateNotEnabled", async (c) => {
|
|
3516
4030
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3517
4031
|
const instance = client.statelessActor.getOrCreate();
|
|
3518
4032
|
const result = await instance.tryGetState();
|
|
3519
|
-
|
|
3520
|
-
|
|
4033
|
+
expect23(result.success).toBe(false);
|
|
4034
|
+
expect23(result.error).toContain("state");
|
|
3521
4035
|
});
|
|
3522
|
-
|
|
4036
|
+
test23("accessing db throws DatabaseNotEnabled", async (c) => {
|
|
3523
4037
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3524
4038
|
const instance = client.statelessActor.getOrCreate();
|
|
3525
4039
|
const result = await instance.tryGetDb();
|
|
3526
|
-
|
|
3527
|
-
|
|
4040
|
+
expect23(result.success).toBe(false);
|
|
4041
|
+
expect23(result.error).toContain("database");
|
|
3528
4042
|
});
|
|
3529
|
-
|
|
4043
|
+
test23("multiple stateless actors can exist independently", async (c) => {
|
|
3530
4044
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3531
4045
|
const actor1 = client.statelessActor.getOrCreate(["actor-1"]);
|
|
3532
4046
|
const actor2 = client.statelessActor.getOrCreate(["actor-2"]);
|
|
3533
4047
|
const id1 = await actor1.getActorId();
|
|
3534
4048
|
const id2 = await actor2.getActorId();
|
|
3535
|
-
|
|
4049
|
+
expect23(id1).not.toBe(id2);
|
|
3536
4050
|
});
|
|
3537
4051
|
});
|
|
3538
4052
|
});
|
|
3539
4053
|
}
|
|
3540
4054
|
|
|
3541
4055
|
// src/driver-test-suite/tests/actor-vars.ts
|
|
3542
|
-
import { describe as
|
|
4056
|
+
import { describe as describe25, expect as expect24, test as test24 } from "vitest";
|
|
3543
4057
|
function runActorVarsTests(driverTestConfig) {
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
4058
|
+
describe25("Actor Variables", () => {
|
|
4059
|
+
describe25("Static vars", () => {
|
|
4060
|
+
test24("should provide access to static vars", async (c) => {
|
|
3547
4061
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3548
4062
|
const instance = client.staticVarActor.getOrCreate();
|
|
3549
4063
|
const result = await instance.getVars();
|
|
3550
|
-
|
|
4064
|
+
expect24(result).toEqual({ counter: 42, name: "test-actor" });
|
|
3551
4065
|
const name = await instance.getName();
|
|
3552
|
-
|
|
4066
|
+
expect24(name).toBe("test-actor");
|
|
3553
4067
|
});
|
|
3554
4068
|
});
|
|
3555
|
-
|
|
3556
|
-
|
|
4069
|
+
describe25("Deep cloning of static vars", () => {
|
|
4070
|
+
test24("should deep clone static vars between actor instances", async (c) => {
|
|
3557
4071
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3558
4072
|
const instance1 = client.nestedVarActor.getOrCreate([
|
|
3559
4073
|
"instance1"
|
|
@@ -3562,52 +4076,52 @@ function runActorVarsTests(driverTestConfig) {
|
|
|
3562
4076
|
"instance2"
|
|
3563
4077
|
]);
|
|
3564
4078
|
const modifiedVars = await instance1.modifyNested();
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
4079
|
+
expect24(modifiedVars.nested.value).toBe("modified");
|
|
4080
|
+
expect24(modifiedVars.nested.array).toContain(4);
|
|
4081
|
+
expect24(modifiedVars.nested.obj.key).toBe("new-value");
|
|
3568
4082
|
const instance2Vars = await instance2.getVars();
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
4083
|
+
expect24(instance2Vars.nested.value).toBe("original");
|
|
4084
|
+
expect24(instance2Vars.nested.array).toEqual([1, 2, 3]);
|
|
4085
|
+
expect24(instance2Vars.nested.obj.key).toBe("value");
|
|
3572
4086
|
});
|
|
3573
4087
|
});
|
|
3574
|
-
|
|
3575
|
-
|
|
4088
|
+
describe25("createVars", () => {
|
|
4089
|
+
test24("should support dynamic vars creation", async (c) => {
|
|
3576
4090
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3577
4091
|
const instance = client.dynamicVarActor.getOrCreate();
|
|
3578
4092
|
const vars = await instance.getVars();
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
4093
|
+
expect24(vars).toHaveProperty("random");
|
|
4094
|
+
expect24(vars).toHaveProperty("computed");
|
|
4095
|
+
expect24(typeof vars.random).toBe("number");
|
|
4096
|
+
expect24(typeof vars.computed).toBe("string");
|
|
4097
|
+
expect24(vars.computed).toMatch(/^Actor-\d+$/);
|
|
3584
4098
|
});
|
|
3585
|
-
|
|
4099
|
+
test24("should create different vars for different instances", async (c) => {
|
|
3586
4100
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3587
4101
|
const instance1 = client.uniqueVarActor.getOrCreate(["test1"]);
|
|
3588
4102
|
const instance2 = client.uniqueVarActor.getOrCreate(["test2"]);
|
|
3589
4103
|
const vars1 = await instance1.getVars();
|
|
3590
4104
|
const vars2 = await instance2.getVars();
|
|
3591
|
-
|
|
4105
|
+
expect24(vars1.id).not.toBe(vars2.id);
|
|
3592
4106
|
});
|
|
3593
4107
|
});
|
|
3594
|
-
|
|
3595
|
-
|
|
4108
|
+
describe25("Driver Context", () => {
|
|
4109
|
+
test24("should provide access to driver context", async (c) => {
|
|
3596
4110
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3597
4111
|
const instance = client.driverCtxActor.getOrCreate();
|
|
3598
4112
|
const vars = await instance.getVars();
|
|
3599
|
-
|
|
4113
|
+
expect24(vars).toHaveProperty("hasDriverCtx");
|
|
3600
4114
|
});
|
|
3601
4115
|
});
|
|
3602
4116
|
});
|
|
3603
4117
|
}
|
|
3604
4118
|
|
|
3605
4119
|
// src/driver-test-suite/tests/actor-workflow.ts
|
|
3606
|
-
import { describe as
|
|
4120
|
+
import { describe as describe26, expect as expect25, test as test25, vi as vi7 } from "vitest";
|
|
3607
4121
|
function runActorWorkflowTests(driverTestConfig) {
|
|
3608
|
-
|
|
3609
|
-
var _a;
|
|
3610
|
-
|
|
4122
|
+
describe26("Actor Workflow Tests", () => {
|
|
4123
|
+
var _a, _b, _c, _d;
|
|
4124
|
+
test25("replays steps and guards state access", async (c) => {
|
|
3611
4125
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3612
4126
|
const actor = client.workflowCounterActor.getOrCreate([
|
|
3613
4127
|
"workflow-basic"
|
|
@@ -3620,32 +4134,146 @@ function runActorWorkflowTests(driverTestConfig) {
|
|
|
3620
4134
|
await waitFor(driverTestConfig, 100);
|
|
3621
4135
|
state = await actor.getState();
|
|
3622
4136
|
}
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
4137
|
+
expect25(state.runCount).toBeGreaterThan(0);
|
|
4138
|
+
expect25(state.history.length).toBeGreaterThan(0);
|
|
4139
|
+
expect25(state.guardTriggered).toBe(true);
|
|
3626
4140
|
});
|
|
3627
|
-
|
|
4141
|
+
test25("consumes queue messages via workflow queue.next", async (c) => {
|
|
3628
4142
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3629
|
-
const actor = client.workflowQueueActor.getOrCreate([
|
|
4143
|
+
const actor = client.workflowQueueActor.getOrCreate([
|
|
4144
|
+
"workflow-queue"
|
|
4145
|
+
]);
|
|
3630
4146
|
await actor.send(WORKFLOW_QUEUE_NAME, {
|
|
3631
4147
|
hello: "world"
|
|
3632
4148
|
});
|
|
3633
4149
|
await waitFor(driverTestConfig, 200);
|
|
3634
4150
|
const messages = await actor.getMessages();
|
|
3635
|
-
|
|
4151
|
+
expect25(messages).toEqual([{ hello: "world" }]);
|
|
3636
4152
|
});
|
|
3637
|
-
|
|
4153
|
+
test25("workflow queue.next supports completing wait sends", async (c) => {
|
|
3638
4154
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3639
4155
|
const actor = client.workflowQueueActor.getOrCreate([
|
|
3640
4156
|
"workflow-queue-wait"
|
|
3641
4157
|
]);
|
|
3642
4158
|
const result = await actor.sendAndWait({ value: 123 });
|
|
3643
|
-
|
|
4159
|
+
expect25(result).toEqual({
|
|
3644
4160
|
status: "completed",
|
|
3645
4161
|
response: { echo: { value: 123 } }
|
|
3646
4162
|
});
|
|
3647
4163
|
});
|
|
3648
|
-
|
|
4164
|
+
for (const testCase of [
|
|
4165
|
+
{
|
|
4166
|
+
name: "nested loops",
|
|
4167
|
+
key: "loop",
|
|
4168
|
+
getActor: (client) => client.workflowNestedLoopActor,
|
|
4169
|
+
firstItems: ["a", "b"],
|
|
4170
|
+
secondItems: ["c"],
|
|
4171
|
+
expected: ["a", "b", "c"]
|
|
4172
|
+
},
|
|
4173
|
+
{
|
|
4174
|
+
name: "nested joins",
|
|
4175
|
+
key: "join",
|
|
4176
|
+
getActor: (client) => client.workflowNestedJoinActor,
|
|
4177
|
+
firstItems: ["a", "b"],
|
|
4178
|
+
secondItems: ["c"],
|
|
4179
|
+
expected: ["a", "b", "c"]
|
|
4180
|
+
},
|
|
4181
|
+
{
|
|
4182
|
+
name: "nested races",
|
|
4183
|
+
key: "race",
|
|
4184
|
+
getActor: (client) => client.workflowNestedRaceActor,
|
|
4185
|
+
firstItems: ["a"],
|
|
4186
|
+
secondItems: ["b"],
|
|
4187
|
+
expected: ["a", "b"]
|
|
4188
|
+
}
|
|
4189
|
+
]) {
|
|
4190
|
+
test25(
|
|
4191
|
+
`replays ${testCase.name} across workflow queue iterations`,
|
|
4192
|
+
async (c) => {
|
|
4193
|
+
const { client } = await setupDriverTest(
|
|
4194
|
+
c,
|
|
4195
|
+
driverTestConfig
|
|
4196
|
+
);
|
|
4197
|
+
const actor = testCase.getActor(client).getOrCreate([
|
|
4198
|
+
`workflow-nested-${testCase.key}`
|
|
4199
|
+
]);
|
|
4200
|
+
const first = await actor.send(
|
|
4201
|
+
WORKFLOW_NESTED_QUEUE_NAME,
|
|
4202
|
+
{
|
|
4203
|
+
items: testCase.firstItems
|
|
4204
|
+
},
|
|
4205
|
+
{
|
|
4206
|
+
wait: true,
|
|
4207
|
+
timeout: 1e3
|
|
4208
|
+
}
|
|
4209
|
+
);
|
|
4210
|
+
expect25(first).toEqual({
|
|
4211
|
+
status: "completed",
|
|
4212
|
+
response: {
|
|
4213
|
+
processed: testCase.firstItems.length
|
|
4214
|
+
}
|
|
4215
|
+
});
|
|
4216
|
+
const second = await actor.send(
|
|
4217
|
+
WORKFLOW_NESTED_QUEUE_NAME,
|
|
4218
|
+
{
|
|
4219
|
+
items: testCase.secondItems
|
|
4220
|
+
},
|
|
4221
|
+
{
|
|
4222
|
+
wait: true,
|
|
4223
|
+
timeout: 1e3
|
|
4224
|
+
}
|
|
4225
|
+
);
|
|
4226
|
+
expect25(second).toEqual({
|
|
4227
|
+
status: "completed",
|
|
4228
|
+
response: {
|
|
4229
|
+
processed: testCase.secondItems.length
|
|
4230
|
+
}
|
|
4231
|
+
});
|
|
4232
|
+
const state = await actor.getState();
|
|
4233
|
+
expect25(state.processed).toEqual(testCase.expected);
|
|
4234
|
+
}
|
|
4235
|
+
);
|
|
4236
|
+
}
|
|
4237
|
+
test25(
|
|
4238
|
+
"starts child workflows created inside workflow steps",
|
|
4239
|
+
async (c) => {
|
|
4240
|
+
const { client } = await setupDriverTest(
|
|
4241
|
+
c,
|
|
4242
|
+
driverTestConfig
|
|
4243
|
+
);
|
|
4244
|
+
const parent = client.workflowSpawnParentActor.getOrCreate([
|
|
4245
|
+
"workflow-spawn-parent"
|
|
4246
|
+
]);
|
|
4247
|
+
expect25(await parent.triggerSpawn("child-1")).toEqual({
|
|
4248
|
+
queued: true
|
|
4249
|
+
});
|
|
4250
|
+
let parentState = await parent.getState();
|
|
4251
|
+
for (let i = 0; i < 30 && parentState.results.length === 0; i++) {
|
|
4252
|
+
await waitFor(driverTestConfig, 100);
|
|
4253
|
+
parentState = await parent.getState();
|
|
4254
|
+
}
|
|
4255
|
+
expect25(parentState.results).toEqual([
|
|
4256
|
+
{
|
|
4257
|
+
key: "child-1",
|
|
4258
|
+
result: {
|
|
4259
|
+
status: "completed",
|
|
4260
|
+
response: { ok: true }
|
|
4261
|
+
},
|
|
4262
|
+
error: null
|
|
4263
|
+
}
|
|
4264
|
+
]);
|
|
4265
|
+
const child = client.workflowSpawnChildActor.getOrCreate([
|
|
4266
|
+
"child-1"
|
|
4267
|
+
]);
|
|
4268
|
+
const childState = await child.getState();
|
|
4269
|
+
expect25(childState).toEqual({
|
|
4270
|
+
label: "child-1",
|
|
4271
|
+
started: true,
|
|
4272
|
+
processed: ["hello"]
|
|
4273
|
+
});
|
|
4274
|
+
}
|
|
4275
|
+
);
|
|
4276
|
+
test25("db and client are step-only in workflow context", async (c) => {
|
|
3649
4277
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3650
4278
|
const actor = client.workflowAccessActor.getOrCreate([
|
|
3651
4279
|
"workflow-access"
|
|
@@ -3655,24 +4283,215 @@ function runActorWorkflowTests(driverTestConfig) {
|
|
|
3655
4283
|
await waitFor(driverTestConfig, 50);
|
|
3656
4284
|
state = await actor.getState();
|
|
3657
4285
|
}
|
|
3658
|
-
|
|
4286
|
+
expect25(state.outsideDbError).toBe(
|
|
3659
4287
|
"db is only available inside workflow steps"
|
|
3660
4288
|
);
|
|
3661
|
-
|
|
4289
|
+
expect25(state.outsideClientError).toBe(
|
|
3662
4290
|
"client is only available inside workflow steps"
|
|
3663
4291
|
);
|
|
3664
|
-
|
|
3665
|
-
|
|
4292
|
+
expect25(state.insideDbCount).toBeGreaterThan(0);
|
|
4293
|
+
expect25(state.insideClientAvailable).toBe(true);
|
|
3666
4294
|
});
|
|
3667
|
-
|
|
4295
|
+
test25("sleeps and resumes between ticks", async (c) => {
|
|
3668
4296
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3669
|
-
const actor = client.workflowSleepActor.getOrCreate([
|
|
4297
|
+
const actor = client.workflowSleepActor.getOrCreate([
|
|
4298
|
+
"workflow-sleep"
|
|
4299
|
+
]);
|
|
3670
4300
|
const initial = await actor.getState();
|
|
3671
4301
|
await waitFor(driverTestConfig, 200);
|
|
3672
4302
|
const next = await actor.getState();
|
|
3673
|
-
|
|
4303
|
+
expect25(next.ticks).toBeGreaterThan(initial.ticks);
|
|
3674
4304
|
});
|
|
3675
|
-
|
|
4305
|
+
test25("workflow onError reports retry metadata", async (c) => {
|
|
4306
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4307
|
+
const actor = client.workflowErrorHookActor.getOrCreate([
|
|
4308
|
+
"workflow-error-hook"
|
|
4309
|
+
]);
|
|
4310
|
+
let state = await actor.getErrorState();
|
|
4311
|
+
for (let i = 0; i < 80 && (state.attempts < 2 || state.events.length === 0); i++) {
|
|
4312
|
+
await waitFor(driverTestConfig, 50);
|
|
4313
|
+
state = await actor.getErrorState();
|
|
4314
|
+
}
|
|
4315
|
+
expect25(state.attempts).toBe(2);
|
|
4316
|
+
expect25(state.events).toHaveLength(1);
|
|
4317
|
+
expect25(state.events[0]).toEqual(
|
|
4318
|
+
expect25.objectContaining({
|
|
4319
|
+
step: expect25.objectContaining({
|
|
4320
|
+
stepName: "flaky",
|
|
4321
|
+
attempt: 1,
|
|
4322
|
+
willRetry: true,
|
|
4323
|
+
retryDelay: 1,
|
|
4324
|
+
error: expect25.objectContaining({
|
|
4325
|
+
name: "Error",
|
|
4326
|
+
message: "workflow hook failed"
|
|
4327
|
+
})
|
|
4328
|
+
})
|
|
4329
|
+
})
|
|
4330
|
+
);
|
|
4331
|
+
});
|
|
4332
|
+
test25("workflow onError can update actor state", async (c) => {
|
|
4333
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4334
|
+
const actor = client.workflowErrorHookEffectsActor.getOrCreate([
|
|
4335
|
+
"workflow-error-state"
|
|
4336
|
+
]);
|
|
4337
|
+
await actor.startWorkflow();
|
|
4338
|
+
let state = await actor.getErrorState();
|
|
4339
|
+
for (let i = 0; i < 80 && (state.attempts < 2 || state.lastError === null || state.errorCount === 0); i++) {
|
|
4340
|
+
await waitFor(driverTestConfig, 50);
|
|
4341
|
+
state = await actor.getErrorState();
|
|
4342
|
+
}
|
|
4343
|
+
expect25(state.attempts).toBe(2);
|
|
4344
|
+
expect25(state.errorCount).toBe(1);
|
|
4345
|
+
expect25(state.lastError).toEqual(
|
|
4346
|
+
expect25.objectContaining({
|
|
4347
|
+
step: expect25.objectContaining({
|
|
4348
|
+
stepName: "flaky",
|
|
4349
|
+
attempt: 1,
|
|
4350
|
+
willRetry: true,
|
|
4351
|
+
retryDelay: 1,
|
|
4352
|
+
error: expect25.objectContaining({
|
|
4353
|
+
name: "Error",
|
|
4354
|
+
message: "workflow hook failed"
|
|
4355
|
+
})
|
|
4356
|
+
})
|
|
4357
|
+
})
|
|
4358
|
+
);
|
|
4359
|
+
});
|
|
4360
|
+
test25("workflow onError can broadcast actor events", async (c) => {
|
|
4361
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4362
|
+
const actor = client.workflowErrorHookEffectsActor.getOrCreate(["workflow-error-broadcast"]).connect();
|
|
4363
|
+
try {
|
|
4364
|
+
const eventPromise = new Promise((resolve) => {
|
|
4365
|
+
actor.once("workflowError", resolve);
|
|
4366
|
+
});
|
|
4367
|
+
await actor.startWorkflow();
|
|
4368
|
+
const event = await eventPromise;
|
|
4369
|
+
expect25(event).toEqual(
|
|
4370
|
+
expect25.objectContaining({
|
|
4371
|
+
step: expect25.objectContaining({
|
|
4372
|
+
stepName: "flaky",
|
|
4373
|
+
attempt: 1,
|
|
4374
|
+
willRetry: true,
|
|
4375
|
+
retryDelay: 1,
|
|
4376
|
+
error: expect25.objectContaining({
|
|
4377
|
+
name: "Error",
|
|
4378
|
+
message: "workflow hook failed"
|
|
4379
|
+
})
|
|
4380
|
+
})
|
|
4381
|
+
})
|
|
4382
|
+
);
|
|
4383
|
+
} finally {
|
|
4384
|
+
await actor.dispose();
|
|
4385
|
+
}
|
|
4386
|
+
});
|
|
4387
|
+
test25("workflow onError can enqueue actor messages", async (c) => {
|
|
4388
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4389
|
+
const actor = client.workflowErrorHookEffectsActor.getOrCreate([
|
|
4390
|
+
"workflow-error-queue"
|
|
4391
|
+
]);
|
|
4392
|
+
await actor.startWorkflow();
|
|
4393
|
+
const queuedError = await actor.receiveQueuedError();
|
|
4394
|
+
expect25(queuedError).toEqual(
|
|
4395
|
+
expect25.objectContaining({
|
|
4396
|
+
step: expect25.objectContaining({
|
|
4397
|
+
stepName: "flaky",
|
|
4398
|
+
attempt: 1,
|
|
4399
|
+
willRetry: true,
|
|
4400
|
+
retryDelay: 1,
|
|
4401
|
+
error: expect25.objectContaining({
|
|
4402
|
+
name: "Error",
|
|
4403
|
+
message: "workflow hook failed"
|
|
4404
|
+
})
|
|
4405
|
+
})
|
|
4406
|
+
})
|
|
4407
|
+
);
|
|
4408
|
+
});
|
|
4409
|
+
test25.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.sleep)(
|
|
4410
|
+
"completed workflows sleep instead of destroying the actor",
|
|
4411
|
+
async (c) => {
|
|
4412
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4413
|
+
const actor = client.workflowCompleteActor.getOrCreate([
|
|
4414
|
+
"workflow-complete"
|
|
4415
|
+
]);
|
|
4416
|
+
let state = await actor.getState();
|
|
4417
|
+
for (let i = 0; i < 10 && state.sleepCount === 0; i++) {
|
|
4418
|
+
await waitFor(driverTestConfig, 100);
|
|
4419
|
+
state = await actor.getState();
|
|
4420
|
+
}
|
|
4421
|
+
expect25(state.runCount).toBeGreaterThan(0);
|
|
4422
|
+
expect25(state.sleepCount).toBeGreaterThan(0);
|
|
4423
|
+
expect25(state.startCount).toBeGreaterThan(1);
|
|
4424
|
+
}
|
|
4425
|
+
);
|
|
4426
|
+
test25("workflow steps can destroy the actor", async (c) => {
|
|
4427
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4428
|
+
const actorKey = "workflow-destroy";
|
|
4429
|
+
const observer = client.destroyObserver.getOrCreate(["observer"]);
|
|
4430
|
+
await observer.reset();
|
|
4431
|
+
const actor = client.workflowDestroyActor.getOrCreate([actorKey]);
|
|
4432
|
+
const actorId = await actor.resolve();
|
|
4433
|
+
await vi7.waitFor(async () => {
|
|
4434
|
+
const wasDestroyed = await observer.wasDestroyed(actorKey);
|
|
4435
|
+
expect25(wasDestroyed, "actor onDestroy not called").toBeTruthy();
|
|
4436
|
+
});
|
|
4437
|
+
await vi7.waitFor(async () => {
|
|
4438
|
+
let actorRunning = false;
|
|
4439
|
+
try {
|
|
4440
|
+
await client.workflowDestroyActor.getForId(actorId).resolve();
|
|
4441
|
+
actorRunning = true;
|
|
4442
|
+
} catch (err) {
|
|
4443
|
+
expect25(err.group).toBe("actor");
|
|
4444
|
+
expect25(err.code).toBe("not_found");
|
|
4445
|
+
}
|
|
4446
|
+
expect25(actorRunning, "actor still running").toBeFalsy();
|
|
4447
|
+
});
|
|
4448
|
+
});
|
|
4449
|
+
test25.skipIf((_b = driverTestConfig.skip) == null ? void 0 : _b.sleep)(
|
|
4450
|
+
"failed workflow steps sleep instead of surfacing as run errors",
|
|
4451
|
+
async (c) => {
|
|
4452
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4453
|
+
const actor = client.workflowFailedStepActor.getOrCreate([
|
|
4454
|
+
"workflow-failed-step"
|
|
4455
|
+
]);
|
|
4456
|
+
let state = await actor.getState();
|
|
4457
|
+
for (let i = 0; i < 10 && state.sleepCount === 0; i++) {
|
|
4458
|
+
await waitFor(driverTestConfig, 100);
|
|
4459
|
+
state = await actor.getState();
|
|
4460
|
+
}
|
|
4461
|
+
expect25(state.runCount).toBeGreaterThan(0);
|
|
4462
|
+
expect25(state.sleepCount).toBeGreaterThan(0);
|
|
4463
|
+
expect25(state.startCount).toBeGreaterThan(1);
|
|
4464
|
+
}
|
|
4465
|
+
);
|
|
4466
|
+
test25.skipIf((_c = driverTestConfig.skip) == null ? void 0 : _c.sleep)(
|
|
4467
|
+
"workflow onError is not reported again after sleep and wake",
|
|
4468
|
+
async (c) => {
|
|
4469
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4470
|
+
const actor = client.workflowErrorHookSleepActor.getOrCreate([
|
|
4471
|
+
"workflow-error-hook-sleep"
|
|
4472
|
+
]);
|
|
4473
|
+
let state = await actor.getErrorState();
|
|
4474
|
+
for (let i = 0; i < 80 && (state.attempts < 2 || state.events.length === 0); i++) {
|
|
4475
|
+
await waitFor(driverTestConfig, 50);
|
|
4476
|
+
state = await actor.getErrorState();
|
|
4477
|
+
}
|
|
4478
|
+
expect25(state.attempts).toBe(2);
|
|
4479
|
+
expect25(state.events).toHaveLength(1);
|
|
4480
|
+
expect25(state.wakeCount).toBe(1);
|
|
4481
|
+
await actor.triggerSleep();
|
|
4482
|
+
await waitFor(driverTestConfig, 250);
|
|
4483
|
+
let resumedState = await actor.getErrorState();
|
|
4484
|
+
for (let i = 0; i < 40 && (resumedState.wakeCount < 2 || resumedState.sleepCount < 1); i++) {
|
|
4485
|
+
await waitFor(driverTestConfig, 50);
|
|
4486
|
+
resumedState = await actor.getErrorState();
|
|
4487
|
+
}
|
|
4488
|
+
expect25(resumedState.sleepCount).toBeGreaterThanOrEqual(1);
|
|
4489
|
+
expect25(resumedState.wakeCount).toBeGreaterThanOrEqual(2);
|
|
4490
|
+
expect25(resumedState.attempts).toBe(2);
|
|
4491
|
+
expect25(resumedState.events).toHaveLength(1);
|
|
4492
|
+
}
|
|
4493
|
+
);
|
|
4494
|
+
test25.skipIf((_d = driverTestConfig.skip) == null ? void 0 : _d.sleep)(
|
|
3676
4495
|
"workflow run teardown does not wait for runStopTimeout",
|
|
3677
4496
|
async (c) => {
|
|
3678
4497
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
@@ -3682,69 +4501,69 @@ function runActorWorkflowTests(driverTestConfig) {
|
|
|
3682
4501
|
await actor.getTimeline();
|
|
3683
4502
|
await waitFor(driverTestConfig, 1200);
|
|
3684
4503
|
const timeline = await actor.getTimeline();
|
|
3685
|
-
|
|
3686
|
-
|
|
4504
|
+
expect25(timeline.wakeAts.length).toBeGreaterThanOrEqual(2);
|
|
4505
|
+
expect25(timeline.sleepAts.length).toBeGreaterThanOrEqual(1);
|
|
3687
4506
|
const firstSleepDelayMs = timeline.sleepAts[0] - timeline.wakeAts[0];
|
|
3688
|
-
|
|
4507
|
+
expect25(firstSleepDelayMs).toBeLessThan(1800);
|
|
3689
4508
|
}
|
|
3690
4509
|
);
|
|
3691
4510
|
});
|
|
3692
4511
|
}
|
|
3693
4512
|
|
|
3694
4513
|
// src/driver-test-suite/tests/manager-driver.ts
|
|
3695
|
-
import { describe as
|
|
4514
|
+
import { describe as describe27, expect as expect26, test as test26 } from "vitest";
|
|
3696
4515
|
function runManagerDriverTests(driverTestConfig) {
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
4516
|
+
describe27("Manager Driver Tests", () => {
|
|
4517
|
+
describe27("Client Connection Methods", () => {
|
|
4518
|
+
test26("connect() - finds or creates a actor", async (c) => {
|
|
3700
4519
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3701
4520
|
const counterA = client.counter.getOrCreate();
|
|
3702
4521
|
await counterA.increment(5);
|
|
3703
4522
|
const counterAAgain = client.counter.getOrCreate();
|
|
3704
4523
|
const count = await counterAAgain.increment(0);
|
|
3705
|
-
|
|
4524
|
+
expect26(count).toBe(5);
|
|
3706
4525
|
const counterB = client.counter.getOrCreate([
|
|
3707
4526
|
"counter-b",
|
|
3708
4527
|
"testing"
|
|
3709
4528
|
]);
|
|
3710
4529
|
await counterB.increment(10);
|
|
3711
4530
|
const countB = await counterB.increment(0);
|
|
3712
|
-
|
|
4531
|
+
expect26(countB).toBe(10);
|
|
3713
4532
|
});
|
|
3714
|
-
|
|
4533
|
+
test26("throws ActorAlreadyExists when creating duplicate actors", async (c) => {
|
|
3715
4534
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3716
4535
|
const uniqueKey = ["duplicate-actor-test", crypto.randomUUID()];
|
|
3717
4536
|
const counter = client.counter.getOrCreate(uniqueKey);
|
|
3718
4537
|
await counter.increment(5);
|
|
3719
4538
|
try {
|
|
3720
4539
|
await client.counter.create(uniqueKey);
|
|
3721
|
-
|
|
4540
|
+
expect26.fail("did not error on duplicate create");
|
|
3722
4541
|
} catch (err) {
|
|
3723
|
-
|
|
3724
|
-
|
|
4542
|
+
expect26(err.group).toBe("actor");
|
|
4543
|
+
expect26(err.code).toBe("duplicate_key");
|
|
3725
4544
|
}
|
|
3726
4545
|
const count = await counter.increment(0);
|
|
3727
|
-
|
|
4546
|
+
expect26(count).toBe(5);
|
|
3728
4547
|
});
|
|
3729
4548
|
});
|
|
3730
|
-
|
|
3731
|
-
|
|
4549
|
+
describe27("Connection Options", () => {
|
|
4550
|
+
test26("get without create prevents actor creation", async (c) => {
|
|
3732
4551
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3733
4552
|
const nonexistentId = `nonexistent-${crypto.randomUUID()}`;
|
|
3734
4553
|
try {
|
|
3735
4554
|
await client.counter.get([nonexistentId]).resolve();
|
|
3736
|
-
|
|
4555
|
+
expect26.fail("did not error for get");
|
|
3737
4556
|
} catch (err) {
|
|
3738
|
-
|
|
3739
|
-
|
|
4557
|
+
expect26(err.group).toBe("actor");
|
|
4558
|
+
expect26(err.code).toBe("not_found");
|
|
3740
4559
|
}
|
|
3741
4560
|
const createdCounter = client.counter.getOrCreate(nonexistentId);
|
|
3742
4561
|
await createdCounter.increment(3);
|
|
3743
4562
|
const retrievedCounter = client.counter.get(nonexistentId);
|
|
3744
4563
|
const count = await retrievedCounter.increment(0);
|
|
3745
|
-
|
|
4564
|
+
expect26(count).toBe(3);
|
|
3746
4565
|
});
|
|
3747
|
-
|
|
4566
|
+
test26("connection params are passed to actors", async (c) => {
|
|
3748
4567
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3749
4568
|
const counter = client.counter.getOrCreate(void 0, {
|
|
3750
4569
|
params: {
|
|
@@ -3755,20 +4574,20 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3755
4574
|
});
|
|
3756
4575
|
await counter.increment(1);
|
|
3757
4576
|
const count = await counter.increment(0);
|
|
3758
|
-
|
|
4577
|
+
expect26(count).toBe(1);
|
|
3759
4578
|
});
|
|
3760
4579
|
});
|
|
3761
|
-
|
|
3762
|
-
|
|
4580
|
+
describe27("Actor Creation & Retrieval", () => {
|
|
4581
|
+
test26("creates and retrieves actors by ID", async (c) => {
|
|
3763
4582
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3764
4583
|
const uniqueId = `test-counter-${crypto.randomUUID()}`;
|
|
3765
4584
|
const counter = client.counter.getOrCreate([uniqueId]);
|
|
3766
4585
|
await counter.increment(10);
|
|
3767
4586
|
const retrievedCounter = client.counter.getOrCreate([uniqueId]);
|
|
3768
4587
|
const count = await retrievedCounter.increment(0);
|
|
3769
|
-
|
|
4588
|
+
expect26(count).toBe(10);
|
|
3770
4589
|
});
|
|
3771
|
-
|
|
4590
|
+
test26("passes input to actor during creation", async (c) => {
|
|
3772
4591
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3773
4592
|
const testInput = {
|
|
3774
4593
|
name: "test-actor",
|
|
@@ -3779,17 +4598,17 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3779
4598
|
input: testInput
|
|
3780
4599
|
});
|
|
3781
4600
|
const inputs = await actor.getInputs();
|
|
3782
|
-
|
|
3783
|
-
|
|
4601
|
+
expect26(inputs.initialInput).toEqual(testInput);
|
|
4602
|
+
expect26(inputs.onCreateInput).toEqual(testInput);
|
|
3784
4603
|
});
|
|
3785
|
-
|
|
4604
|
+
test26("input is undefined when not provided", async (c) => {
|
|
3786
4605
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3787
4606
|
const actor = await client.inputActor.create();
|
|
3788
4607
|
const inputs = await actor.getInputs();
|
|
3789
|
-
|
|
3790
|
-
|
|
4608
|
+
expect26(inputs.initialInput).toBeUndefined();
|
|
4609
|
+
expect26(inputs.onCreateInput).toBeUndefined();
|
|
3791
4610
|
});
|
|
3792
|
-
|
|
4611
|
+
test26("getOrCreate passes input to actor during creation", async (c) => {
|
|
3793
4612
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3794
4613
|
const uniqueKey = [`input-test-${crypto.randomUUID()}`];
|
|
3795
4614
|
const testInput = {
|
|
@@ -3801,22 +4620,22 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3801
4620
|
createWithInput: testInput
|
|
3802
4621
|
});
|
|
3803
4622
|
const inputs = await actor.getInputs();
|
|
3804
|
-
|
|
3805
|
-
|
|
4623
|
+
expect26(inputs.initialInput).toEqual(testInput);
|
|
4624
|
+
expect26(inputs.onCreateInput).toEqual(testInput);
|
|
3806
4625
|
const existingActor = client.inputActor.getOrCreate(uniqueKey);
|
|
3807
4626
|
const existingInputs = await existingActor.getInputs();
|
|
3808
|
-
|
|
3809
|
-
|
|
4627
|
+
expect26(existingInputs.initialInput).toEqual(testInput);
|
|
4628
|
+
expect26(existingInputs.onCreateInput).toEqual(testInput);
|
|
3810
4629
|
});
|
|
3811
4630
|
});
|
|
3812
|
-
|
|
3813
|
-
|
|
4631
|
+
describe27("Key Matching", () => {
|
|
4632
|
+
test26("multi-part actor keys are passed through correctly", async (c) => {
|
|
3814
4633
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3815
4634
|
const multiPartKey = ["tenant/with/slash", "room"];
|
|
3816
4635
|
const counter = client.counter.getOrCreate(multiPartKey);
|
|
3817
|
-
|
|
4636
|
+
expect26(await counter.getKey()).toEqual(multiPartKey);
|
|
3818
4637
|
});
|
|
3819
|
-
|
|
4638
|
+
test26("matches actors only with exactly the same keys", async (c) => {
|
|
3820
4639
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3821
4640
|
const originalCounter = client.counter.getOrCreate([
|
|
3822
4641
|
"counter-match",
|
|
@@ -3830,20 +4649,20 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3830
4649
|
"us-east"
|
|
3831
4650
|
]);
|
|
3832
4651
|
const exactMatchCount = await exactMatchCounter.increment(0);
|
|
3833
|
-
|
|
4652
|
+
expect26(exactMatchCount).toBe(10);
|
|
3834
4653
|
const subsetMatchCounter = client.counter.getOrCreate([
|
|
3835
4654
|
"counter-match",
|
|
3836
4655
|
"test"
|
|
3837
4656
|
]);
|
|
3838
4657
|
const subsetMatchCount = await subsetMatchCounter.increment(0);
|
|
3839
|
-
|
|
4658
|
+
expect26(subsetMatchCount).toBe(0);
|
|
3840
4659
|
const singleKeyCounter = client.counter.getOrCreate([
|
|
3841
4660
|
"counter-match"
|
|
3842
4661
|
]);
|
|
3843
4662
|
const singleKeyCount = await singleKeyCounter.increment(0);
|
|
3844
|
-
|
|
4663
|
+
expect26(singleKeyCount).toBe(0);
|
|
3845
4664
|
});
|
|
3846
|
-
|
|
4665
|
+
test26("string key matches array with single string key", async (c) => {
|
|
3847
4666
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3848
4667
|
const stringKeyCounter = client.counter.getOrCreate("string-key-test");
|
|
3849
4668
|
await stringKeyCounter.increment(7);
|
|
@@ -3851,20 +4670,20 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3851
4670
|
"string-key-test"
|
|
3852
4671
|
]);
|
|
3853
4672
|
const count = await arrayKeyCounter.increment(0);
|
|
3854
|
-
|
|
4673
|
+
expect26(count).toBe(7);
|
|
3855
4674
|
});
|
|
3856
|
-
|
|
4675
|
+
test26("undefined key matches empty array key and no key", async (c) => {
|
|
3857
4676
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3858
4677
|
const undefinedKeyCounter = client.counter.getOrCreate(void 0);
|
|
3859
4678
|
await undefinedKeyCounter.increment(12);
|
|
3860
4679
|
const emptyArrayKeyCounter = client.counter.getOrCreate([]);
|
|
3861
4680
|
const emptyArrayCount = await emptyArrayKeyCounter.increment(0);
|
|
3862
|
-
|
|
4681
|
+
expect26(emptyArrayCount).toBe(12);
|
|
3863
4682
|
const noKeyCounter = client.counter.getOrCreate();
|
|
3864
4683
|
const noKeyCount = await noKeyCounter.increment(0);
|
|
3865
|
-
|
|
4684
|
+
expect26(noKeyCount).toBe(12);
|
|
3866
4685
|
});
|
|
3867
|
-
|
|
4686
|
+
test26("no keys does not match actors with keys", async (c) => {
|
|
3868
4687
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3869
4688
|
const keyedCounter = client.counter.getOrCreate([
|
|
3870
4689
|
"counter-with-keys",
|
|
@@ -3873,9 +4692,9 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3873
4692
|
await keyedCounter.increment(15);
|
|
3874
4693
|
const noKeysCounter = client.counter.getOrCreate();
|
|
3875
4694
|
const count = await noKeysCounter.increment(10);
|
|
3876
|
-
|
|
4695
|
+
expect26(count).toBe(10);
|
|
3877
4696
|
});
|
|
3878
|
-
|
|
4697
|
+
test26("actors with keys match actors with no keys", async (c) => {
|
|
3879
4698
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3880
4699
|
const noKeysCounter = client.counter.getOrCreate();
|
|
3881
4700
|
await noKeysCounter.increment(25);
|
|
@@ -3884,11 +4703,11 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3884
4703
|
"prod"
|
|
3885
4704
|
]);
|
|
3886
4705
|
const keyedCount = await keyedCounter.increment(0);
|
|
3887
|
-
|
|
4706
|
+
expect26(keyedCount).toBe(0);
|
|
3888
4707
|
});
|
|
3889
4708
|
});
|
|
3890
|
-
|
|
3891
|
-
|
|
4709
|
+
describe27("Multiple Actor Instances", () => {
|
|
4710
|
+
test26("creates multiple actor instances of the same type", async (c) => {
|
|
3892
4711
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3893
4712
|
const instance1 = client.counter.getOrCreate(["multi-1"]);
|
|
3894
4713
|
const instance2 = client.counter.getOrCreate(["multi-2"]);
|
|
@@ -3899,35 +4718,35 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
3899
4718
|
const retrieved1 = client.counter.getOrCreate(["multi-1"]);
|
|
3900
4719
|
const retrieved2 = client.counter.getOrCreate(["multi-2"]);
|
|
3901
4720
|
const retrieved3 = client.counter.getOrCreate(["multi-3"]);
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
4721
|
+
expect26(await retrieved1.increment(0)).toBe(1);
|
|
4722
|
+
expect26(await retrieved2.increment(0)).toBe(2);
|
|
4723
|
+
expect26(await retrieved3.increment(0)).toBe(3);
|
|
3905
4724
|
});
|
|
3906
|
-
|
|
4725
|
+
test26("handles default instance with no explicit ID", async (c) => {
|
|
3907
4726
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3908
4727
|
const defaultCounter = client.counter.getOrCreate();
|
|
3909
4728
|
await defaultCounter.increment(5);
|
|
3910
4729
|
const sameDefaultCounter = client.counter.getOrCreate();
|
|
3911
4730
|
const count = await sameDefaultCounter.increment(0);
|
|
3912
|
-
|
|
4731
|
+
expect26(count).toBe(5);
|
|
3913
4732
|
});
|
|
3914
4733
|
});
|
|
3915
4734
|
});
|
|
3916
4735
|
}
|
|
3917
4736
|
|
|
3918
4737
|
// src/driver-test-suite/tests/raw-http.ts
|
|
3919
|
-
import { describe as
|
|
4738
|
+
import { describe as describe28, expect as expect27, test as test27 } from "vitest";
|
|
3920
4739
|
function runRawHttpTests(driverTestConfig) {
|
|
3921
|
-
|
|
3922
|
-
|
|
4740
|
+
describe28("raw http", () => {
|
|
4741
|
+
test27("should handle raw HTTP GET requests", async (c) => {
|
|
3923
4742
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3924
4743
|
const actor = client.rawHttpActor.getOrCreate(["test"]);
|
|
3925
4744
|
const helloResponse = await actor.fetch("api/hello");
|
|
3926
|
-
|
|
4745
|
+
expect27(helloResponse.ok).toBe(true);
|
|
3927
4746
|
const helloData = await helloResponse.json();
|
|
3928
|
-
|
|
4747
|
+
expect27(helloData).toEqual({ message: "Hello from actor!" });
|
|
3929
4748
|
});
|
|
3930
|
-
|
|
4749
|
+
test27("should handle raw HTTP POST requests with echo", async (c) => {
|
|
3931
4750
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3932
4751
|
const actor = client.rawHttpActor.getOrCreate(["test"]);
|
|
3933
4752
|
const testData = { test: "data", number: 123 };
|
|
@@ -3938,22 +4757,22 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
3938
4757
|
},
|
|
3939
4758
|
body: JSON.stringify(testData)
|
|
3940
4759
|
});
|
|
3941
|
-
|
|
4760
|
+
expect27(echoResponse.ok).toBe(true);
|
|
3942
4761
|
const echoData = await echoResponse.json();
|
|
3943
|
-
|
|
4762
|
+
expect27(echoData).toEqual(testData);
|
|
3944
4763
|
});
|
|
3945
|
-
|
|
4764
|
+
test27("should track state across raw HTTP requests", async (c) => {
|
|
3946
4765
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3947
4766
|
const actor = client.rawHttpActor.getOrCreate(["state-test"]);
|
|
3948
4767
|
await actor.fetch("api/hello");
|
|
3949
4768
|
await actor.fetch("api/hello");
|
|
3950
4769
|
await actor.fetch("api/state");
|
|
3951
4770
|
const stateResponse = await actor.fetch("api/state");
|
|
3952
|
-
|
|
4771
|
+
expect27(stateResponse.ok).toBe(true);
|
|
3953
4772
|
const stateData = await stateResponse.json();
|
|
3954
|
-
|
|
4773
|
+
expect27(stateData.requestCount).toBe(4);
|
|
3955
4774
|
});
|
|
3956
|
-
|
|
4775
|
+
test27("should pass headers correctly", async (c) => {
|
|
3957
4776
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3958
4777
|
const actor = client.rawHttpActor.getOrCreate(["headers-test"]);
|
|
3959
4778
|
const customHeaders = {
|
|
@@ -3963,44 +4782,44 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
3963
4782
|
const response = await actor.fetch("api/headers", {
|
|
3964
4783
|
headers: customHeaders
|
|
3965
4784
|
});
|
|
3966
|
-
|
|
4785
|
+
expect27(response.ok).toBe(true);
|
|
3967
4786
|
const headers = await response.json();
|
|
3968
|
-
|
|
3969
|
-
|
|
4787
|
+
expect27(headers["x-custom-header"]).toBe("test-value");
|
|
4788
|
+
expect27(headers["x-another-header"]).toBe("another-value");
|
|
3970
4789
|
});
|
|
3971
|
-
|
|
4790
|
+
test27("should return 404 for unhandled paths", async (c) => {
|
|
3972
4791
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3973
4792
|
const actor = client.rawHttpActor.getOrCreate(["404-test"]);
|
|
3974
4793
|
const response = await actor.fetch("api/nonexistent");
|
|
3975
|
-
|
|
3976
|
-
|
|
4794
|
+
expect27(response.ok).toBe(false);
|
|
4795
|
+
expect27(response.status).toBe(404);
|
|
3977
4796
|
});
|
|
3978
|
-
|
|
4797
|
+
test27("should return 404 when no onRequest handler defined", async (c) => {
|
|
3979
4798
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3980
4799
|
const actor = client.rawHttpNoHandlerActor.getOrCreate([
|
|
3981
4800
|
"no-handler"
|
|
3982
4801
|
]);
|
|
3983
4802
|
const response = await actor.fetch("api/anything");
|
|
3984
|
-
|
|
3985
|
-
|
|
4803
|
+
expect27(response.ok).toBe(false);
|
|
4804
|
+
expect27(response.status).toBe(404);
|
|
3986
4805
|
});
|
|
3987
|
-
|
|
4806
|
+
test27("should return 500 error when onRequest returns void", async (c) => {
|
|
3988
4807
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3989
4808
|
const actor = client.rawHttpVoidReturnActor.getOrCreate([
|
|
3990
4809
|
"void-return"
|
|
3991
4810
|
]);
|
|
3992
4811
|
const response = await actor.fetch("api/anything");
|
|
3993
|
-
|
|
3994
|
-
|
|
4812
|
+
expect27(response.ok).toBe(false);
|
|
4813
|
+
expect27(response.status).toBe(500);
|
|
3995
4814
|
try {
|
|
3996
4815
|
const errorData = await response.json();
|
|
3997
|
-
|
|
4816
|
+
expect27(errorData.message).toContain(
|
|
3998
4817
|
"onRequest handler must return a Response"
|
|
3999
4818
|
);
|
|
4000
4819
|
} catch {
|
|
4001
4820
|
}
|
|
4002
4821
|
});
|
|
4003
|
-
|
|
4822
|
+
test27("should handle different HTTP methods", async (c) => {
|
|
4004
4823
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4005
4824
|
const actor = client.rawHttpActor.getOrCreate(["methods-test"]);
|
|
4006
4825
|
const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
@@ -4010,17 +4829,17 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
4010
4829
|
body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
|
|
4011
4830
|
});
|
|
4012
4831
|
if (method === "POST") {
|
|
4013
|
-
|
|
4832
|
+
expect27(response.ok).toBe(true);
|
|
4014
4833
|
const data = await response.json();
|
|
4015
|
-
|
|
4834
|
+
expect27(data).toEqual({ method });
|
|
4016
4835
|
} else if (method === "GET") {
|
|
4017
|
-
|
|
4836
|
+
expect27(response.status).toBe(404);
|
|
4018
4837
|
} else {
|
|
4019
|
-
|
|
4838
|
+
expect27(response.status).toBe(404);
|
|
4020
4839
|
}
|
|
4021
4840
|
}
|
|
4022
4841
|
});
|
|
4023
|
-
|
|
4842
|
+
test27("should handle binary data", async (c) => {
|
|
4024
4843
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4025
4844
|
const actor = client.rawHttpActor.getOrCreate(["binary-test"]);
|
|
4026
4845
|
const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
@@ -4031,82 +4850,82 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
4031
4850
|
},
|
|
4032
4851
|
body: binaryData
|
|
4033
4852
|
});
|
|
4034
|
-
|
|
4853
|
+
expect27(response.ok).toBe(true);
|
|
4035
4854
|
const responseBuffer = await response.arrayBuffer();
|
|
4036
4855
|
const responseArray = new Uint8Array(responseBuffer);
|
|
4037
|
-
|
|
4856
|
+
expect27(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
|
|
4038
4857
|
});
|
|
4039
|
-
|
|
4858
|
+
test27("should work with Hono router using createVars", async (c) => {
|
|
4040
4859
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4041
4860
|
const actor = client.rawHttpHonoActor.getOrCreate(["hono-test"]);
|
|
4042
4861
|
const rootResponse = await actor.fetch("/");
|
|
4043
|
-
|
|
4862
|
+
expect27(rootResponse.ok).toBe(true);
|
|
4044
4863
|
const rootData = await rootResponse.json();
|
|
4045
|
-
|
|
4864
|
+
expect27(rootData).toEqual({ message: "Welcome to Hono actor!" });
|
|
4046
4865
|
const usersResponse = await actor.fetch("/users");
|
|
4047
|
-
|
|
4866
|
+
expect27(usersResponse.ok).toBe(true);
|
|
4048
4867
|
const users = await usersResponse.json();
|
|
4049
|
-
|
|
4868
|
+
expect27(users).toEqual([
|
|
4050
4869
|
{ id: 1, name: "Alice" },
|
|
4051
4870
|
{ id: 2, name: "Bob" }
|
|
4052
4871
|
]);
|
|
4053
4872
|
const userResponse = await actor.fetch("/users/1");
|
|
4054
|
-
|
|
4873
|
+
expect27(userResponse.ok).toBe(true);
|
|
4055
4874
|
const user = await userResponse.json();
|
|
4056
|
-
|
|
4875
|
+
expect27(user).toEqual({ id: 1, name: "Alice" });
|
|
4057
4876
|
const newUser = { name: "Charlie" };
|
|
4058
4877
|
const createResponse = await actor.fetch("/users", {
|
|
4059
4878
|
method: "POST",
|
|
4060
4879
|
headers: { "Content-Type": "application/json" },
|
|
4061
4880
|
body: JSON.stringify(newUser)
|
|
4062
4881
|
});
|
|
4063
|
-
|
|
4064
|
-
|
|
4882
|
+
expect27(createResponse.ok).toBe(true);
|
|
4883
|
+
expect27(createResponse.status).toBe(201);
|
|
4065
4884
|
const createdUser = await createResponse.json();
|
|
4066
|
-
|
|
4885
|
+
expect27(createdUser).toEqual({ id: 3, name: "Charlie" });
|
|
4067
4886
|
const updateData = { name: "Alice Updated" };
|
|
4068
4887
|
const updateResponse = await actor.fetch("/users/1", {
|
|
4069
4888
|
method: "PUT",
|
|
4070
4889
|
headers: { "Content-Type": "application/json" },
|
|
4071
4890
|
body: JSON.stringify(updateData)
|
|
4072
4891
|
});
|
|
4073
|
-
|
|
4892
|
+
expect27(updateResponse.ok).toBe(true);
|
|
4074
4893
|
const updatedUser = await updateResponse.json();
|
|
4075
|
-
|
|
4894
|
+
expect27(updatedUser).toEqual({ id: 1, name: "Alice Updated" });
|
|
4076
4895
|
const deleteResponse = await actor.fetch("/users/2", {
|
|
4077
4896
|
method: "DELETE"
|
|
4078
4897
|
});
|
|
4079
|
-
|
|
4898
|
+
expect27(deleteResponse.ok).toBe(true);
|
|
4080
4899
|
const deleteResult = await deleteResponse.json();
|
|
4081
|
-
|
|
4900
|
+
expect27(deleteResult).toEqual({ message: "User 2 deleted" });
|
|
4082
4901
|
const notFoundResponse = await actor.fetch("/api/unknown");
|
|
4083
|
-
|
|
4084
|
-
|
|
4902
|
+
expect27(notFoundResponse.ok).toBe(false);
|
|
4903
|
+
expect27(notFoundResponse.status).toBe(404);
|
|
4085
4904
|
});
|
|
4086
|
-
|
|
4905
|
+
test27("should handle paths with and without leading slashes", async (c) => {
|
|
4087
4906
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4088
4907
|
const actor = client.rawHttpActor.getOrCreate(["path-test"]);
|
|
4089
4908
|
const responseWithoutSlash = await actor.fetch("api/hello");
|
|
4090
|
-
|
|
4909
|
+
expect27(responseWithoutSlash.ok).toBe(true);
|
|
4091
4910
|
const dataWithoutSlash = await responseWithoutSlash.json();
|
|
4092
|
-
|
|
4911
|
+
expect27(dataWithoutSlash).toEqual({ message: "Hello from actor!" });
|
|
4093
4912
|
const responseWithSlash = await actor.fetch("/api/hello");
|
|
4094
|
-
|
|
4913
|
+
expect27(responseWithSlash.ok).toBe(true);
|
|
4095
4914
|
const dataWithSlash = await responseWithSlash.json();
|
|
4096
|
-
|
|
4915
|
+
expect27(dataWithSlash).toEqual({ message: "Hello from actor!" });
|
|
4097
4916
|
});
|
|
4098
|
-
|
|
4917
|
+
test27("should not create double slashes in request URLs", async (c) => {
|
|
4099
4918
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4100
4919
|
const actor = client.rawHttpHonoActor.getOrCreate(["url-test"]);
|
|
4101
4920
|
const response = await actor.fetch("/users");
|
|
4102
|
-
|
|
4921
|
+
expect27(response.ok).toBe(true);
|
|
4103
4922
|
const data = await response.json();
|
|
4104
|
-
|
|
4923
|
+
expect27(data).toEqual([
|
|
4105
4924
|
{ id: 1, name: "Alice" },
|
|
4106
4925
|
{ id: 2, name: "Bob" }
|
|
4107
4926
|
]);
|
|
4108
4927
|
});
|
|
4109
|
-
|
|
4928
|
+
test27("should handle forwarded requests correctly without double slashes", async (c) => {
|
|
4110
4929
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4111
4930
|
const actor = client.rawHttpHonoActor.getOrCreate(["forward-test"]);
|
|
4112
4931
|
const truncatedPath = "/users";
|
|
@@ -4118,14 +4937,14 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
4118
4937
|
truncatedPath,
|
|
4119
4938
|
newRequest
|
|
4120
4939
|
);
|
|
4121
|
-
|
|
4940
|
+
expect27(response.ok).toBe(true);
|
|
4122
4941
|
const users = await response.json();
|
|
4123
|
-
|
|
4942
|
+
expect27(users).toEqual([
|
|
4124
4943
|
{ id: 1, name: "Alice" },
|
|
4125
4944
|
{ id: 2, name: "Bob" }
|
|
4126
4945
|
]);
|
|
4127
4946
|
});
|
|
4128
|
-
|
|
4947
|
+
test27("example fix: should properly forward requests using just Request object", async (c) => {
|
|
4129
4948
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4130
4949
|
const actor = client.rawHttpHonoActor.getOrCreate(["forward-fix"]);
|
|
4131
4950
|
const truncatedPath = "/users/1";
|
|
@@ -4134,11 +4953,11 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
4134
4953
|
method: "GET"
|
|
4135
4954
|
});
|
|
4136
4955
|
const response = await actor.fetch(newRequest);
|
|
4137
|
-
|
|
4956
|
+
expect27(response.ok).toBe(true);
|
|
4138
4957
|
const user = await response.json();
|
|
4139
|
-
|
|
4958
|
+
expect27(user).toEqual({ id: 1, name: "Alice" });
|
|
4140
4959
|
});
|
|
4141
|
-
|
|
4960
|
+
test27("should support standard fetch API with URL and Request objects", async (c) => {
|
|
4142
4961
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4143
4962
|
const actor = client.rawHttpActor.getOrCreate(["fetch-api-test"]);
|
|
4144
4963
|
const url = new URL("/api/echo", "http://example.com");
|
|
@@ -4147,18 +4966,18 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
4147
4966
|
headers: { "Content-Type": "application/json" },
|
|
4148
4967
|
body: JSON.stringify({ from: "URL object" })
|
|
4149
4968
|
});
|
|
4150
|
-
|
|
4969
|
+
expect27(urlResponse.ok).toBe(true);
|
|
4151
4970
|
const urlData = await urlResponse.json();
|
|
4152
|
-
|
|
4971
|
+
expect27(urlData).toEqual({ from: "URL object" });
|
|
4153
4972
|
const request = new Request("http://example.com/api/echo", {
|
|
4154
4973
|
method: "POST",
|
|
4155
4974
|
headers: { "Content-Type": "application/json" },
|
|
4156
4975
|
body: JSON.stringify({ from: "Request object" })
|
|
4157
4976
|
});
|
|
4158
4977
|
const requestResponse = await actor.fetch(request);
|
|
4159
|
-
|
|
4978
|
+
expect27(requestResponse.ok).toBe(true);
|
|
4160
4979
|
const requestData = await requestResponse.json();
|
|
4161
|
-
|
|
4980
|
+
expect27(requestData).toEqual({ from: "Request object" });
|
|
4162
4981
|
const request2 = new Request("http://example.com/api/headers", {
|
|
4163
4982
|
method: "GET",
|
|
4164
4983
|
headers: { "X-Original": "request-header" }
|
|
@@ -4166,19 +4985,19 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
4166
4985
|
const overrideResponse = await actor.fetch(request2, {
|
|
4167
4986
|
headers: { "X-Override": "init-header" }
|
|
4168
4987
|
});
|
|
4169
|
-
|
|
4988
|
+
expect27(overrideResponse.ok).toBe(true);
|
|
4170
4989
|
const headers = await overrideResponse.json();
|
|
4171
|
-
|
|
4172
|
-
|
|
4990
|
+
expect27(headers["x-override"]).toBe("init-header");
|
|
4991
|
+
expect27(headers["x-original"]).toBe("request-header");
|
|
4173
4992
|
});
|
|
4174
4993
|
});
|
|
4175
4994
|
}
|
|
4176
4995
|
|
|
4177
4996
|
// src/driver-test-suite/tests/raw-http-request-properties.ts
|
|
4178
|
-
import { describe as
|
|
4997
|
+
import { describe as describe29, expect as expect28, test as test28 } from "vitest";
|
|
4179
4998
|
function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
4180
|
-
|
|
4181
|
-
|
|
4999
|
+
describe29("raw http request properties", () => {
|
|
5000
|
+
test28("should pass all Request properties correctly to onRequest", async (c) => {
|
|
4182
5001
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4183
5002
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4184
5003
|
"test"
|
|
@@ -4192,22 +5011,22 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4192
5011
|
},
|
|
4193
5012
|
body: JSON.stringify({ test: "data" })
|
|
4194
5013
|
});
|
|
4195
|
-
|
|
5014
|
+
expect28(response.ok).toBe(true);
|
|
4196
5015
|
const data = await response.json();
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
5016
|
+
expect28(data.url).toContain("/test/path?foo=bar&baz=qux");
|
|
5017
|
+
expect28(data.pathname).toBe("/test/path");
|
|
5018
|
+
expect28(data.search).toBe("?foo=bar&baz=qux");
|
|
5019
|
+
expect28(data.searchParams).toEqual({
|
|
4201
5020
|
foo: "bar",
|
|
4202
5021
|
baz: "qux"
|
|
4203
5022
|
});
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
5023
|
+
expect28(data.method).toBe("POST");
|
|
5024
|
+
expect28(data.headers["content-type"]).toBe("application/json");
|
|
5025
|
+
expect28(data.headers["x-custom-header"]).toBe("custom-value");
|
|
5026
|
+
expect28(data.headers["authorization"]).toBe("Bearer test-token");
|
|
5027
|
+
expect28(data.body).toEqual({ test: "data" });
|
|
4209
5028
|
});
|
|
4210
|
-
|
|
5029
|
+
test28("should handle GET requests with no body", async (c) => {
|
|
4211
5030
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4212
5031
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4213
5032
|
"test"
|
|
@@ -4215,12 +5034,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4215
5034
|
const response = await actor.fetch("test/get", {
|
|
4216
5035
|
method: "GET"
|
|
4217
5036
|
});
|
|
4218
|
-
|
|
5037
|
+
expect28(response.ok).toBe(true);
|
|
4219
5038
|
const data = await response.json();
|
|
4220
|
-
|
|
4221
|
-
|
|
5039
|
+
expect28(data.method).toBe("GET");
|
|
5040
|
+
expect28(data.body).toBeNull();
|
|
4222
5041
|
});
|
|
4223
|
-
|
|
5042
|
+
test28("should handle different content types", async (c) => {
|
|
4224
5043
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4225
5044
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4226
5045
|
"test"
|
|
@@ -4235,12 +5054,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4235
5054
|
},
|
|
4236
5055
|
body: formData.toString()
|
|
4237
5056
|
});
|
|
4238
|
-
|
|
5057
|
+
expect28(formResponse.ok).toBe(true);
|
|
4239
5058
|
const formResult = await formResponse.json();
|
|
4240
|
-
|
|
5059
|
+
expect28(formResult.headers["content-type"]).toBe(
|
|
4241
5060
|
"application/x-www-form-urlencoded"
|
|
4242
5061
|
);
|
|
4243
|
-
|
|
5062
|
+
expect28(formResult.bodyText).toBe("field1=value1&field2=value2");
|
|
4244
5063
|
const textResponse = await actor.fetch("test/text", {
|
|
4245
5064
|
method: "POST",
|
|
4246
5065
|
headers: {
|
|
@@ -4248,12 +5067,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4248
5067
|
},
|
|
4249
5068
|
body: "Hello, World!"
|
|
4250
5069
|
});
|
|
4251
|
-
|
|
5070
|
+
expect28(textResponse.ok).toBe(true);
|
|
4252
5071
|
const textResult = await textResponse.json();
|
|
4253
|
-
|
|
4254
|
-
|
|
5072
|
+
expect28(textResult.headers["content-type"]).toBe("text/plain");
|
|
5073
|
+
expect28(textResult.bodyText).toBe("Hello, World!");
|
|
4255
5074
|
});
|
|
4256
|
-
|
|
5075
|
+
test28("should preserve all header casing and values", async (c) => {
|
|
4257
5076
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4258
5077
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4259
5078
|
"test"
|
|
@@ -4267,38 +5086,38 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4267
5086
|
"X-Request-ID": "12345"
|
|
4268
5087
|
}
|
|
4269
5088
|
});
|
|
4270
|
-
|
|
5089
|
+
expect28(response.ok).toBe(true);
|
|
4271
5090
|
const data = await response.json();
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
5091
|
+
expect28(data.headers["accept"]).toBe("application/json");
|
|
5092
|
+
expect28(data.headers["accept-language"]).toBe("en-US,en;q=0.9");
|
|
5093
|
+
expect28(data.headers["cache-control"]).toBe("no-cache");
|
|
5094
|
+
expect28(data.headers["user-agent"]).toBeTruthy();
|
|
5095
|
+
expect28(data.headers["x-request-id"]).toBe("12345");
|
|
4277
5096
|
});
|
|
4278
|
-
|
|
5097
|
+
test28("should handle empty and special URL paths", async (c) => {
|
|
4279
5098
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4280
5099
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4281
5100
|
"test"
|
|
4282
5101
|
]);
|
|
4283
5102
|
const rootResponse = await actor.fetch("");
|
|
4284
|
-
|
|
5103
|
+
expect28(rootResponse.ok).toBe(true);
|
|
4285
5104
|
const rootData = await rootResponse.json();
|
|
4286
|
-
|
|
5105
|
+
expect28(rootData.pathname).toBe("/");
|
|
4287
5106
|
const specialResponse = await actor.fetch(
|
|
4288
5107
|
"test/path%20with%20spaces/and%2Fslashes"
|
|
4289
5108
|
);
|
|
4290
|
-
|
|
5109
|
+
expect28(specialResponse.ok).toBe(true);
|
|
4291
5110
|
const specialData = await specialResponse.json();
|
|
4292
|
-
|
|
5111
|
+
expect28(specialData.pathname).toMatch(
|
|
4293
5112
|
/path.*with.*spaces.*and.*slashes/
|
|
4294
5113
|
);
|
|
4295
5114
|
const fragmentResponse = await actor.fetch("test/path#fragment");
|
|
4296
|
-
|
|
5115
|
+
expect28(fragmentResponse.ok).toBe(true);
|
|
4297
5116
|
const fragmentData = await fragmentResponse.json();
|
|
4298
|
-
|
|
4299
|
-
|
|
5117
|
+
expect28(fragmentData.pathname).toBe("/test/path");
|
|
5118
|
+
expect28(fragmentData.hash).toBe("");
|
|
4300
5119
|
});
|
|
4301
|
-
|
|
5120
|
+
test28("should handle request properties for all HTTP methods", async (c) => {
|
|
4302
5121
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4303
5122
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4304
5123
|
"test"
|
|
@@ -4322,21 +5141,21 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4322
5141
|
}
|
|
4323
5142
|
);
|
|
4324
5143
|
if (method === "HEAD") {
|
|
4325
|
-
|
|
5144
|
+
expect28(response.status).toBe(200);
|
|
4326
5145
|
const text = await response.text();
|
|
4327
|
-
|
|
5146
|
+
expect28(text).toBe("");
|
|
4328
5147
|
} else if (method === "OPTIONS") {
|
|
4329
|
-
|
|
5148
|
+
expect28(response.status).toBe(204);
|
|
4330
5149
|
const text = await response.text();
|
|
4331
|
-
|
|
5150
|
+
expect28(text).toBe("");
|
|
4332
5151
|
} else {
|
|
4333
|
-
|
|
5152
|
+
expect28(response.ok).toBe(true);
|
|
4334
5153
|
const data = await response.json();
|
|
4335
|
-
|
|
5154
|
+
expect28(data.method).toBe(method);
|
|
4336
5155
|
}
|
|
4337
5156
|
}
|
|
4338
5157
|
});
|
|
4339
|
-
|
|
5158
|
+
test28("should handle complex query parameters", async (c) => {
|
|
4340
5159
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4341
5160
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4342
5161
|
"test"
|
|
@@ -4344,13 +5163,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4344
5163
|
const response = await actor.fetch(
|
|
4345
5164
|
"test?key=value1&key=value2&array[]=1&array[]=2&nested[prop]=val"
|
|
4346
5165
|
);
|
|
4347
|
-
|
|
5166
|
+
expect28(response.ok).toBe(true);
|
|
4348
5167
|
const data = await response.json();
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
5168
|
+
expect28(data.searchParams.key).toBe("value2");
|
|
5169
|
+
expect28(data.searchParams["array[]"]).toBe("2");
|
|
5170
|
+
expect28(data.searchParams["nested[prop]"]).toBe("val");
|
|
4352
5171
|
});
|
|
4353
|
-
|
|
5172
|
+
test28("should handle multipart form data", async (c) => {
|
|
4354
5173
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4355
5174
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4356
5175
|
"test"
|
|
@@ -4374,27 +5193,27 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4374
5193
|
},
|
|
4375
5194
|
body
|
|
4376
5195
|
});
|
|
4377
|
-
|
|
5196
|
+
expect28(response.ok).toBe(true);
|
|
4378
5197
|
const data = await response.json();
|
|
4379
|
-
|
|
5198
|
+
expect28(data.headers["content-type"]).toContain(
|
|
4380
5199
|
"multipart/form-data"
|
|
4381
5200
|
);
|
|
4382
|
-
|
|
4383
|
-
|
|
5201
|
+
expect28(data.bodyText).toContain("field1");
|
|
5202
|
+
expect28(data.bodyText).toContain("value1");
|
|
4384
5203
|
});
|
|
4385
|
-
|
|
5204
|
+
test28("should handle very long URLs", async (c) => {
|
|
4386
5205
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4387
5206
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4388
5207
|
"test"
|
|
4389
5208
|
]);
|
|
4390
5209
|
const longValue = "x".repeat(1e3);
|
|
4391
5210
|
const response = await actor.fetch(`test/long?param=${longValue}`);
|
|
4392
|
-
|
|
5211
|
+
expect28(response.ok).toBe(true);
|
|
4393
5212
|
const data = await response.json();
|
|
4394
|
-
|
|
4395
|
-
|
|
5213
|
+
expect28(data.searchParams.param).toBe(longValue);
|
|
5214
|
+
expect28(data.search.length).toBeGreaterThan(1e3);
|
|
4396
5215
|
});
|
|
4397
|
-
|
|
5216
|
+
test28.skip("should handle large request bodies", async (c) => {
|
|
4398
5217
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4399
5218
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4400
5219
|
"test"
|
|
@@ -4411,11 +5230,11 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4411
5230
|
},
|
|
4412
5231
|
body: JSON.stringify(largeArray)
|
|
4413
5232
|
});
|
|
4414
|
-
|
|
5233
|
+
expect28(response.ok).toBe(true);
|
|
4415
5234
|
const data = await response.json();
|
|
4416
|
-
|
|
5235
|
+
expect28(data.body).toHaveLength(1e4);
|
|
4417
5236
|
});
|
|
4418
|
-
|
|
5237
|
+
test28("should handle missing content-type header", async (c) => {
|
|
4419
5238
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4420
5239
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4421
5240
|
"test"
|
|
@@ -4424,11 +5243,11 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4424
5243
|
method: "POST",
|
|
4425
5244
|
body: "plain text without content-type"
|
|
4426
5245
|
});
|
|
4427
|
-
|
|
5246
|
+
expect28(response.ok).toBe(true);
|
|
4428
5247
|
const data = await response.json();
|
|
4429
|
-
|
|
5248
|
+
expect28(data.bodyText).toBe("plain text without content-type");
|
|
4430
5249
|
});
|
|
4431
|
-
|
|
5250
|
+
test28("should handle empty request body", async (c) => {
|
|
4432
5251
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4433
5252
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4434
5253
|
"test"
|
|
@@ -4440,9 +5259,9 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4440
5259
|
},
|
|
4441
5260
|
body: ""
|
|
4442
5261
|
});
|
|
4443
|
-
|
|
5262
|
+
expect28(response.ok).toBe(true);
|
|
4444
5263
|
});
|
|
4445
|
-
|
|
5264
|
+
test28("should handle custom HTTP methods", async (c) => {
|
|
4446
5265
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4447
5266
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4448
5267
|
"test"
|
|
@@ -4453,12 +5272,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4453
5272
|
});
|
|
4454
5273
|
if (response.ok) {
|
|
4455
5274
|
const data = await response.json();
|
|
4456
|
-
|
|
5275
|
+
expect28(data.method).toBe("CUSTOM");
|
|
4457
5276
|
}
|
|
4458
5277
|
} catch (error) {
|
|
4459
5278
|
}
|
|
4460
5279
|
});
|
|
4461
|
-
|
|
5280
|
+
test28("should handle cookies in headers", async (c) => {
|
|
4462
5281
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4463
5282
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4464
5283
|
"test"
|
|
@@ -4468,13 +5287,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4468
5287
|
Cookie: "session=abc123; user=test; preferences=dark_mode"
|
|
4469
5288
|
}
|
|
4470
5289
|
});
|
|
4471
|
-
|
|
5290
|
+
expect28(response.ok).toBe(true);
|
|
4472
5291
|
const data = await response.json();
|
|
4473
|
-
|
|
5292
|
+
expect28(data.headers.cookie).toBe(
|
|
4474
5293
|
"session=abc123; user=test; preferences=dark_mode"
|
|
4475
5294
|
);
|
|
4476
5295
|
});
|
|
4477
|
-
|
|
5296
|
+
test28("should handle URL encoding properly", async (c) => {
|
|
4478
5297
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4479
5298
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4480
5299
|
"test"
|
|
@@ -4482,13 +5301,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4482
5301
|
const response = await actor.fetch(
|
|
4483
5302
|
"test/encoded?special=%20%21%40%23%24%25%5E%26&unicode=%E2%9C%93&email=test%40example.com"
|
|
4484
5303
|
);
|
|
4485
|
-
|
|
5304
|
+
expect28(response.ok).toBe(true);
|
|
4486
5305
|
const data = await response.json();
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
5306
|
+
expect28(data.searchParams.special).toBe(" !@#$%^&");
|
|
5307
|
+
expect28(data.searchParams.unicode).toBe("\u2713");
|
|
5308
|
+
expect28(data.searchParams.email).toBe("test@example.com");
|
|
4490
5309
|
});
|
|
4491
|
-
|
|
5310
|
+
test28("should handle concurrent requests maintaining separate contexts", async (c) => {
|
|
4492
5311
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4493
5312
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
4494
5313
|
"test"
|
|
@@ -4512,24 +5331,24 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
4512
5331
|
const results = await Promise.all(
|
|
4513
5332
|
responses.map((r) => r.json())
|
|
4514
5333
|
);
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
5334
|
+
expect28(results[0].searchParams.id).toBe("1");
|
|
5335
|
+
expect28(results[0].method).toBe("POST");
|
|
5336
|
+
expect28(results[0].body).toEqual({ request: 1 });
|
|
5337
|
+
expect28(results[1].searchParams.id).toBe("2");
|
|
5338
|
+
expect28(results[1].method).toBe("PUT");
|
|
5339
|
+
expect28(results[1].body).toEqual({ request: 2 });
|
|
5340
|
+
expect28(results[2].searchParams.id).toBe("3");
|
|
5341
|
+
expect28(results[2].method).toBe("DELETE");
|
|
5342
|
+
expect28(results[2].body).toBeNull();
|
|
4524
5343
|
});
|
|
4525
5344
|
});
|
|
4526
5345
|
}
|
|
4527
5346
|
|
|
4528
5347
|
// src/driver-test-suite/tests/raw-websocket.ts
|
|
4529
|
-
import { describe as
|
|
5348
|
+
import { describe as describe30, expect as expect29, test as test29 } from "vitest";
|
|
4530
5349
|
function runRawWebSocketTests(driverTestConfig) {
|
|
4531
|
-
|
|
4532
|
-
|
|
5350
|
+
describe30("raw websocket", () => {
|
|
5351
|
+
test29("should establish raw WebSocket connection", async (c) => {
|
|
4533
5352
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4534
5353
|
const actor = client.rawWebSocketActor.getOrCreate(["basic"]);
|
|
4535
5354
|
const ws = await actor.webSocket();
|
|
@@ -4556,11 +5375,11 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4556
5375
|
);
|
|
4557
5376
|
ws.addEventListener("close", reject);
|
|
4558
5377
|
});
|
|
4559
|
-
|
|
4560
|
-
|
|
5378
|
+
expect29(welcomeMessage.type).toBe("welcome");
|
|
5379
|
+
expect29(welcomeMessage.connectionCount).toBe(1);
|
|
4561
5380
|
ws.close();
|
|
4562
5381
|
});
|
|
4563
|
-
|
|
5382
|
+
test29("should echo messages", async (c) => {
|
|
4564
5383
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4565
5384
|
const actor = client.rawWebSocketActor.getOrCreate(["echo"]);
|
|
4566
5385
|
const ws = await actor.webSocket();
|
|
@@ -4588,10 +5407,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4588
5407
|
);
|
|
4589
5408
|
ws.addEventListener("close", reject);
|
|
4590
5409
|
});
|
|
4591
|
-
|
|
5410
|
+
expect29(echoMessage).toEqual(testMessage);
|
|
4592
5411
|
ws.close();
|
|
4593
5412
|
});
|
|
4594
|
-
|
|
5413
|
+
test29("should handle ping/pong protocol", async (c) => {
|
|
4595
5414
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4596
5415
|
const actor = client.rawWebSocketActor.getOrCreate(["ping"]);
|
|
4597
5416
|
const ws = await actor.webSocket();
|
|
@@ -4617,11 +5436,11 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4617
5436
|
});
|
|
4618
5437
|
ws.addEventListener("close", reject);
|
|
4619
5438
|
});
|
|
4620
|
-
|
|
4621
|
-
|
|
5439
|
+
expect29(pongMessage.type).toBe("pong");
|
|
5440
|
+
expect29(pongMessage.timestamp).toBeDefined();
|
|
4622
5441
|
ws.close();
|
|
4623
5442
|
});
|
|
4624
|
-
|
|
5443
|
+
test29("should track stats across connections", async (c) => {
|
|
4625
5444
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4626
5445
|
const actor1 = client.rawWebSocketActor.getOrCreate(["stats"]);
|
|
4627
5446
|
const ws1 = await actor1.webSocket();
|
|
@@ -4665,15 +5484,15 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4665
5484
|
});
|
|
4666
5485
|
ws1.send(JSON.stringify({ type: "getStats" }));
|
|
4667
5486
|
const stats = await statsPromise;
|
|
4668
|
-
|
|
4669
|
-
|
|
5487
|
+
expect29(stats.connectionCount).toBe(2);
|
|
5488
|
+
expect29(stats.messageCount).toBe(4);
|
|
4670
5489
|
const actionStats = await actor1.getStats();
|
|
4671
|
-
|
|
4672
|
-
|
|
5490
|
+
expect29(actionStats.connectionCount).toBe(2);
|
|
5491
|
+
expect29(actionStats.messageCount).toBe(4);
|
|
4673
5492
|
ws1.close();
|
|
4674
5493
|
ws2.close();
|
|
4675
5494
|
});
|
|
4676
|
-
|
|
5495
|
+
test29("should handle binary data", async (c) => {
|
|
4677
5496
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4678
5497
|
const actor = client.rawWebSocketBinaryActor.getOrCreate([
|
|
4679
5498
|
"binary"
|
|
@@ -4706,7 +5525,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4706
5525
|
const smallData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
4707
5526
|
ws.send(smallData);
|
|
4708
5527
|
const smallReversed = await receiveBinaryMessage();
|
|
4709
|
-
|
|
5528
|
+
expect29(Array.from(smallReversed)).toEqual([5, 4, 3, 2, 1]);
|
|
4710
5529
|
const largeData = new Uint8Array(1024);
|
|
4711
5530
|
for (let i = 0; i < largeData.length; i++) {
|
|
4712
5531
|
largeData[i] = i % 256;
|
|
@@ -4714,13 +5533,13 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4714
5533
|
ws.send(largeData);
|
|
4715
5534
|
const largeReversed = await receiveBinaryMessage();
|
|
4716
5535
|
for (let i = 0; i < largeData.length; i++) {
|
|
4717
|
-
|
|
5536
|
+
expect29(largeReversed[i]).toBe(
|
|
4718
5537
|
largeData[largeData.length - 1 - i]
|
|
4719
5538
|
);
|
|
4720
5539
|
}
|
|
4721
5540
|
ws.close();
|
|
4722
5541
|
});
|
|
4723
|
-
|
|
5542
|
+
test29("should work with custom paths", async (c) => {
|
|
4724
5543
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4725
5544
|
const actor = client.rawWebSocketActor.getOrCreate(["paths"]);
|
|
4726
5545
|
const ws = await actor.webSocket("custom/path");
|
|
@@ -4740,10 +5559,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4740
5559
|
{ once: true }
|
|
4741
5560
|
);
|
|
4742
5561
|
});
|
|
4743
|
-
|
|
5562
|
+
expect29(welcomeMessage.type).toBe("welcome");
|
|
4744
5563
|
ws.close();
|
|
4745
5564
|
});
|
|
4746
|
-
|
|
5565
|
+
test29("should handle connection close properly", async (c) => {
|
|
4747
5566
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4748
5567
|
const actor = client.rawWebSocketActor.getOrCreate(["close-test"]);
|
|
4749
5568
|
const ws = await actor.webSocket();
|
|
@@ -4756,7 +5575,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4756
5575
|
});
|
|
4757
5576
|
}
|
|
4758
5577
|
const initialStats = await actor.getStats();
|
|
4759
|
-
|
|
5578
|
+
expect29(initialStats.connectionCount).toBe(1);
|
|
4760
5579
|
const closePromise = new Promise((resolve) => {
|
|
4761
5580
|
ws.addEventListener("close", () => resolve(), { once: true });
|
|
4762
5581
|
});
|
|
@@ -4770,9 +5589,9 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4770
5589
|
}
|
|
4771
5590
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
4772
5591
|
}
|
|
4773
|
-
|
|
5592
|
+
expect29(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
|
|
4774
5593
|
});
|
|
4775
|
-
|
|
5594
|
+
test29("should properly handle onWebSocket open and close events", async (c) => {
|
|
4776
5595
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4777
5596
|
const actor = client.rawWebSocketActor.getOrCreate([
|
|
4778
5597
|
"open-close-test"
|
|
@@ -4792,8 +5611,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4792
5611
|
);
|
|
4793
5612
|
ws1.addEventListener("close", reject);
|
|
4794
5613
|
});
|
|
4795
|
-
|
|
4796
|
-
|
|
5614
|
+
expect29(welcome1.type).toBe("welcome");
|
|
5615
|
+
expect29(welcome1.connectionCount).toBe(1);
|
|
4797
5616
|
const ws2 = await actor.webSocket();
|
|
4798
5617
|
await new Promise((resolve, reject) => {
|
|
4799
5618
|
ws2.addEventListener("open", () => resolve(), { once: true });
|
|
@@ -4809,10 +5628,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4809
5628
|
);
|
|
4810
5629
|
ws2.addEventListener("close", reject);
|
|
4811
5630
|
});
|
|
4812
|
-
|
|
4813
|
-
|
|
5631
|
+
expect29(welcome2.type).toBe("welcome");
|
|
5632
|
+
expect29(welcome2.connectionCount).toBe(2);
|
|
4814
5633
|
const midStats = await actor.getStats();
|
|
4815
|
-
|
|
5634
|
+
expect29(midStats.connectionCount).toBe(2);
|
|
4816
5635
|
ws1.close();
|
|
4817
5636
|
await new Promise((resolve) => {
|
|
4818
5637
|
ws1.addEventListener("close", () => resolve(), { once: true });
|
|
@@ -4825,7 +5644,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4825
5644
|
}
|
|
4826
5645
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
4827
5646
|
}
|
|
4828
|
-
|
|
5647
|
+
expect29(afterFirstClose == null ? void 0 : afterFirstClose.connectionCount).toBe(1);
|
|
4829
5648
|
ws2.close();
|
|
4830
5649
|
await new Promise((resolve) => {
|
|
4831
5650
|
ws2.addEventListener("close", () => resolve(), { once: true });
|
|
@@ -4838,9 +5657,9 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4838
5657
|
}
|
|
4839
5658
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
4840
5659
|
}
|
|
4841
|
-
|
|
5660
|
+
expect29(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
|
|
4842
5661
|
});
|
|
4843
|
-
|
|
5662
|
+
test29("should handle query parameters in websocket paths", async (c) => {
|
|
4844
5663
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4845
5664
|
const actor = client.rawWebSocketActor.getOrCreate([
|
|
4846
5665
|
"query-params"
|
|
@@ -4863,12 +5682,12 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4863
5682
|
});
|
|
4864
5683
|
ws.send(JSON.stringify({ type: "getRequestInfo" }));
|
|
4865
5684
|
const requestInfo = await requestInfoPromise;
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
5685
|
+
expect29(requestInfo.url).toContain("api/v1/stream");
|
|
5686
|
+
expect29(requestInfo.url).toContain("token=abc123");
|
|
5687
|
+
expect29(requestInfo.url).toContain("user=test");
|
|
4869
5688
|
ws.close();
|
|
4870
5689
|
});
|
|
4871
|
-
|
|
5690
|
+
test29("should handle query parameters on base websocket path (no subpath)", async (c) => {
|
|
4872
5691
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4873
5692
|
const actor = client.rawWebSocketActor.getOrCreate([
|
|
4874
5693
|
"base-path-query-params"
|
|
@@ -4878,7 +5697,11 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4878
5697
|
ws.addEventListener("open", () => resolve(), { once: true });
|
|
4879
5698
|
ws.addEventListener("error", reject);
|
|
4880
5699
|
ws.addEventListener("close", (evt) => {
|
|
4881
|
-
reject(
|
|
5700
|
+
reject(
|
|
5701
|
+
new Error(
|
|
5702
|
+
`WebSocket closed: code=${evt.code} reason=${evt.reason}`
|
|
5703
|
+
)
|
|
5704
|
+
);
|
|
4882
5705
|
});
|
|
4883
5706
|
});
|
|
4884
5707
|
const requestInfoPromise = new Promise((resolve, reject) => {
|
|
@@ -4892,18 +5715,237 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
4892
5715
|
});
|
|
4893
5716
|
ws.send(JSON.stringify({ type: "getRequestInfo" }));
|
|
4894
5717
|
const requestInfo = await requestInfoPromise;
|
|
4895
|
-
|
|
4896
|
-
|
|
5718
|
+
expect29(requestInfo.url).toContain("token=secret");
|
|
5719
|
+
expect29(requestInfo.url).toContain("session=123");
|
|
4897
5720
|
ws.close();
|
|
4898
5721
|
});
|
|
4899
5722
|
});
|
|
4900
5723
|
}
|
|
4901
5724
|
|
|
5725
|
+
// src/driver-test-suite/tests/actor-db-kv-stats.ts
|
|
5726
|
+
import { describe as describe31, expect as expect30, test as test30 } from "vitest";
|
|
5727
|
+
function runActorDbKvStatsTests(driverTestConfig) {
|
|
5728
|
+
describe31("Actor Database KV Stats Tests", () => {
|
|
5729
|
+
test30(
|
|
5730
|
+
"warm UPDATE uses BATCH_ATOMIC: exactly 1 putBatch, 0 reads, no journal",
|
|
5731
|
+
async (c) => {
|
|
5732
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5733
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5734
|
+
`kv-stats-ba-${crypto.randomUUID()}`
|
|
5735
|
+
]);
|
|
5736
|
+
await actor.warmUp();
|
|
5737
|
+
await actor.increment();
|
|
5738
|
+
const stats = await actor.getStats();
|
|
5739
|
+
const log = await actor.getLog();
|
|
5740
|
+
expect30(stats.putBatchCalls).toBe(1);
|
|
5741
|
+
expect30(stats.getBatchCalls).toBe(0);
|
|
5742
|
+
const allKeys = log.flatMap((e) => e.keys);
|
|
5743
|
+
const journalKeys = allKeys.filter((k) => k.includes("journal"));
|
|
5744
|
+
expect30(journalKeys.length).toBe(0);
|
|
5745
|
+
},
|
|
5746
|
+
3e4
|
|
5747
|
+
);
|
|
5748
|
+
test30(
|
|
5749
|
+
"warm SELECT uses 0 KV round trips",
|
|
5750
|
+
async (c) => {
|
|
5751
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5752
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5753
|
+
`kv-stats-2-${crypto.randomUUID()}`
|
|
5754
|
+
]);
|
|
5755
|
+
await actor.warmUp();
|
|
5756
|
+
await actor.getCount();
|
|
5757
|
+
const stats = await actor.getStats();
|
|
5758
|
+
expect30(stats.getBatchCalls).toBe(0);
|
|
5759
|
+
expect30(stats.putBatchCalls).toBe(0);
|
|
5760
|
+
},
|
|
5761
|
+
3e4
|
|
5762
|
+
);
|
|
5763
|
+
test30(
|
|
5764
|
+
"warm SELECT after UPDATE adds no KV round trips",
|
|
5765
|
+
async (c) => {
|
|
5766
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5767
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5768
|
+
`kv-stats-3-${crypto.randomUUID()}`
|
|
5769
|
+
]);
|
|
5770
|
+
await actor.warmUp();
|
|
5771
|
+
await actor.increment();
|
|
5772
|
+
const updateStats = await actor.getStats();
|
|
5773
|
+
await actor.resetStats();
|
|
5774
|
+
await actor.incrementAndRead();
|
|
5775
|
+
const combinedStats = await actor.getStats();
|
|
5776
|
+
expect30(combinedStats.putBatchCalls).toBe(updateStats.putBatchCalls);
|
|
5777
|
+
expect30(combinedStats.getBatchCalls).toBe(updateStats.getBatchCalls);
|
|
5778
|
+
},
|
|
5779
|
+
3e4
|
|
5780
|
+
);
|
|
5781
|
+
test30(
|
|
5782
|
+
"warm multi-page INSERT writes multiple chunk keys",
|
|
5783
|
+
async (c) => {
|
|
5784
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5785
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5786
|
+
`kv-stats-4-${crypto.randomUUID()}`
|
|
5787
|
+
]);
|
|
5788
|
+
await actor.insertWithIndex();
|
|
5789
|
+
await actor.resetStats();
|
|
5790
|
+
await actor.insertWithIndex();
|
|
5791
|
+
const stats = await actor.getStats();
|
|
5792
|
+
const log = await actor.getLog();
|
|
5793
|
+
expect30(stats.putBatchCalls).toBeGreaterThanOrEqual(1);
|
|
5794
|
+
expect30(stats.putBatchEntries).toBeGreaterThan(1);
|
|
5795
|
+
const putOps = log.filter(
|
|
5796
|
+
(e) => e.op === "putBatch" || e.op === "put"
|
|
5797
|
+
);
|
|
5798
|
+
const allKeys = putOps.flatMap((e) => e.keys);
|
|
5799
|
+
const mainChunkKeys = allKeys.filter(
|
|
5800
|
+
(k) => k.startsWith("chunk:main[")
|
|
5801
|
+
);
|
|
5802
|
+
expect30(mainChunkKeys.length).toBeGreaterThanOrEqual(1);
|
|
5803
|
+
},
|
|
5804
|
+
3e4
|
|
5805
|
+
);
|
|
5806
|
+
test30(
|
|
5807
|
+
"warm ROLLBACK produces no data page writes",
|
|
5808
|
+
async (c) => {
|
|
5809
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5810
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5811
|
+
`kv-stats-5-${crypto.randomUUID()}`
|
|
5812
|
+
]);
|
|
5813
|
+
await actor.rollbackTest();
|
|
5814
|
+
await actor.resetStats();
|
|
5815
|
+
await actor.rollbackTest();
|
|
5816
|
+
const log = await actor.getLog();
|
|
5817
|
+
const putOps = log.filter(
|
|
5818
|
+
(e) => e.op === "putBatch" || e.op === "put"
|
|
5819
|
+
);
|
|
5820
|
+
const mainChunkKeys = putOps.flatMap((e) => e.keys).filter((k) => k.startsWith("chunk:main["));
|
|
5821
|
+
expect30(mainChunkKeys.length).toBe(0);
|
|
5822
|
+
},
|
|
5823
|
+
3e4
|
|
5824
|
+
);
|
|
5825
|
+
test30(
|
|
5826
|
+
"warm multi-statement transaction produces writes",
|
|
5827
|
+
async (c) => {
|
|
5828
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5829
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5830
|
+
`kv-stats-6-${crypto.randomUUID()}`
|
|
5831
|
+
]);
|
|
5832
|
+
await actor.multiStmtTx();
|
|
5833
|
+
await actor.resetStats();
|
|
5834
|
+
await actor.multiStmtTx();
|
|
5835
|
+
const stats = await actor.getStats();
|
|
5836
|
+
expect30(stats.putBatchCalls).toBeGreaterThanOrEqual(1);
|
|
5837
|
+
},
|
|
5838
|
+
3e4
|
|
5839
|
+
);
|
|
5840
|
+
test30(
|
|
5841
|
+
"no WAL or SHM operations occur",
|
|
5842
|
+
async (c) => {
|
|
5843
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5844
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5845
|
+
`kv-stats-7-${crypto.randomUUID()}`
|
|
5846
|
+
]);
|
|
5847
|
+
await actor.warmUp();
|
|
5848
|
+
await actor.increment();
|
|
5849
|
+
const log = await actor.getLog();
|
|
5850
|
+
const allKeys = log.flatMap((e) => e.keys);
|
|
5851
|
+
const walOrShmKeys = allKeys.filter(
|
|
5852
|
+
(k) => k.includes("wal") || k.includes("shm")
|
|
5853
|
+
);
|
|
5854
|
+
expect30(walOrShmKeys.length).toBe(0);
|
|
5855
|
+
},
|
|
5856
|
+
3e4
|
|
5857
|
+
);
|
|
5858
|
+
test30(
|
|
5859
|
+
"every putBatch has at most 128 keys",
|
|
5860
|
+
async (c) => {
|
|
5861
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5862
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5863
|
+
`kv-stats-8-${crypto.randomUUID()}`
|
|
5864
|
+
]);
|
|
5865
|
+
await actor.warmUp();
|
|
5866
|
+
await actor.increment();
|
|
5867
|
+
const log = await actor.getLog();
|
|
5868
|
+
const putBatchOps = log.filter(
|
|
5869
|
+
(e) => e.op === "putBatch"
|
|
5870
|
+
);
|
|
5871
|
+
for (const entry of putBatchOps) {
|
|
5872
|
+
expect30(
|
|
5873
|
+
entry.keys.length
|
|
5874
|
+
).toBeLessThanOrEqual(128);
|
|
5875
|
+
}
|
|
5876
|
+
},
|
|
5877
|
+
3e4
|
|
5878
|
+
);
|
|
5879
|
+
test30(
|
|
5880
|
+
"large transaction falls back to journal when exceeding 127 dirty pages",
|
|
5881
|
+
async (c) => {
|
|
5882
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5883
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5884
|
+
`kv-stats-9-${crypto.randomUUID()}`
|
|
5885
|
+
]);
|
|
5886
|
+
await actor.warmUp();
|
|
5887
|
+
await actor.bulkInsertLarge();
|
|
5888
|
+
const stats = await actor.getStats();
|
|
5889
|
+
const log = await actor.getLog();
|
|
5890
|
+
expect30(stats.putBatchCalls).toBeGreaterThan(1);
|
|
5891
|
+
const allKeys = log.flatMap((e) => e.keys);
|
|
5892
|
+
const journalKeys = allKeys.filter(
|
|
5893
|
+
(k) => k.includes("journal")
|
|
5894
|
+
);
|
|
5895
|
+
expect30(journalKeys.length).toBeGreaterThan(0);
|
|
5896
|
+
const putBatchOps = log.filter(
|
|
5897
|
+
(e) => e.op === "putBatch"
|
|
5898
|
+
);
|
|
5899
|
+
for (const entry of putBatchOps) {
|
|
5900
|
+
expect30(
|
|
5901
|
+
entry.keys.length
|
|
5902
|
+
).toBeLessThanOrEqual(128);
|
|
5903
|
+
}
|
|
5904
|
+
},
|
|
5905
|
+
6e4
|
|
5906
|
+
);
|
|
5907
|
+
test30(
|
|
5908
|
+
"large transaction data integrity: 200 rows and integrity check pass",
|
|
5909
|
+
async (c) => {
|
|
5910
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5911
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5912
|
+
`kv-stats-10-${crypto.randomUUID()}`
|
|
5913
|
+
]);
|
|
5914
|
+
await actor.bulkInsertLarge();
|
|
5915
|
+
const count = await actor.getRowCount();
|
|
5916
|
+
expect30(count).toBe(200);
|
|
5917
|
+
const integrity = await actor.runIntegrityCheck();
|
|
5918
|
+
expect30(integrity).toBe("ok");
|
|
5919
|
+
},
|
|
5920
|
+
6e4
|
|
5921
|
+
);
|
|
5922
|
+
test30(
|
|
5923
|
+
"large transaction survives actor sleep and wake",
|
|
5924
|
+
async (c) => {
|
|
5925
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
5926
|
+
const actor = client.dbKvStatsActor.getOrCreate([
|
|
5927
|
+
`kv-stats-11-${crypto.randomUUID()}`
|
|
5928
|
+
]);
|
|
5929
|
+
await actor.bulkInsertLarge();
|
|
5930
|
+
const countBefore = await actor.getRowCount();
|
|
5931
|
+
expect30(countBefore).toBe(200);
|
|
5932
|
+
await actor.triggerSleep();
|
|
5933
|
+
await waitFor(driverTestConfig, 250);
|
|
5934
|
+
const countAfter = await actor.getRowCount();
|
|
5935
|
+
expect30(countAfter).toBe(200);
|
|
5936
|
+
const integrity = await actor.runIntegrityCheck();
|
|
5937
|
+
expect30(integrity).toBe("ok");
|
|
5938
|
+
},
|
|
5939
|
+
6e4
|
|
5940
|
+
);
|
|
5941
|
+
});
|
|
5942
|
+
}
|
|
5943
|
+
|
|
4902
5944
|
// src/driver-test-suite/tests/request-access.ts
|
|
4903
|
-
import { describe as
|
|
5945
|
+
import { describe as describe32, expect as expect31, test as test31 } from "vitest";
|
|
4904
5946
|
function runRequestAccessTests(driverTestConfig) {
|
|
4905
|
-
|
|
4906
|
-
|
|
5947
|
+
describe32("Request Access in Lifecycle Hooks", () => {
|
|
5948
|
+
test31("should have access to request object in onBeforeConnect and createConnState", async (c) => {
|
|
4907
5949
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4908
5950
|
const handle = client.requestAccessActor.getOrCreate(
|
|
4909
5951
|
["test-request"],
|
|
@@ -4914,23 +5956,23 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
4914
5956
|
const connection = handle.connect();
|
|
4915
5957
|
const requestInfo = await connection.getRequestInfo();
|
|
4916
5958
|
if (driverTestConfig.clientType === "http") {
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
5959
|
+
expect31(requestInfo.onBeforeConnect.hasRequest).toBe(true);
|
|
5960
|
+
expect31(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
|
|
5961
|
+
expect31(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
|
|
5962
|
+
expect31(
|
|
4921
5963
|
requestInfo.onBeforeConnect.requestHeaders
|
|
4922
5964
|
).toBeDefined();
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
5965
|
+
expect31(requestInfo.createConnState.hasRequest).toBe(true);
|
|
5966
|
+
expect31(requestInfo.createConnState.requestUrl).toBeDefined();
|
|
5967
|
+
expect31(requestInfo.createConnState.requestMethod).toBeDefined();
|
|
5968
|
+
expect31(
|
|
4927
5969
|
requestInfo.createConnState.requestHeaders
|
|
4928
5970
|
).toBeDefined();
|
|
4929
5971
|
} else {
|
|
4930
5972
|
}
|
|
4931
5973
|
await connection.dispose();
|
|
4932
5974
|
});
|
|
4933
|
-
|
|
5975
|
+
test31("should not have request when trackRequest is false", async (c) => {
|
|
4934
5976
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4935
5977
|
const handle = client.requestAccessActor.getOrCreate(
|
|
4936
5978
|
["test-no-request"],
|
|
@@ -4940,21 +5982,21 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
4940
5982
|
);
|
|
4941
5983
|
const connection = handle.connect();
|
|
4942
5984
|
const requestInfo = await connection.getRequestInfo();
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
5985
|
+
expect31(requestInfo.onBeforeConnect.hasRequest).toBe(false);
|
|
5986
|
+
expect31(requestInfo.onBeforeConnect.requestUrl).toBeNull();
|
|
5987
|
+
expect31(requestInfo.onBeforeConnect.requestMethod).toBeNull();
|
|
5988
|
+
expect31(
|
|
4947
5989
|
Object.keys(requestInfo.onBeforeConnect.requestHeaders)
|
|
4948
5990
|
).toHaveLength(0);
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
5991
|
+
expect31(requestInfo.createConnState.hasRequest).toBe(false);
|
|
5992
|
+
expect31(requestInfo.createConnState.requestUrl).toBeNull();
|
|
5993
|
+
expect31(requestInfo.createConnState.requestMethod).toBeNull();
|
|
5994
|
+
expect31(
|
|
4953
5995
|
Object.keys(requestInfo.createConnState.requestHeaders)
|
|
4954
5996
|
).toHaveLength(0);
|
|
4955
5997
|
await connection.dispose();
|
|
4956
5998
|
});
|
|
4957
|
-
|
|
5999
|
+
test31("should capture request headers and method", async (c) => {
|
|
4958
6000
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
4959
6001
|
const handle = client.requestAccessActor.getOrCreate(
|
|
4960
6002
|
["test-headers"],
|
|
@@ -4965,18 +6007,18 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
4965
6007
|
const connection = handle.connect();
|
|
4966
6008
|
const requestInfo = await connection.getRequestInfo();
|
|
4967
6009
|
if (driverTestConfig.clientType === "http") {
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
6010
|
+
expect31(requestInfo.onBeforeConnect.hasRequest).toBe(true);
|
|
6011
|
+
expect31(requestInfo.onBeforeConnect.requestMethod).toBeTruthy();
|
|
6012
|
+
expect31(requestInfo.onBeforeConnect.requestUrl).toBeTruthy();
|
|
6013
|
+
expect31(requestInfo.onBeforeConnect.requestHeaders).toBeTruthy();
|
|
6014
|
+
expect31(typeof requestInfo.onBeforeConnect.requestHeaders).toBe(
|
|
4973
6015
|
"object"
|
|
4974
6016
|
);
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
6017
|
+
expect31(requestInfo.createConnState.hasRequest).toBe(true);
|
|
6018
|
+
expect31(requestInfo.createConnState.requestMethod).toBeTruthy();
|
|
6019
|
+
expect31(requestInfo.createConnState.requestUrl).toBeTruthy();
|
|
6020
|
+
expect31(requestInfo.createConnState.requestHeaders).toBeTruthy();
|
|
6021
|
+
expect31(typeof requestInfo.createConnState.requestHeaders).toBe(
|
|
4980
6022
|
"object"
|
|
4981
6023
|
);
|
|
4982
6024
|
} else {
|
|
@@ -4988,14 +6030,14 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
4988
6030
|
|
|
4989
6031
|
// src/driver-test-suite/mod.ts
|
|
4990
6032
|
function runDriverTests(driverTestConfigPartial) {
|
|
4991
|
-
|
|
6033
|
+
describe33("Driver Tests", () => {
|
|
4992
6034
|
var _a;
|
|
4993
6035
|
const clientTypes = ((_a = driverTestConfigPartial.skip) == null ? void 0 : _a.inline) ? ["http"] : ["http", "inline"];
|
|
4994
6036
|
for (const clientType of clientTypes) {
|
|
4995
|
-
|
|
6037
|
+
describe33(`client type (${clientType})`, () => {
|
|
4996
6038
|
const encodings = ["bare", "cbor", "json"];
|
|
4997
6039
|
for (const encoding of encodings) {
|
|
4998
|
-
|
|
6040
|
+
describe33(`encoding (${encoding})`, () => {
|
|
4999
6041
|
const driverTestConfig = {
|
|
5000
6042
|
...driverTestConfigPartial,
|
|
5001
6043
|
clientType,
|
|
@@ -5019,6 +6061,7 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
5019
6061
|
runActorErrorHandlingTests(driverTestConfig);
|
|
5020
6062
|
runActorQueueTests(driverTestConfig);
|
|
5021
6063
|
runActorRunTests(driverTestConfig);
|
|
6064
|
+
runActorSandboxTests(driverTestConfig);
|
|
5022
6065
|
runActorInlineClientTests(driverTestConfig);
|
|
5023
6066
|
runActorKvTests(driverTestConfig);
|
|
5024
6067
|
runActorWorkflowTests(driverTestConfig);
|
|
@@ -5027,6 +6070,7 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
5027
6070
|
runRawHttpRequestPropertiesTests(driverTestConfig);
|
|
5028
6071
|
runRawWebSocketTests(driverTestConfig);
|
|
5029
6072
|
runActorInspectorTests(driverTestConfig);
|
|
6073
|
+
runActorDbKvStatsTests(driverTestConfig);
|
|
5030
6074
|
});
|
|
5031
6075
|
}
|
|
5032
6076
|
});
|
|
@@ -5085,7 +6129,10 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
5085
6129
|
);
|
|
5086
6130
|
nodeWebSocket.injectWebSocket(server);
|
|
5087
6131
|
const address = server.address();
|
|
5088
|
-
invariant2(
|
|
6132
|
+
invariant2(
|
|
6133
|
+
address && typeof address !== "string",
|
|
6134
|
+
"missing server address"
|
|
6135
|
+
);
|
|
5089
6136
|
const port = address.port;
|
|
5090
6137
|
const serverEndpoint = `http://127.0.0.1:${port}`;
|
|
5091
6138
|
logger().info({ msg: "test serer listening", port });
|