Skip to content

Commit f54207c

Browse files
authored
Use duration strings in disruptor api (#1137)
* Document duration parameters as strings Signed-off-by: Pablo Chacin <[email protected]>
1 parent b6e8621 commit f54207c

File tree

12 files changed

+99
-100
lines changed

12 files changed

+99
-100
lines changed

src/data/markdown/docs/40 xk6-disruptor/03 API/01 Faults/01 Grpc.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ A gRPC Fault describes the characteristics of the faults to be injected in the g
77

88
A gRPC fault is described by the following attributes:
99

10-
| Attribute | Description |
11-
| --------- | ------------|
12-
| averageDelay | average delay added to requests in milliseconds (default `0ms`) |
13-
| delayVariation| variation in the injected delay in milliseconds (default `0ms`) |
14-
| statusMessage | message to be returned when an error is injected |
15-
| statusCode | status to be returned when an error is injected |
16-
| errorRate | rate of requests that will return an error, represented as a float in the range `0.0` to `1.0` (default `0.0`) |
17-
| exclude | comma-separated list of services to be excluded from disruption |
18-
| port | port on which the requests will be intercepted |
10+
| Attribute | Type | Description |
11+
| -------------- | ------ | -------|
12+
| averageDelay | string | average delay added to requests represented as a string (default `0`) |
13+
| delayVariation | string | variation in the injected delay (default `0`) |
14+
| statusMessage | string | message to be returned when an error is injected |
15+
| statusCode | number | status to be returned when an error is injected |
16+
| errorRate | number | rate of requests that will return an error, represented as a float in the range `0.0` to `1.0` (default `0.0`) |
17+
| exclude | string | comma-separated list of services to be excluded from disruption |
18+
| port | number | port on which the requests will be intercepted |
1919

2020
<Blockquote mod="note">
2121

@@ -29,7 +29,7 @@ This example defines a gRPC fault that introduces a delay of `50ms` in all reque
2929

3030
```javascript
3131
const fault = {
32-
averageDelay: 50,
32+
averageDelay: '50ms',
3333
statusCode: 10,
3434
errorRate: 0.1,
3535
};

src/data/markdown/docs/40 xk6-disruptor/03 API/01 Faults/02 HTTP .md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ A HTTP Fault describes the characteristics of the faults to be injected in the H
77

88
A HTTP fault is described by the following attributes:
99

10-
| Attribute | Description |
11-
| --------- | ------------|
12-
| averageDelay | average delay added to requests in milliseconds (default `0ms`) |
13-
| delayVariation| variation in the injected delay in milliseconds (default `0ms`) |
14-
| errorBody | body to be returned when an error is injected |
15-
| errorCode | error code to return |
16-
| errorRate | rate of requests that will return an error, represented as a float in the range `0.0` to `1.0` (default `0.0`) |
17-
| exclude | comma-separated list of urls to be excluded from disruption (e.g. /health) |
18-
| port | port on which the requests will be intercepted |
10+
| Attribute | Type | Description |
11+
| ------------- | ------ | --------|
12+
| averageDelay | string | average delay added to requests represented as a string (default `0`) |
13+
| delayVariation| string | variation in the injected delay (default `0`) |
14+
| errorBody | string | body to be returned when an error is injected |
15+
| errorCode | number | error code to return |
16+
| errorRate | number | rate of requests that will return an error, represented as a float in the range `0.0` to `1.0` (default `0.0`) |
17+
| exclude | string | comma-separated list of urls to be excluded from disruption (e.g. /health) |
18+
| port | number | port on which the requests will be intercepted |
1919

2020
<Blockquote mod="note">
2121

@@ -29,7 +29,7 @@ This example defines a HTTP fault that introduces a delay of `50ms` in all reque
2929

3030
```javascript
3131
const fault = {
32-
averageDelay: 50,
32+
averageDelay: '50ms',
3333
errorCde: 500,
3434
errorRate: 0.1,
3535
};

src/data/markdown/docs/40 xk6-disruptor/03 API/02 PodDisruptor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const selector = {
3636
};
3737

3838
const fault = {
39-
averageDelay: 100,
39+
averageDelay: '100ms',
4040
errorRate: 0.1,
4141
errorCode: 500,
4242
};
@@ -48,7 +48,7 @@ export default function () {
4848
throw new Error('expected list to have one target');
4949
}
5050

51-
disruptor.injectHTTPFaults(fault, 30);
51+
disruptor.injectHTTPFaults(fault, '30s');
5252
}
5353
```
5454

src/data/markdown/docs/40 xk6-disruptor/03 API/02 PodDisruptor/01 Constructor.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ excerpt: 'xk6-disruptor: PodDisruptor constructor'
77
The `PodDisruptor()` constructor creates a new instance of a [PodDisruptor](/javascript-api/xk6-disruptor/api/poddisruptor) class.
88

99

10-
| Parameter | Description |
11-
| --------- | ----------- |
12-
| [selector](#selector) | criteria for selecting the target pods |
13-
| [options](#options) | options for controlling the behavior of the disruptor |
10+
| Parameter | Type | Description |
11+
| --------- | -----| ------ |
12+
| selector | object | [criteria](#selector) for selecting the target pods |
13+
| options (optional) | object | [options](#options) for controlling the behavior of the disruptor |
1414

1515
### Selector
1616

1717
The `selector` defines the criteria a pod must satisfy to be a valid target:
1818

19-
| Attribute | Description |
20-
| --------- | ----------- |
21-
| namespace | namespace the selector will look for pods |
22-
| select | [attributes](#pod-attributes) that a pod must match to be selected |
23-
| exclude | [attributes](#pod-attributes) that exclude a pod (even if it matches the select attributes) |
19+
| Attribute | Type | Description |
20+
| --------- | -----|------------ |
21+
| namespace | string | namespace the selector will look for pods |
22+
| select | object | [attributes](#pod-attributes) that a pod must match to be selected |
23+
| exclude | object | [attributes](#pod-attributes) that exclude a pod (even if it matches the select attributes) |
2424

2525
You can use the following attributes to select or exclude pods:
2626

2727
### Pod attributes
2828

29-
| Attribute | Description |
30-
| --------- | ----------- |
31-
| labels | map with the labels to be matched for selection or exclusion |
29+
| Attribute | Type | Description |
30+
| --------- | -------| ----------- |
31+
| labels | object | map with the labels to be matched for selection or exclusion |
3232

3333
### Options
3434

3535
The `options` control the creation and behavior of the `PodDisruptor`:
3636

37-
| Attribute | Description |
38-
| --------- | ----------- |
39-
| injectTimeout | maximum time to wait for the disruptor to be ready in the target pods, in seconds (default 30s). Zero value forces default. Negative values force no waiting. |
37+
| Attribute | Type | Description |
38+
| --------- | -----|------ |
39+
| injectTimeout | string | maximum time to wait for the disruptor to be ready in the target pods (default 30s) |
4040

4141
## Example
4242

src/data/markdown/docs/40 xk6-disruptor/03 API/02 PodDisruptor/02 injectGrpcFaults.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ excerpt: 'xk6-disruptor: PodDisruptor.injectGrpcFaults method'
55

66
injectGrpcFaults injects gRPC faults in the requests served by a target Pod.
77

8-
| Parameter | Description |
9-
| ---------- | ----------- |
10-
| fault | description of the [gRPC faults](/javascript-api/xk6-disruptor/api/faults/grpc) to be injected |
11-
| duration | duration of the disruption in seconds |
12-
| [options](#options) | options that control the injection of the fault |
8+
| Parameter | Type | Description |
9+
| --------- | ------ |------- |
10+
| fault | object | description of the [gRPC faults](/javascript-api/xk6-disruptor/api/faults/grpc) to be injected |
11+
| duration | string | duration of the disruption |
12+
| options (optional) | object | [options](#options) that control the injection of the fault |
1313

1414

1515
## options
1616

1717
The injection of the fault is controlled by the following options:
1818

19-
| Option | Description |
20-
| ------ | ----------- |
21-
| proxyPort | port the agent will use to listen for requests in the target pods ( default `8080`) |
22-
| iface | network interface where the agent will capture the traffic ( default `eth0`) |
19+
| Option | Type | Description |
20+
| --------- | ------ | -------- |
21+
| proxyPort | number | port the agent will use to listen for requests in the target pods ( default `8080`) |
22+
| iface | string | network interface where the agent will capture the traffic ( default `eth0`) |
2323

2424

2525
## Example
@@ -28,9 +28,9 @@ The injection of the fault is controlled by the following options:
2828

2929
```javascript
3030
const fault = {
31-
averageDelay: 50,
31+
averageDelay: "50ms",
3232
statusCode: 13,
3333
errorRate: 0.1
3434
}
35-
disruptor.injectGrpcFaults(fault, 30)
35+
disruptor.injectGrpcFaults(fault, "30s")
3636
```

src/data/markdown/docs/40 xk6-disruptor/03 API/02 PodDisruptor/03 injectHTTPFaults.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ excerpt: 'xk6-disruptor: PodDisruptor.injectHTTPFaults method'
55

66
injectHTTPFaults injects HTTP faults in the requests served by a target Pod.
77

8-
| Parameter | Description |
9-
| ---------- | ----------- |
10-
| fault | description of the [http faults](/javascript-api/xk6-disruptor/api/faults/http) to be injected |
11-
| duration | duration of the disruption in seconds |
12-
| [options](#options) | options that control the injection of the fault |
8+
| Parameter | Type | Description |
9+
| --------- | ------ | ------- |
10+
| fault | object | description of the [http faults](/javascript-api/xk6-disruptor/api/faults/http) to be injected |
11+
| duration | string | duration of the disruption |
12+
| options (optional) | object | [options](#options) that control the injection of the fault |
1313

1414

1515
## options
1616

1717
The injection of the fault is controlled by the following options:
1818

19-
| Option | Description |
20-
| ------ | ----------- |
21-
| proxyPort | port the agent will use to listen for requests in the target pods ( default `8080`) |
22-
| iface | network interface where the agent will capture the traffic ( default `eth0`) |
19+
| Option | Type | Description |
20+
| --------- | ------ | -------- |
21+
| proxyPort | number | port the agent will use to listen for requests in the target pods ( default `8080`) |
22+
| iface | string | network interface where the agent will capture the traffic ( default `eth0`) |
2323

2424
<Blockquote mod="note">
2525

@@ -37,9 +37,9 @@ This is normal and means that one request was "in transit" at the time the fault
3737

3838
```javascript
3939
const fault = {
40-
averageDelay: 50,
40+
averageDelay: "50ms",
4141
errorCode: 500,
4242
errorRate: 0.1
4343
}
44-
disruptor.injectHTTPFaults(fault, 30)
44+
disruptor.injectHTTPFaults(fault, "30s")
4545
```

src/data/markdown/docs/40 xk6-disruptor/03 API/03 ServiceDisruptor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following example:
2626
import { ServiceDisruptor } from 'k6/x/disruptor';
2727

2828
const fault = {
29-
averageDelay: 100,
29+
averageDelay: '100ms',
3030
errorRate: 0.1,
3131
errorCode: 500,
3232
};
@@ -38,7 +38,7 @@ export default function () {
3838
throw new Error('expected list to have one target');
3939
}
4040

41-
disruptor.injectHTTPFaults(fault, 30);
41+
disruptor.injectHTTPFaults(fault, '30s');
4242
}
4343
```
4444

src/data/markdown/docs/40 xk6-disruptor/03 API/03 ServiceDisruptor/01 Constructor.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ excerpt: 'xk6-disruptor: ServiceDisruptor constructor'
77
The `ServiceDisruptor()` constructor creates a new instance of a [ServiceDisruptor](/javascript-api/xk6-disruptor/api/servicedisruptor) class.
88

99

10-
| Parameter | Description |
11-
| --------- | ----------- |
12-
| service | name of the service |
13-
| namespace | namespace on which the service is defined |
14-
| [options](#options) | options for controlling the behavior of the disruptor |
10+
| Parameter | Type | Description |
11+
| --------- | ---- | ----------- |
12+
| service | string | name of the service |
13+
| namespace | string | namespace on which the service is defined |
14+
| options (optional) | object | [options](#options) for controlling the behavior of the disruptor |
1515

1616

1717
### Options
1818

1919
The following options control the creation and behavior of the `ServiceDisruptor`:
2020

21-
| Attribute | Description |
22-
| --------- | ----------- |
23-
| injectTimeout | maximum time for waiting the disruptor to be ready in the target pods, in seconds (default 30s). Zero value forces default. Negative values force no waiting. |
21+
| Attribute | Type | Description |
22+
| --------- | ---- |------ |
23+
| injectTimeout | string | maximum time for waiting the disruptor to be ready in the target pods (default 30s) |
2424

2525
## Example
2626

src/data/markdown/docs/40 xk6-disruptor/03 API/03 ServiceDisruptor/02 injectGrpcFaults.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,30 @@ excerpt: 'xk6-disruptor: ServiceDisruptor.injectGrpcFaults method'
55

66
injectGrpcFaults injects gRPC faults in the requests served by a target Service.
77

8-
| Parameters | Description |
9-
| ---------- | ----------- |
10-
| fault | description of the [gRPC faults](/javascript-api/xk6-disruptor/api/faults/grpc) to be injected |
11-
| duration | duration of the disruption in seconds |
12-
| [options](#options) | options that control the injection of the fault |
8+
| Parameters | Type | Description |
9+
| ---------- | ------ | ------- |
10+
| fault | object | description of the [gRPC faults](/javascript-api/xk6-disruptor/api/faults/grpc) to be injected |
11+
| duration | string | duration of the disruption |
12+
| options (optional) | object | [options](#options) that control the injection of the fault |
1313

1414
## Options
1515

1616
The injection of the fault is controlled by the following options:
1717

18-
| Option | Description |
19-
| ------ | ----------- |
20-
| proxyPort | port the agent will use to listen for requests in the target pods ( default `8080`) |
21-
| iface | network interface where the agent will capture the traffic ( default `eth0`) |
22-
18+
| Option | Type | Description |
19+
| --------- | ------ | ------- |
20+
| proxyPort | number | port the agent will use to listen for requests in the target pods ( default `8080`) |
21+
| iface | string | network interface where the agent will capture the traffic ( default `eth0`) |
2322

2423
## Example
2524

2625
<!-- eslint-skip -->
2726

2827
```javascript
2928
const fault = {
30-
averageDelay: 50,
29+
averageDelay: "50ms",
3130
statusCode: 13,
3231
errorRate: 0.1
3332
}
34-
disruptor.injectGrpcFaults(fault, 30)
33+
disruptor.injectGrpcFaults(fault, "30s")
3534
```

src/data/markdown/docs/40 xk6-disruptor/03 API/03 ServiceDisruptor/03 injectHTTPFaults.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ excerpt: 'xk6-disruptor: ServiceDisruptor.injectHTTPFaults method'
55

66
injectHTTPFaults injects HTTP faults in the requests served by a target Service.
77

8-
| Parameters | Description |
9-
| ---------- | ----------- |
10-
| fault | description of the [http faults](/javascript-api/xk6-disruptor/api/faults/http) to be injected |
11-
| duration | duration of the disruption in seconds |
12-
| [options](#options) | options that control the injection of the fault |
8+
| Parameters | Type | Description |
9+
| ---------- | ------ | ----------- |
10+
| fault | object | description of the [http faults](/javascript-api/xk6-disruptor/api/faults/http) to be injected |
11+
| duration | string | duration of the disruption |
12+
| options (optional) | object | [options](#options) that control the injection of the fault |
1313

1414
## Options
1515

1616
The injection of the fault is controlled by the following options:
1717

18-
| Option | Description |
19-
| ------ | ----------- |
20-
| proxyPort | port the agent will use to listen for requests in the target pods ( default `8080`) |
21-
| iface | network interface where the agent will capture the traffic ( default `eth0`) |
18+
| Option | Type | Description |
19+
| --------- | ------ | ----------- |
20+
| proxyPort | number | port the agent will use to listen for requests in the target pods ( default `8080`) |
21+
| iface | string | network interface where the agent will capture the traffic ( default `eth0`) |
2222

2323
<Blockquote mod="note">
2424

@@ -36,9 +36,9 @@ This is normal and means that one request was "in transit" at the time the fault
3636

3737
```javascript
3838
const fault = {
39-
averageDelay: 50,
39+
averageDelay: "50ms",
4040
errorCode: 500,
4141
errorRate: 0.1
4242
}
43-
disruptor.injectHTTPFaults(fault, 30)
43+
disruptor.injectHTTPFaults(fault, "30s")
4444
```

0 commit comments

Comments
 (0)