teraslice-client-js 0.55.1 → 0.56.0
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/src/assets.d.ts +7 -6
- package/dist/src/assets.d.ts.map +1 -1
- package/dist/src/assets.js +15 -15
- package/dist/src/assets.js.map +1 -1
- package/dist/src/client.d.ts +1 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +14 -15
- package/dist/src/client.js.map +1 -1
- package/dist/src/cluster.d.ts +7 -7
- package/dist/src/cluster.d.ts.map +1 -1
- package/dist/src/cluster.js +2 -2
- package/dist/src/cluster.js.map +1 -1
- package/dist/src/ex.d.ts +14 -13
- package/dist/src/ex.d.ts.map +1 -1
- package/dist/src/ex.js +18 -17
- package/dist/src/ex.js.map +1 -1
- package/dist/src/executions.d.ts +6 -6
- package/dist/src/executions.d.ts.map +1 -1
- package/dist/src/executions.js +7 -7
- package/dist/src/executions.js.map +1 -1
- package/dist/src/interfaces.d.ts +1 -218
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/interfaces.js +0 -20
- package/dist/src/interfaces.js.map +1 -1
- package/dist/src/job.d.ts +19 -19
- package/dist/src/job.d.ts.map +1 -1
- package/dist/src/job.js +23 -21
- package/dist/src/job.js.map +1 -1
- package/dist/src/jobs.d.ts +4 -4
- package/dist/src/jobs.d.ts.map +1 -1
- package/dist/src/jobs.js +3 -3
- package/dist/src/jobs.js.map +1 -1
- package/dist/test/assets-spec.js +2 -0
- package/dist/test/assets-spec.js.map +1 -1
- package/dist/test/cluster-spec.js +0 -2
- package/dist/test/cluster-spec.js.map +1 -1
- package/dist/test/ex-spec.js +25 -25
- package/dist/test/ex-spec.js.map +1 -1
- package/dist/test/job-spec.js +79 -52
- package/dist/test/job-spec.js.map +1 -1
- package/dist/test/jobs-spec.js +4 -4
- package/dist/test/jobs-spec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/assets.ts +24 -19
- package/src/client.ts +9 -11
- package/src/cluster.ts +10 -16
- package/src/ex.ts +44 -54
- package/src/executions.ts +15 -21
- package/src/interfaces.ts +1 -334
- package/src/job.ts +65 -64
- package/src/jobs.ts +10 -14
- package/test/assets-spec.ts +6 -4
- package/test/cluster-spec.ts +0 -2
- package/test/ex-spec.ts +32 -32
- package/test/job-spec.ts +87 -61
- package/test/jobs-spec.ts +5 -5
package/test/ex-spec.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
|
-
import {
|
|
2
|
+
import { Teraslice } from '@terascope/types';
|
|
3
3
|
import Ex from '../src/ex';
|
|
4
|
-
import {
|
|
5
|
-
ExecutionStatus,
|
|
6
|
-
ClusterStateNative,
|
|
7
|
-
WorkerJobProcesses
|
|
8
|
-
} from '../src/interfaces';
|
|
9
4
|
|
|
10
5
|
describe('Teraslice Ex', () => {
|
|
11
6
|
let scope: nock.Scope;
|
|
@@ -18,7 +13,7 @@ describe('Teraslice Ex', () => {
|
|
|
18
13
|
|
|
19
14
|
const requestOptions = { headers: { 'Random-Header': 'true' } };
|
|
20
15
|
|
|
21
|
-
const clusterState:
|
|
16
|
+
const clusterState: any = {
|
|
22
17
|
'some-node-id': {
|
|
23
18
|
hostname: 'host',
|
|
24
19
|
pid: 111,
|
|
@@ -223,7 +218,7 @@ describe('Teraslice Ex', () => {
|
|
|
223
218
|
describe('when called with a query', () => {
|
|
224
219
|
beforeEach(() => {
|
|
225
220
|
scope.post('/ex/some-ex-id/_recover')
|
|
226
|
-
.query({ cleanup: RecoveryCleanupType.errors })
|
|
221
|
+
.query({ cleanup: Teraslice.RecoveryCleanupType.errors })
|
|
227
222
|
.reply(200, {
|
|
228
223
|
job_id: 'some-job-key',
|
|
229
224
|
ex_id: 'some-ex-key'
|
|
@@ -232,7 +227,9 @@ describe('Teraslice Ex', () => {
|
|
|
232
227
|
|
|
233
228
|
it('should resolve json results from Teraslice', async () => {
|
|
234
229
|
const ex = new Ex({ baseUrl }, 'some-ex-id');
|
|
235
|
-
const instance = await ex.recover({
|
|
230
|
+
const instance = await ex.recover({
|
|
231
|
+
cleanup: Teraslice.RecoveryCleanupType.errors
|
|
232
|
+
});
|
|
236
233
|
|
|
237
234
|
expect(instance).toBeInstanceOf(Ex);
|
|
238
235
|
expect(instance.id()).toEqual('some-ex-key');
|
|
@@ -253,7 +250,7 @@ describe('Teraslice Ex', () => {
|
|
|
253
250
|
it('should resolve json results from Teraslice', async () => {
|
|
254
251
|
const ex = new Ex({ baseUrl }, 'some-ex-id');
|
|
255
252
|
const instance = await ex.recover({
|
|
256
|
-
cleanup: RecoveryCleanupType.errors
|
|
253
|
+
cleanup: Teraslice.RecoveryCleanupType.errors
|
|
257
254
|
}, requestOptions);
|
|
258
255
|
|
|
259
256
|
expect(instance).toBeInstanceOf(Ex);
|
|
@@ -364,15 +361,14 @@ describe('Teraslice Ex', () => {
|
|
|
364
361
|
});
|
|
365
362
|
|
|
366
363
|
describe('->workers', () => {
|
|
367
|
-
const workerData:
|
|
364
|
+
const workerData: Teraslice.WorkerNode[] = [];
|
|
368
365
|
|
|
369
366
|
const exId = 'some-ex-id';
|
|
370
367
|
for (const [nodeName, node] of Object.entries(clusterState)) {
|
|
371
|
-
|
|
368
|
+
// @ts-expect-error TODO: fixme
|
|
369
|
+
node.active.forEach((child: any) => {
|
|
372
370
|
if (child.assignment === 'worker' && child.ex_id === exId) {
|
|
373
|
-
// @ts-expect-error
|
|
374
371
|
child.node_id = nodeName;
|
|
375
|
-
// @ts-expect-error
|
|
376
372
|
workerData.push(child);
|
|
377
373
|
}
|
|
378
374
|
});
|
|
@@ -502,14 +498,14 @@ describe('Teraslice Ex', () => {
|
|
|
502
498
|
.reply(200, {
|
|
503
499
|
ex_id: 'example-ex-id',
|
|
504
500
|
job_id: 'example-job-id',
|
|
505
|
-
_status:
|
|
501
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
506
502
|
});
|
|
507
503
|
});
|
|
508
504
|
|
|
509
505
|
it('should resolve json results from Teraslice', async () => {
|
|
510
506
|
const ex = new Ex({ baseUrl }, 'example-ex-id');
|
|
511
|
-
const results = await ex.waitForStatus(
|
|
512
|
-
expect(results).toEqual(
|
|
507
|
+
const results = await ex.waitForStatus(Teraslice.ExecutionStatusEnum.running);
|
|
508
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
513
509
|
});
|
|
514
510
|
});
|
|
515
511
|
|
|
@@ -522,19 +518,19 @@ describe('Teraslice Ex', () => {
|
|
|
522
518
|
.reply(200, {
|
|
523
519
|
ex_id: 'example-ex-id',
|
|
524
520
|
job_id: 'example-job-id',
|
|
525
|
-
_status:
|
|
521
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
526
522
|
});
|
|
527
523
|
});
|
|
528
524
|
|
|
529
525
|
it('should resolve json results from Teraslice', async () => {
|
|
530
526
|
const ex = new Ex({ baseUrl }, 'example-ex-id');
|
|
531
527
|
const results = await ex.waitForStatus(
|
|
532
|
-
|
|
528
|
+
Teraslice.ExecutionStatusEnum.running,
|
|
533
529
|
1000,
|
|
534
530
|
0,
|
|
535
531
|
searchOptions
|
|
536
532
|
);
|
|
537
|
-
expect(results).toEqual(
|
|
533
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
538
534
|
});
|
|
539
535
|
});
|
|
540
536
|
|
|
@@ -543,20 +539,20 @@ describe('Teraslice Ex', () => {
|
|
|
543
539
|
scope.get('/ex/other-ex-id')
|
|
544
540
|
.reply(200, {
|
|
545
541
|
ex_id: 'other-ex-id',
|
|
546
|
-
_status:
|
|
542
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
547
543
|
});
|
|
548
544
|
|
|
549
545
|
scope.get('/ex/other-ex-id')
|
|
550
546
|
.reply(200, {
|
|
551
547
|
ex_id: 'other-ex-id',
|
|
552
|
-
_status:
|
|
548
|
+
_status: Teraslice.ExecutionStatusEnum.completed
|
|
553
549
|
});
|
|
554
550
|
});
|
|
555
551
|
|
|
556
552
|
it('should resolve json results from Teraslice', async () => {
|
|
557
553
|
const ex = new Ex({ baseUrl }, 'other-ex-id');
|
|
558
|
-
const results = await ex.waitForStatus(
|
|
559
|
-
expect(results).toEqual(
|
|
554
|
+
const results = await ex.waitForStatus(Teraslice.ExecutionStatusEnum.completed);
|
|
555
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.completed);
|
|
560
556
|
});
|
|
561
557
|
});
|
|
562
558
|
|
|
@@ -566,7 +562,7 @@ describe('Teraslice Ex', () => {
|
|
|
566
562
|
.times(12)
|
|
567
563
|
.reply(200, {
|
|
568
564
|
ex_id: 'foo-bar-ex-id',
|
|
569
|
-
_status:
|
|
565
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
570
566
|
});
|
|
571
567
|
});
|
|
572
568
|
|
|
@@ -574,7 +570,7 @@ describe('Teraslice Ex', () => {
|
|
|
574
570
|
expect.hasAssertions();
|
|
575
571
|
const ex = new Ex({ baseUrl }, 'foo-bar-ex-id');
|
|
576
572
|
try {
|
|
577
|
-
await ex.waitForStatus(
|
|
573
|
+
await ex.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
|
|
578
574
|
} catch (err) {
|
|
579
575
|
expect(err.message).toEqual('Execution status failed to change from status "running" to "completed" within 1000ms');
|
|
580
576
|
}
|
|
@@ -587,20 +583,24 @@ describe('Teraslice Ex', () => {
|
|
|
587
583
|
.delay(1100)
|
|
588
584
|
.reply(200, {
|
|
589
585
|
ex_id: 'example-ex-id',
|
|
590
|
-
_status:
|
|
586
|
+
_status: Teraslice.ExecutionStatusEnum.initializing
|
|
591
587
|
});
|
|
592
588
|
|
|
593
589
|
scope.get('/ex/some-job-id')
|
|
594
590
|
.reply(200, {
|
|
595
591
|
ex_id: 'example-ex-id',
|
|
596
|
-
_status:
|
|
592
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
597
593
|
});
|
|
598
594
|
});
|
|
599
595
|
|
|
600
596
|
it('should resolve with the correct status', async () => {
|
|
601
597
|
const ex = new Ex({ baseUrl }, 'some-job-id');
|
|
602
|
-
const status = await ex.waitForStatus(
|
|
603
|
-
|
|
598
|
+
const status = await ex.waitForStatus(
|
|
599
|
+
Teraslice.ExecutionStatusEnum.running,
|
|
600
|
+
100,
|
|
601
|
+
1500
|
|
602
|
+
);
|
|
603
|
+
expect(status).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
604
604
|
});
|
|
605
605
|
});
|
|
606
606
|
|
|
@@ -609,7 +609,7 @@ describe('Teraslice Ex', () => {
|
|
|
609
609
|
scope.get('/ex/example-ex-id')
|
|
610
610
|
.reply(200, {
|
|
611
611
|
ex_id: 'example-ex-id',
|
|
612
|
-
_status:
|
|
612
|
+
_status: Teraslice.ExecutionStatusEnum.failed
|
|
613
613
|
});
|
|
614
614
|
});
|
|
615
615
|
|
|
@@ -617,7 +617,7 @@ describe('Teraslice Ex', () => {
|
|
|
617
617
|
expect.hasAssertions();
|
|
618
618
|
const ex = new Ex({ baseUrl }, 'example-ex-id');
|
|
619
619
|
try {
|
|
620
|
-
await ex.waitForStatus(
|
|
620
|
+
await ex.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
|
|
621
621
|
} catch (err) {
|
|
622
622
|
const errMsg = 'Execution cannot reach the target status, "completed", because it is in the terminal state, "failed"';
|
|
623
623
|
expect(err.message).toEqual(errMsg);
|
package/test/job-spec.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
|
-
import {
|
|
2
|
+
import { Teraslice } from '@terascope/types';
|
|
3
3
|
import Job from '../src/job';
|
|
4
|
-
import {
|
|
5
|
-
ExecutionStatus,
|
|
6
|
-
Execution,
|
|
7
|
-
ClusterStateNative,
|
|
8
|
-
WorkerJobProcesses,
|
|
9
|
-
JobConfiguration
|
|
10
|
-
} from '../src/interfaces';
|
|
11
4
|
|
|
12
5
|
describe('Teraslice Job', () => {
|
|
13
6
|
let scope: nock.Scope;
|
|
@@ -20,7 +13,7 @@ describe('Teraslice Job', () => {
|
|
|
20
13
|
|
|
21
14
|
const requestOptions = { headers: { 'Some-Header': 'yes' } };
|
|
22
15
|
|
|
23
|
-
const clusterState:
|
|
16
|
+
const clusterState: any = {
|
|
24
17
|
'some-node-id': {
|
|
25
18
|
hostname: 'host',
|
|
26
19
|
pid: 111,
|
|
@@ -83,7 +76,7 @@ describe('Teraslice Job', () => {
|
|
|
83
76
|
};
|
|
84
77
|
const date = new Date().toISOString();
|
|
85
78
|
|
|
86
|
-
const executionResults:
|
|
79
|
+
const executionResults: Teraslice.ExecutionRecord[] = [
|
|
87
80
|
{
|
|
88
81
|
active: true,
|
|
89
82
|
analytics: false,
|
|
@@ -103,11 +96,14 @@ describe('Teraslice Job', () => {
|
|
|
103
96
|
_created: date,
|
|
104
97
|
_updated: date,
|
|
105
98
|
_context: 'ex',
|
|
106
|
-
_status:
|
|
99
|
+
_status: Teraslice.ExecutionStatusEnum.running,
|
|
107
100
|
ex_id: '123456789',
|
|
108
101
|
job_id: '123456789',
|
|
109
102
|
slicer_hostname: 'hostname',
|
|
110
|
-
slicer_port: 5673
|
|
103
|
+
slicer_port: 5673,
|
|
104
|
+
_has_errors: false,
|
|
105
|
+
_slicer_stats: {},
|
|
106
|
+
_failureReason: ''
|
|
111
107
|
},
|
|
112
108
|
];
|
|
113
109
|
|
|
@@ -252,7 +248,7 @@ describe('Teraslice Job', () => {
|
|
|
252
248
|
it('should resolve json results from Teraslice', async () => {
|
|
253
249
|
const job = new Job({ baseUrl }, 'foo-bar');
|
|
254
250
|
const results = await job.recover({
|
|
255
|
-
cleanup: RecoveryCleanupType.errors
|
|
251
|
+
cleanup: Teraslice.RecoveryCleanupType.errors
|
|
256
252
|
});
|
|
257
253
|
expect(results).toEqual({ job_id: 'foo-bar' });
|
|
258
254
|
});
|
|
@@ -271,7 +267,7 @@ describe('Teraslice Job', () => {
|
|
|
271
267
|
it('should resolve json results from Teraslice', async () => {
|
|
272
268
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
273
269
|
const results = await job.recover({
|
|
274
|
-
cleanup: RecoveryCleanupType.errors
|
|
270
|
+
cleanup: Teraslice.RecoveryCleanupType.errors
|
|
275
271
|
}, requestOptions);
|
|
276
272
|
expect(results).toEqual({
|
|
277
273
|
key: 'some-other-key'
|
|
@@ -312,12 +308,25 @@ describe('Teraslice Job', () => {
|
|
|
312
308
|
|
|
313
309
|
describe('->update', () => {
|
|
314
310
|
describe('when updating the whole config', () => {
|
|
315
|
-
const body =
|
|
311
|
+
const body: Teraslice.JobRecord = {
|
|
316
312
|
name: 'hello',
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
313
|
+
apis: [],
|
|
314
|
+
operations: [],
|
|
315
|
+
active: true,
|
|
316
|
+
analytics: false,
|
|
317
|
+
autorecover: false,
|
|
318
|
+
assets: [],
|
|
319
|
+
lifecycle: 'once',
|
|
320
|
+
max_retries: 0,
|
|
321
|
+
probation_window: 30000,
|
|
322
|
+
slicers: 1,
|
|
323
|
+
workers: 1,
|
|
324
|
+
env_vars: {},
|
|
325
|
+
_context: 'job',
|
|
326
|
+
job_id: 'some-job-id',
|
|
327
|
+
_created: 'hello',
|
|
328
|
+
_updated: 'hello',
|
|
329
|
+
};
|
|
321
330
|
|
|
322
331
|
beforeEach(() => {
|
|
323
332
|
scope.put('/jobs/some-job-id', body as any)
|
|
@@ -334,12 +343,26 @@ describe('Teraslice Job', () => {
|
|
|
334
343
|
|
|
335
344
|
describe('->updatePartial', () => {
|
|
336
345
|
describe('when updating a partial config', () => {
|
|
337
|
-
const body =
|
|
346
|
+
const body: Teraslice.JobRecord = {
|
|
338
347
|
name: 'hello',
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
apis: [],
|
|
349
|
+
operations: [],
|
|
350
|
+
active: true,
|
|
351
|
+
analytics: false,
|
|
352
|
+
autorecover: false,
|
|
353
|
+
assets: [],
|
|
354
|
+
lifecycle: 'once',
|
|
355
|
+
max_retries: 0,
|
|
356
|
+
probation_window: 30000,
|
|
357
|
+
slicers: 1,
|
|
358
|
+
workers: 1,
|
|
359
|
+
env_vars: {},
|
|
360
|
+
_context: 'job',
|
|
361
|
+
job_id: 'some-job-id',
|
|
362
|
+
_created: 'hello',
|
|
363
|
+
_updated: 'hello',
|
|
364
|
+
};
|
|
365
|
+
|
|
343
366
|
const expected = {
|
|
344
367
|
...body,
|
|
345
368
|
name: 'howdy'
|
|
@@ -489,15 +512,14 @@ describe('Teraslice Job', () => {
|
|
|
489
512
|
});
|
|
490
513
|
|
|
491
514
|
describe('->workers', () => {
|
|
492
|
-
const workerData:
|
|
515
|
+
const workerData: Teraslice.WorkerNode[] = [];
|
|
493
516
|
|
|
494
517
|
const jobId = 'some-job-id';
|
|
495
518
|
for (const [nodeName, node] of Object.entries(clusterState)) {
|
|
519
|
+
// @ts-expect-error TODO: fixme
|
|
496
520
|
node.active.forEach((child) => {
|
|
497
521
|
if (child.assignment === 'worker' && child.job_id === jobId) {
|
|
498
|
-
// @ts-expect-error
|
|
499
522
|
child.node_id = nodeName;
|
|
500
|
-
// @ts-expect-error
|
|
501
523
|
workerData.push(child);
|
|
502
524
|
}
|
|
503
525
|
});
|
|
@@ -626,14 +648,14 @@ describe('Teraslice Job', () => {
|
|
|
626
648
|
scope.get('/jobs/some-job-id/ex')
|
|
627
649
|
.reply(200, {
|
|
628
650
|
ex_id: 'example-ex-id',
|
|
629
|
-
_status:
|
|
651
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
630
652
|
});
|
|
631
653
|
});
|
|
632
654
|
|
|
633
655
|
it('should resolve json results from Teraslice', async () => {
|
|
634
656
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
635
|
-
const results = await job.waitForStatus(
|
|
636
|
-
expect(results).toEqual(
|
|
657
|
+
const results = await job.waitForStatus(Teraslice.ExecutionStatusEnum.running);
|
|
658
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
637
659
|
});
|
|
638
660
|
});
|
|
639
661
|
|
|
@@ -642,18 +664,18 @@ describe('Teraslice Job', () => {
|
|
|
642
664
|
scope.get('/jobs/some-job-id/ex')
|
|
643
665
|
.reply(200, {
|
|
644
666
|
ex_id: 'example-ex-id',
|
|
645
|
-
_status:
|
|
667
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
646
668
|
});
|
|
647
669
|
});
|
|
648
670
|
|
|
649
671
|
it('should resolve json results from Teraslice', async () => {
|
|
650
672
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
651
673
|
const results = await job.waitForStatus([
|
|
652
|
-
|
|
653
|
-
|
|
674
|
+
Teraslice.ExecutionStatusEnum.failing,
|
|
675
|
+
Teraslice.ExecutionStatusEnum.running
|
|
654
676
|
]);
|
|
655
677
|
|
|
656
|
-
expect(results).toEqual(
|
|
678
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
657
679
|
});
|
|
658
680
|
});
|
|
659
681
|
|
|
@@ -665,19 +687,19 @@ describe('Teraslice Job', () => {
|
|
|
665
687
|
.matchHeader('Some-Header', 'yes')
|
|
666
688
|
.reply(200, {
|
|
667
689
|
ex_id: 'example-ex-id',
|
|
668
|
-
_status:
|
|
690
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
669
691
|
});
|
|
670
692
|
});
|
|
671
693
|
|
|
672
694
|
it('should resolve json results from Teraslice', async () => {
|
|
673
695
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
674
696
|
const results = await job.waitForStatus(
|
|
675
|
-
|
|
697
|
+
Teraslice.ExecutionStatusEnum.running,
|
|
676
698
|
1000,
|
|
677
699
|
0,
|
|
678
700
|
searchOptions
|
|
679
701
|
);
|
|
680
|
-
expect(results).toEqual(
|
|
702
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
681
703
|
});
|
|
682
704
|
});
|
|
683
705
|
|
|
@@ -686,20 +708,20 @@ describe('Teraslice Job', () => {
|
|
|
686
708
|
scope.get('/jobs/some-job-id/ex')
|
|
687
709
|
.reply(200, {
|
|
688
710
|
ex_id: 'example-ex-id',
|
|
689
|
-
_status:
|
|
711
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
690
712
|
});
|
|
691
713
|
|
|
692
714
|
scope.get('/jobs/some-job-id/ex')
|
|
693
715
|
.reply(200, {
|
|
694
716
|
ex_id: 'example-ex-id',
|
|
695
|
-
_status:
|
|
717
|
+
_status: Teraslice.ExecutionStatusEnum.completed
|
|
696
718
|
});
|
|
697
719
|
});
|
|
698
720
|
|
|
699
721
|
it('should resolve json results from Teraslice', async () => {
|
|
700
722
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
701
|
-
const results = await job.waitForStatus(
|
|
702
|
-
expect(results).toEqual(
|
|
723
|
+
const results = await job.waitForStatus(Teraslice.ExecutionStatusEnum.completed);
|
|
724
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.completed);
|
|
703
725
|
});
|
|
704
726
|
});
|
|
705
727
|
|
|
@@ -708,25 +730,25 @@ describe('Teraslice Job', () => {
|
|
|
708
730
|
scope.get('/jobs/some-job-id/ex')
|
|
709
731
|
.reply(200, {
|
|
710
732
|
ex_id: 'example-ex-id',
|
|
711
|
-
_status:
|
|
733
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
712
734
|
});
|
|
713
735
|
|
|
714
736
|
scope.get('/jobs/some-job-id/ex')
|
|
715
737
|
.reply(200, {
|
|
716
738
|
ex_id: 'example-ex-id',
|
|
717
|
-
_status:
|
|
739
|
+
_status: Teraslice.ExecutionStatusEnum.terminated
|
|
718
740
|
});
|
|
719
741
|
});
|
|
720
742
|
|
|
721
743
|
it('should resolve json results from Teraslice', async () => {
|
|
722
744
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
723
745
|
const results = await job.waitForStatus([
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
746
|
+
Teraslice.ExecutionStatusEnum.completed,
|
|
747
|
+
Teraslice.ExecutionStatusEnum.failed,
|
|
748
|
+
Teraslice.ExecutionStatusEnum.terminated
|
|
727
749
|
]);
|
|
728
750
|
|
|
729
|
-
expect(results).toEqual(
|
|
751
|
+
expect(results).toEqual(Teraslice.ExecutionStatusEnum.terminated);
|
|
730
752
|
});
|
|
731
753
|
});
|
|
732
754
|
|
|
@@ -736,14 +758,14 @@ describe('Teraslice Job', () => {
|
|
|
736
758
|
.times(1)
|
|
737
759
|
.reply(200, {
|
|
738
760
|
ex_id: 'example-ex-id',
|
|
739
|
-
_status:
|
|
761
|
+
_status: Teraslice.ExecutionStatusEnum.initializing
|
|
740
762
|
});
|
|
741
763
|
|
|
742
764
|
scope.get('/jobs/some-job-id/ex')
|
|
743
765
|
.times(11)
|
|
744
766
|
.reply(200, {
|
|
745
767
|
ex_id: 'example-ex-id',
|
|
746
|
-
_status:
|
|
768
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
747
769
|
});
|
|
748
770
|
});
|
|
749
771
|
|
|
@@ -751,7 +773,7 @@ describe('Teraslice Job', () => {
|
|
|
751
773
|
expect.hasAssertions();
|
|
752
774
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
753
775
|
try {
|
|
754
|
-
await job.waitForStatus(
|
|
776
|
+
await job.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
|
|
755
777
|
} catch (err) {
|
|
756
778
|
expect(err.message).toEqual('Job status failed to change from status "running" to "completed" within 1000ms');
|
|
757
779
|
}
|
|
@@ -764,14 +786,14 @@ describe('Teraslice Job', () => {
|
|
|
764
786
|
.times(1)
|
|
765
787
|
.reply(200, {
|
|
766
788
|
ex_id: 'example-ex-id',
|
|
767
|
-
_status:
|
|
789
|
+
_status: Teraslice.ExecutionStatusEnum.initializing
|
|
768
790
|
});
|
|
769
791
|
|
|
770
792
|
scope.get('/jobs/some-job-id/ex')
|
|
771
793
|
.times(11)
|
|
772
794
|
.reply(200, {
|
|
773
795
|
ex_id: 'example-ex-id',
|
|
774
|
-
_status:
|
|
796
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
775
797
|
});
|
|
776
798
|
});
|
|
777
799
|
|
|
@@ -780,9 +802,9 @@ describe('Teraslice Job', () => {
|
|
|
780
802
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
781
803
|
try {
|
|
782
804
|
await job.waitForStatus([
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
805
|
+
Teraslice.ExecutionStatusEnum.completed,
|
|
806
|
+
Teraslice.ExecutionStatusEnum.failed,
|
|
807
|
+
Teraslice.ExecutionStatusEnum.stopped
|
|
786
808
|
], 100, 1000);
|
|
787
809
|
} catch (err) {
|
|
788
810
|
expect(err.message).toEqual('Job status failed to change from status "running" to "completed,failed,stopped" within 1000ms');
|
|
@@ -796,20 +818,24 @@ describe('Teraslice Job', () => {
|
|
|
796
818
|
.delay(1100)
|
|
797
819
|
.reply(200, {
|
|
798
820
|
ex_id: 'example-ex-id',
|
|
799
|
-
_status:
|
|
821
|
+
_status: Teraslice.ExecutionStatusEnum.initializing
|
|
800
822
|
});
|
|
801
823
|
|
|
802
824
|
scope.get('/jobs/some-job-id/ex')
|
|
803
825
|
.reply(200, {
|
|
804
826
|
ex_id: 'example-ex-id',
|
|
805
|
-
_status:
|
|
827
|
+
_status: Teraslice.ExecutionStatusEnum.running
|
|
806
828
|
});
|
|
807
829
|
});
|
|
808
830
|
|
|
809
831
|
it('should resolve with the correct status', async () => {
|
|
810
832
|
const job = new Job({ baseUrl }, 'some-job-id');
|
|
811
|
-
const status = await job.waitForStatus(
|
|
812
|
-
|
|
833
|
+
const status = await job.waitForStatus(
|
|
834
|
+
Teraslice.ExecutionStatusEnum.running,
|
|
835
|
+
100,
|
|
836
|
+
1500
|
|
837
|
+
);
|
|
838
|
+
expect(status).toEqual(Teraslice.ExecutionStatusEnum.running);
|
|
813
839
|
});
|
|
814
840
|
});
|
|
815
841
|
|
|
@@ -818,7 +844,7 @@ describe('Teraslice Job', () => {
|
|
|
818
844
|
scope.get('/jobs/other-job-id/ex')
|
|
819
845
|
.reply(200, {
|
|
820
846
|
ex_id: 'example-ex-id',
|
|
821
|
-
_status:
|
|
847
|
+
_status: Teraslice.ExecutionStatusEnum.failed
|
|
822
848
|
});
|
|
823
849
|
});
|
|
824
850
|
|
|
@@ -826,7 +852,7 @@ describe('Teraslice Job', () => {
|
|
|
826
852
|
expect.hasAssertions();
|
|
827
853
|
const job = new Job({ baseUrl }, 'other-job-id');
|
|
828
854
|
try {
|
|
829
|
-
await job.waitForStatus(
|
|
855
|
+
await job.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
|
|
830
856
|
} catch (err) {
|
|
831
857
|
const errMsg = 'Job cannot reach the target status, "completed", because it is in the terminal state, "failed"';
|
|
832
858
|
expect(err.message).toEqual(errMsg);
|
package/test/jobs-spec.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'jest-extended';
|
|
2
2
|
import nock from 'nock';
|
|
3
|
+
import { Teraslice } from '@terascope/types';
|
|
3
4
|
import Job from '../src/job';
|
|
4
5
|
import Jobs from '../src/jobs';
|
|
5
|
-
import { ExecutionStatus, JobConfiguration } from '../src/interfaces';
|
|
6
6
|
|
|
7
7
|
describe('Teraslice Jobs', () => {
|
|
8
8
|
let jobs: Jobs;
|
|
@@ -22,7 +22,7 @@ describe('Teraslice Jobs', () => {
|
|
|
22
22
|
|
|
23
23
|
const date = new Date().toISOString();
|
|
24
24
|
|
|
25
|
-
const list:
|
|
25
|
+
const list: Teraslice.JobRecord[] = [
|
|
26
26
|
{
|
|
27
27
|
job_id: 'some-random-job-id',
|
|
28
28
|
active: true,
|
|
@@ -183,19 +183,19 @@ describe('Teraslice Jobs', () => {
|
|
|
183
183
|
describe('when called with a string', () => {
|
|
184
184
|
beforeEach(() => {
|
|
185
185
|
scope.get('/jobs')
|
|
186
|
-
.query({ status:
|
|
186
|
+
.query({ status: Teraslice.ExecutionStatusEnum.running })
|
|
187
187
|
.reply(200, list);
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
it('should resolve json result from Teraslice', async () => {
|
|
191
|
-
const results = await jobs.list(
|
|
191
|
+
const results = await jobs.list(Teraslice.ExecutionStatusEnum.running);
|
|
192
192
|
expect(results).toEqual(list);
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
describe('when called with an object', () => {
|
|
197
197
|
const searchOptions = { headers: { 'Some-Header': 'yes' } };
|
|
198
|
-
const queryOptions = { status:
|
|
198
|
+
const queryOptions = { status: Teraslice.ExecutionStatusEnum.running, size: 10 };
|
|
199
199
|
|
|
200
200
|
beforeEach(() => {
|
|
201
201
|
scope.get('/jobs')
|