@nocobase/test 2.0.0-alpha.5 → 2.0.0-alpha.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/test",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.50",
4
4
  "main": "lib/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./lib/index.d.ts",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@faker-js/faker": "8.1.0",
54
- "@nocobase/server": "2.0.0-alpha.5",
54
+ "@nocobase/server": "2.0.0-alpha.50",
55
55
  "@playwright/test": "^1.45.3",
56
56
  "@testing-library/jest-dom": "^6.4.2",
57
57
  "@testing-library/react": "^14.0.0",
@@ -75,5 +75,5 @@
75
75
  "vitest-dom": "^0.1.1",
76
76
  "ws": "^8.13.0"
77
77
  },
78
- "gitHead": "943e035bbec27f9ecfe8ce8857955945f20976f3"
78
+ "gitHead": "a6eb64abf3632e116ad0b295a7f410270a1059d1"
79
79
  }
@@ -11,9 +11,11 @@ export const options = {
11
11
  // { target: 100, duration: '1s' },
12
12
  // { target: 100, duration: '58s' },
13
13
  // { target: 0, duration: '1s' },
14
+
15
+ // 10min
14
16
  { target: 100, duration: '30s' },
15
- { target: 200, duration: '1m' },
16
- { target: 200, duration: '1m' },
17
+ { target: 200, duration: '30s' },
18
+ { target: 200, duration: '3m' },
17
19
  { target: 100, duration: '30s' },
18
20
  { target: 0, duration: '30s' },
19
21
  ],
@@ -45,8 +47,6 @@ export default function () {
45
47
 
46
48
  check(resp, { 'status equals 200': (r) => r.status === 200 });
47
49
 
48
- sleep(1);
49
-
50
50
  params = {
51
51
  headers: {
52
52
  'Proxy-Connection': `keep-alive`,
@@ -66,8 +66,6 @@ export default function () {
66
66
 
67
67
  check(resp, { 'status equals 200': (r) => r.status === 200 });
68
68
 
69
- sleep(1);
70
-
71
69
  params = {
72
70
  headers: {
73
71
  'Proxy-Connection': `keep-alive`,
@@ -87,8 +85,6 @@ export default function () {
87
85
 
88
86
  check(resp, { 'status equals 200': (r) => r.status === 200 });
89
87
 
90
- sleep(1);
91
-
92
88
  params = {
93
89
  headers: {
94
90
  'Proxy-Connection': `keep-alive`,
@@ -127,8 +123,6 @@ export default function () {
127
123
 
128
124
  check(resp, { 'status equals 200': (r) => r.status === 200 });
129
125
 
130
- sleep(1);
131
-
132
126
  params = {
133
127
  headers: {
134
128
  'Proxy-Connection': `keep-alive`,
@@ -167,8 +161,6 @@ export default function () {
167
161
 
168
162
  check(resp, { 'status equals 200': (r) => r.status === 200 });
169
163
 
170
- sleep(1);
171
-
172
164
  params = {
173
165
  headers: {
174
166
  'Proxy-Connection': `keep-alive`,
@@ -190,8 +182,6 @@ export default function () {
190
182
 
191
183
  check(resp, { 'status equals 200': (r) => r.status === 200 });
192
184
 
193
- sleep(1);
194
-
195
185
  params = {
196
186
  headers: {
197
187
  'Proxy-Connection': `keep-alive`,
@@ -214,8 +204,6 @@ export default function () {
214
204
 
215
205
  check(resp, { 'status equals 200': (r) => r.status === 200 });
216
206
 
217
- sleep(1);
218
-
219
207
  token = resp.json('data.token');
220
208
 
221
209
  params = {
@@ -239,8 +227,6 @@ export default function () {
239
227
 
240
228
  check(resp, { 'status equals 200': (r) => r.status === 200 });
241
229
 
242
- sleep(1);
243
-
244
230
  params = {
245
231
  headers: {
246
232
  'Proxy-Connection': `keep-alive`,
@@ -262,8 +248,6 @@ export default function () {
262
248
 
263
249
  check(resp, { 'status equals 200': (r) => r.status === 200 });
264
250
 
265
- sleep(1);
266
-
267
251
  params = {
268
252
  headers: {
269
253
  'Proxy-Connection': `keep-alive`,
@@ -285,8 +269,6 @@ export default function () {
285
269
 
286
270
  check(resp, { 'status equals 200': (r) => r.status === 200 });
287
271
 
288
- sleep(1);
289
-
290
272
  params = {
291
273
  headers: {
292
274
  'Proxy-Connection': `keep-alive`,
@@ -308,8 +290,6 @@ export default function () {
308
290
 
309
291
  check(resp, { 'status equals 200': (r) => r.status === 200 });
310
292
 
311
- sleep(1);
312
-
313
293
  params = {
314
294
  headers: {
315
295
  'Proxy-Connection': `keep-alive`,
@@ -333,8 +313,6 @@ export default function () {
333
313
 
334
314
  check(resp, { 'status equals 200': (r) => r.status === 200 });
335
315
 
336
- sleep(1);
337
-
338
316
  params = {
339
317
  headers: {
340
318
  'Proxy-Connection': `keep-alive`,
@@ -356,8 +334,6 @@ export default function () {
356
334
 
357
335
  check(resp, { 'status equals 200': (r) => r.status === 200 });
358
336
 
359
- sleep(1);
360
-
361
337
  params = {
362
338
  headers: {
363
339
  'Proxy-Connection': `keep-alive`,
@@ -379,8 +355,6 @@ export default function () {
379
355
 
380
356
  check(resp, { 'status equals 200': (r) => r.status === 200 });
381
357
 
382
- sleep(1);
383
-
384
358
  params = {
385
359
  headers: {
386
360
  'Proxy-Connection': `keep-alive`,
@@ -403,8 +377,6 @@ export default function () {
403
377
 
404
378
  check(resp, { 'status equals 200': (r) => r.status === 200 });
405
379
 
406
- sleep(1);
407
-
408
380
  params = {
409
381
  headers: {
410
382
  'Proxy-Connection': `keep-alive`,
@@ -427,8 +399,6 @@ export default function () {
427
399
 
428
400
  check(resp, { 'status equals 200': (r) => r.status === 200 });
429
401
 
430
- sleep(1);
431
-
432
402
  params = {
433
403
  headers: {
434
404
  'Proxy-Connection': `keep-alive`,
@@ -451,8 +421,6 @@ export default function () {
451
421
 
452
422
  check(resp, { 'status equals 200': (r) => r.status === 200 });
453
423
 
454
- sleep(1);
455
-
456
424
  params = {
457
425
  headers: {
458
426
  'Proxy-Connection': `keep-alive`,
@@ -475,8 +443,6 @@ export default function () {
475
443
 
476
444
  check(resp, { 'status equals 200': (r) => r.status === 200 });
477
445
 
478
- sleep(1);
479
-
480
446
  params = {
481
447
  headers: {
482
448
  'Proxy-Connection': `keep-alive`,
@@ -499,8 +465,6 @@ export default function () {
499
465
 
500
466
  check(resp, { 'status equals 200': (r) => r.status === 200 });
501
467
 
502
- sleep(1);
503
-
504
468
  params = {
505
469
  headers: {
506
470
  'Proxy-Connection': `keep-alive`,
@@ -525,8 +489,6 @@ export default function () {
525
489
 
526
490
  check(resp, { 'status equals 200': (r) => r.status === 200 });
527
491
 
528
- sleep(1);
529
-
530
492
  params = {
531
493
  headers: {
532
494
  'Proxy-Connection': `keep-alive`,
@@ -549,8 +511,6 @@ export default function () {
549
511
 
550
512
  check(resp, { 'status equals 200': (r) => r.status === 200 });
551
513
 
552
- sleep(1);
553
-
554
514
  params = {
555
515
  headers: {
556
516
  'Proxy-Connection': `keep-alive`,
@@ -575,8 +535,6 @@ export default function () {
575
535
 
576
536
  check(resp, { 'status equals 200': (r) => r.status === 200 });
577
537
 
578
- sleep(1);
579
-
580
538
  params = {
581
539
  headers: {
582
540
  'Proxy-Connection': `keep-alive`,
@@ -599,8 +557,6 @@ export default function () {
599
557
 
600
558
  check(resp, { 'status equals 200': (r) => r.status === 200 });
601
559
 
602
- sleep(1);
603
-
604
560
  params = {
605
561
  headers: {
606
562
  'Proxy-Connection': `keep-alive`,
@@ -623,8 +579,6 @@ export default function () {
623
579
 
624
580
  check(resp, { 'status equals 200': (r) => r.status === 200 });
625
581
 
626
- sleep(1);
627
-
628
582
  params = {
629
583
  headers: {
630
584
  'Proxy-Connection': `keep-alive`,
@@ -647,8 +601,6 @@ export default function () {
647
601
 
648
602
  check(resp, { 'status equals 200': (r) => r.status === 200 });
649
603
 
650
- sleep(1);
651
-
652
604
  params = {
653
605
  headers: {
654
606
  'Proxy-Connection': `keep-alive`,
@@ -671,8 +623,6 @@ export default function () {
671
623
 
672
624
  check(resp, { 'status equals 200': (r) => r.status === 200 });
673
625
 
674
- sleep(1);
675
-
676
626
  params = {
677
627
  headers: {
678
628
  'Proxy-Connection': `keep-alive`,
@@ -792,8 +742,6 @@ export default function () {
792
742
 
793
743
  check(resp, { 'status equals 200': (r) => r.status === 200 });
794
744
 
795
- sleep(1);
796
-
797
745
  params = {
798
746
  headers: {
799
747
  'Proxy-Connection': `keep-alive`,
@@ -815,9 +763,7 @@ export default function () {
815
763
  resp = http.request('GET', url, null, params);
816
764
 
817
765
  check(resp, { 'status equals 200': (r) => r.status === 200 });
818
-
819
- sleep(1);
820
766
  });
821
767
 
822
- // sleep(1);
768
+ sleep(1);
823
769
  }
@@ -0,0 +1,74 @@
1
+ // __benchmarks__/k6/write-single.js
2
+ import http from 'k6/http';
3
+ import { check, sleep } from 'k6';
4
+
5
+ // export { setup } from './setup.js';
6
+
7
+ export const options = {
8
+ stages: [
9
+ { duration: '1s', target: 100 },
10
+ { duration: '59s', target: 100 },
11
+ ],
12
+ thresholds: {
13
+ http_req_duration: ['p(95)<500'], // 95% 请求 < 500ms
14
+ http_req_failed: ['rate<0.01'], // 失败率 < 1%
15
+ },
16
+ };
17
+
18
+ export default function () {
19
+ const url = `${__ENV.TARGET_ORIGIN}/posts`;
20
+ const params = {
21
+ headers: {
22
+ 'Content-Type': 'application/json',
23
+ // Authorization: `Bearer ${token}`,
24
+ // 'X-Role': 'admin',
25
+ },
26
+ };
27
+ const payload = JSON.stringify({
28
+ title: `Title ${__VU}-${__ITER} ${Math.random().toString(36)}`,
29
+ content: 'Some content',
30
+ categoryId: 1,
31
+ tags: [1, 2],
32
+ publishedAt: new Date().toISOString(),
33
+ status: 'published',
34
+ allowComments: true,
35
+ featured: false,
36
+ viewCount: Math.floor(Math.random() * 1000),
37
+ excerpt: 'This is a short excerpt of the post.',
38
+ musicUrl: 'https://example.com/music.mp3',
39
+ coverImage: 'https://example.com/cover.jpg',
40
+ slug: `title-${__VU}-${__ITER}-${Math.random().toString(36)}`,
41
+ read: 1,
42
+ score: 4.5,
43
+ });
44
+
45
+ const res = http.post(url, payload, params);
46
+
47
+ check(res, {
48
+ 'status is 201': (r) => {
49
+ if (r.status !== 201) {
50
+ console.log('status:', r.status);
51
+ }
52
+ return r.status === 201;
53
+ },
54
+ });
55
+ }
56
+
57
+ // export function teardown({ token }) {
58
+ // const url = `${__ENV.TARGET_ORIGIN}/api/posts:destroy`;
59
+ // const params = {
60
+ // headers: {
61
+ // 'Content-Type': 'application/json',
62
+ // Authorization: `Bearer ${token}`,
63
+ // },
64
+ // queries: {
65
+ // filter: JSON.stringify({ id: { $gt: 1000000 } }),
66
+ // },
67
+ // };
68
+
69
+ // let res = http.delete(url, params);
70
+
71
+ // check(res, {
72
+ // 'status is 200': (r) => r.status === 200,
73
+ // });
74
+ // }
@@ -0,0 +1,41 @@
1
+ // __benchmarks__/k6/write-single.js
2
+ import http from 'k6/http';
3
+ import { check, sleep } from 'k6';
4
+
5
+ import { uid } from '../../utils.js';
6
+ // export { setup } from './setup.js';
7
+
8
+ export const options = {
9
+ stages: [
10
+ // { duration: '1s', target: 1 },
11
+ { duration: '1s', target: 100 },
12
+ { duration: '59s', target: 100 },
13
+ ],
14
+ thresholds: {
15
+ http_req_duration: ['p(95)<400'], // 95% 请求 < 400ms
16
+ http_req_failed: ['rate<0.01'], // 失败率 < 1%
17
+ },
18
+ };
19
+
20
+ export default function () {
21
+ const keyword = uid(2);
22
+ const url = `${__ENV.TARGET_ORIGIN}/posts?filter=${JSON.stringify({
23
+ title: { $iLike: `${keyword}%` },
24
+ })}&sort=-createdAt&pageSize=50&page=${Math.floor(Math.random() * 200) + 1}&appends[]=category&appends[]=tags`;
25
+ const params = {
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ },
29
+ };
30
+
31
+ const res = http.get(url, params);
32
+
33
+ check(res, {
34
+ 'status is 200': (r) => r.status === 200,
35
+ 'has data': (r) => {
36
+ return r.json().length > 1;
37
+ },
38
+ });
39
+
40
+ sleep(1);
41
+ }
@@ -0,0 +1,40 @@
1
+ // __benchmarks__/k6/write-single.js
2
+ import http from 'k6/http';
3
+ import { check, sleep } from 'k6';
4
+
5
+ import { uid } from '../../utils.js';
6
+ // export { setup } from './setup.js';
7
+
8
+ export const options = {
9
+ stages: [
10
+ { duration: '1s', target: 100 },
11
+ { duration: '59s', target: 100 },
12
+ ],
13
+ thresholds: {
14
+ http_req_duration: ['p(95)<500'], // 95% 请求 < 200ms
15
+ http_req_failed: ['rate<0.01'], // 失败率 < 1%
16
+ },
17
+ };
18
+
19
+ export default function () {
20
+ const keyword = uid(2);
21
+ const url = `${__ENV.TARGET_ORIGIN}/posts`;
22
+ const params = {
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ },
26
+ queries: {
27
+ filter: JSON.stringify({ title: { $iLike: keyword } }),
28
+ sort: '-createdAt',
29
+ pageSize: 50,
30
+ },
31
+ };
32
+
33
+ const res = http.get(url, params);
34
+
35
+ check(res, {
36
+ 'status is 200': (r) => r.status === 200,
37
+ });
38
+
39
+ // sleep(1);
40
+ }
package/vitest.mjs CHANGED
@@ -9,7 +9,7 @@ import { mergeConfig, defineConfig as vitestConfig } from 'vitest/config';
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
11
 
12
- const CORE_CLIENT_PACKAGES = ['sdk', 'client', 'flow-engine'];
12
+ const CORE_CLIENT_PACKAGES = ['sdk', 'client', 'client-v2', 'flow-engine'];
13
13
 
14
14
  const relativePathToAbsolute = (relativePath) => {
15
15
  return path.resolve(process.cwd(), relativePath);