@skyramp/skyramp 0.4.56 → 0.4.58
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/README.md +575 -30
- package/lib/dev-darwin-amd64.dylib +0 -0
- package/lib/dev-darwin-amd64.h +7 -2
- package/lib/dev-darwin-arm64.dylib +0 -0
- package/lib/dev-darwin-arm64.h +7 -2
- package/lib/dev-linux-386.h +7 -2
- package/lib/dev-linux-386.so +0 -0
- package/lib/dev-linux-amd64.h +7 -2
- package/lib/dev-linux-amd64.so +0 -0
- package/lib/dev-windows-amd64.dll +0 -0
- package/lib/dev-windows-amd64.h +7 -2
- package/package.json +9 -2
- package/src/classes/DelayConfig.d.ts +4 -0
- package/src/classes/DelayConfig.js +25 -0
- package/src/classes/Endpoint.d.ts +1 -1
- package/src/classes/Endpoint.js +40 -8
- package/src/classes/GrpcEndpoint.d.ts +1 -1
- package/src/classes/GrpcEndpoint.js +16 -3
- package/src/classes/RequestValue.d.ts +23 -0
- package/src/classes/RequestValue.js +111 -0
- package/src/classes/ResponseValue.d.ts +21 -0
- package/src/classes/ResponseValue.js +93 -0
- package/src/classes/RestEndpoint.d.ts +10 -2
- package/src/classes/RestEndpoint.js +77 -4
- package/src/classes/RestParam.d.ts +4 -0
- package/src/classes/RestParam.js +32 -0
- package/src/classes/Scenario.d.ts +6 -3
- package/src/classes/Scenario.js +44 -1
- package/src/classes/SkyrampClient.d.ts +14 -5
- package/src/classes/SkyrampClient.js +219 -53
- package/src/classes/TrafficConfig.d.ts +6 -0
- package/src/classes/TrafficConfig.js +28 -0
- package/src/index.d.ts +6 -1
- package/src/index.js +11 -1
package/README.md
CHANGED
|
@@ -12,83 +12,628 @@ npm install @skyramp/skyramp
|
|
|
12
12
|
Once you've installed Skyramp, you can import it into your project like this:
|
|
13
13
|
|
|
14
14
|
```javascript
|
|
15
|
+
// Import necessary modules from skyramp
|
|
15
16
|
const { GrpcEndpoint, RestEndpoint, SkyrampClient, Scenario } = require('skyramp');
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
### SkyrampClient
|
|
19
|
-
The `SkyrampClient` class is the main entry point to interact with the skyramp module. It allows you to apply configurations, start test scenarios, and deploy and delete workers.
|
|
20
|
+
The `SkyrampClient` class is the main entry point to interact with the skyramp module. It allows you to apply configurations, start test scenarios, and deploy and delete workers. You have the option of configuring the `SkyrampClient` to be used either in the Kubernetes setting (by deploying a local cluster or connecting to an existing cluster) and deploying the Skyramp worker.
|
|
21
|
+
|
|
22
|
+
#### Kubernetes Configuration
|
|
23
|
+
First, you must set up the `SkyrampClient` with a Kubernetes cluster.
|
|
20
24
|
|
|
21
25
|
**Example: Provision Local Cluster with Skyramp**
|
|
22
26
|
```javascript
|
|
27
|
+
// Create a SkyrampClient instance
|
|
23
28
|
const skyrampClient = new SkyrampClient();
|
|
24
|
-
|
|
29
|
+
|
|
30
|
+
// Apply a local Kubernetes cluster
|
|
31
|
+
skyrampClient.applyLocal().then(() => {
|
|
25
32
|
// Local cluster provisioned
|
|
26
|
-
}).catch(
|
|
33
|
+
}).catch((error) => {
|
|
27
34
|
// Error occurred during provisioning
|
|
28
35
|
});
|
|
29
36
|
```
|
|
30
|
-
|
|
37
|
+
|
|
38
|
+
Once you have a `SkyrampClient` instance configured with a Kubernetes cluster, you can deploy the Skyramp Worker in-cluster, for applying mocks and running tests.
|
|
31
39
|
|
|
32
40
|
**Example: Deploy Skyramp Worker**
|
|
33
41
|
```javascript
|
|
34
|
-
|
|
42
|
+
// Deploy Skyramp Worker in-cluster
|
|
43
|
+
skyrampClient.deploySkyrampWorker('my-namespace').then(() => {
|
|
35
44
|
// Worker deployed successfully
|
|
36
|
-
}).catch(
|
|
45
|
+
}).catch((error) => {
|
|
37
46
|
// Error occurred during deployment
|
|
38
47
|
});
|
|
39
48
|
```
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
#### Docker Configuration
|
|
51
|
+
For the Docker setting, you can bring up a `SkyrampClient` instance and deploy the Skyramp Worker in the network of your choice, for applying mocks and running tests.
|
|
52
|
+
|
|
53
|
+
**Example: Run Skyramp Worker in Docker Network**
|
|
54
|
+
```javascript
|
|
55
|
+
// Create a SkyrampClient instance
|
|
56
|
+
const skyrampClient = new SkyrampClient();
|
|
57
|
+
|
|
58
|
+
// Run Skyramp Worker in Docker network
|
|
59
|
+
skyrampClient.runDockerSkyrampWorker().then(() => {
|
|
60
|
+
// Worker run successfully
|
|
61
|
+
}).catch((error) => {
|
|
62
|
+
// Error occurred during worker bring-up
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Mocking
|
|
67
|
+
|
|
68
|
+
To configure mock responses to apply them to the `SkyrampClient`, you must first create an `Endpoint` object (currently supported: `GrpcEndpoint` and `RestEndpoint`) and configure a `ResponseValue` for the method you wish to mock and passing through a dynamic `javascriptFunction` (a handler function) or a JSON `blob`.
|
|
69
|
+
|
|
70
|
+
Here is an example flow of creating a REST Mock Configuration from a `RestEndpoint` object:
|
|
43
71
|
|
|
44
72
|
**Example: Create REST Mock Configuration**
|
|
45
73
|
```javascript
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
74
|
+
// Define endpoint options
|
|
75
|
+
const endpointOptions = {
|
|
76
|
+
serviceName: 'payment-service',
|
|
77
|
+
port: 8080,
|
|
78
|
+
restPath: '/payment',
|
|
79
|
+
methodTypes: ['POST'],
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Create a RestEndpoint instance
|
|
83
|
+
const restEndpoint = new RestEndpoint(endpointOptions);
|
|
84
|
+
|
|
85
|
+
// Define JSON blob for mock response
|
|
86
|
+
const jsonBlob = '{"transaction_id": "default-value"}';
|
|
87
|
+
|
|
88
|
+
// Create a ResponseValue for the mock
|
|
89
|
+
const paymentResponse = new ResponseValue({
|
|
90
|
+
name: 'payment',
|
|
91
|
+
endpoint: restEndpoint,
|
|
92
|
+
methodType: 'POST',
|
|
93
|
+
blob: jsonBlob
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Create a traffic configuration
|
|
97
|
+
trafficConfig = new TrafficConfig(100, new DelayConfig(9000, 10000));
|
|
98
|
+
|
|
99
|
+
// Apply the mock with the response and traffic configuration
|
|
100
|
+
skyrampClient.mockerApplyV1('my-namespace', '', paymentResponse, trafficConfig).then(() => {
|
|
49
101
|
// Mock applied successfully
|
|
50
|
-
}).catch(
|
|
102
|
+
}).catch((error) => {
|
|
51
103
|
// Error occurred during mock application
|
|
52
104
|
});
|
|
53
105
|
```
|
|
54
106
|
|
|
55
|
-
|
|
56
|
-
The `GrpcEndpoint` class represents a gRPC API endpoint and provides methods to configure mock responses to apply them to the `SkyrampClient`.
|
|
107
|
+
Here is an example flow of creating a gRPC Mock Configuration from a `GrpcEndpoint` object:
|
|
57
108
|
|
|
58
109
|
**Example: Create gRPC Mock Configuration**
|
|
59
110
|
```javascript
|
|
60
|
-
|
|
61
|
-
grpcEndpoint
|
|
62
|
-
|
|
111
|
+
// Create a GrpcEndpoint instance
|
|
112
|
+
const grpcEndpoint = new GrpcEndpoint('helloworld', 'Greeter', 50052, 'pb/helloworld.proto');
|
|
113
|
+
|
|
114
|
+
// Define mock handler js function
|
|
115
|
+
function handler(req) {
|
|
116
|
+
return {
|
|
117
|
+
value: {
|
|
118
|
+
name: 'mock'
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Create a ResponseValue for the mock
|
|
124
|
+
const helloResponse = new ResponseValue({
|
|
125
|
+
name: 'SayHello',
|
|
126
|
+
endpoint: grpcEndpoint,
|
|
127
|
+
methodName: 'SayHello',
|
|
128
|
+
javascriptFunction: handler.toString()
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Create a traffic configuration
|
|
132
|
+
trafficConfig = new TrafficConfig(100, new DelayConfig(9000, 10000));
|
|
133
|
+
|
|
134
|
+
// Apply the mock with the response and traffic configuration
|
|
135
|
+
skyrampClient.mockerApplyV1('my-namespace', '', helloResponse, trafficConfig).then(() => {
|
|
63
136
|
// Mock applied successfully
|
|
64
|
-
}).catch(
|
|
137
|
+
}).catch((error) => {
|
|
65
138
|
// Error occurred during mock application
|
|
66
139
|
});
|
|
67
140
|
```
|
|
68
141
|
|
|
69
|
-
###
|
|
70
|
-
|
|
142
|
+
### Testing
|
|
143
|
+
|
|
144
|
+
To configure test requests to apply them to the `SkyrampClient`, you must first create an `Endpoint` object (currently supported: `GrpcEndpoint` and `RestEndpoint`) and configure `Scenario` built from `AssertEqual`s and `RequestValue`s for the method you wish to test and passing through a dynamic `javascriptFunction` (a handler function) or a JSON `blob`.
|
|
145
|
+
|
|
146
|
+
Here is an example flow of creating a REST Mock Configuration from a `RestEndpoint` object:
|
|
71
147
|
|
|
72
148
|
**Example: Test Assert Scenario (REST)**
|
|
73
149
|
```javascript
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
150
|
+
// Define a REST parameter
|
|
151
|
+
const param = new RestParam('echo', 'path', 'string', 'echo_param');
|
|
152
|
+
|
|
153
|
+
// Define a REST request
|
|
154
|
+
const request = new RequestValue({
|
|
155
|
+
name: 'echo-post',
|
|
156
|
+
endpoint: echoEndpoint,
|
|
157
|
+
methodType: 'POST',
|
|
158
|
+
params: [param],
|
|
159
|
+
blob: '{ "v": "echo test" }'
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Create a Scenario for testing
|
|
163
|
+
const scenario = new Scenario('payment-assert-test');
|
|
164
|
+
|
|
165
|
+
// Add the REST request to the scenario
|
|
166
|
+
const step1 = scenario.addRequestV1(request);
|
|
167
|
+
|
|
168
|
+
// Define global headers
|
|
169
|
+
const globalHeaders = {'Authorization': 'Bearer 1234567890'};
|
|
170
|
+
|
|
171
|
+
// Start the test scenario
|
|
172
|
+
skyrampClient.testerStartV1('my-namespace', '', scenario, 'test', globalHeaders ).then(() => {
|
|
78
173
|
// Test scenario started
|
|
79
|
-
}).catch(
|
|
174
|
+
}).catch((error) => {
|
|
80
175
|
// Error occurred during the test scenario
|
|
81
176
|
});
|
|
82
177
|
```
|
|
83
178
|
|
|
84
179
|
**Example: Test Assert Scenario (gRPC)**
|
|
85
180
|
```javascript
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
181
|
+
// Define handler for gRPC mock response
|
|
182
|
+
function handler(req) {
|
|
183
|
+
return {
|
|
184
|
+
value: {
|
|
185
|
+
name: 'name'
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Define gRPC request value
|
|
191
|
+
const grpcRequest = new RequestValue({
|
|
192
|
+
name: 'SayHello',
|
|
193
|
+
endpoint: dynamicGrpcEndpoint,
|
|
194
|
+
methodName: 'SayHello',
|
|
195
|
+
javascriptFunction: handler.toString()
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Create a Scenario for gRPC testing
|
|
199
|
+
const grpcScenario = new Scenario('routeguide-assert-test');
|
|
200
|
+
|
|
201
|
+
// Add the gRPC request to the scenario
|
|
202
|
+
const step1 = grpcScenario.addRequestV1(grpcRequest);
|
|
203
|
+
|
|
204
|
+
// Add an assertion to the scenario
|
|
205
|
+
const step2 = grpcScenario.addAssertEqual(`${step1}.res.message`, 'mock');
|
|
206
|
+
|
|
207
|
+
// Define global headers for gRPC testing
|
|
208
|
+
const grpcGlobalHeaders = {'Authorization': 'Bearer 1234567890'};
|
|
209
|
+
|
|
210
|
+
// Start the gRPC test scenario
|
|
211
|
+
skyrampClient.testerStartV1('my-namespace', '', grpcScenario, 'test', grpcGlobalHeaders ).then(() => {
|
|
90
212
|
// Test scenario started
|
|
91
|
-
}).catch(
|
|
213
|
+
}).catch((error) => {
|
|
92
214
|
// Error occurred during the test scenario
|
|
93
215
|
});
|
|
94
216
|
```
|
|
217
|
+
|
|
218
|
+
## Reference
|
|
219
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
220
|
+
|
|
221
|
+
### Table of Contents
|
|
222
|
+
|
|
223
|
+
* [DelayConfig][1]
|
|
224
|
+
* [Parameters][2]
|
|
225
|
+
* [Endpoint][3]
|
|
226
|
+
* [Parameters][4]
|
|
227
|
+
* [GrpcEndpoint][5]
|
|
228
|
+
* [Parameters][6]
|
|
229
|
+
* [RequestValueOptions][7]
|
|
230
|
+
* [Properties][8]
|
|
231
|
+
* [RequestValue][9]
|
|
232
|
+
* [Parameters][10]
|
|
233
|
+
* [ResponseValueOptions][11]
|
|
234
|
+
* [Properties][12]
|
|
235
|
+
* [ResponseValue][13]
|
|
236
|
+
* [Parameters][14]
|
|
237
|
+
* [RestEndpoint][15]
|
|
238
|
+
* [Parameters][16]
|
|
239
|
+
* [RestParam][17]
|
|
240
|
+
* [Parameters][18]
|
|
241
|
+
* [Scenario][19]
|
|
242
|
+
* [Parameters][20]
|
|
243
|
+
* [addRequestV1][21]
|
|
244
|
+
* [Parameters][22]
|
|
245
|
+
* [addAssertEqual][23]
|
|
246
|
+
* [Parameters][24]
|
|
247
|
+
* [SkyrampClient][25]
|
|
248
|
+
* [applyLocal][26]
|
|
249
|
+
* [addKubeConfig][27]
|
|
250
|
+
* [Parameters][28]
|
|
251
|
+
* [removeLocal][29]
|
|
252
|
+
* [removeCluster][30]
|
|
253
|
+
* [Parameters][31]
|
|
254
|
+
* [deploySkyrampWorker][32]
|
|
255
|
+
* [Parameters][33]
|
|
256
|
+
* [deleteSkyrampWorker][34]
|
|
257
|
+
* [Parameters][35]
|
|
258
|
+
* [runDockerSkyrampWorker][36]
|
|
259
|
+
* [Parameters][37]
|
|
260
|
+
* [removeDockerSkyrampWorker][38]
|
|
261
|
+
* [Parameters][39]
|
|
262
|
+
* [mockerApplyV1][40]
|
|
263
|
+
* [Parameters][41]
|
|
264
|
+
* [testerStartV1][42]
|
|
265
|
+
* [Parameters][43]
|
|
266
|
+
* [TrafficConfig][44]
|
|
267
|
+
* [Parameters][45]
|
|
268
|
+
|
|
269
|
+
## DelayConfig
|
|
270
|
+
|
|
271
|
+
The `DelayConfig` class represents a configuration for delay values.
|
|
272
|
+
|
|
273
|
+
### Parameters
|
|
274
|
+
|
|
275
|
+
* `minDelay` **[number][46]** The minimum delay value.
|
|
276
|
+
* `maxDelay` **[number][46]** The maximum delay value.
|
|
277
|
+
|
|
278
|
+
## Endpoint
|
|
279
|
+
|
|
280
|
+
The `Endpoint` class represents an endpoint object to manage endpoint data and generate mock configurations.
|
|
281
|
+
|
|
282
|
+
### Parameters
|
|
283
|
+
|
|
284
|
+
* `endpointData` **[string][47]** The endpoint data in JSON format.
|
|
285
|
+
* `endpointAddress` **[string][47]** The address of the endpoint.
|
|
286
|
+
|
|
287
|
+
## GrpcEndpoint
|
|
288
|
+
|
|
289
|
+
**Extends Endpoint**
|
|
290
|
+
|
|
291
|
+
The `GrpcEndpoint` class represents a gRPC API Endpoint.
|
|
292
|
+
|
|
293
|
+
### Parameters
|
|
294
|
+
|
|
295
|
+
* `name` **[string][47]** The name of the endpoint.
|
|
296
|
+
* `service` **[string][47]** The name of the service.
|
|
297
|
+
* `port` **[number][46]** The port number.
|
|
298
|
+
* `pbFile` **[string][47]** The protocol buffer file containing the API schema definition.
|
|
299
|
+
* `endpointAddress` **[string][47]** The endpoint address.
|
|
300
|
+
|
|
301
|
+
## RequestValueOptions
|
|
302
|
+
|
|
303
|
+
Type: [Object][48]
|
|
304
|
+
|
|
305
|
+
### Properties
|
|
306
|
+
|
|
307
|
+
* `name` **[string][47]** The name of the request.
|
|
308
|
+
* `endpoint` **[Object][48]** The descriptor for the endpoint of the request.
|
|
309
|
+
* `methodType` **[string][47]** The type of HTTP method for the request.
|
|
310
|
+
* `methodName` **[string][47]** The name of the method for the request.
|
|
311
|
+
* `params` **[Object][48]** The parameters for the request.
|
|
312
|
+
* `headers` **[Object][48]** The headers for the request.
|
|
313
|
+
* `vars` **[Object][48]** The variables for the request.
|
|
314
|
+
* `blob` **[Object][48]** The blob data for the request.
|
|
315
|
+
* `javascriptPath` **[string][47]** The path to the JavaScript file for the request.
|
|
316
|
+
* `javascriptFunction` **[string][47]** The JavaScript function for the request.
|
|
317
|
+
|
|
318
|
+
## RequestValue
|
|
319
|
+
|
|
320
|
+
The `RequestValue` class represents a request value to use for testing API endpoint methods.
|
|
321
|
+
|
|
322
|
+
### Parameters
|
|
323
|
+
|
|
324
|
+
* `options` **[RequestValueOptions][7]** The options for initializing the RequestValue object.
|
|
325
|
+
|
|
326
|
+
## ResponseValueOptions
|
|
327
|
+
|
|
328
|
+
Type: [Object][48]
|
|
329
|
+
|
|
330
|
+
### Properties
|
|
331
|
+
|
|
332
|
+
* `name` **[string][47]** The name of the response value.
|
|
333
|
+
* `endpoint` **[Object][48]** The descriptor of the endpoint associated with the response.
|
|
334
|
+
* `methodType` **[string][47]** The type of the HTTP method used for the response.
|
|
335
|
+
* `methodName` **[string][47]** The name of the method used for the response.
|
|
336
|
+
* `params` **[Object][48]** The parameters of the response.
|
|
337
|
+
* `headers` **[Object][48]** The headers of the response.
|
|
338
|
+
* `vars` **[Object][48]** The variables of the response.
|
|
339
|
+
* `blob` **[string][47]** The blob data of the response.
|
|
340
|
+
* `javascriptPath` **[string][47]** The path to the JavaScript file associated with the response.
|
|
341
|
+
* `javascriptFunction` **[string][47]** The JavaScript function associated with the response.
|
|
342
|
+
|
|
343
|
+
## ResponseValue
|
|
344
|
+
|
|
345
|
+
The `ResponseValue` class represents a response value to use for mocking API endpoint methods.
|
|
346
|
+
|
|
347
|
+
### Parameters
|
|
348
|
+
|
|
349
|
+
* `options` **[ResponseValueOptions][11]** The options for initializing the ResponseValue object.
|
|
350
|
+
|
|
351
|
+
## RestEndpoint
|
|
352
|
+
|
|
353
|
+
**Extends Endpoint**
|
|
354
|
+
|
|
355
|
+
The `RestEndpoint` class represents a REST API Endpoint.
|
|
356
|
+
|
|
357
|
+
### Parameters
|
|
358
|
+
|
|
359
|
+
* `args` **...any** The arguments to create the REST endpoint.
|
|
360
|
+
|
|
361
|
+
## RestParam
|
|
362
|
+
|
|
363
|
+
The `RestParam` class represents a REST (query, path, etc) param.
|
|
364
|
+
|
|
365
|
+
### Parameters
|
|
366
|
+
|
|
367
|
+
* `name` **[string][47]** The name of the parameter.
|
|
368
|
+
* `in_` **[string][47]** The location of the parameter (e.g., 'query', 'header', 'path').
|
|
369
|
+
* `type_` **[string][47]** The data type of the parameter.
|
|
370
|
+
* `value` **any** The value of the parameter.
|
|
371
|
+
|
|
372
|
+
## Scenario
|
|
373
|
+
|
|
374
|
+
The `Scenario` class allows you to define test scenarios by adding requests and asserts.
|
|
375
|
+
|
|
376
|
+
### Parameters
|
|
377
|
+
|
|
378
|
+
* `name` **[string][47]** The name of the scenario.
|
|
379
|
+
|
|
380
|
+
### addRequestV1
|
|
381
|
+
|
|
382
|
+
Adds a request to the scenario and updates the list of services and endpoints.
|
|
383
|
+
|
|
384
|
+
#### Parameters
|
|
385
|
+
|
|
386
|
+
* `request` **[Request][49]** The request to add to the scenario.
|
|
387
|
+
|
|
388
|
+
Returns **[string][47]** The name of the added request.
|
|
389
|
+
|
|
390
|
+
### addAssertEqual
|
|
391
|
+
|
|
392
|
+
Adds an assertion to the scenario that checks if the value of value1 is equal to value2.
|
|
393
|
+
|
|
394
|
+
#### Parameters
|
|
395
|
+
|
|
396
|
+
* `value1` **[string][47]** The first value to compare.
|
|
397
|
+
* `value2` **[string][47]** The second value to compare.
|
|
398
|
+
|
|
399
|
+
Returns **[string][47]** The assertion string.
|
|
400
|
+
|
|
401
|
+
## SkyrampClient
|
|
402
|
+
|
|
403
|
+
The `SkyrampClient` class is the main client that provides methods for interacting with the Skyramp service.
|
|
404
|
+
It allows users to manage Kubernetes clusters, deploy and delete workers and targets, apply mock descriptions, and start tests.
|
|
405
|
+
|
|
406
|
+
### applyLocal
|
|
407
|
+
|
|
408
|
+
Applies local changes to the Kubernetes cluster configuration.
|
|
409
|
+
|
|
410
|
+
Returns **[Promise][50]** A promise that resolves when the local changes are successfully applied, or rejects with an error if any error occurs.
|
|
411
|
+
|
|
412
|
+
### addKubeConfig
|
|
413
|
+
|
|
414
|
+
Adds a Kubernetes configuration to the SkyrampClient object.
|
|
415
|
+
|
|
416
|
+
#### Parameters
|
|
417
|
+
|
|
418
|
+
* `context` **[string][47]** The context of the Kubernetes configuration.
|
|
419
|
+
* `clusterName` **[string][47]** The name of the Kubernetes cluster.
|
|
420
|
+
* `kubeConfigPath` **[string][47]** The path to the kubeconfig file.
|
|
421
|
+
|
|
422
|
+
Returns **[Promise][50]** A Promise that resolves if the operation is successful or rejects with an error if an error occurs.
|
|
423
|
+
|
|
424
|
+
### removeLocal
|
|
425
|
+
|
|
426
|
+
Removes the local configuration of the SkyrampClient.
|
|
427
|
+
|
|
428
|
+
Returns **[Promise][50]\<void>** A promise that resolves when the removal is successful, or rejects with an error if an error occurs during the removal process.
|
|
429
|
+
|
|
430
|
+
### removeCluster
|
|
431
|
+
|
|
432
|
+
Asynchronously removes a cluster from the configuration.
|
|
433
|
+
|
|
434
|
+
#### Parameters
|
|
435
|
+
|
|
436
|
+
* `clusterName` **[string][47]** The name of the cluster to be removed from the configuration.
|
|
437
|
+
|
|
438
|
+
Returns **[Promise][50]** A Promise that resolves if the cluster is successfully removed, or rejects with an error if the removal fails.
|
|
439
|
+
|
|
440
|
+
### deploySkyrampWorker
|
|
441
|
+
|
|
442
|
+
Deploys a worker to a Kubernetes cluster.
|
|
443
|
+
|
|
444
|
+
#### Parameters
|
|
445
|
+
|
|
446
|
+
* `namespace` **[string][47]** The namespace where the worker will be deployed.
|
|
447
|
+
* `workerImage` **[string][47]** The image of the worker to be deployed. (optional, default `''`)
|
|
448
|
+
* `localImage` **[boolean][51]** Indicates whether the worker image is local or not. (optional, default `false`)
|
|
449
|
+
|
|
450
|
+
<!---->
|
|
451
|
+
|
|
452
|
+
* Throws **[Error][52]** If there is no cluster to deploy the worker to.
|
|
453
|
+
|
|
454
|
+
Returns **[Promise][50]** A Promise that resolves if deployment is successful, and rejects with an error if any error occurs during deployment.
|
|
455
|
+
|
|
456
|
+
### deleteSkyrampWorker
|
|
457
|
+
|
|
458
|
+
Deletes a worker from a specified namespace in the SkyrampClient class.
|
|
459
|
+
|
|
460
|
+
#### Parameters
|
|
461
|
+
|
|
462
|
+
* `namespace` **[string][47]** The namespace from which the worker should be deleted.
|
|
463
|
+
|
|
464
|
+
<!---->
|
|
465
|
+
|
|
466
|
+
* Throws **[Error][52]** If there is no cluster to delete the worker from or if there is no worker to delete from the specified namespace.
|
|
467
|
+
|
|
468
|
+
Returns **[Promise][50]** A promise that resolves with no value upon successful deletion.
|
|
469
|
+
|
|
470
|
+
### runDockerSkyrampWorker
|
|
471
|
+
|
|
472
|
+
Asynchronous method that runs a Docker worker using the provided image, tag, port, and network name.
|
|
473
|
+
|
|
474
|
+
#### Parameters
|
|
475
|
+
|
|
476
|
+
* `workerImage` **[string][47]** The URL of the Docker worker image. (optional, default `WORKER_URL`)
|
|
477
|
+
* `workerTag` **[string][47]** The tag of the Docker worker image. (optional, default `WORKER_TAG`)
|
|
478
|
+
* `hostPost` (optional, default `CONTAINER_PORT`)
|
|
479
|
+
* `targetNetworkName` **[string][47]** The name of the network to connect the Docker worker to. (optional, default `""`)
|
|
480
|
+
* `hostPort` **[number][46]** The port on the host machine to expose for the Docker worker. (optional, default `CONTAINER_PORT`)
|
|
481
|
+
|
|
482
|
+
Returns **[Promise][50]** A Promise that resolves if the Docker worker starts successfully and rejects if there is an error starting the worker.
|
|
483
|
+
|
|
484
|
+
### removeDockerSkyrampWorker
|
|
485
|
+
|
|
486
|
+
Asynchronous method that removes a Docker container running the Skyramp worker.
|
|
487
|
+
|
|
488
|
+
#### Parameters
|
|
489
|
+
|
|
490
|
+
* `containerName` **[string][47]** The name of the Docker container to be removed.
|
|
491
|
+
|
|
492
|
+
<!---->
|
|
493
|
+
|
|
494
|
+
* Throws **[Error][52]** If an error occurs during the removal process.
|
|
495
|
+
* Throws **[Error][52]** If a non-empty response is received.
|
|
496
|
+
|
|
497
|
+
Returns **[Promise][50]** A promise that resolves when the container is successfully removed.
|
|
498
|
+
|
|
499
|
+
### mockerApplyV1
|
|
500
|
+
|
|
501
|
+
Applies a mock description to a specified namespace and address.
|
|
502
|
+
|
|
503
|
+
#### Parameters
|
|
504
|
+
|
|
505
|
+
* `namespace` **[string][47]** The namespace where the mock description will be applied.
|
|
506
|
+
* `address` **[string][47]** The address to which the mock description will be applied.
|
|
507
|
+
* `response` **[object][48]** The details of the mock response.
|
|
508
|
+
* `trafficConfig` **[object][48]** The traffic configuration parameters.
|
|
509
|
+
|
|
510
|
+
Returns **[Promise][50]** A Promise that resolves when the mock description is successfully applied.
|
|
511
|
+
|
|
512
|
+
### testerStartV1
|
|
513
|
+
|
|
514
|
+
Starts a test scenario in a specified namespace.
|
|
515
|
+
|
|
516
|
+
#### Parameters
|
|
517
|
+
|
|
518
|
+
* `namespace` **[string][47]** The namespace in which to start the test scenario.
|
|
519
|
+
* `address` **[string][47]** The address of the target service to test.
|
|
520
|
+
* `scenario` **[object][48]** The scenario object that defines the test steps and assertions.
|
|
521
|
+
* `testName` **[string][47]** The name of the test.
|
|
522
|
+
* `globalHeaders` **[object][48]** Optional global headers to be included in the test requests.
|
|
523
|
+
* `generateTestReport` **[boolean][51]** Optional flag to generate a test report. Default is false. (optional, default `false`)
|
|
524
|
+
* `isDockerenv` **[boolean][51]** Optional flag to indicate if the test is running in a Docker environment. Default is false. (optional, default `false`)
|
|
525
|
+
|
|
526
|
+
Returns **[Promise][50]** A promise that resolves when the test scenario is started.
|
|
527
|
+
|
|
528
|
+
## TrafficConfig
|
|
529
|
+
|
|
530
|
+
Represents a configuration for traffic values.
|
|
531
|
+
|
|
532
|
+
### Parameters
|
|
533
|
+
|
|
534
|
+
* `lossPercentage` **[number][46]** The loss percentage for traffic configuration.
|
|
535
|
+
* `delayConfig` **[DelayConfig][1]** The delay configuration for traffic. It is an optional field and can be set using an instance of the DelayConfig class.
|
|
536
|
+
|
|
537
|
+
[1]: #delayconfig
|
|
538
|
+
|
|
539
|
+
[2]: #parameters
|
|
540
|
+
|
|
541
|
+
[3]: #endpoint
|
|
542
|
+
|
|
543
|
+
[4]: #parameters-1
|
|
544
|
+
|
|
545
|
+
[5]: #grpcendpoint
|
|
546
|
+
|
|
547
|
+
[6]: #parameters-2
|
|
548
|
+
|
|
549
|
+
[7]: #requestvalueoptions
|
|
550
|
+
|
|
551
|
+
[8]: #properties
|
|
552
|
+
|
|
553
|
+
[9]: #requestvalue
|
|
554
|
+
|
|
555
|
+
[10]: #parameters-3
|
|
556
|
+
|
|
557
|
+
[11]: #responsevalueoptions
|
|
558
|
+
|
|
559
|
+
[12]: #properties-1
|
|
560
|
+
|
|
561
|
+
[13]: #responsevalue
|
|
562
|
+
|
|
563
|
+
[14]: #parameters-4
|
|
564
|
+
|
|
565
|
+
[15]: #restendpoint
|
|
566
|
+
|
|
567
|
+
[16]: #parameters-5
|
|
568
|
+
|
|
569
|
+
[17]: #restparam
|
|
570
|
+
|
|
571
|
+
[18]: #parameters-6
|
|
572
|
+
|
|
573
|
+
[19]: #scenario
|
|
574
|
+
|
|
575
|
+
[20]: #parameters-7
|
|
576
|
+
|
|
577
|
+
[21]: #addrequestv1
|
|
578
|
+
|
|
579
|
+
[22]: #parameters-8
|
|
580
|
+
|
|
581
|
+
[23]: #addassertequal
|
|
582
|
+
|
|
583
|
+
[24]: #parameters-9
|
|
584
|
+
|
|
585
|
+
[25]: #skyrampclient
|
|
586
|
+
|
|
587
|
+
[26]: #applylocal
|
|
588
|
+
|
|
589
|
+
[27]: #addkubeconfig
|
|
590
|
+
|
|
591
|
+
[28]: #parameters-10
|
|
592
|
+
|
|
593
|
+
[29]: #removelocal
|
|
594
|
+
|
|
595
|
+
[30]: #removecluster
|
|
596
|
+
|
|
597
|
+
[31]: #parameters-11
|
|
598
|
+
|
|
599
|
+
[32]: #deployskyrampworker
|
|
600
|
+
|
|
601
|
+
[33]: #parameters-12
|
|
602
|
+
|
|
603
|
+
[34]: #deleteskyrampworker
|
|
604
|
+
|
|
605
|
+
[35]: #parameters-13
|
|
606
|
+
|
|
607
|
+
[36]: #rundockerskyrampworker
|
|
608
|
+
|
|
609
|
+
[37]: #parameters-14
|
|
610
|
+
|
|
611
|
+
[38]: #removedockerskyrampworker
|
|
612
|
+
|
|
613
|
+
[39]: #parameters-15
|
|
614
|
+
|
|
615
|
+
[40]: #mockerapplyv1
|
|
616
|
+
|
|
617
|
+
[41]: #parameters-16
|
|
618
|
+
|
|
619
|
+
[42]: #testerstartv1
|
|
620
|
+
|
|
621
|
+
[43]: #parameters-17
|
|
622
|
+
|
|
623
|
+
[44]: #trafficconfig
|
|
624
|
+
|
|
625
|
+
[45]: #parameters-18
|
|
626
|
+
|
|
627
|
+
[46]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
628
|
+
|
|
629
|
+
[47]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
630
|
+
|
|
631
|
+
[48]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
632
|
+
|
|
633
|
+
[49]: https://developer.mozilla.org/Add-ons/SDK/High-Level_APIs/request
|
|
634
|
+
|
|
635
|
+
[50]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
636
|
+
|
|
637
|
+
[51]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
638
|
+
|
|
639
|
+
[52]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
|
Binary file
|
package/lib/dev-darwin-amd64.h
CHANGED
|
@@ -35,6 +35,11 @@ struct credential_response {
|
|
|
35
35
|
char *error;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
struct worker_info {
|
|
39
|
+
char *container_name;
|
|
40
|
+
char *error;
|
|
41
|
+
};
|
|
42
|
+
|
|
38
43
|
#line 1 "cgo-generated-wrapper"
|
|
39
44
|
|
|
40
45
|
|
|
@@ -110,6 +115,8 @@ extern char* registerUserWrapper(char* provider, char* email, char* code);
|
|
|
110
115
|
extern struct oauthresponse runOAuthLoopback(char* provider, GoInt port);
|
|
111
116
|
extern char* validateTokenWrapper(char* userToken);
|
|
112
117
|
extern char* generateUserTokenWrapper(char* provider, char* email, char* oauthToken);
|
|
118
|
+
extern struct worker_info newStartDockerSkyrampWorkerWrapper(char* image, char* tag, GoInt hostPort, char* targetNetworkName);
|
|
119
|
+
extern char* newDeleteDockerSkyrampWorkerWrapper(char* containerName);
|
|
113
120
|
extern char* newGrpcEndpointWrapper(char* name, char* serviceName, GoInt port, char* inputFile);
|
|
114
121
|
extern char* newRestEndpointWrapper(char* name, char* openApiTag, GoInt port, char* inputFile);
|
|
115
122
|
extern char* getEndpointWrapper(char* service, GoInt port, char* restPath);
|
|
@@ -120,8 +127,6 @@ extern char* buildRequestsWrapper(char* mockDescription);
|
|
|
120
127
|
extern char* runTesterStartWrapper(char* namespace, char* address, char* testDescription, GoUint8 generateResult);
|
|
121
128
|
extern char* runTesterStartWrapperWithGlobalHeaders(char* namespace, char* address, char* testDescription, char* testName, char* globalJsonHeaders, GoUint8 generateResult, GoUint8 isDockerEnv);
|
|
122
129
|
extern char* runTesterStatusWrapper(char* namespace, char* address);
|
|
123
|
-
extern char* newStartDockerSkyrampWorkerWrapper(char* image, char* tag, GoInt hostPort, char* targetNetworkName);
|
|
124
|
-
extern char* newDeleteDockerSkyrampWorkerWrapper();
|
|
125
130
|
|
|
126
131
|
#ifdef __cplusplus
|
|
127
132
|
}
|
|
Binary file
|