@dxos/functions-testing 0.8.4-main.3c1ae3b → 0.8.4-main.69d29f4
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/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +4 -3
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -13
- package/src/cpu-limit.test.ts +10 -4
- package/src/testing/util.ts +6 -4
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/functions-testing",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.69d29f4",
|
|
4
4
|
"description": "Functions tests",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "info@dxos.org",
|
|
9
13
|
"sideEffects": true,
|
|
@@ -33,19 +37,18 @@
|
|
|
33
37
|
"src"
|
|
34
38
|
],
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@effect/platform": "0.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/functions-runtime": "0.8.4-main.
|
|
43
|
-
"@dxos/functions
|
|
44
|
-
"@dxos/invariant": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
40
|
+
"@effect/platform": "0.93.6",
|
|
41
|
+
"@dxos/client": "0.8.4-main.69d29f4",
|
|
42
|
+
"@dxos/async": "0.8.4-main.69d29f4",
|
|
43
|
+
"@dxos/config": "0.8.4-main.69d29f4",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.69d29f4",
|
|
45
|
+
"@dxos/functions-runtime-cloudflare": "0.8.4-main.69d29f4",
|
|
46
|
+
"@dxos/functions-runtime": "0.8.4-main.69d29f4",
|
|
47
|
+
"@dxos/functions": "0.8.4-main.69d29f4",
|
|
48
|
+
"@dxos/invariant": "0.8.4-main.69d29f4",
|
|
49
|
+
"@dxos/protocols": "0.8.4-main.69d29f4",
|
|
50
|
+
"@dxos/log": "0.8.4-main.69d29f4"
|
|
47
51
|
},
|
|
48
|
-
"devDependencies": {},
|
|
49
52
|
"publishConfig": {
|
|
50
53
|
"access": "public"
|
|
51
54
|
},
|
package/src/cpu-limit.test.ts
CHANGED
|
@@ -86,7 +86,9 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
{
|
|
89
|
-
trigger
|
|
89
|
+
Obj.change(trigger, (t) => {
|
|
90
|
+
t.input!.iterations = 100;
|
|
91
|
+
});
|
|
90
92
|
await sync(space);
|
|
91
93
|
const result = await functionsServiceClient.forceRunCronTrigger(space.id, trigger.id);
|
|
92
94
|
console.log(result);
|
|
@@ -113,7 +115,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
|
|
|
113
115
|
await observeInvocations(space, 100);
|
|
114
116
|
});
|
|
115
117
|
|
|
116
|
-
test('break CPU limit through natural exection', { timeout: 520_000 }, async ({ expect }) => {
|
|
118
|
+
test.only('break CPU limit through natural exection', { timeout: 520_000 }, async ({ expect }) => {
|
|
117
119
|
const { client, space, functionsServiceClient } = await setup(config);
|
|
118
120
|
const func = await deployFunction(
|
|
119
121
|
space,
|
|
@@ -132,11 +134,15 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
|
|
|
132
134
|
await sync(space);
|
|
133
135
|
await observeInvocations(space, 5);
|
|
134
136
|
|
|
135
|
-
trigger
|
|
137
|
+
Obj.change(trigger, (t) => {
|
|
138
|
+
t.input!.iterations = 1_000_000_000;
|
|
139
|
+
});
|
|
136
140
|
await sync(space);
|
|
137
141
|
await observeInvocations(space, 10);
|
|
138
142
|
|
|
139
|
-
trigger
|
|
143
|
+
Obj.change(trigger, (t) => {
|
|
144
|
+
t.input!.iterations = 100;
|
|
145
|
+
});
|
|
140
146
|
await sync(space);
|
|
141
147
|
await observeInvocations(space, 1_000);
|
|
142
148
|
});
|
package/src/testing/util.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { InvocationTraceEndEvent, InvocationTraceStartEvent } from '@dxos/functi
|
|
|
14
14
|
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
15
15
|
import { bundleFunction } from '@dxos/functions-runtime/native';
|
|
16
16
|
import type { BundleResult } from '@dxos/functions-runtime/native';
|
|
17
|
-
import { type FunctionRuntimeKind } from '@dxos/protocols';
|
|
17
|
+
import { ErrorCodec, type FunctionRuntimeKind } from '@dxos/protocols';
|
|
18
18
|
import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
19
19
|
|
|
20
20
|
export const writeBundle = (path: string, bundle: BundleResult) => {
|
|
@@ -95,7 +95,9 @@ export const observeInvocations = async (space: Space, maxCount: number | null)
|
|
|
95
95
|
count: count++,
|
|
96
96
|
begin: invocation,
|
|
97
97
|
});
|
|
98
|
-
console.log(
|
|
98
|
+
console.log(
|
|
99
|
+
`${count.toString().padStart(3, ' ')}: BEGIN ${invocation.runtime ?? '(unknown runtime)'} ${JSON.stringify(invocation.input)}`,
|
|
100
|
+
);
|
|
99
101
|
} else if (Obj.instanceOf(InvocationTraceEndEvent, invocation)) {
|
|
100
102
|
const data = invocationData.get(invocation.invocationId);
|
|
101
103
|
if (!data || !!data.end) {
|
|
@@ -107,8 +109,8 @@ export const observeInvocations = async (space: Space, maxCount: number | null)
|
|
|
107
109
|
console.log(
|
|
108
110
|
`${data.count.toString().padStart(3, ' ')}: END outcome=${outcome} duration=${data.end.timestamp - data.begin.timestamp}`,
|
|
109
111
|
);
|
|
110
|
-
if (outcome === 'failure') {
|
|
111
|
-
console.
|
|
112
|
+
if (outcome === 'failure' && data.end.error) {
|
|
113
|
+
console.error(ErrorCodec.decode(data.end.error));
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
}
|