## Introduction
- It can target random pods with a Spring Boot application and allows configuring the assaults to inject multiple spring boot faults simultaneously on the target pod.
- It supports `app-kill`, `cpu-stress`, `memory-stress`, `latency`, and `exceptions` faults
!!! tip "Scenario: Inject Spring Boot Faults"

## Uses
??? info "View the uses of the experiment"
coming soon
## Prerequisites
??? info "Verify the prerequisites"
Variables |
Description |
Notes |
CM_PORT |
It contains port of the spring boot application |
|
CM_KILL_APPLICATION_ACTIVE |
It enable the app-kill faults |
It supports boolean values. Default is false |
CM_LATENCY_ACTIVE |
It enable the latency faults |
It supports boolean values. Default is false |
CM_MEMORY_ACTIVE |
It enable the memory stress faults |
It supports boolean values. Default is false |
CM_CPU_ACTIVE |
It enable the cpu stress faults |
It supports boolean values. Default is false |
CM_EXCEPTIONS_ACTIVE |
It enable the exceptions faults |
It supports boolean values. Default is false |
CPU_LOAD_FRACTION |
It contains fraction of cpu to be stressed, 0.95 equals 95% |
default value is 0.9. It supports value in range [0.1,1.0] |
CM_EXCEPTIONS_TYPE |
It contains type of raised exception |
Defaults value: java.lang.IllegalArgumentException |
CM_EXCEPTIONS_ARGUMENTS |
It contains argument of raised exception |
Defaults value: java.lang.String:custom illegal argument exception |
LATENCY |
It contains network latency to be injected(in ms) |
default value is 2000 |
MEMORY_FILL_FRACTION |
It contains fraction of memory to be stressed, 0.7 equals 70% |
default value is 0.70. It supports value in range [0.01,0.95] |
Variables |
Description |
Notes |
CM_LEVEL |
It contains number of requests are to be attacked, n value means nth request will be affected |
Defaults value: 1, it lies in [1,10000] range |
CM_WATCHED_CUSTOM_SERVICES |
It limits watched packages/classes/methods, it contains comma seperated list of fully qualified packages(class and/or method names) |
ByDefault it is empty list, which means it target all services |
CM_WATCHERS |
It contains comma separated list of watchers from the following watchers list [controller, restController, service, repository, component, webClient] |
ByDefault it is restController |
TOTAL_CHAOS_DURATION |
The time duration for chaos injection (seconds) |
Defaults to 30 |
SEQUENCE |
It defines sequence of chaos execution for multiple target pods |
Default value: parallel. Supported: serial, parallel |
PODS_AFFECTED_PERC |
The Percentage of total pods to target |
Defaults to 0% (corresponds to 1 replica) |
LIB |
The chaos lib used to inject the chaos |
Defaults to litmus . Supported litmus only |
RAMP_TIME |
Period to wait before and after injection of chaos in sec |
|
## Experiment Examples
### Common Experiment Tunables
Refer the [common attributes](../common/common-tunables-for-all-experiments.md) and [Spring Boot specific tunable](spring-boot-experiments-tunables.md) to tune the common tunables for all experiments and spring-boot specific tunables.
### Inject Multiple Faults Simultaneously (CPU, Latency and Exceptions)
It injects cpu, latency, and exceptions faults simultaneously on the target pods
Use the following example to tune this:
[embedmd]:# (./spring-boot-faults/cpu-latency-exceptions-faults.yaml yaml)
```yaml
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: spring-boot-chaos
namespace: default
spec:
appinfo:
appns: 'default'
applabel: 'app=spring-boot'
appkind: 'deployment'
# It can be active/stop
engineState: 'active'
chaosServiceAccount: spring-boot-faults-sa
experiments:
- name: spring-boot-faults
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# port of the spring boot application
- name: CM_PORT
value: '8080'
# it enables spring-boot latency fault
- name: CM_LATENCY_ACTIVE
value: 'true'
# provide the latency (ms)
# it is applicable when latency is active
- name: LATENCY
value: '2000'
# it enables spring-boot cpu stress fault
- name: CM_CPU_ACTIVE
value: 'true'
# it contains fraction of cpu to be stressed(0.95 equals 95%)
# it supports value in range [0.1,1.0]
# it is applicable when cpu is active
- name: CPU_LOAD_FRACTION
value: '0.9'
# it enables spring-boot exceptions fault
- name: CM_EXCEPTIONS_ACTIVE
value: 'true'
# Type of raised exception
# it is applicable when exceptions is active
- name: CM_EXCEPTIONS_TYPE
value: 'java.lang.IllegalArgumentException'
# Argument of raised exception
# it is applicable when exceptions is active
- name: CM_EXCEPTIONS_ARGUMENTS
value: 'java.lang.String:custom illegal argument exception'
## percentage of total pods to target
- name: PODS_AFFECTED_PERC
value: ''
```
### Inject Multiple Faults Simultaneously (Appkill and Memory)
It injects appkill and memory stress faults simultaneously on the target pods
Use the following example to tune this:
[embedmd]:# (./spring-boot-faults/appkill-memory-faults.yaml yaml)
```yaml
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: spring-boot-chaos
namespace: default
spec:
appinfo:
appns: 'default'
applabel: 'app=spring-boot'
appkind: 'deployment'
# It can be active/stop
engineState: 'active'
chaosServiceAccount: spring-boot-faults-sa
experiments:
- name: spring-boot-faults
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# port of the spring boot application
- name: CM_PORT
value: '8080'
# it enables spring app-kill fault
- name: CM_KILL_APPLICATION_ACTIVE
value: 'true'
# it enables spring-boot memory stress fault
- name: CM_MEMORY_ACTIVE
value: ''
# it contains fraction of memory to be stressed(0.70 equals 70%)
# it supports value in range [0.01,0.95]
# it is applicable when memory is active
- name: MEMORY_FILL_FRACTION
value: '0.70'
## percentage of total pods to target
- name: PODS_AFFECTED_PERC
value: ''
```