@pikku/redis 0.12.19 → 0.12.21
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/CHANGELOG.md +52 -0
- package/dist/src/redis-agent-run-service.js.map +1 -1
- package/dist/src/redis-deployment-service.js.map +1 -1
- package/dist/src/redis-secret-service.js +1 -1
- package/dist/src/redis-secret-service.js.map +1 -1
- package/dist/src/redis-workflow-run-service.js.map +1 -1
- package/dist/src/redis-workflow-service.js.map +1 -1
- package/package.json +10 -6
- package/run-tests.sh +59 -24
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/index.ts +0 -10
- package/src/redis-agent-run-service.ts +0 -207
- package/src/redis-channel-store.ts +0 -158
- package/src/redis-deployment-service.ts +0 -171
- package/src/redis-eventhub-store.ts +0 -104
- package/src/redis-secret-service.test.ts +0 -122
- package/src/redis-secret-service.ts +0 -210
- package/src/redis-session-store.ts +0 -71
- package/src/redis-workflow-run-service.ts +0 -231
- package/src/redis-workflow-service.test.ts +0 -115
- package/src/redis-workflow-service.ts +0 -1025
- package/tsconfig.json +0 -17
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, test, beforeEach, afterEach } from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import Redis from 'ioredis-mock'
|
|
4
|
-
|
|
5
|
-
import { RedisWorkflowService } from './redis-workflow-service.js'
|
|
6
|
-
|
|
7
|
-
const KEY_PREFIX = 'workflows'
|
|
8
|
-
|
|
9
|
-
let ws: RedisWorkflowService
|
|
10
|
-
let redis: any
|
|
11
|
-
|
|
12
|
-
const newRun = () =>
|
|
13
|
-
ws.createRun('flow', {}, false, 'hash', { type: 'test' } as any)
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
redis = new Redis()
|
|
17
|
-
ws = new RedisWorkflowService(redis, KEY_PREFIX)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
afterEach(() => {
|
|
21
|
-
redis.disconnect()
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
describe('workflow run state in redis', () => {
|
|
25
|
-
test('two branches setting different keys both survive', async () => {
|
|
26
|
-
const runId = await newRun()
|
|
27
|
-
|
|
28
|
-
await Promise.all([
|
|
29
|
-
ws.updateRunState(runId, 'left', 'a'),
|
|
30
|
-
ws.updateRunState(runId, 'right', 'b'),
|
|
31
|
-
])
|
|
32
|
-
|
|
33
|
-
assert.deepEqual(
|
|
34
|
-
await ws.getRunState(runId),
|
|
35
|
-
{ left: 'a', right: 'b' },
|
|
36
|
-
'a parallel branch overwrote the other branch’s state'
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test('many concurrent writers all land', async () => {
|
|
41
|
-
const runId = await newRun()
|
|
42
|
-
const keys = Array.from({ length: 20 }, (_, i) => `k${i}`)
|
|
43
|
-
|
|
44
|
-
await Promise.all(keys.map((k, i) => ws.updateRunState(runId, k, i)))
|
|
45
|
-
|
|
46
|
-
const state = await ws.getRunState(runId)
|
|
47
|
-
assert.equal(Object.keys(state).length, keys.length)
|
|
48
|
-
keys.forEach((k, i) => assert.equal(state[k], i))
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test('an empty array stays an array when another key is written', async () => {
|
|
52
|
-
const runId = await newRun()
|
|
53
|
-
|
|
54
|
-
await ws.updateRunState(runId, 'items', [])
|
|
55
|
-
await ws.updateRunState(runId, 'count', 0)
|
|
56
|
-
|
|
57
|
-
const state = await ws.getRunState(runId)
|
|
58
|
-
assert.ok(
|
|
59
|
-
Array.isArray(state.items),
|
|
60
|
-
`an empty array came back as ${JSON.stringify(state.items)}`
|
|
61
|
-
)
|
|
62
|
-
assert.equal(state.count, 0)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('values keep their types, including null and nested objects', async () => {
|
|
66
|
-
const runId = await newRun()
|
|
67
|
-
|
|
68
|
-
await ws.updateRunState(runId, 'nothing', null)
|
|
69
|
-
await ws.updateRunState(runId, 'nested', { a: [1, { b: true }] })
|
|
70
|
-
await ws.updateRunState(runId, 'flag', false)
|
|
71
|
-
|
|
72
|
-
assert.deepEqual(await ws.getRunState(runId), {
|
|
73
|
-
nothing: null,
|
|
74
|
-
nested: { a: [1, { b: true }] },
|
|
75
|
-
flag: false,
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test('a later write to the same key replaces it', async () => {
|
|
80
|
-
const runId = await newRun()
|
|
81
|
-
|
|
82
|
-
await ws.updateRunState(runId, 'attempt', 1)
|
|
83
|
-
await ws.updateRunState(runId, 'attempt', 2)
|
|
84
|
-
|
|
85
|
-
assert.deepEqual(await ws.getRunState(runId), { attempt: 2 })
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('the state of a run that has none is empty', async () => {
|
|
89
|
-
assert.deepEqual(await ws.getRunState(await newRun()), {})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test('state written before the per-key layout is still readable', async () => {
|
|
93
|
-
const runId = await newRun()
|
|
94
|
-
const redis = (ws as any).redis
|
|
95
|
-
await redis.hset(
|
|
96
|
-
(ws as any).runKey(runId),
|
|
97
|
-
'state',
|
|
98
|
-
JSON.stringify({ legacy: 'kept', shared: 'old' })
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
assert.deepEqual(await ws.getRunState(runId), {
|
|
102
|
-
legacy: 'kept',
|
|
103
|
-
shared: 'old',
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
await ws.updateRunState(runId, 'shared', 'new')
|
|
107
|
-
await ws.updateRunState(runId, 'fresh', 1)
|
|
108
|
-
|
|
109
|
-
assert.deepEqual(
|
|
110
|
-
await ws.getRunState(runId),
|
|
111
|
-
{ legacy: 'kept', shared: 'new', fresh: 1 },
|
|
112
|
-
'a run in flight across the deploy lost the state it already had'
|
|
113
|
-
)
|
|
114
|
-
})
|
|
115
|
-
})
|