teraslice 3.3.0 → 3.3.2
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/LICENSE +202 -0
- package/package.json +25 -28
- package/dist/src/interfaces.js +0 -12
- package/dist/src/lib/cluster/cluster_master.js +0 -246
- package/dist/src/lib/cluster/node_master.js +0 -355
- package/dist/src/lib/cluster/services/api.js +0 -663
- package/dist/src/lib/cluster/services/assets.js +0 -224
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/index.js +0 -192
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/interfaces.js +0 -2
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8s.js +0 -419
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sDeploymentResource.js +0 -60
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sJobResource.js +0 -55
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sResource.js +0 -357
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sServiceResource.js +0 -37
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sState.js +0 -60
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/utils.js +0 -170
- package/dist/src/lib/cluster/services/cluster/backends/native/dispatch.js +0 -13
- package/dist/src/lib/cluster/services/cluster/backends/native/index.js +0 -526
- package/dist/src/lib/cluster/services/cluster/backends/native/messaging.js +0 -548
- package/dist/src/lib/cluster/services/cluster/backends/state-utils.js +0 -26
- package/dist/src/lib/cluster/services/cluster/index.js +0 -13
- package/dist/src/lib/cluster/services/execution.js +0 -435
- package/dist/src/lib/cluster/services/index.js +0 -6
- package/dist/src/lib/cluster/services/interfaces.js +0 -2
- package/dist/src/lib/cluster/services/jobs.js +0 -458
- package/dist/src/lib/config/default-sysconfig.js +0 -25
- package/dist/src/lib/config/index.js +0 -20
- package/dist/src/lib/config/schemas/system.js +0 -360
- package/dist/src/lib/storage/analytics.js +0 -86
- package/dist/src/lib/storage/assets.js +0 -401
- package/dist/src/lib/storage/backends/elasticsearch_store.js +0 -496
- package/dist/src/lib/storage/backends/mappings/analytics.js +0 -20
- package/dist/src/lib/storage/backends/mappings/asset.js +0 -32
- package/dist/src/lib/storage/backends/mappings/ex.js +0 -53
- package/dist/src/lib/storage/backends/mappings/job.js +0 -42
- package/dist/src/lib/storage/backends/mappings/state.js +0 -16
- package/dist/src/lib/storage/backends/s3_store.js +0 -237
- package/dist/src/lib/storage/execution.js +0 -302
- package/dist/src/lib/storage/index.js +0 -7
- package/dist/src/lib/storage/jobs.js +0 -81
- package/dist/src/lib/storage/state.js +0 -254
- package/dist/src/lib/utils/api_utils.js +0 -128
- package/dist/src/lib/utils/asset_utils.js +0 -94
- package/dist/src/lib/utils/date_utils.js +0 -52
- package/dist/src/lib/utils/encoding_utils.js +0 -27
- package/dist/src/lib/utils/events.js +0 -4
- package/dist/src/lib/utils/file_utils.js +0 -124
- package/dist/src/lib/utils/id_utils.js +0 -15
- package/dist/src/lib/utils/port_utils.js +0 -32
- package/dist/src/lib/workers/assets/index.js +0 -3
- package/dist/src/lib/workers/assets/loader-executable.js +0 -40
- package/dist/src/lib/workers/assets/loader.js +0 -73
- package/dist/src/lib/workers/assets/spawn.js +0 -55
- package/dist/src/lib/workers/context/execution-context.js +0 -12
- package/dist/src/lib/workers/context/terafoundation-context.js +0 -8
- package/dist/src/lib/workers/execution-controller/execution-analytics.js +0 -188
- package/dist/src/lib/workers/execution-controller/index.js +0 -1024
- package/dist/src/lib/workers/execution-controller/recovery.js +0 -151
- package/dist/src/lib/workers/execution-controller/scheduler.js +0 -390
- package/dist/src/lib/workers/execution-controller/slice-analytics.js +0 -96
- package/dist/src/lib/workers/helpers/job.js +0 -80
- package/dist/src/lib/workers/helpers/op-analytics.js +0 -22
- package/dist/src/lib/workers/helpers/terafoundation.js +0 -34
- package/dist/src/lib/workers/helpers/worker-shutdown.js +0 -147
- package/dist/src/lib/workers/metrics/index.js +0 -108
- package/dist/src/lib/workers/worker/index.js +0 -378
- package/dist/src/lib/workers/worker/slice.js +0 -122
- package/dist/test/config/schemas/system_schema-spec.js +0 -26
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8s-v2-spec.js +0 -458
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sResource-v2-spec.js +0 -818
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sState-multicluster-v2-spec.js +0 -67
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sState-v2-spec.js +0 -84
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/utils-v2-spec.js +0 -320
- package/dist/test/lib/cluster/services/cluster/backends/state-utils-spec.js +0 -37
- package/dist/test/node_master-spec.js +0 -194
- package/dist/test/services/api-spec.js +0 -79
- package/dist/test/services/assets-spec.js +0 -158
- package/dist/test/services/messaging-spec.js +0 -440
- package/dist/test/storage/assets_storage-spec.js +0 -95
- package/dist/test/storage/s3_store-spec.js +0 -149
- package/dist/test/test.config.js +0 -23
- package/dist/test/test.setup.js +0 -6
- package/dist/test/utils/api_utils-spec.js +0 -25
- package/dist/test/utils/asset_utils-spec.js +0 -141
- package/dist/test/utils/elastic_utils-spec.js +0 -25
- package/dist/test/workers/execution-controller/execution-controller-spec.js +0 -371
- package/dist/test/workers/execution-controller/execution-special-test-cases-spec.js +0 -519
- package/dist/test/workers/execution-controller/execution-test-cases-spec.js +0 -343
- package/dist/test/workers/execution-controller/recovery-spec.js +0 -160
- package/dist/test/workers/execution-controller/scheduler-spec.js +0 -249
- package/dist/test/workers/execution-controller/slice-analytics-spec.js +0 -121
- package/dist/test/workers/fixtures/ops/example-op/processor.js +0 -20
- package/dist/test/workers/fixtures/ops/example-op/schema.js +0 -19
- package/dist/test/workers/fixtures/ops/example-reader/fetcher.js +0 -20
- package/dist/test/workers/fixtures/ops/example-reader/schema.js +0 -41
- package/dist/test/workers/fixtures/ops/example-reader/slicer.js +0 -37
- package/dist/test/workers/fixtures/ops/new-op/processor.js +0 -29
- package/dist/test/workers/fixtures/ops/new-op/schema.js +0 -18
- package/dist/test/workers/fixtures/ops/new-reader/fetcher.js +0 -19
- package/dist/test/workers/fixtures/ops/new-reader/schema.js +0 -23
- package/dist/test/workers/fixtures/ops/new-reader/slicer.js +0 -13
- package/dist/test/workers/helpers/configs.js +0 -128
- package/dist/test/workers/helpers/execution-controller-helper.js +0 -49
- package/dist/test/workers/helpers/index.js +0 -5
- package/dist/test/workers/helpers/test-context.js +0 -210
- package/dist/test/workers/helpers/zip-directory.js +0 -25
- package/dist/test/workers/worker/slice-spec.js +0 -333
- package/dist/test/workers/worker/worker-spec.js +0 -356
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { pDelay, times, random } from '@terascope/core-utils';
|
|
3
|
-
import { RecoveryCleanupType } from '@terascope/job-components';
|
|
4
|
-
import { ExecutionController as ExController } from '@terascope/teraslice-messaging';
|
|
5
|
-
import { TestContext } from '../helpers/index.js';
|
|
6
|
-
import { makeShutdownEarlyFn, getTestCases } from '../helpers/execution-controller-helper.js';
|
|
7
|
-
import { ExecutionController } from '../../../src/lib/workers/execution-controller/index.js';
|
|
8
|
-
import { findPort } from '../../../src/lib/utils/port_utils.js';
|
|
9
|
-
import { newId } from '../../../src/lib/utils/id_utils.js';
|
|
10
|
-
const ExecutionControllerClient = ExController.Client;
|
|
11
|
-
describe('ExecutionController Special Tests', () => {
|
|
12
|
-
// [ message, config ]
|
|
13
|
-
const testCases = [
|
|
14
|
-
[
|
|
15
|
-
'when recovering a slicer no cleanup type',
|
|
16
|
-
{
|
|
17
|
-
slicerResults: [
|
|
18
|
-
{ example: 'slice-recovery-after' },
|
|
19
|
-
{ example: 'slice-recovery-after' },
|
|
20
|
-
null
|
|
21
|
-
],
|
|
22
|
-
isRecovery: true,
|
|
23
|
-
recoverySlices: [
|
|
24
|
-
{
|
|
25
|
-
state: 'start',
|
|
26
|
-
slice: {
|
|
27
|
-
slice_id: uuidv4(),
|
|
28
|
-
request: {
|
|
29
|
-
example: 'slice-recovery'
|
|
30
|
-
},
|
|
31
|
-
slicer_id: 0,
|
|
32
|
-
slicer_order: 0,
|
|
33
|
-
_created: new Date().toISOString()
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
state: 'start',
|
|
38
|
-
slice: {
|
|
39
|
-
slice_id: uuidv4(),
|
|
40
|
-
request: {
|
|
41
|
-
example: 'slice-recovery'
|
|
42
|
-
},
|
|
43
|
-
slicer_id: 0,
|
|
44
|
-
slicer_order: 1,
|
|
45
|
-
_created: new Date().toISOString()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
processedSliceCount: 4,
|
|
50
|
-
incompleteSliceCount: 0,
|
|
51
|
-
completedSliceCount: 4,
|
|
52
|
-
analytics: true
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
'when recovering with no slices to recover',
|
|
57
|
-
{
|
|
58
|
-
slicerResults: [
|
|
59
|
-
{ example: 'slice-recovery-no-slices-after' },
|
|
60
|
-
{ example: 'slice-recovery-no-slices-after' },
|
|
61
|
-
null
|
|
62
|
-
],
|
|
63
|
-
isRecovery: true,
|
|
64
|
-
recoverySlices: [],
|
|
65
|
-
incompleteSliceCount: 0,
|
|
66
|
-
completedSliceCount: 2,
|
|
67
|
-
processedSliceCount: 2,
|
|
68
|
-
analytics: true
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
[
|
|
72
|
-
'when recovering a slicer with a cleanup type of errors',
|
|
73
|
-
{
|
|
74
|
-
slicerResults: [
|
|
75
|
-
{ example: 'slice-recovery-error-after' },
|
|
76
|
-
null
|
|
77
|
-
],
|
|
78
|
-
isRecovery: true,
|
|
79
|
-
cleanupType: RecoveryCleanupType.errors,
|
|
80
|
-
recoverySlices: [
|
|
81
|
-
{
|
|
82
|
-
state: 'completed',
|
|
83
|
-
slice: {
|
|
84
|
-
slice_id: uuidv4(),
|
|
85
|
-
request: {
|
|
86
|
-
example: 'slice-recovery-error-completed'
|
|
87
|
-
},
|
|
88
|
-
slicer_id: 0,
|
|
89
|
-
slicer_order: 0,
|
|
90
|
-
_created: new Date().toISOString()
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
state: 'start',
|
|
95
|
-
slice: {
|
|
96
|
-
slice_id: uuidv4(),
|
|
97
|
-
request: {
|
|
98
|
-
example: 'slice-recovery-error-start'
|
|
99
|
-
},
|
|
100
|
-
slicer_id: 0,
|
|
101
|
-
slicer_order: 1,
|
|
102
|
-
_created: new Date().toISOString()
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
state: 'error',
|
|
107
|
-
slice: {
|
|
108
|
-
slice_id: uuidv4(),
|
|
109
|
-
request: {
|
|
110
|
-
example: 'slice-recovery-error'
|
|
111
|
-
},
|
|
112
|
-
slicer_id: 0,
|
|
113
|
-
slicer_order: 2,
|
|
114
|
-
_created: new Date().toISOString()
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
incompleteSliceCount: 1,
|
|
119
|
-
completedSliceCount: 2,
|
|
120
|
-
processedSliceCount: 1,
|
|
121
|
-
analytics: false
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
[
|
|
125
|
-
'when recovering a slicer with a cleanup type of all',
|
|
126
|
-
{
|
|
127
|
-
slicerResults: [
|
|
128
|
-
{ example: 'slice-recovery-all-after' },
|
|
129
|
-
null
|
|
130
|
-
],
|
|
131
|
-
isRecovery: true,
|
|
132
|
-
cleanupType: RecoveryCleanupType.all,
|
|
133
|
-
recoverySlices: [
|
|
134
|
-
{
|
|
135
|
-
state: 'error',
|
|
136
|
-
slice: {
|
|
137
|
-
slice_id: uuidv4(),
|
|
138
|
-
request: {
|
|
139
|
-
example: 'slice-recovery-all'
|
|
140
|
-
},
|
|
141
|
-
slicer_id: 0,
|
|
142
|
-
slicer_order: 0,
|
|
143
|
-
_created: new Date().toISOString()
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
state: 'start',
|
|
148
|
-
slice: {
|
|
149
|
-
slice_id: uuidv4(),
|
|
150
|
-
request: {
|
|
151
|
-
example: 'slice-recovery-all'
|
|
152
|
-
},
|
|
153
|
-
slicer_id: 0,
|
|
154
|
-
slicer_order: 1,
|
|
155
|
-
_created: new Date().toISOString()
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
processedSliceCount: 2,
|
|
160
|
-
incompleteSliceCount: 0,
|
|
161
|
-
completedSliceCount: 2,
|
|
162
|
-
analytics: true
|
|
163
|
-
}
|
|
164
|
-
],
|
|
165
|
-
[
|
|
166
|
-
'when recovering a slicer with a cleanup type of pending',
|
|
167
|
-
{
|
|
168
|
-
slicerResults: [
|
|
169
|
-
{ example: 'slice-recovery-pending-after' },
|
|
170
|
-
null
|
|
171
|
-
],
|
|
172
|
-
isRecovery: true,
|
|
173
|
-
cleanupType: RecoveryCleanupType.pending,
|
|
174
|
-
recoverySlices: [
|
|
175
|
-
{
|
|
176
|
-
state: 'completed',
|
|
177
|
-
slice: {
|
|
178
|
-
slice_id: uuidv4(),
|
|
179
|
-
request: {
|
|
180
|
-
example: 'slice-recovery-pending-completed'
|
|
181
|
-
},
|
|
182
|
-
slicer_id: 0,
|
|
183
|
-
slicer_order: 0,
|
|
184
|
-
_created: new Date().toISOString()
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
state: 'start',
|
|
189
|
-
slice: {
|
|
190
|
-
slice_id: uuidv4(),
|
|
191
|
-
request: {
|
|
192
|
-
example: 'slice-recovery-pending-start'
|
|
193
|
-
},
|
|
194
|
-
slicer_id: 0,
|
|
195
|
-
slicer_order: 1,
|
|
196
|
-
_created: new Date().toISOString()
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
state: 'pending',
|
|
201
|
-
slice: {
|
|
202
|
-
slice_id: uuidv4(),
|
|
203
|
-
request: {
|
|
204
|
-
example: 'slice-recovery-pending'
|
|
205
|
-
},
|
|
206
|
-
slicer_id: 0,
|
|
207
|
-
slicer_order: 2,
|
|
208
|
-
_created: new Date().toISOString()
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
state: 'pending',
|
|
213
|
-
slice: {
|
|
214
|
-
slice_id: uuidv4(),
|
|
215
|
-
request: {
|
|
216
|
-
example: 'slice-recovery-pending'
|
|
217
|
-
},
|
|
218
|
-
slicer_id: 0,
|
|
219
|
-
slicer_order: 3,
|
|
220
|
-
_created: new Date().toISOString()
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
],
|
|
224
|
-
incompleteSliceCount: 1,
|
|
225
|
-
completedSliceCount: 3,
|
|
226
|
-
processedSliceCount: 2,
|
|
227
|
-
analytics: false
|
|
228
|
-
}
|
|
229
|
-
],
|
|
230
|
-
[
|
|
231
|
-
'when autorecovering a slicer with a cleanup type of pending',
|
|
232
|
-
{
|
|
233
|
-
slicerResults: [
|
|
234
|
-
{ example: 'slice-autorecover-pending-after-1' },
|
|
235
|
-
{ example: 'slice-autorecover-pending-after-2' },
|
|
236
|
-
{ example: 'slice-autorecover-pending-after-3' },
|
|
237
|
-
null
|
|
238
|
-
],
|
|
239
|
-
autorecover: true,
|
|
240
|
-
isRecovery: true,
|
|
241
|
-
recoverySlices: [
|
|
242
|
-
{
|
|
243
|
-
state: 'completed',
|
|
244
|
-
slice: {
|
|
245
|
-
slice_id: uuidv4(),
|
|
246
|
-
request: {
|
|
247
|
-
example: 'slice-autorecover-pending-completed'
|
|
248
|
-
},
|
|
249
|
-
slicer_id: 0,
|
|
250
|
-
slicer_order: 0,
|
|
251
|
-
_created: new Date().toISOString()
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
state: 'start',
|
|
256
|
-
slice: {
|
|
257
|
-
slice_id: uuidv4(),
|
|
258
|
-
request: {
|
|
259
|
-
example: 'slice-autorecover-pending-start'
|
|
260
|
-
},
|
|
261
|
-
slicer_id: 0,
|
|
262
|
-
slicer_order: 1,
|
|
263
|
-
_created: new Date().toISOString()
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
state: 'pending',
|
|
268
|
-
slice: {
|
|
269
|
-
slice_id: uuidv4(),
|
|
270
|
-
request: {
|
|
271
|
-
example: 'slice-autorecover-pending'
|
|
272
|
-
},
|
|
273
|
-
slicer_id: 0,
|
|
274
|
-
slicer_order: 2,
|
|
275
|
-
_created: new Date().toISOString()
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
state: 'pending',
|
|
280
|
-
slice: {
|
|
281
|
-
slice_id: uuidv4(),
|
|
282
|
-
request: {
|
|
283
|
-
example: 'slice-autorecover-pending'
|
|
284
|
-
},
|
|
285
|
-
slicer_id: 0,
|
|
286
|
-
slicer_order: 3,
|
|
287
|
-
_created: new Date().toISOString()
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
incompleteSliceCount: 1,
|
|
292
|
-
completedSliceCount: 6,
|
|
293
|
-
processedSliceCount: 5,
|
|
294
|
-
analytics: false
|
|
295
|
-
}
|
|
296
|
-
],
|
|
297
|
-
[
|
|
298
|
-
'when processing slices and the execution gets shutdown early',
|
|
299
|
-
{
|
|
300
|
-
slicerResults: [
|
|
301
|
-
{ example: 'slice-shutdown-early' },
|
|
302
|
-
{ example: 'slice-shutdown-early' },
|
|
303
|
-
{ example: 'slice-shutdown-early' },
|
|
304
|
-
{ example: 'slice-shutdown-early' }
|
|
305
|
-
],
|
|
306
|
-
lifecycle: 'persistent',
|
|
307
|
-
shutdownTimeout: 2000,
|
|
308
|
-
shutdownEarly: true,
|
|
309
|
-
incompleteSliceCount: 1,
|
|
310
|
-
completedSliceCount: 1,
|
|
311
|
-
processedSliceCount: 1,
|
|
312
|
-
analytics: false
|
|
313
|
-
}
|
|
314
|
-
]
|
|
315
|
-
];
|
|
316
|
-
// for testing add a "only" property to the test cases you want
|
|
317
|
-
// or add a skip property to the test cases you don't want
|
|
318
|
-
describe.each(getTestCases(testCases))('%s', (m, options) => {
|
|
319
|
-
const { slicerResults, slicerQueueLength, incompleteSliceCount = 0, completedSliceCount = 0, processedSliceCount = 0, lifecycle = 'once', reconnect = false, analytics = false, workers = 1, lastStatus, shutdownTimeout = 4000, shutdownEarly = false, cleanupType, isRecovery = false, autorecover = false, recoverySlices = [] } = options;
|
|
320
|
-
let exController;
|
|
321
|
-
let testContext;
|
|
322
|
-
let slices;
|
|
323
|
-
let exStore;
|
|
324
|
-
let stateStore;
|
|
325
|
-
let shutdownEarlyFn;
|
|
326
|
-
let executionRecord;
|
|
327
|
-
beforeAll(async () => {
|
|
328
|
-
slices = [];
|
|
329
|
-
const port = await findPort();
|
|
330
|
-
testContext = new TestContext({
|
|
331
|
-
assignment: 'execution_controller',
|
|
332
|
-
slicerPort: port,
|
|
333
|
-
slicerQueueLength,
|
|
334
|
-
slicerResults,
|
|
335
|
-
shutdownTimeout,
|
|
336
|
-
timeout: reconnect ? 5000 : 3000,
|
|
337
|
-
lifecycle,
|
|
338
|
-
workers,
|
|
339
|
-
autorecover,
|
|
340
|
-
analytics
|
|
341
|
-
});
|
|
342
|
-
// needs to be in this order
|
|
343
|
-
await testContext.initialize(true, {
|
|
344
|
-
isRecovery,
|
|
345
|
-
cleanupType,
|
|
346
|
-
lastStatus,
|
|
347
|
-
recoverySlices
|
|
348
|
-
});
|
|
349
|
-
await testContext.addClusterMaster();
|
|
350
|
-
const { clusterMaster, exId } = testContext;
|
|
351
|
-
stateStore = await testContext.addStateStore();
|
|
352
|
-
exStore = await testContext.addExStore();
|
|
353
|
-
if (shutdownEarly) {
|
|
354
|
-
// @ts-expect-error TODO fix this
|
|
355
|
-
testContext.executionContext.slicer().maxQueueLength = () => 1;
|
|
356
|
-
}
|
|
357
|
-
exController = new ExecutionController(testContext.context, testContext.executionContext);
|
|
358
|
-
const { network_latency_buffer: networkLatencyBuffer, action_timeout: actionTimeout } = testContext.context.sysconfig.teraslice;
|
|
359
|
-
testContext.attachCleanup(() => exController.shutdown());
|
|
360
|
-
const opCount = testContext.executionContext.config.operations.length;
|
|
361
|
-
await exController.initialize();
|
|
362
|
-
const socketOptions = reconnect
|
|
363
|
-
? {
|
|
364
|
-
reconnection: true,
|
|
365
|
-
reconnectionAttempts: 10,
|
|
366
|
-
reconnectionDelay: 500,
|
|
367
|
-
reconnectionDelayMax: 500
|
|
368
|
-
}
|
|
369
|
-
: {
|
|
370
|
-
reconnection: false
|
|
371
|
-
};
|
|
372
|
-
let firedReconnect = false;
|
|
373
|
-
shutdownEarlyFn = makeShutdownEarlyFn({
|
|
374
|
-
enabled: shutdownEarly,
|
|
375
|
-
exController
|
|
376
|
-
});
|
|
377
|
-
const workerClients = [];
|
|
378
|
-
clusterMaster.onExecutionFinished(() => {
|
|
379
|
-
workerClients.forEach((workerClient) => {
|
|
380
|
-
workerClient.shutdown();
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
async function startWorker() {
|
|
384
|
-
const workerId = newId('worker');
|
|
385
|
-
const workerClient = new ExecutionControllerClient({
|
|
386
|
-
executionControllerUrl: `http://localhost:${port}`,
|
|
387
|
-
workerId,
|
|
388
|
-
networkLatencyBuffer,
|
|
389
|
-
workerDisconnectTimeout: 5000,
|
|
390
|
-
actionTimeout,
|
|
391
|
-
connectTimeout: 1000,
|
|
392
|
-
socketOptions
|
|
393
|
-
});
|
|
394
|
-
workerClients.push(workerClient);
|
|
395
|
-
testContext.attachCleanup(() => workerClient.shutdown());
|
|
396
|
-
await workerClient.start();
|
|
397
|
-
async function waitForReconnect() {
|
|
398
|
-
if (!reconnect)
|
|
399
|
-
return;
|
|
400
|
-
if (firedReconnect)
|
|
401
|
-
return;
|
|
402
|
-
firedReconnect = true;
|
|
403
|
-
await Promise.all([
|
|
404
|
-
workerClient.forceReconnect(),
|
|
405
|
-
exController.server.waitForClientReady(workerId)
|
|
406
|
-
]);
|
|
407
|
-
}
|
|
408
|
-
const isDone = () => exController.isExecutionDone;
|
|
409
|
-
async function processWork() {
|
|
410
|
-
if (isDone())
|
|
411
|
-
return;
|
|
412
|
-
const slice = await workerClient.waitForSlice(isDone);
|
|
413
|
-
if (!slice)
|
|
414
|
-
return;
|
|
415
|
-
slices.push(slice);
|
|
416
|
-
const msg = { slice };
|
|
417
|
-
if (analytics) {
|
|
418
|
-
msg.analytics = {
|
|
419
|
-
time: times(opCount, () => random(0, 2000)),
|
|
420
|
-
size: times(opCount, () => random(0, 100)),
|
|
421
|
-
memory: times(opCount, () => random(0, 10000))
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
// add a natural delay for completing a slice
|
|
425
|
-
await pDelay(100);
|
|
426
|
-
await stateStore.updateState(slice, 'completed');
|
|
427
|
-
async function completeSlice() {
|
|
428
|
-
await pDelay(0);
|
|
429
|
-
await workerClient.sendSliceComplete(msg);
|
|
430
|
-
await shutdownEarlyFn.shutdown();
|
|
431
|
-
}
|
|
432
|
-
await Promise.all([waitForReconnect(), completeSlice()]);
|
|
433
|
-
await processWork();
|
|
434
|
-
}
|
|
435
|
-
await processWork();
|
|
436
|
-
}
|
|
437
|
-
function startWorkers() {
|
|
438
|
-
return Promise.all(times(workers, startWorker));
|
|
439
|
-
}
|
|
440
|
-
const requestAnalytics = setTimeout(async () => {
|
|
441
|
-
try {
|
|
442
|
-
await clusterMaster.sendExecutionAnalyticsRequest(exId);
|
|
443
|
-
}
|
|
444
|
-
catch (err) {
|
|
445
|
-
// it shouldn't matter
|
|
446
|
-
}
|
|
447
|
-
}, 100);
|
|
448
|
-
testContext.attachCleanup(() => clearTimeout(requestAnalytics));
|
|
449
|
-
await Promise.all([shutdownEarlyFn.wait(), startWorkers(), exController.run()]);
|
|
450
|
-
clearTimeout(requestAnalytics);
|
|
451
|
-
executionRecord = await exStore.get(exId);
|
|
452
|
-
});
|
|
453
|
-
afterAll(() => testContext.cleanup());
|
|
454
|
-
it('should have the correct complete slices', async () => {
|
|
455
|
-
const { exId } = testContext.executionContext;
|
|
456
|
-
const recoverFrom = testContext.executionContext.config.recovered_execution;
|
|
457
|
-
const exIds = recoverFrom ? [exId, recoverFrom] : [exId];
|
|
458
|
-
expect(await stateStore.count(`ex_id:("${exIds.join('" OR "')}") AND state:completed`, 0)).toEqual(completedSliceCount);
|
|
459
|
-
});
|
|
460
|
-
it('should have the correct incomplete slices', async () => {
|
|
461
|
-
const { exId } = testContext.executionContext;
|
|
462
|
-
const recoverFrom = testContext.executionContext.config.recovered_execution;
|
|
463
|
-
const exIds = recoverFrom ? [exId, recoverFrom] : [exId];
|
|
464
|
-
expect(await stateStore.count(`ex_id:("${exIds.join('" OR "')}") AND NOT state:completed`, 0)).toEqual(incompleteSliceCount);
|
|
465
|
-
});
|
|
466
|
-
if (isRecovery) {
|
|
467
|
-
it('should recover the correct slices', async () => {
|
|
468
|
-
const { exId } = testContext.executionContext;
|
|
469
|
-
const recoverFrom = testContext.executionContext.config.recovered_execution;
|
|
470
|
-
expect(recoverFrom).toBeString();
|
|
471
|
-
expect(recoverFrom).not.toEqual(exId);
|
|
472
|
-
if (cleanupType) {
|
|
473
|
-
const actualCleanupType = testContext
|
|
474
|
-
.executionContext
|
|
475
|
-
.config
|
|
476
|
-
.recovered_slice_type;
|
|
477
|
-
expect(actualCleanupType).toEqual(cleanupType);
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
it('should process the right number of slices', async () => {
|
|
482
|
-
if (shutdownEarly) {
|
|
483
|
-
expect(slices.length).toBeGreaterThanOrEqual(processedSliceCount);
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
expect(slices).toBeArrayOfSize(processedSliceCount);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
it('should have the correct execution status', () => {
|
|
490
|
-
const { exId } = testContext.executionContext;
|
|
491
|
-
expect(executionRecord).toBeObject();
|
|
492
|
-
expect(executionRecord).toHaveProperty('_slicer_stats.processed');
|
|
493
|
-
expect(executionRecord).toHaveProperty('_slicer_stats.queued');
|
|
494
|
-
expect(executionRecord).toHaveProperty('_slicer_stats.slicers');
|
|
495
|
-
if (shutdownEarly) {
|
|
496
|
-
expect(executionRecord).toHaveProperty('_failureReason', `execution ${exId} received shutdown before the slicer could complete, setting status to "terminated"`);
|
|
497
|
-
expect(executionRecord._slicer_stats.failed).toEqual(0);
|
|
498
|
-
expect(executionRecord).toMatchObject({
|
|
499
|
-
_has_errors: true,
|
|
500
|
-
_status: 'terminated'
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
expect(executionRecord).toMatchObject({
|
|
505
|
-
_has_errors: false,
|
|
506
|
-
_status: 'completed'
|
|
507
|
-
});
|
|
508
|
-
if (slicerQueueLength !== 'QUEUE_MINIMUM_SIZE') {
|
|
509
|
-
expect(executionRecord._slicer_stats.processed).toEqual(processedSliceCount);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
expect(executionRecord._slicer_stats.workers_joined).toBeGreaterThanOrEqual(1);
|
|
513
|
-
if (reconnect && slicerQueueLength !== 'QUEUE_MINIMUM_SIZE') {
|
|
514
|
-
expect(executionRecord._slicer_stats.workers_reconnected).toBeGreaterThan(0);
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
//# sourceMappingURL=execution-special-test-cases-spec.js.map
|