teraslice-client-js 2.16.2 → 2.17.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/executions.d.ts +1 -1
- package/dist/src/executions.d.ts.map +1 -1
- package/package.json +7 -4
- package/dist/test/assets-spec.d.ts +0 -2
- package/dist/test/assets-spec.d.ts.map +0 -1
- package/dist/test/assets-spec.js +0 -322
- package/dist/test/assets-spec.js.map +0 -1
- package/dist/test/client-spec.d.ts +0 -2
- package/dist/test/client-spec.d.ts.map +0 -1
- package/dist/test/client-spec.js +0 -374
- package/dist/test/client-spec.js.map +0 -1
- package/dist/test/cluster-spec.d.ts +0 -2
- package/dist/test/cluster-spec.d.ts.map +0 -1
- package/dist/test/cluster-spec.js +0 -143
- package/dist/test/cluster-spec.js.map +0 -1
- package/dist/test/ex-spec.d.ts +0 -2
- package/dist/test/ex-spec.d.ts.map +0 -1
- package/dist/test/ex-spec.js +0 -550
- package/dist/test/ex-spec.js.map +0 -1
- package/dist/test/executions-spec.d.ts +0 -2
- package/dist/test/executions-spec.d.ts.map +0 -1
- package/dist/test/executions-spec.js +0 -233
- package/dist/test/executions-spec.js.map +0 -1
- package/dist/test/job-spec.d.ts +0 -2
- package/dist/test/job-spec.d.ts.map +0 -1
- package/dist/test/job-spec.js +0 -837
- package/dist/test/job-spec.js.map +0 -1
- package/dist/test/jobs-spec.d.ts +0 -2
- package/dist/test/jobs-spec.d.ts.map +0 -1
- package/dist/test/jobs-spec.js +0 -241
- package/dist/test/jobs-spec.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/examples/cluster.js +0 -13
- package/examples/list.js +0 -16
- package/examples/submit.js +0 -48
- package/src/assets.ts +0 -99
- package/src/client.ts +0 -197
- package/src/cluster.ts +0 -48
- package/src/ex.ts +0 -223
- package/src/executions.ts +0 -82
- package/src/index.ts +0 -39
- package/src/interfaces.ts +0 -12
- package/src/job.ts +0 -260
- package/src/jobs.ts +0 -66
- package/test/assets-spec.ts +0 -376
- package/test/client-spec.ts +0 -416
- package/test/cluster-spec.ts +0 -167
- package/test/ex-spec.ts +0 -628
- package/test/executions-spec.ts +0 -260
- package/test/fixtures/test.txt +0 -1
- package/test/job-spec.ts +0 -947
- package/test/jobs-spec.ts +0 -272
- package/tsconfig.json +0 -12
package/test/executions-spec.ts
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import nock from 'nock';
|
|
2
|
-
import Ex from '../src/ex.js';
|
|
3
|
-
import Executions from '../src/executions.js';
|
|
4
|
-
|
|
5
|
-
describe('Teraslice Executions', () => {
|
|
6
|
-
let executions: Executions;
|
|
7
|
-
let scope: nock.Scope;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
executions = new Executions({
|
|
11
|
-
baseUrl: 'http://teraslice.example.dev'
|
|
12
|
-
});
|
|
13
|
-
scope = nock('http://teraslice.example.dev/v1');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
nock.cleanAll();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('->submit', () => {
|
|
21
|
-
describe('when submitting without a jobSpec', () => {
|
|
22
|
-
it('should fail', async () => {
|
|
23
|
-
expect.hasAssertions();
|
|
24
|
-
try {
|
|
25
|
-
// @ts-expect-error
|
|
26
|
-
await executions.submit();
|
|
27
|
-
} catch (err) {
|
|
28
|
-
expect(err.message).toEqual('Submit requires a jobSpec');
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('when submitting with a valid jobSpec', () => {
|
|
34
|
-
const jobSpec = {
|
|
35
|
-
operations: [{ _op: 'operation' }]
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
scope.post('/jobs', jobSpec)
|
|
40
|
-
.query({ start: true })
|
|
41
|
-
.reply(202, {
|
|
42
|
-
ex_id: 'some-execution-id',
|
|
43
|
-
job_id: 'some-job-id'
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should resolve an instanceof a Job', async () => {
|
|
48
|
-
const instance = await executions.submit(jobSpec);
|
|
49
|
-
expect(instance).toBeInstanceOf(Ex);
|
|
50
|
-
expect(instance.id()).toEqual('some-execution-id');
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('when submitting with a valid and start is set false', () => {
|
|
55
|
-
const jobSpec = {
|
|
56
|
-
operations: [{ _op: 'operation' }]
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
scope.post('/jobs', jobSpec)
|
|
61
|
-
.query({ start: false })
|
|
62
|
-
.reply(202, { job_id: 'some-job-id', ex_id: 'foobar' });
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should resolve an instanceof a Job', async () => {
|
|
66
|
-
const instance = await executions.submit(jobSpec, true);
|
|
67
|
-
expect(instance).toBeInstanceOf(Ex);
|
|
68
|
-
expect(instance.id()).toEqual('foobar');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('when submitting and the request fails', () => {
|
|
73
|
-
const jobSpec = {
|
|
74
|
-
operations: [{ _op: 'operation' }]
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
beforeEach(() => {
|
|
78
|
-
scope.post('/jobs', jobSpec)
|
|
79
|
-
.query({ start: true })
|
|
80
|
-
.reply(500, 'Unable to process request');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should reject with the error message from the server', async () => {
|
|
84
|
-
expect.hasAssertions();
|
|
85
|
-
try {
|
|
86
|
-
await executions.submit(jobSpec);
|
|
87
|
-
} catch (err) {
|
|
88
|
-
expect(err.message).toEqual('Unable to process request');
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('when submitting without operations', () => {
|
|
94
|
-
const jobSpec = {
|
|
95
|
-
some_job: true
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
beforeEach(() => {
|
|
99
|
-
scope.post('/jobs', jobSpec)
|
|
100
|
-
.query({ start: true })
|
|
101
|
-
.reply(400, 'No job was posted');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should have a message of No job was posted', async () => {
|
|
105
|
-
expect.hasAssertions();
|
|
106
|
-
try {
|
|
107
|
-
await executions.submit(jobSpec as any);
|
|
108
|
-
} catch (err) {
|
|
109
|
-
expect(err.message).toEqual('No job was posted');
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('->list', () => {
|
|
116
|
-
describe('when called with nothing', () => {
|
|
117
|
-
const data = [
|
|
118
|
-
{
|
|
119
|
-
id: 'example'
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
id: 'example-other'
|
|
123
|
-
}
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
beforeEach(() => {
|
|
127
|
-
scope.get('/ex')
|
|
128
|
-
.query({})
|
|
129
|
-
.reply(200, data);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('should resolve json results from Teraslice', async () => {
|
|
133
|
-
const results = await executions.list();
|
|
134
|
-
expect(results).toEqual(data);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('when called with a string', () => {
|
|
139
|
-
const data = [
|
|
140
|
-
{
|
|
141
|
-
id: 'hello-example'
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
id: 'hello-example-2'
|
|
145
|
-
}
|
|
146
|
-
];
|
|
147
|
-
|
|
148
|
-
beforeEach(() => {
|
|
149
|
-
scope.get('/ex')
|
|
150
|
-
.query({ status: 'hello' })
|
|
151
|
-
.reply(200, data);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('should resolve json results from Teraslice', async () => {
|
|
155
|
-
const results = await executions.list('hello');
|
|
156
|
-
expect(results).toEqual(data);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe('when called with an object', () => {
|
|
161
|
-
const data = [
|
|
162
|
-
{
|
|
163
|
-
id: 'object-example'
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
id: 'object-example-2'
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
|
|
170
|
-
beforeEach(() => {
|
|
171
|
-
scope.get('/ex')
|
|
172
|
-
.query({ anything: true })
|
|
173
|
-
.reply(200, data);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should resolve json results from Teraslice', async () => {
|
|
177
|
-
const results = await executions.list({ anything: true });
|
|
178
|
-
expect(results).toEqual(data);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe('->errors', () => {
|
|
184
|
-
describe('when called with nothing', () => {
|
|
185
|
-
const errors = [
|
|
186
|
-
{
|
|
187
|
-
slice_id: 'hello',
|
|
188
|
-
slicer_id: 0,
|
|
189
|
-
slicer_order: 1,
|
|
190
|
-
request: '{"foo":"bar"}',
|
|
191
|
-
state: 'error',
|
|
192
|
-
ex_id: 'howdy',
|
|
193
|
-
_created: new Date().toISOString(),
|
|
194
|
-
_updated: new Date().toISOString(),
|
|
195
|
-
error: 'Error: uh oh'
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
slice_id: 'hello-there',
|
|
199
|
-
slicer_id: 0,
|
|
200
|
-
slicer_order: 2,
|
|
201
|
-
request: '{"foo":"bar"}',
|
|
202
|
-
state: 'error',
|
|
203
|
-
ex_id: 'howdy',
|
|
204
|
-
_created: new Date().toISOString(),
|
|
205
|
-
_updated: new Date().toISOString(),
|
|
206
|
-
error: 'Error: uh oh'
|
|
207
|
-
}
|
|
208
|
-
];
|
|
209
|
-
|
|
210
|
-
beforeEach(() => {
|
|
211
|
-
scope.get('/ex/errors')
|
|
212
|
-
.query({ size: 10 })
|
|
213
|
-
.reply(200, errors);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('should resolve json results from Teraslice', async () => {
|
|
217
|
-
const results = await executions.errors({ size: 10 });
|
|
218
|
-
expect(results).toEqual(errors);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe('when called with an exId', () => {
|
|
223
|
-
const errors = [
|
|
224
|
-
{
|
|
225
|
-
slice_id: 'hello',
|
|
226
|
-
slicer_id: 0,
|
|
227
|
-
slicer_order: 1,
|
|
228
|
-
request: '{"foo":"bar"}',
|
|
229
|
-
state: 'error',
|
|
230
|
-
ex_id: 'howdy',
|
|
231
|
-
_created: new Date().toISOString(),
|
|
232
|
-
_updated: new Date().toISOString(),
|
|
233
|
-
error: 'Error: uh oh'
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
slice_id: 'hello-there',
|
|
237
|
-
slicer_id: 0,
|
|
238
|
-
slicer_order: 2,
|
|
239
|
-
request: '{"foo":"bar"}',
|
|
240
|
-
state: 'error',
|
|
241
|
-
ex_id: 'howdy',
|
|
242
|
-
_created: new Date().toISOString(),
|
|
243
|
-
_updated: new Date().toISOString(),
|
|
244
|
-
error: 'Error: uh oh'
|
|
245
|
-
}
|
|
246
|
-
];
|
|
247
|
-
|
|
248
|
-
beforeEach(() => {
|
|
249
|
-
scope.get('/ex/foo/errors')
|
|
250
|
-
.query({ from: 10 })
|
|
251
|
-
.reply(200, errors);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should resolve json results from Teraslice', async () => {
|
|
255
|
-
const results = await executions.errors('foo', { from: 10 });
|
|
256
|
-
expect(results).toEqual(errors);
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
});
|
package/test/fixtures/test.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hello-there
|