rivetkit 2.1.2 → 2.1.4
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 +11 -0
- package/dist/browser/client.js +1 -1
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/inspector.tar.gz +0 -0
- package/dist/tsup/{chunk-MNS5LY6M.cjs → chunk-3B6PCYJB.cjs} +280 -115
- package/dist/tsup/chunk-3B6PCYJB.cjs.map +1 -0
- package/dist/tsup/{chunk-YQ5P6KMN.js → chunk-3GTO6H3E.js} +12 -5
- package/dist/tsup/chunk-3GTO6H3E.js.map +1 -0
- package/dist/tsup/{chunk-RMJJE43B.cjs → chunk-4KSHPFXF.cjs} +2 -2
- package/dist/tsup/{chunk-RMJJE43B.cjs.map → chunk-4KSHPFXF.cjs.map} +1 -1
- package/dist/tsup/{chunk-PW3YONDJ.js → chunk-5UEFNG7P.js} +2 -2
- package/dist/tsup/{chunk-PSUVV4HM.js → chunk-ANKZ2FS6.js} +2 -4
- package/dist/tsup/chunk-ANKZ2FS6.js.map +1 -0
- package/dist/tsup/{chunk-GVQAVU7R.cjs → chunk-AQD4CBZ2.cjs} +4 -4
- package/dist/tsup/{chunk-GVQAVU7R.cjs.map → chunk-AQD4CBZ2.cjs.map} +1 -1
- package/dist/tsup/{chunk-WUXR722E.js → chunk-DZXDUGLL.js} +2 -2
- package/dist/tsup/{chunk-WUXR722E.js.map → chunk-DZXDUGLL.js.map} +1 -1
- package/dist/tsup/{chunk-NXEHFUDB.cjs → chunk-GXRVSSVD.cjs} +28 -21
- package/dist/tsup/chunk-GXRVSSVD.cjs.map +1 -0
- package/dist/tsup/{chunk-UZV7NXC6.cjs → chunk-H5TSEPN4.cjs} +30 -30
- package/dist/tsup/{chunk-UZV7NXC6.cjs.map → chunk-H5TSEPN4.cjs.map} +1 -1
- package/dist/tsup/{chunk-TDFDR7AO.js → chunk-HBYEYBIC.js} +2 -2
- package/dist/tsup/{chunk-772NPMTY.cjs → chunk-HKOSZKKZ.cjs} +263 -299
- package/dist/tsup/chunk-HKOSZKKZ.cjs.map +1 -0
- package/dist/tsup/{chunk-HB4RGGMC.js → chunk-I6PL6QIY.js} +5 -5
- package/dist/tsup/{chunk-RHUII57M.js → chunk-KTWY3K6Z.js} +23 -12
- package/dist/tsup/chunk-KTWY3K6Z.js.map +1 -0
- package/dist/tsup/{chunk-HFWRHT5T.cjs → chunk-LK36OGGO.cjs} +3 -5
- package/dist/tsup/chunk-LK36OGGO.cjs.map +1 -0
- package/dist/tsup/{chunk-BSIJG3LG.js → chunk-M6H4XIF4.js} +179 -215
- package/dist/tsup/chunk-M6H4XIF4.js.map +1 -0
- package/dist/tsup/{chunk-ZHQDRRMY.cjs → chunk-QPADHLDU.cjs} +3 -3
- package/dist/tsup/{chunk-ZHQDRRMY.cjs.map → chunk-QPADHLDU.cjs.map} +1 -1
- package/dist/tsup/{chunk-BFI4LYS2.js → chunk-TEFYRRAK.js} +4 -4
- package/dist/tsup/{chunk-PZAV6PP2.cjs → chunk-TEUL4UYN.cjs} +152 -152
- package/dist/tsup/{chunk-PZAV6PP2.cjs.map → chunk-TEUL4UYN.cjs.map} +1 -1
- package/dist/tsup/{chunk-VMX4I4MP.js → chunk-UDMRZR6A.js} +212 -47
- package/dist/tsup/chunk-UDMRZR6A.js.map +1 -0
- package/dist/tsup/{chunk-QABDKI3W.cjs → chunk-UWAGLDT6.cjs} +263 -252
- package/dist/tsup/chunk-UWAGLDT6.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-P3XujgRr.d.ts → config-Qj-zLJPc.d.ts} +11 -0
- package/dist/tsup/{config-_gfywqqI.d.cts → config-iPj5l1bL.d.cts} +11 -0
- package/dist/tsup/{context-uNA4TRn3.d.ts → context-CQCMuHND.d.ts} +1 -1
- package/dist/tsup/{context-Bxd8Cx4H.d.cts → context-DzvH1PBK.d.cts} +1 -1
- package/dist/tsup/{driver-CPGHKXyh.d.ts → driver-Jo8v-kbU.d.ts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +4 -4
- package/dist/tsup/driver-helpers/mod.d.cts +4 -4
- package/dist/tsup/driver-helpers/mod.d.ts +4 -4
- package/dist/tsup/driver-helpers/mod.js +3 -3
- package/dist/tsup/{driver-BcLvZcKl.d.cts → driver-iV8J-WMv.d.cts} +1 -1
- package/dist/tsup/driver-test-suite/mod.cjs +556 -333
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +2 -2
- package/dist/tsup/driver-test-suite/mod.d.ts +2 -2
- package/dist/tsup/driver-test-suite/mod.js +1332 -1109
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +3 -3
- package/dist/tsup/inspector/mod.js +2 -2
- package/dist/tsup/mod.cjs +8 -8
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +7 -7
- package/dist/tsup/serve-test-suite/mod.cjs +194 -100
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +105 -11
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +5 -5
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +5 -5
- package/src/actor/config.ts +0 -2
- package/src/actor/instance/mod.ts +30 -6
- package/src/actor/router.ts +9 -6
- package/src/driver-test-suite/mod.ts +3 -0
- package/src/driver-test-suite/tests/actor-db.ts +299 -216
- package/src/driver-test-suite/tests/actor-driver.ts +4 -0
- package/src/driver-test-suite/tests/actor-lifecycle.ts +157 -0
- package/src/driver-test-suite/tests/actor-queue.ts +10 -9
- package/src/driver-test-suite/tests/actor-workflow.ts +12 -2
- package/src/driver-test-suite/tests/conn-error-serialization.ts +64 -0
- package/src/driver-test-suite/utils.ts +8 -8
- package/src/drivers/engine/actor-driver.ts +113 -11
- package/src/manager/router.ts +20 -6
- package/src/{registry → utils}/serve.ts +38 -4
- package/src/workflow/context.ts +4 -0
- package/src/workflow/driver.ts +4 -1
- package/dist/tsup/chunk-772NPMTY.cjs.map +0 -1
- package/dist/tsup/chunk-BSIJG3LG.js.map +0 -1
- package/dist/tsup/chunk-HFWRHT5T.cjs.map +0 -1
- package/dist/tsup/chunk-MNS5LY6M.cjs.map +0 -1
- package/dist/tsup/chunk-NXEHFUDB.cjs.map +0 -1
- package/dist/tsup/chunk-PSUVV4HM.js.map +0 -1
- package/dist/tsup/chunk-QABDKI3W.cjs.map +0 -1
- package/dist/tsup/chunk-RHUII57M.js.map +0 -1
- package/dist/tsup/chunk-VMX4I4MP.js.map +0 -1
- package/dist/tsup/chunk-YQ5P6KMN.js.map +0 -1
- /package/dist/tsup/{chunk-PW3YONDJ.js.map → chunk-5UEFNG7P.js.map} +0 -0
- /package/dist/tsup/{chunk-TDFDR7AO.js.map → chunk-HBYEYBIC.js.map} +0 -0
- /package/dist/tsup/{chunk-HB4RGGMC.js.map → chunk-I6PL6QIY.js.map} +0 -0
- /package/dist/tsup/{chunk-BFI4LYS2.js.map → chunk-TEFYRRAK.js.map} +0 -0
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
11
|
-
require('../chunk-
|
|
7
|
+
var _chunkH5TSEPN4cjs = require('../chunk-H5TSEPN4.cjs');
|
|
8
|
+
require('../chunk-GXRVSSVD.cjs');
|
|
9
|
+
require('../chunk-AQD4CBZ2.cjs');
|
|
10
|
+
require('../chunk-HKOSZKKZ.cjs');
|
|
11
|
+
require('../chunk-UWAGLDT6.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkTEUL4UYNcjs = require('../chunk-TEUL4UYN.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkQPADHLDUcjs = require('../chunk-QPADHLDU.cjs');
|
|
21
21
|
require('../chunk-6LJAZ5R4.cjs');
|
|
22
22
|
require('../chunk-SR3KQE7Q.cjs');
|
|
23
23
|
|
|
@@ -29,14 +29,14 @@ require('../chunk-SR3KQE7Q.cjs');
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunk3B6PCYJBcjs = require('../chunk-3B6PCYJB.cjs');
|
|
33
33
|
require('../chunk-NIYZDWMW.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkLK36OGGOcjs = require('../chunk-LK36OGGO.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunk4KSHPFXFcjs = require('../chunk-4KSHPFXF.cjs');
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -85,20 +85,20 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
85
85
|
const oldUrl = new URL(actorRequest.url);
|
|
86
86
|
const normalizedPath = oldUrl.pathname.startsWith("/") ? oldUrl.pathname.slice(1) : oldUrl.pathname;
|
|
87
87
|
const pathWithQuery = normalizedPath + oldUrl.search;
|
|
88
|
-
|
|
88
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
|
|
89
89
|
msg: "sending raw http request via test inline driver",
|
|
90
90
|
actorId,
|
|
91
91
|
encoding,
|
|
92
92
|
path: pathWithQuery
|
|
93
93
|
});
|
|
94
94
|
const url = `${endpoint}/.test/inline-driver/send-request/${pathWithQuery}`;
|
|
95
|
-
|
|
95
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
|
|
96
96
|
msg: "rewriting http url",
|
|
97
97
|
from: oldUrl,
|
|
98
98
|
to: url
|
|
99
99
|
});
|
|
100
100
|
const headers = new Headers(actorRequest.headers);
|
|
101
|
-
headers.set(
|
|
101
|
+
headers.set(_chunk3B6PCYJBcjs.HEADER_ACTOR_ID, actorId);
|
|
102
102
|
const response = await fetch(
|
|
103
103
|
new Request(url, {
|
|
104
104
|
method: actorRequest.method,
|
|
@@ -114,7 +114,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
114
114
|
const errorData = await clonedResponse.json();
|
|
115
115
|
if (errorData.error) {
|
|
116
116
|
if (typeof errorData.error === "object") {
|
|
117
|
-
throw new (0,
|
|
117
|
+
throw new (0, _chunkTEUL4UYNcjs.ActorError)(
|
|
118
118
|
errorData.error.code,
|
|
119
119
|
errorData.error.message,
|
|
120
120
|
errorData.error.metadata
|
|
@@ -122,7 +122,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
} catch (e) {
|
|
125
|
-
if (!(e instanceof
|
|
125
|
+
if (!(e instanceof _chunkTEUL4UYNcjs.ActorError)) {
|
|
126
126
|
return response;
|
|
127
127
|
}
|
|
128
128
|
throw e;
|
|
@@ -131,33 +131,33 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
131
131
|
return response;
|
|
132
132
|
},
|
|
133
133
|
async openWebSocket(path, actorId, encoding2, params) {
|
|
134
|
-
const WebSocket2 = await
|
|
134
|
+
const WebSocket2 = await _chunkQPADHLDUcjs.importWebSocket.call(void 0, );
|
|
135
135
|
const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
136
136
|
const wsUrl = new URL(
|
|
137
137
|
`${endpoint}/.test/inline-driver/connect-websocket/ws`
|
|
138
138
|
);
|
|
139
|
-
|
|
139
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
|
|
140
140
|
msg: "creating websocket connection via test inline driver",
|
|
141
141
|
url: wsUrl.toString()
|
|
142
142
|
});
|
|
143
143
|
const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
144
144
|
const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}`;
|
|
145
145
|
const protocols = [];
|
|
146
|
-
protocols.push(
|
|
147
|
-
protocols.push(`${
|
|
146
|
+
protocols.push(_chunk3B6PCYJBcjs.WS_PROTOCOL_STANDARD);
|
|
147
|
+
protocols.push(`${_chunk3B6PCYJBcjs.WS_PROTOCOL_TARGET}actor`);
|
|
148
148
|
protocols.push(
|
|
149
|
-
`${
|
|
149
|
+
`${_chunk3B6PCYJBcjs.WS_PROTOCOL_ACTOR}${encodeURIComponent(actorId)}`
|
|
150
150
|
);
|
|
151
|
-
protocols.push(`${
|
|
151
|
+
protocols.push(`${_chunk3B6PCYJBcjs.WS_PROTOCOL_ENCODING}${encoding2}`);
|
|
152
152
|
protocols.push(
|
|
153
|
-
`${
|
|
153
|
+
`${_chunk3B6PCYJBcjs.WS_TEST_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
|
|
154
154
|
);
|
|
155
155
|
if (params !== void 0) {
|
|
156
156
|
protocols.push(
|
|
157
|
-
`${
|
|
157
|
+
`${_chunk3B6PCYJBcjs.WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
|
|
161
161
|
msg: "connecting to websocket",
|
|
162
162
|
url: finalWsUrl,
|
|
163
163
|
protocols
|
|
@@ -177,7 +177,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
177
177
|
encoding2,
|
|
178
178
|
params
|
|
179
179
|
);
|
|
180
|
-
return upgradeWebSocket(() => wsHandler)(c,
|
|
180
|
+
return upgradeWebSocket(() => wsHandler)(c, _chunk4KSHPFXFcjs.noopNext.call(void 0, ));
|
|
181
181
|
},
|
|
182
182
|
async buildGatewayUrl(actorId) {
|
|
183
183
|
return `${endpoint}/gateway/${actorId}`;
|
|
@@ -194,7 +194,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
async function makeInlineRequest(endpoint, encoding, method, args) {
|
|
197
|
-
|
|
197
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
|
|
198
198
|
msg: "sending inline request",
|
|
199
199
|
encoding,
|
|
200
200
|
method,
|
|
@@ -224,14 +224,14 @@ async function makeInlineRequest(endpoint, encoding, method, args) {
|
|
|
224
224
|
if ("ok" in callResponse) {
|
|
225
225
|
return callResponse.ok;
|
|
226
226
|
} else if ("err" in callResponse) {
|
|
227
|
-
throw new (0,
|
|
227
|
+
throw new (0, _chunkTEUL4UYNcjs.ActorError)(
|
|
228
228
|
callResponse.err.group,
|
|
229
229
|
callResponse.err.code,
|
|
230
230
|
callResponse.err.message,
|
|
231
231
|
callResponse.err.metadata
|
|
232
232
|
);
|
|
233
233
|
} else {
|
|
234
|
-
|
|
234
|
+
_chunkLK36OGGOcjs.assertUnreachable.call(void 0, callResponse);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -243,13 +243,9 @@ async function setupDriverTest(c, driverTestConfig) {
|
|
|
243
243
|
_vitest.vi.setSystemTime(FAKE_TIME);
|
|
244
244
|
}
|
|
245
245
|
const { endpoint, namespace, runnerName, cleanup } = await driverTestConfig.start();
|
|
246
|
-
c.onTestFinished(() => {
|
|
247
|
-
_chunkUZV7NXC6cjs.logger.call(void 0, ).info("cleaning up test");
|
|
248
|
-
cleanup();
|
|
249
|
-
});
|
|
250
246
|
let client;
|
|
251
247
|
if (driverTestConfig.clientType === "http") {
|
|
252
|
-
client =
|
|
248
|
+
client = _chunkTEUL4UYNcjs.createClient.call(void 0, {
|
|
253
249
|
endpoint,
|
|
254
250
|
namespace,
|
|
255
251
|
runnerName,
|
|
@@ -262,16 +258,20 @@ async function setupDriverTest(c, driverTestConfig) {
|
|
|
262
258
|
} else if (driverTestConfig.clientType === "inline") {
|
|
263
259
|
const encoding = _nullishCoalesce(driverTestConfig.encoding, () => ( "bare"));
|
|
264
260
|
const managerDriver = createTestInlineClientDriver(endpoint, encoding);
|
|
265
|
-
const runConfig =
|
|
261
|
+
const runConfig = _chunkTEUL4UYNcjs.ClientConfigSchema.parse({
|
|
266
262
|
encoding
|
|
267
263
|
});
|
|
268
|
-
client =
|
|
264
|
+
client = _chunkTEUL4UYNcjs.createClientWithDriver.call(void 0, managerDriver, runConfig);
|
|
269
265
|
} else {
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
if (!driverTestConfig.HACK_skipCleanupNet) {
|
|
273
|
-
c.onTestFinished(async () => await client.dispose());
|
|
266
|
+
_chunkLK36OGGOcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
|
|
274
267
|
}
|
|
268
|
+
c.onTestFinished(async () => {
|
|
269
|
+
if (!driverTestConfig.HACK_skipCleanupNet) {
|
|
270
|
+
await client.dispose();
|
|
271
|
+
}
|
|
272
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).info("cleaning up test");
|
|
273
|
+
await cleanup();
|
|
274
|
+
});
|
|
275
275
|
return {
|
|
276
276
|
client,
|
|
277
277
|
endpoint
|
|
@@ -989,7 +989,7 @@ function runActorConnHibernationTests(driverTestConfig) {
|
|
|
989
989
|
await hibernatingActor.triggerSleep();
|
|
990
990
|
await waitFor(
|
|
991
991
|
driverTestConfig,
|
|
992
|
-
|
|
992
|
+
_chunkH5TSEPN4cjs.HIBERNATION_SLEEP_TIMEOUT + 100
|
|
993
993
|
);
|
|
994
994
|
const ping2 = await hibernatingActor.ping();
|
|
995
995
|
_vitest.expect.call(void 0, ping2).toBe("pong");
|
|
@@ -1011,7 +1011,7 @@ function runActorConnHibernationTests(driverTestConfig) {
|
|
|
1011
1011
|
await hibernatingActor.triggerSleep();
|
|
1012
1012
|
await waitFor(
|
|
1013
1013
|
driverTestConfig,
|
|
1014
|
-
|
|
1014
|
+
_chunkH5TSEPN4cjs.HIBERNATION_SLEEP_TIMEOUT + 100
|
|
1015
1015
|
);
|
|
1016
1016
|
const count3 = await hibernatingActor.getConnCount();
|
|
1017
1017
|
_vitest.expect.call(void 0, count3).toBe(2);
|
|
@@ -1033,7 +1033,7 @@ function runActorConnHibernationTests(driverTestConfig) {
|
|
|
1033
1033
|
await conn1.triggerSleep();
|
|
1034
1034
|
await waitFor(
|
|
1035
1035
|
driverTestConfig,
|
|
1036
|
-
|
|
1036
|
+
_chunkH5TSEPN4cjs.HIBERNATION_SLEEP_TIMEOUT + 100
|
|
1037
1037
|
);
|
|
1038
1038
|
await conn1.dispose();
|
|
1039
1039
|
await waitFor(driverTestConfig, 250);
|
|
@@ -1247,6 +1247,7 @@ var HIGH_VOLUME_COUNT = 1e3;
|
|
|
1247
1247
|
var SLEEP_WAIT_MS = 150;
|
|
1248
1248
|
var LIFECYCLE_POLL_INTERVAL_MS = 25;
|
|
1249
1249
|
var LIFECYCLE_POLL_ATTEMPTS = 40;
|
|
1250
|
+
var REAL_TIMER_DB_TIMEOUT_MS = 18e4;
|
|
1250
1251
|
var CHUNK_BOUNDARY_SIZES = [
|
|
1251
1252
|
CHUNK_SIZE - 1,
|
|
1252
1253
|
CHUNK_SIZE,
|
|
@@ -1271,293 +1272,410 @@ function getDbActor(client, variant) {
|
|
|
1271
1272
|
}
|
|
1272
1273
|
function runActorDbTests(driverTestConfig) {
|
|
1273
1274
|
const variants = ["raw", "drizzle"];
|
|
1275
|
+
const dbTestTimeout = driverTestConfig.useRealTimers ? REAL_TIMER_DB_TIMEOUT_MS : void 0;
|
|
1276
|
+
const lifecycleTestTimeout = driverTestConfig.useRealTimers ? REAL_TIMER_DB_TIMEOUT_MS : void 0;
|
|
1274
1277
|
for (const variant of variants) {
|
|
1275
1278
|
_vitest.describe.call(void 0, `Actor Database (${variant}) Tests`, () => {
|
|
1276
|
-
_vitest.test.call(void 0,
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1279
|
+
_vitest.test.call(void 0,
|
|
1280
|
+
"bootstraps schema on startup",
|
|
1281
|
+
async (c) => {
|
|
1282
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1283
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1284
|
+
`db-${variant}-bootstrap-${crypto.randomUUID()}`
|
|
1285
|
+
]);
|
|
1286
|
+
const count = await actor.getCount();
|
|
1287
|
+
_vitest.expect.call(void 0, count).toBe(0);
|
|
1288
|
+
},
|
|
1289
|
+
dbTestTimeout
|
|
1290
|
+
);
|
|
1291
|
+
_vitest.test.call(void 0,
|
|
1292
|
+
"supports CRUD, raw SQL, and multi-statement exec",
|
|
1293
|
+
async (c) => {
|
|
1294
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1295
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1296
|
+
`db-${variant}-crud-${crypto.randomUUID()}`
|
|
1297
|
+
]);
|
|
1298
|
+
await actor.reset();
|
|
1299
|
+
const first = await actor.insertValue("alpha");
|
|
1300
|
+
const second = await actor.insertValue("beta");
|
|
1301
|
+
const values = await actor.getValues();
|
|
1302
|
+
_vitest.expect.call(void 0, values.length).toBeGreaterThanOrEqual(2);
|
|
1303
|
+
_vitest.expect.call(void 0, values.some((row) => row.value === "alpha")).toBeTruthy();
|
|
1304
|
+
_vitest.expect.call(void 0, values.some((row) => row.value === "beta")).toBeTruthy();
|
|
1305
|
+
await actor.updateValue(first.id, "alpha-updated");
|
|
1306
|
+
const updated = await actor.getValue(first.id);
|
|
1307
|
+
_vitest.expect.call(void 0, updated).toBe("alpha-updated");
|
|
1308
|
+
await actor.deleteValue(second.id);
|
|
1309
|
+
const count = await actor.getCount();
|
|
1310
|
+
if (driverTestConfig.useRealTimers) {
|
|
1311
|
+
_vitest.expect.call(void 0, count).toBeGreaterThanOrEqual(1);
|
|
1312
|
+
} else {
|
|
1313
|
+
_vitest.expect.call(void 0, count).toBe(1);
|
|
1314
|
+
}
|
|
1315
|
+
const rawCount = await actor.rawSelectCount();
|
|
1316
|
+
if (driverTestConfig.useRealTimers) {
|
|
1317
|
+
_vitest.expect.call(void 0, rawCount).toBeGreaterThanOrEqual(1);
|
|
1318
|
+
} else {
|
|
1319
|
+
_vitest.expect.call(void 0, rawCount).toBe(1);
|
|
1320
|
+
}
|
|
1321
|
+
const multiValue = await actor.multiStatementInsert("gamma");
|
|
1322
|
+
_vitest.expect.call(void 0, multiValue).toBe("gamma-updated");
|
|
1323
|
+
},
|
|
1324
|
+
dbTestTimeout
|
|
1325
|
+
);
|
|
1326
|
+
_vitest.test.call(void 0,
|
|
1327
|
+
"handles transactions",
|
|
1328
|
+
async (c) => {
|
|
1329
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1330
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1331
|
+
`db-${variant}-tx-${crypto.randomUUID()}`
|
|
1332
|
+
]);
|
|
1333
|
+
await actor.reset();
|
|
1334
|
+
await actor.transactionCommit("commit");
|
|
1329
1335
|
_vitest.expect.call(void 0, await actor.getCount()).toBe(1);
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1336
|
+
await actor.transactionRollback("rollback");
|
|
1337
|
+
_vitest.expect.call(void 0, await actor.getCount()).toBe(1);
|
|
1338
|
+
},
|
|
1339
|
+
dbTestTimeout
|
|
1340
|
+
);
|
|
1341
|
+
_vitest.test.call(void 0,
|
|
1342
|
+
"persists across sleep and wake cycles",
|
|
1343
|
+
async (c) => {
|
|
1344
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1345
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1346
|
+
`db-${variant}-sleep-${crypto.randomUUID()}`
|
|
1347
|
+
]);
|
|
1348
|
+
await actor.reset();
|
|
1349
|
+
await actor.insertValue("sleepy");
|
|
1350
|
+
const baselineCount = await actor.getCount();
|
|
1351
|
+
_vitest.expect.call(void 0, baselineCount).toBeGreaterThan(0);
|
|
1352
|
+
for (let i = 0; i < 3; i++) {
|
|
1353
|
+
await actor.triggerSleep();
|
|
1354
|
+
await waitFor(driverTestConfig, SLEEP_WAIT_MS);
|
|
1355
|
+
_vitest.expect.call(void 0, await actor.getCount()).toBe(baselineCount);
|
|
1356
|
+
}
|
|
1357
|
+
},
|
|
1358
|
+
dbTestTimeout
|
|
1359
|
+
);
|
|
1360
|
+
_vitest.test.call(void 0,
|
|
1361
|
+
"completes onDisconnect DB writes before sleeping",
|
|
1362
|
+
async (c) => {
|
|
1363
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1364
|
+
const key = `db-${variant}-disconnect-${crypto.randomUUID()}`;
|
|
1365
|
+
const actor = getDbActor(client, variant).getOrCreate([key]);
|
|
1366
|
+
await actor.reset();
|
|
1367
|
+
await actor.configureDisconnectInsert(true, 250);
|
|
1368
|
+
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 250);
|
|
1369
|
+
await actor.configureDisconnectInsert(false, 0);
|
|
1370
|
+
_vitest.expect.call(void 0, await actor.getDisconnectInsertCount()).toBe(1);
|
|
1371
|
+
},
|
|
1372
|
+
dbTestTimeout
|
|
1373
|
+
);
|
|
1374
|
+
_vitest.test.call(void 0,
|
|
1375
|
+
"handles high-volume inserts",
|
|
1376
|
+
async (c) => {
|
|
1377
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1378
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1379
|
+
`db-${variant}-high-volume-${crypto.randomUUID()}`
|
|
1380
|
+
]);
|
|
1381
|
+
await actor.reset();
|
|
1382
|
+
await actor.insertMany(HIGH_VOLUME_COUNT);
|
|
1383
|
+
const count = await actor.getCount();
|
|
1384
|
+
if (driverTestConfig.useRealTimers) {
|
|
1385
|
+
_vitest.expect.call(void 0, count).toBeGreaterThanOrEqual(HIGH_VOLUME_COUNT);
|
|
1386
|
+
} else {
|
|
1387
|
+
_vitest.expect.call(void 0, count).toBe(HIGH_VOLUME_COUNT);
|
|
1388
|
+
}
|
|
1389
|
+
},
|
|
1390
|
+
dbTestTimeout
|
|
1391
|
+
);
|
|
1392
|
+
_vitest.test.call(void 0,
|
|
1393
|
+
"handles payloads across chunk boundaries",
|
|
1394
|
+
async (c) => {
|
|
1395
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1396
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1397
|
+
`db-${variant}-chunk-${crypto.randomUUID()}`
|
|
1398
|
+
]);
|
|
1399
|
+
await actor.reset();
|
|
1400
|
+
for (const size of CHUNK_BOUNDARY_SIZES) {
|
|
1401
|
+
const { id } = await actor.insertPayloadOfSize(size);
|
|
1402
|
+
const storedSize = await actor.getPayloadSize(id);
|
|
1403
|
+
_vitest.expect.call(void 0, storedSize).toBe(size);
|
|
1404
|
+
}
|
|
1405
|
+
},
|
|
1406
|
+
dbTestTimeout
|
|
1407
|
+
);
|
|
1408
|
+
_vitest.test.call(void 0,
|
|
1409
|
+
"handles large payloads",
|
|
1410
|
+
async (c) => {
|
|
1411
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1412
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1413
|
+
`db-${variant}-large-${crypto.randomUUID()}`
|
|
1414
|
+
]);
|
|
1415
|
+
await actor.reset();
|
|
1416
|
+
const { id } = await actor.insertPayloadOfSize(LARGE_PAYLOAD_SIZE);
|
|
1417
|
+
const storedSize = await actor.getPayloadSize(id);
|
|
1418
|
+
_vitest.expect.call(void 0, storedSize).toBe(LARGE_PAYLOAD_SIZE);
|
|
1419
|
+
},
|
|
1420
|
+
dbTestTimeout
|
|
1421
|
+
);
|
|
1422
|
+
_vitest.test.call(void 0,
|
|
1423
|
+
"supports shrink and regrow workloads with vacuum",
|
|
1424
|
+
async (c) => {
|
|
1425
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1426
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1427
|
+
`db-${variant}-shrink-regrow-${crypto.randomUUID()}`
|
|
1428
|
+
]);
|
|
1429
|
+
await actor.reset();
|
|
1430
|
+
await actor.vacuum();
|
|
1431
|
+
const baselinePages = await actor.getPageCount();
|
|
1432
|
+
await actor.insertPayloadRows(
|
|
1433
|
+
SHRINK_GROW_INITIAL_ROWS,
|
|
1434
|
+
SHRINK_GROW_INITIAL_PAYLOAD
|
|
1435
|
+
);
|
|
1436
|
+
const grownPages = await actor.getPageCount();
|
|
1437
|
+
await actor.reset();
|
|
1438
|
+
await actor.vacuum();
|
|
1439
|
+
const shrunkPages = await actor.getPageCount();
|
|
1440
|
+
await actor.insertPayloadRows(
|
|
1441
|
+
SHRINK_GROW_REGROW_ROWS,
|
|
1442
|
+
SHRINK_GROW_REGROW_PAYLOAD
|
|
1443
|
+
);
|
|
1444
|
+
const regrownPages = await actor.getPageCount();
|
|
1445
|
+
_vitest.expect.call(void 0, grownPages).toBeGreaterThanOrEqual(baselinePages);
|
|
1446
|
+
_vitest.expect.call(void 0, shrunkPages).toBeLessThanOrEqual(grownPages);
|
|
1447
|
+
_vitest.expect.call(void 0, regrownPages).toBeGreaterThan(shrunkPages);
|
|
1448
|
+
},
|
|
1449
|
+
dbTestTimeout
|
|
1450
|
+
);
|
|
1451
|
+
_vitest.test.call(void 0,
|
|
1452
|
+
"handles repeated updates to the same row",
|
|
1453
|
+
async (c) => {
|
|
1454
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1455
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1456
|
+
`db-${variant}-updates-${crypto.randomUUID()}`
|
|
1457
|
+
]);
|
|
1458
|
+
await actor.reset();
|
|
1459
|
+
const { id } = await actor.insertValue("base");
|
|
1460
|
+
const result = await actor.repeatUpdate(id, 50);
|
|
1461
|
+
_vitest.expect.call(void 0, result.value).toBe("Updated 49");
|
|
1462
|
+
const value = await actor.getValue(id);
|
|
1463
|
+
_vitest.expect.call(void 0, value).toBe("Updated 49");
|
|
1464
|
+
const hotRowIds = [];
|
|
1465
|
+
for (let i = 0; i < HOT_ROW_COUNT; i++) {
|
|
1466
|
+
const row = await actor.insertValue(`init-${i}`);
|
|
1467
|
+
hotRowIds.push(row.id);
|
|
1468
|
+
}
|
|
1469
|
+
const updatedRows = await actor.roundRobinUpdateValues(
|
|
1470
|
+
hotRowIds,
|
|
1471
|
+
HOT_ROW_UPDATES
|
|
1472
|
+
);
|
|
1473
|
+
_vitest.expect.call(void 0, updatedRows).toHaveLength(HOT_ROW_COUNT);
|
|
1474
|
+
for (const row of updatedRows) {
|
|
1475
|
+
_vitest.expect.call(void 0, row.value).toMatch(/^v-\d+$/);
|
|
1476
|
+
}
|
|
1477
|
+
},
|
|
1478
|
+
dbTestTimeout
|
|
1479
|
+
);
|
|
1480
|
+
_vitest.test.call(void 0,
|
|
1481
|
+
"passes integrity checks after mixed workload and sleep",
|
|
1482
|
+
async (c) => {
|
|
1483
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1484
|
+
const actor = getDbActor(client, variant).getOrCreate([
|
|
1485
|
+
`db-${variant}-integrity-${crypto.randomUUID()}`
|
|
1486
|
+
]);
|
|
1487
|
+
await actor.reset();
|
|
1488
|
+
await actor.runMixedWorkload(
|
|
1489
|
+
INTEGRITY_SEED_COUNT,
|
|
1490
|
+
INTEGRITY_CHURN_COUNT
|
|
1491
|
+
);
|
|
1492
|
+
_vitest.expect.call(void 0, (await actor.integrityCheck()).toLowerCase()).toBe("ok");
|
|
1493
|
+
await actor.triggerSleep();
|
|
1494
|
+
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1495
|
+
_vitest.expect.call(void 0, (await actor.integrityCheck()).toLowerCase()).toBe("ok");
|
|
1496
|
+
},
|
|
1497
|
+
dbTestTimeout
|
|
1498
|
+
);
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
_vitest.describe.call(void 0, "Actor Database Lifecycle Cleanup Tests", () => {
|
|
1502
|
+
_vitest.test.call(void 0,
|
|
1503
|
+
"runs db provider cleanup on sleep",
|
|
1504
|
+
async (c) => {
|
|
1343
1505
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1506
|
+
const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
|
|
1507
|
+
const lifecycle = client.dbLifecycle.getOrCreate([
|
|
1508
|
+
`db-lifecycle-sleep-${crypto.randomUUID()}`
|
|
1346
1509
|
]);
|
|
1347
|
-
await
|
|
1348
|
-
await
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1510
|
+
const actorId = await lifecycle.getActorId();
|
|
1511
|
+
const before = await observer.getCounts(actorId);
|
|
1512
|
+
await lifecycle.insertValue("before-sleep");
|
|
1513
|
+
await lifecycle.triggerSleep();
|
|
1514
|
+
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1515
|
+
await lifecycle.ping();
|
|
1516
|
+
let after = before;
|
|
1517
|
+
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1518
|
+
after = await observer.getCounts(actorId);
|
|
1519
|
+
if (after.cleanup >= before.cleanup + 1) {
|
|
1520
|
+
break;
|
|
1521
|
+
}
|
|
1522
|
+
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1523
|
+
}
|
|
1524
|
+
_vitest.expect.call(void 0, after.create).toBeGreaterThanOrEqual(before.create);
|
|
1525
|
+
_vitest.expect.call(void 0, after.migrate).toBeGreaterThanOrEqual(before.migrate);
|
|
1526
|
+
_vitest.expect.call(void 0, after.cleanup).toBeGreaterThanOrEqual(before.cleanup + 1);
|
|
1527
|
+
},
|
|
1528
|
+
lifecycleTestTimeout
|
|
1529
|
+
);
|
|
1530
|
+
_vitest.test.call(void 0,
|
|
1531
|
+
"runs db provider cleanup on destroy",
|
|
1532
|
+
async (c) => {
|
|
1352
1533
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1534
|
+
const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
|
|
1535
|
+
const lifecycle = client.dbLifecycle.getOrCreate([
|
|
1536
|
+
`db-lifecycle-destroy-${crypto.randomUUID()}`
|
|
1355
1537
|
]);
|
|
1356
|
-
await
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1538
|
+
const actorId = await lifecycle.getActorId();
|
|
1539
|
+
const before = await observer.getCounts(actorId);
|
|
1540
|
+
await lifecycle.insertValue("before-destroy");
|
|
1541
|
+
await lifecycle.triggerDestroy();
|
|
1542
|
+
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1543
|
+
let cleanupCount = before.cleanup;
|
|
1544
|
+
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1545
|
+
const counts = await observer.getCounts(actorId);
|
|
1546
|
+
cleanupCount = counts.cleanup;
|
|
1547
|
+
if (cleanupCount >= before.cleanup + 1) {
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1361
1551
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1552
|
+
_vitest.expect.call(void 0, cleanupCount).toBeGreaterThanOrEqual(before.cleanup + 1);
|
|
1553
|
+
},
|
|
1554
|
+
lifecycleTestTimeout
|
|
1555
|
+
);
|
|
1556
|
+
_vitest.test.call(void 0,
|
|
1557
|
+
"runs db provider cleanup when migration fails",
|
|
1558
|
+
async (c) => {
|
|
1364
1559
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1560
|
+
const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
|
|
1561
|
+
const beforeTotalCleanup = await observer.getTotalCleanupCount();
|
|
1562
|
+
const key = `db-lifecycle-migrate-failure-${crypto.randomUUID()}`;
|
|
1563
|
+
const lifecycle = client.dbLifecycleFailing.getOrCreate([key]);
|
|
1564
|
+
let threw = false;
|
|
1565
|
+
try {
|
|
1566
|
+
await lifecycle.ping();
|
|
1567
|
+
} catch (e3) {
|
|
1568
|
+
threw = true;
|
|
1569
|
+
}
|
|
1570
|
+
_vitest.expect.call(void 0, threw).toBeTruthy();
|
|
1571
|
+
let cleanupCount = beforeTotalCleanup;
|
|
1572
|
+
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1573
|
+
cleanupCount = await observer.getTotalCleanupCount();
|
|
1574
|
+
if (cleanupCount >= beforeTotalCleanup + 1) {
|
|
1575
|
+
break;
|
|
1576
|
+
}
|
|
1577
|
+
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1578
|
+
}
|
|
1579
|
+
_vitest.expect.call(void 0, cleanupCount).toBeGreaterThanOrEqual(beforeTotalCleanup + 1);
|
|
1580
|
+
},
|
|
1581
|
+
lifecycleTestTimeout
|
|
1582
|
+
);
|
|
1583
|
+
_vitest.test.call(void 0,
|
|
1584
|
+
"handles parallel actor lifecycle churn",
|
|
1585
|
+
async (c) => {
|
|
1374
1586
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
await actor.insertPayloadRows(
|
|
1382
|
-
SHRINK_GROW_INITIAL_ROWS,
|
|
1383
|
-
SHRINK_GROW_INITIAL_PAYLOAD
|
|
1587
|
+
const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
|
|
1588
|
+
const actorHandles = Array.from(
|
|
1589
|
+
{ length: 12 },
|
|
1590
|
+
(_, i) => client.dbLifecycle.getOrCreate([
|
|
1591
|
+
`db-lifecycle-stress-${i}-${crypto.randomUUID()}`
|
|
1592
|
+
])
|
|
1384
1593
|
);
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1387
|
-
await actor.vacuum();
|
|
1388
|
-
const shrunkPages = await actor.getPageCount();
|
|
1389
|
-
await actor.insertPayloadRows(
|
|
1390
|
-
SHRINK_GROW_REGROW_ROWS,
|
|
1391
|
-
SHRINK_GROW_REGROW_PAYLOAD
|
|
1594
|
+
const actorIds = await Promise.all(
|
|
1595
|
+
actorHandles.map((handle) => handle.getActorId())
|
|
1392
1596
|
);
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
_vitest.expect.call(void 0, shrunkPages).toBeLessThanOrEqual(grownPages);
|
|
1396
|
-
_vitest.expect.call(void 0, regrownPages).toBeGreaterThan(shrunkPages);
|
|
1397
|
-
});
|
|
1398
|
-
_vitest.test.call(void 0, "handles repeated updates to the same row", async (c) => {
|
|
1399
|
-
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1400
|
-
const actor = getDbActor(client, variant).getOrCreate([
|
|
1401
|
-
`db-${variant}-updates-${crypto.randomUUID()}`
|
|
1402
|
-
]);
|
|
1403
|
-
await actor.reset();
|
|
1404
|
-
const { id } = await actor.insertValue("base");
|
|
1405
|
-
const result = await actor.repeatUpdate(id, 50);
|
|
1406
|
-
_vitest.expect.call(void 0, result.value).toBe("Updated 49");
|
|
1407
|
-
const value = await actor.getValue(id);
|
|
1408
|
-
_vitest.expect.call(void 0, value).toBe("Updated 49");
|
|
1409
|
-
const hotRowIds = [];
|
|
1410
|
-
for (let i = 0; i < HOT_ROW_COUNT; i++) {
|
|
1411
|
-
const row = await actor.insertValue(`init-${i}`);
|
|
1412
|
-
hotRowIds.push(row.id);
|
|
1413
|
-
}
|
|
1414
|
-
const updatedRows = await actor.roundRobinUpdateValues(
|
|
1415
|
-
hotRowIds,
|
|
1416
|
-
HOT_ROW_UPDATES
|
|
1597
|
+
await Promise.all(
|
|
1598
|
+
actorHandles.map((handle, i) => handle.insertValue(`phase-1-${i}`))
|
|
1417
1599
|
);
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
});
|
|
1423
|
-
_vitest.test.call(void 0, "passes integrity checks after mixed workload and sleep", async (c) => {
|
|
1424
|
-
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1425
|
-
const actor = getDbActor(client, variant).getOrCreate([
|
|
1426
|
-
`db-${variant}-integrity-${crypto.randomUUID()}`
|
|
1427
|
-
]);
|
|
1428
|
-
await actor.reset();
|
|
1429
|
-
await actor.runMixedWorkload(
|
|
1430
|
-
INTEGRITY_SEED_COUNT,
|
|
1431
|
-
INTEGRITY_CHURN_COUNT
|
|
1600
|
+
await Promise.all(actorHandles.map((handle) => handle.triggerSleep()));
|
|
1601
|
+
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1602
|
+
await Promise.all(
|
|
1603
|
+
actorHandles.map((handle, i) => handle.insertValue(`phase-2-${i}`))
|
|
1432
1604
|
);
|
|
1433
|
-
|
|
1434
|
-
|
|
1605
|
+
const survivors = actorHandles.slice(0, 6);
|
|
1606
|
+
const destroyed = actorHandles.slice(6);
|
|
1607
|
+
await Promise.all(destroyed.map((handle) => handle.triggerDestroy()));
|
|
1608
|
+
await Promise.all(survivors.map((handle) => handle.triggerSleep()));
|
|
1435
1609
|
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
]);
|
|
1447
|
-
const actorId = await lifecycle.getActorId();
|
|
1448
|
-
const before = await observer.getCounts(actorId);
|
|
1449
|
-
await lifecycle.insertValue("before-sleep");
|
|
1450
|
-
await lifecycle.triggerSleep();
|
|
1451
|
-
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1452
|
-
await lifecycle.ping();
|
|
1453
|
-
let after = before;
|
|
1454
|
-
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1455
|
-
after = await observer.getCounts(actorId);
|
|
1456
|
-
if (after.cleanup >= before.cleanup + 1) {
|
|
1457
|
-
break;
|
|
1610
|
+
await Promise.all(survivors.map((handle) => handle.ping()));
|
|
1611
|
+
const survivorCounts = await Promise.all(
|
|
1612
|
+
survivors.map((handle) => handle.getCount())
|
|
1613
|
+
);
|
|
1614
|
+
for (const count of survivorCounts) {
|
|
1615
|
+
if (driverTestConfig.useRealTimers) {
|
|
1616
|
+
_vitest.expect.call(void 0, count).toBeGreaterThanOrEqual(2);
|
|
1617
|
+
} else {
|
|
1618
|
+
_vitest.expect.call(void 0, count).toBe(2);
|
|
1619
|
+
}
|
|
1458
1620
|
}
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
await lifecycle.insertValue("before-destroy");
|
|
1474
|
-
await lifecycle.triggerDestroy();
|
|
1475
|
-
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1476
|
-
let cleanupCount = before.cleanup;
|
|
1477
|
-
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1478
|
-
const counts = await observer.getCounts(actorId);
|
|
1479
|
-
cleanupCount = counts.cleanup;
|
|
1480
|
-
if (cleanupCount >= before.cleanup + 1) {
|
|
1481
|
-
break;
|
|
1621
|
+
const lifecycleCleanup = /* @__PURE__ */ new Map();
|
|
1622
|
+
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1623
|
+
let allCleaned = true;
|
|
1624
|
+
for (const actorId of actorIds) {
|
|
1625
|
+
const counts = await observer.getCounts(actorId);
|
|
1626
|
+
lifecycleCleanup.set(actorId, counts.cleanup);
|
|
1627
|
+
if (counts.cleanup < 1) {
|
|
1628
|
+
allCleaned = false;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
if (allCleaned) {
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1482
1635
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1636
|
+
for (const actorId of actorIds) {
|
|
1637
|
+
_vitest.expect.call(void 0, _nullishCoalesce(lifecycleCleanup.get(actorId), () => ( 0))).toBeGreaterThanOrEqual(1);
|
|
1638
|
+
}
|
|
1639
|
+
},
|
|
1640
|
+
lifecycleTestTimeout
|
|
1641
|
+
);
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
// src/driver-test-suite/tests/conn-error-serialization.ts
|
|
1646
|
+
|
|
1647
|
+
function runConnErrorSerializationTests(driverTestConfig) {
|
|
1648
|
+
_vitest.describe.call(void 0, "Connection Error Serialization Tests", () => {
|
|
1649
|
+
_vitest.test.call(void 0, "error thrown in createConnState preserves group and code through WebSocket serialization", async (c) => {
|
|
1488
1650
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1489
|
-
const
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1492
|
-
|
|
1651
|
+
const actorKey = `test-error-serialization-${Date.now()}`;
|
|
1652
|
+
const actor = client.connErrorSerializationActor.getOrCreate(
|
|
1653
|
+
[actorKey],
|
|
1654
|
+
{ params: { shouldThrow: true } }
|
|
1655
|
+
);
|
|
1656
|
+
const conn = actor.connect();
|
|
1657
|
+
let caughtError;
|
|
1493
1658
|
try {
|
|
1494
|
-
await
|
|
1495
|
-
} catch (
|
|
1496
|
-
|
|
1497
|
-
}
|
|
1498
|
-
_vitest.expect.call(void 0, threw).toBeTruthy();
|
|
1499
|
-
const actorId = await client.dbLifecycleFailing.get([key]).resolve();
|
|
1500
|
-
let cleanupCount = 0;
|
|
1501
|
-
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1502
|
-
const counts = await observer.getCounts(actorId);
|
|
1503
|
-
cleanupCount = counts.cleanup;
|
|
1504
|
-
if (cleanupCount >= 1) {
|
|
1505
|
-
break;
|
|
1506
|
-
}
|
|
1507
|
-
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1659
|
+
await conn.getValue();
|
|
1660
|
+
} catch (err) {
|
|
1661
|
+
caughtError = err;
|
|
1508
1662
|
}
|
|
1509
|
-
_vitest.expect.call(void 0,
|
|
1663
|
+
_vitest.expect.call(void 0, caughtError).toBeDefined();
|
|
1664
|
+
_vitest.expect.call(void 0, caughtError.group).toBe("connection");
|
|
1665
|
+
_vitest.expect.call(void 0, caughtError.code).toBe("custom_error");
|
|
1666
|
+
await conn.dispose();
|
|
1510
1667
|
});
|
|
1511
|
-
_vitest.test.call(void 0, "
|
|
1668
|
+
_vitest.test.call(void 0, "successful createConnState does not throw error", async (c) => {
|
|
1512
1669
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1513
|
-
const
|
|
1514
|
-
const
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
`db-lifecycle-stress-${i}-${crypto.randomUUID()}`
|
|
1518
|
-
])
|
|
1670
|
+
const actorKey = `test-no-error-${Date.now()}`;
|
|
1671
|
+
const actor = client.connErrorSerializationActor.getOrCreate(
|
|
1672
|
+
[actorKey],
|
|
1673
|
+
{ params: { shouldThrow: false } }
|
|
1519
1674
|
);
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
);
|
|
1523
|
-
await
|
|
1524
|
-
actorHandles.map((handle, i) => handle.insertValue(`phase-1-${i}`))
|
|
1525
|
-
);
|
|
1526
|
-
await Promise.all(actorHandles.map((handle) => handle.triggerSleep()));
|
|
1527
|
-
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1528
|
-
await Promise.all(
|
|
1529
|
-
actorHandles.map((handle, i) => handle.insertValue(`phase-2-${i}`))
|
|
1530
|
-
);
|
|
1531
|
-
const survivors = actorHandles.slice(0, 6);
|
|
1532
|
-
const destroyed = actorHandles.slice(6);
|
|
1533
|
-
await Promise.all(destroyed.map((handle) => handle.triggerDestroy()));
|
|
1534
|
-
await Promise.all(survivors.map((handle) => handle.triggerSleep()));
|
|
1535
|
-
await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
|
|
1536
|
-
await Promise.all(survivors.map((handle) => handle.ping()));
|
|
1537
|
-
const survivorCounts = await Promise.all(
|
|
1538
|
-
survivors.map((handle) => handle.getCount())
|
|
1539
|
-
);
|
|
1540
|
-
for (const count of survivorCounts) {
|
|
1541
|
-
_vitest.expect.call(void 0, count).toBe(2);
|
|
1542
|
-
}
|
|
1543
|
-
const lifecycleCleanup = /* @__PURE__ */ new Map();
|
|
1544
|
-
for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
|
|
1545
|
-
let allCleaned = true;
|
|
1546
|
-
for (const actorId of actorIds) {
|
|
1547
|
-
const counts = await observer.getCounts(actorId);
|
|
1548
|
-
lifecycleCleanup.set(actorId, counts.cleanup);
|
|
1549
|
-
if (counts.cleanup < 1) {
|
|
1550
|
-
allCleaned = false;
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
if (allCleaned) {
|
|
1554
|
-
break;
|
|
1555
|
-
}
|
|
1556
|
-
await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
|
|
1557
|
-
}
|
|
1558
|
-
for (const actorId of actorIds) {
|
|
1559
|
-
_vitest.expect.call(void 0, _nullishCoalesce(lifecycleCleanup.get(actorId), () => ( 0))).toBeGreaterThanOrEqual(1);
|
|
1560
|
-
}
|
|
1675
|
+
const conn = actor.connect();
|
|
1676
|
+
const value = await conn.getValue();
|
|
1677
|
+
_vitest.expect.call(void 0, value).toBe(0);
|
|
1678
|
+
await conn.dispose();
|
|
1561
1679
|
});
|
|
1562
1680
|
});
|
|
1563
1681
|
}
|
|
@@ -1750,6 +1868,102 @@ function runActorDestroyTests(driverTestConfig) {
|
|
|
1750
1868
|
// src/driver-test-suite/tests/actor-driver.ts
|
|
1751
1869
|
|
|
1752
1870
|
|
|
1871
|
+
// src/driver-test-suite/tests/actor-lifecycle.ts
|
|
1872
|
+
|
|
1873
|
+
function runActorLifecycleTests(driverTestConfig) {
|
|
1874
|
+
_vitest.describe.call(void 0, "Actor Lifecycle Tests", () => {
|
|
1875
|
+
_vitest.test.call(void 0, "actor stop during start waits for start to complete", async (c) => {
|
|
1876
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1877
|
+
const actorKey = `test-stop-during-start-${Date.now()}`;
|
|
1878
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1879
|
+
const pingPromise = actor.ping();
|
|
1880
|
+
const actorId = await actor.resolve();
|
|
1881
|
+
await actor.destroy();
|
|
1882
|
+
const result = await pingPromise;
|
|
1883
|
+
_vitest.expect.call(void 0, result).toBe("pong");
|
|
1884
|
+
let destroyed = false;
|
|
1885
|
+
try {
|
|
1886
|
+
await client.startStopRaceActor.getForId(actorId).ping();
|
|
1887
|
+
} catch (err) {
|
|
1888
|
+
destroyed = true;
|
|
1889
|
+
_vitest.expect.call(void 0, err.group).toBe("actor");
|
|
1890
|
+
_vitest.expect.call(void 0, err.code).toBe("not_found");
|
|
1891
|
+
}
|
|
1892
|
+
_vitest.expect.call(void 0, destroyed).toBe(true);
|
|
1893
|
+
});
|
|
1894
|
+
_vitest.test.call(void 0, "actor stop before actor instantiation completes cleans up handler", async (c) => {
|
|
1895
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1896
|
+
const actorKey = `test-stop-before-instantiation-${Date.now()}`;
|
|
1897
|
+
const actors = Array.from(
|
|
1898
|
+
{ length: 5 },
|
|
1899
|
+
(_, i) => client.startStopRaceActor.getOrCreate([
|
|
1900
|
+
`${actorKey}-${i}`
|
|
1901
|
+
])
|
|
1902
|
+
);
|
|
1903
|
+
const ids = await Promise.all(actors.map((a) => a.resolve()));
|
|
1904
|
+
await Promise.all(actors.map((a) => a.destroy()));
|
|
1905
|
+
for (const id of ids) {
|
|
1906
|
+
let destroyed = false;
|
|
1907
|
+
try {
|
|
1908
|
+
await client.startStopRaceActor.getForId(id).ping();
|
|
1909
|
+
} catch (err) {
|
|
1910
|
+
destroyed = true;
|
|
1911
|
+
_vitest.expect.call(void 0, err.group).toBe("actor");
|
|
1912
|
+
_vitest.expect.call(void 0, err.code).toBe("not_found");
|
|
1913
|
+
}
|
|
1914
|
+
_vitest.expect.call(void 0, destroyed, `actor ${id} should be destroyed`).toBe(
|
|
1915
|
+
true
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
_vitest.test.call(void 0, "onBeforeActorStart completes before stop proceeds", async (c) => {
|
|
1920
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1921
|
+
const actorKey = `test-before-actor-start-${Date.now()}`;
|
|
1922
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1923
|
+
const statePromise = actor.getState();
|
|
1924
|
+
await actor.destroy();
|
|
1925
|
+
const state = await statePromise;
|
|
1926
|
+
_vitest.expect.call(void 0, state.initialized).toBe(true);
|
|
1927
|
+
_vitest.expect.call(void 0, state.startCompleted).toBe(true);
|
|
1928
|
+
});
|
|
1929
|
+
_vitest.test.call(void 0, "multiple rapid create/destroy cycles handle race correctly", async (c) => {
|
|
1930
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1931
|
+
for (let i = 0; i < 10; i++) {
|
|
1932
|
+
const actorKey = `test-rapid-cycle-${Date.now()}-${i}`;
|
|
1933
|
+
const actor = client.startStopRaceActor.getOrCreate([
|
|
1934
|
+
actorKey
|
|
1935
|
+
]);
|
|
1936
|
+
const resolvePromise = actor.resolve();
|
|
1937
|
+
const destroyPromise = actor.destroy();
|
|
1938
|
+
await Promise.all([resolvePromise, destroyPromise]);
|
|
1939
|
+
}
|
|
1940
|
+
_vitest.expect.call(void 0, true).toBe(true);
|
|
1941
|
+
});
|
|
1942
|
+
_vitest.test.call(void 0, "actor stop called with no actor instance cleans up handler", async (c) => {
|
|
1943
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1944
|
+
const actorKey = `test-cleanup-no-instance-${Date.now()}`;
|
|
1945
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1946
|
+
const id = await actor.resolve();
|
|
1947
|
+
await actor.destroy();
|
|
1948
|
+
const newActor = client.startStopRaceActor.getOrCreate([
|
|
1949
|
+
actorKey
|
|
1950
|
+
]);
|
|
1951
|
+
const result = await newActor.ping();
|
|
1952
|
+
_vitest.expect.call(void 0, result).toBe("pong");
|
|
1953
|
+
await newActor.destroy();
|
|
1954
|
+
});
|
|
1955
|
+
_vitest.test.call(void 0, "onDestroy is called even when actor is destroyed during start", async (c) => {
|
|
1956
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1957
|
+
const actorKey = `test-ondestroy-during-start-${Date.now()}`;
|
|
1958
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1959
|
+
const statePromise = actor.getState();
|
|
1960
|
+
await actor.destroy();
|
|
1961
|
+
const state = await statePromise;
|
|
1962
|
+
_vitest.expect.call(void 0, state.destroyCalled).toBe(true);
|
|
1963
|
+
});
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1753
1967
|
// src/driver-test-suite/tests/actor-schedule.ts
|
|
1754
1968
|
|
|
1755
1969
|
function runActorScheduleTests(driverTestConfig) {
|
|
@@ -1844,7 +2058,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1844
2058
|
}
|
|
1845
2059
|
await sleepActor.triggerSleep();
|
|
1846
2060
|
await sleepActor.dispose();
|
|
1847
|
-
await waitFor(driverTestConfig,
|
|
2061
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1848
2062
|
const sleepActor2 = client.sleep.getOrCreate();
|
|
1849
2063
|
{
|
|
1850
2064
|
const { startCount, sleepCount } = await sleepActor2.getCounts();
|
|
@@ -1860,7 +2074,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1860
2074
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1861
2075
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1862
2076
|
}
|
|
1863
|
-
await waitFor(driverTestConfig,
|
|
2077
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1864
2078
|
{
|
|
1865
2079
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1866
2080
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1876,7 +2090,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1876
2090
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1877
2091
|
}
|
|
1878
2092
|
await sleepActor.dispose();
|
|
1879
|
-
await waitFor(driverTestConfig,
|
|
2093
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1880
2094
|
const sleepActor2 = client.sleep.getOrCreate();
|
|
1881
2095
|
{
|
|
1882
2096
|
const { startCount, sleepCount } = await sleepActor2.getCounts();
|
|
@@ -1892,19 +2106,19 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1892
2106
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1893
2107
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1894
2108
|
}
|
|
1895
|
-
await waitFor(driverTestConfig,
|
|
2109
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT - 250);
|
|
1896
2110
|
{
|
|
1897
2111
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1898
2112
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1899
2113
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1900
2114
|
}
|
|
1901
|
-
await waitFor(driverTestConfig,
|
|
2115
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT - 250);
|
|
1902
2116
|
{
|
|
1903
2117
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1904
2118
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1905
2119
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1906
2120
|
}
|
|
1907
|
-
await waitFor(driverTestConfig,
|
|
2121
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1908
2122
|
{
|
|
1909
2123
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1910
2124
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1919,8 +2133,8 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1919
2133
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1920
2134
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1921
2135
|
}
|
|
1922
|
-
await sleepActor.setAlarm(
|
|
1923
|
-
await waitFor(driverTestConfig,
|
|
2136
|
+
await sleepActor.setAlarm(_chunkH5TSEPN4cjs.SLEEP_TIMEOUT - 250);
|
|
2137
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1924
2138
|
{
|
|
1925
2139
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1926
2140
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
@@ -1935,8 +2149,8 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1935
2149
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1936
2150
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1937
2151
|
}
|
|
1938
|
-
await sleepActor.setAlarm(
|
|
1939
|
-
await waitFor(driverTestConfig,
|
|
2152
|
+
await sleepActor.setAlarm(_chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
2153
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 200);
|
|
1940
2154
|
{
|
|
1941
2155
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1942
2156
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1956,7 +2170,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1956
2170
|
);
|
|
1957
2171
|
const longRunningPromise = sleepActor.longRunningRpc();
|
|
1958
2172
|
await waitPromise;
|
|
1959
|
-
await waitFor(driverTestConfig,
|
|
2173
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1960
2174
|
await sleepActor.finishLongRunningRpc();
|
|
1961
2175
|
await longRunningPromise;
|
|
1962
2176
|
{
|
|
@@ -1965,7 +2179,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1965
2179
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1966
2180
|
}
|
|
1967
2181
|
await sleepActor.dispose();
|
|
1968
|
-
await waitFor(driverTestConfig,
|
|
2182
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
1969
2183
|
const sleepActor2 = client.sleepWithLongRpc.getOrCreate();
|
|
1970
2184
|
{
|
|
1971
2185
|
const { startCount, sleepCount } = await sleepActor2.getCounts();
|
|
@@ -1997,7 +2211,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1997
2211
|
}
|
|
1998
2212
|
};
|
|
1999
2213
|
});
|
|
2000
|
-
await waitFor(driverTestConfig,
|
|
2214
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
2001
2215
|
ws.send(JSON.stringify({ type: "getCounts" }));
|
|
2002
2216
|
const counts = await new Promise((resolve) => {
|
|
2003
2217
|
ws.onmessage = (event) => {
|
|
@@ -2010,7 +2224,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
2010
2224
|
_vitest.expect.call(void 0, counts.sleepCount).toBe(0);
|
|
2011
2225
|
_vitest.expect.call(void 0, counts.startCount).toBe(1);
|
|
2012
2226
|
ws.close();
|
|
2013
|
-
await waitFor(driverTestConfig,
|
|
2227
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
2014
2228
|
{
|
|
2015
2229
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
2016
2230
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -2028,7 +2242,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
2028
2242
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
2029
2243
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
2030
2244
|
}
|
|
2031
|
-
const fetchDuration =
|
|
2245
|
+
const fetchDuration = _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250;
|
|
2032
2246
|
const fetchPromise = sleepActor.fetch(
|
|
2033
2247
|
`long-request?duration=${fetchDuration}`
|
|
2034
2248
|
);
|
|
@@ -2041,7 +2255,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
2041
2255
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
2042
2256
|
_vitest.expect.call(void 0, requestCount).toBe(1);
|
|
2043
2257
|
}
|
|
2044
|
-
await waitFor(driverTestConfig,
|
|
2258
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
2045
2259
|
{
|
|
2046
2260
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
2047
2261
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -2056,13 +2270,13 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
2056
2270
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
2057
2271
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
2058
2272
|
}
|
|
2059
|
-
await waitFor(driverTestConfig,
|
|
2273
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
2060
2274
|
{
|
|
2061
2275
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
2062
2276
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
2063
2277
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
2064
2278
|
}
|
|
2065
|
-
await waitFor(driverTestConfig,
|
|
2279
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
|
|
2066
2280
|
{
|
|
2067
2281
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
2068
2282
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
@@ -2115,6 +2329,7 @@ function runActorDriverTests(driverTestConfig) {
|
|
|
2115
2329
|
runActorStateTests(driverTestConfig);
|
|
2116
2330
|
runActorScheduleTests(driverTestConfig);
|
|
2117
2331
|
runActorSleepTests(driverTestConfig);
|
|
2332
|
+
runActorLifecycleTests(driverTestConfig);
|
|
2118
2333
|
});
|
|
2119
2334
|
}
|
|
2120
2335
|
|
|
@@ -3042,11 +3257,12 @@ function runActorQueueTests(driverTestConfig) {
|
|
|
3042
3257
|
_vitest.test.call(void 0, "wait send returns completion response", async (c) => {
|
|
3043
3258
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3044
3259
|
const handle = client.queueActor.getOrCreate(["wait-complete"]);
|
|
3260
|
+
const waitTimeout = driverTestConfig.useRealTimers ? 5e3 : 1e3;
|
|
3045
3261
|
const actionPromise = handle.receiveAndComplete("tasks");
|
|
3046
3262
|
const result = await handle.send(
|
|
3047
3263
|
"tasks",
|
|
3048
3264
|
{ value: 123 },
|
|
3049
|
-
{ wait: true, timeout:
|
|
3265
|
+
{ wait: true, timeout: waitTimeout }
|
|
3050
3266
|
);
|
|
3051
3267
|
await actionPromise;
|
|
3052
3268
|
_vitest.expect.call(void 0, result).toEqual({
|
|
@@ -3189,7 +3405,7 @@ function runActorRunTests(driverTestConfig) {
|
|
|
3189
3405
|
const state1 = await actor.getState();
|
|
3190
3406
|
_vitest.expect.call(void 0, state1.runStarted).toBe(true);
|
|
3191
3407
|
const tickCount1 = state1.tickCount;
|
|
3192
|
-
await waitFor(driverTestConfig,
|
|
3408
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.RUN_SLEEP_TIMEOUT + 300);
|
|
3193
3409
|
const state2 = await actor.getState();
|
|
3194
3410
|
_vitest.expect.call(void 0, state2.runStarted).toBe(true);
|
|
3195
3411
|
_vitest.expect.call(void 0, state2.runExited).toBe(false);
|
|
@@ -3202,7 +3418,7 @@ function runActorRunTests(driverTestConfig) {
|
|
|
3202
3418
|
]);
|
|
3203
3419
|
const state = await actor.getState();
|
|
3204
3420
|
_vitest.expect.call(void 0, state.wakeCount).toBe(1);
|
|
3205
|
-
await waitFor(driverTestConfig,
|
|
3421
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.RUN_SLEEP_TIMEOUT + 300);
|
|
3206
3422
|
const state2 = await actor.getState();
|
|
3207
3423
|
_vitest.expect.call(void 0, state2.wakeCount).toBe(2);
|
|
3208
3424
|
});
|
|
@@ -3240,7 +3456,7 @@ function runActorRunTests(driverTestConfig) {
|
|
|
3240
3456
|
await waitFor(driverTestConfig, 100);
|
|
3241
3457
|
const state1 = await actor.getState();
|
|
3242
3458
|
_vitest.expect.call(void 0, state1.runStarted).toBe(true);
|
|
3243
|
-
await waitFor(driverTestConfig,
|
|
3459
|
+
await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.RUN_SLEEP_TIMEOUT + 500);
|
|
3244
3460
|
const state2 = await actor.getState();
|
|
3245
3461
|
_vitest.expect.call(void 0, state2.wakeCount).toBeGreaterThan(state1.wakeCount);
|
|
3246
3462
|
});
|
|
@@ -3396,8 +3612,14 @@ function runActorWorkflowTests(driverTestConfig) {
|
|
|
3396
3612
|
const actor = client.workflowCounterActor.getOrCreate([
|
|
3397
3613
|
"workflow-basic"
|
|
3398
3614
|
]);
|
|
3399
|
-
await
|
|
3400
|
-
|
|
3615
|
+
let state = await actor.getState();
|
|
3616
|
+
for (let i = 0; i < 50; i++) {
|
|
3617
|
+
if (state.runCount > 0 && state.history.length > 0 && state.guardTriggered) {
|
|
3618
|
+
break;
|
|
3619
|
+
}
|
|
3620
|
+
await waitFor(driverTestConfig, 100);
|
|
3621
|
+
state = await actor.getState();
|
|
3622
|
+
}
|
|
3401
3623
|
_vitest.expect.call(void 0, state.runCount).toBeGreaterThan(0);
|
|
3402
3624
|
_vitest.expect.call(void 0, state.history.length).toBeGreaterThan(0);
|
|
3403
3625
|
_vitest.expect.call(void 0, state.guardTriggered).toBe(true);
|
|
@@ -3405,7 +3627,7 @@ function runActorWorkflowTests(driverTestConfig) {
|
|
|
3405
3627
|
_vitest.test.call(void 0, "consumes queue messages via workflow queue.next", async (c) => {
|
|
3406
3628
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3407
3629
|
const actor = client.workflowQueueActor.getOrCreate(["workflow-queue"]);
|
|
3408
|
-
await actor.send(
|
|
3630
|
+
await actor.send(_chunkH5TSEPN4cjs.WORKFLOW_QUEUE_NAME, {
|
|
3409
3631
|
hello: "world"
|
|
3410
3632
|
});
|
|
3411
3633
|
await waitFor(driverTestConfig, 200);
|
|
@@ -4784,6 +5006,7 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
4784
5006
|
runActorConnTests(driverTestConfig);
|
|
4785
5007
|
runActorConnStateTests(driverTestConfig);
|
|
4786
5008
|
runActorConnHibernationTests(driverTestConfig);
|
|
5009
|
+
runConnErrorSerializationTests(driverTestConfig);
|
|
4787
5010
|
runActorDbTests(driverTestConfig);
|
|
4788
5011
|
runActorDestroyTests(driverTestConfig);
|
|
4789
5012
|
runRequestAccessTests(driverTestConfig);
|
|
@@ -4838,7 +5061,7 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
4838
5061
|
const parsedConfig = registry.parseConfig();
|
|
4839
5062
|
const managerDriver = (_a = driver.manager) == null ? void 0 : _a.call(driver, parsedConfig);
|
|
4840
5063
|
_invariant2.default.call(void 0, managerDriver, "missing manager driver");
|
|
4841
|
-
const { router } =
|
|
5064
|
+
const { router } = _chunk3B6PCYJBcjs.buildManagerRouter.call(void 0,
|
|
4842
5065
|
parsedConfig,
|
|
4843
5066
|
managerDriver,
|
|
4844
5067
|
() => upgradeWebSocket
|
|
@@ -4865,7 +5088,7 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
4865
5088
|
_invariant2.default.call(void 0, address && typeof address !== "string", "missing server address");
|
|
4866
5089
|
const port = address.port;
|
|
4867
5090
|
const serverEndpoint = `http://127.0.0.1:${port}`;
|
|
4868
|
-
|
|
5091
|
+
_chunkH5TSEPN4cjs.logger.call(void 0, ).info({ msg: "test serer listening", port });
|
|
4869
5092
|
const cleanup = async () => {
|
|
4870
5093
|
await new Promise(
|
|
4871
5094
|
(resolve) => server.close(() => resolve(void 0))
|