Skip to content

Commit

Permalink
Document Pod termination fault
Browse files Browse the repository at this point in the history
  • Loading branch information
heitortsergent committed Nov 1, 2023
1 parent 2a1c296 commit e590350
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'Faults'
excerpt: 'xk6-disruptor: Fault Description'
weight: 01
weight: 100
---

# Faults
Expand All @@ -12,3 +12,4 @@ A fault is as an abnormal condition that affects a system component and which ma
| ------------------------------------------------------------------------------------ | ------------------------------------------- |
| [gRPC Fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/grpc) | Fault affecting gRPC requests from a target |
| [HTTP Fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/http) | Fault affecting HTTP requests from a target |
| [Pod Termination Fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/pod-termination) | Fault terminating a number of target Pods |
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: 'Pod Termination'
description: 'xk6-disruptor: Pod Termination Fault attributes'
weight: 03
---

# Pod Termination

A Pod Termination Fault allows terminating either a fixed number or a percentage of the pods that matching a selector or back a service.

A Pod Termination fault is defined by the following attributes:

| Attribute | Type | Description |
| ------------- | ------ | --------|
| count | integer or percentage | the number of pods to be terminated. It can be specified as a integer number or as a percentage (e.g. `30%`) that defines the fraction of target pods to be terminated|

{{% admonition type="note" %}}

If the count is a percentage and there are no enough elements in the target pod list, the number is rounded up.
For example '25%' of a list of 2 target pods will terminate one pod.
If the list of target pods is not empty, at least one pod is always terminated.

{{% /admonition %}}

## Example

This example defines a PorTermination fault that will terminate `30%` of target pods

```javascript
const fault = {
count: '30%'
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: 'Get started'
excerpt: 'xk6-disruptor is an extension that adds fault injection capabilities to k6. Start here to learn the basics and how to use the disruptor'
weight: 01
weight: 01
---

# Get started
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'PodDisruptor'
excerpt: 'xk6-disruptor: PodDisruptor class'
weight: 02
weight: 200
---

# PodDisruptor
Expand All @@ -17,6 +17,7 @@ To construct a `PodDisruptor`, use the [PodDisruptor() constructor](https://graf
| [PodDisruptor.injectGrpcFaults()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/poddisruptor/injectgrpcfaults) | Inject [gRPC faults](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/grpc) in the target Pods |
| [PodDisruptor.injectHTTPFaults()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/poddisruptor/injecthttpfaults) | Inject [HTTP faults](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/http) in the target Pods |
| PodDisruptor.targets() | Returns the list of target Pods of the PodDisruptor |
| [PodDisruptor.terminatePods()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/poddisruptor/terminate-pods) | executes a [Pod Termination fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/pod-termination) in the target Pods |

## Example

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: 'terminatePods()'
description: 'xk6-disruptor: PodDisruptor.terminatePods method'
---

# terminatePods()

`terminatePods` terminates a number of the pods matching the selector configured in the PodDisruptor.

| Parameter | Type | Description |
| --------- | ------ |------- |
| fault | object | description of the [Pod Termination fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/pod-termination) |

## Example

<!-- eslint-skip -->

```javascript
const fault = {
count: 2,
}
disruptor.terminatePods(fault)
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'ServiceDisruptor'
excerpt: 'xk6-disruptor: ServiceDisruptor class'
weight: 03
weight: 300
---

# ServiceDisruptor
Expand All @@ -16,6 +16,8 @@ To construct a `ServiceDisruptor`, use the [ServiceDisruptor() constructor](http
| ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [ServiceDisruptor.injectGrpcFaults()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/servicedisruptor/injectgrpcfaults) | Inject [gRPC faults](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/grpc) in the target Pods |
| [ServiceDisruptor.injectHTTPFaults()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/servicedisruptor/injecthttpfaults) | Inject [HTTTP faults](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/http) in the target Pods |
| ServiceDisruptor.targets() | Returns the list of target Pods of the ServiceDisruptor |
| [ServiceDisruptor.terminatePods()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/servicedisruptor/terminate-pods) | executes a [Pod Termination fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/pod-termination) in the target Pods|

## Example

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: 'terminatePods()'
description: 'xk6-disruptor: ServiceDisruptor.terminatePods method'
---

# terminatePods()

`terminatePods` terminates a number of pods that belong to the service specified in the ServiceDisruptor.

| Parameter | Type | Description |
| --------- | ------ |------- |
| fault | object | description of the [Pod Termination fault](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/xk6-disruptor/faults/pod-termination) |

## Example

<!-- eslint-skip -->

```javascript
const fault = {
count: 2,
}
disruptor.terminatePods(fault)
```

0 comments on commit e590350

Please sign in to comment.