Linux JVM modify return
Linux JVM modify return modifies the return value of a method in a Java application for a specific duration. It is used to determine the performance and resilience of the application (or services) running on Linux machines.
JVM chaos faults use the Byteman utility to inject chaos faults into the JVM.
Use cases
Linux JVM modify return:
- Helps test the functionality of snippets of code by replacing specific portions of the request or response body to simulate different scenarios and validate how your application handles different data variations.
- Helps obscure or redact personally identifiable information (PII), such as email addresses or phone numbers, before logging or transmitting the data for security and privacy compliance.
- Determines how efficiently an application recovers and returns to normalcy.
- This fault can be executed on Ubuntu 16 or higher, Debian 10 or higher, CentOS 7 or higher, RHEL 7 or higher, Fedora 30 or higher, and openSUSE LEAP 15.4 or higher.
- The
linux-chaos-infrastructure
systemd service should be in an active state, and the infrastructure should be inCONNECTED
state.
Fault permissions
The fault uses the root
Linux user and root
user group.
Mandatory tunables
Tunable | Description | Notes |
---|---|---|
class | Specify as packageName.className that specifies the class in which you define the exception. | For example, org.framework.appName.system.WelcomeController . For more information, go to class name. |
pid | The process ID that Byteman uses to target the service. This is mutually exclusive with Startup command. If startupCommand is specified, pid is specified as 0. | For example, 6429 . For more information, go to process Ids. |
method | The method to which exception is applied. | For example, Welcome . For more information, go to method name. |
return | The modified return value of the method. | For example, "modified string" . For more information, go to return value. |
startupCommand | The command used to start the Java process. A substring match is used with the given command for all processes. This is mutually exclusive with pid. | For example, /usr/local/bin/pet-clinic.jar . For more information, go to startup command. |
Optional tunables
Tunable | Description | Notes |
---|---|---|
duration | Duration through which chaos is injected into the target resource. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. | Default: 30s . Examples: 1m25s , 1h3m2s , 1h3s . For more information, go to duration of the chaos. |
port | Port used by the Byteman agent. | Default: 9091 . |
rampTime | Period to wait before and after injecting chaos. Should be provided in [numeric-hours]h[numeric-minutes]m[numeric-seconds]s format. | Default: 0s . Examples: 1m25s , 1h3m2s , 1h3s . For more information, go to ramp time. |
Class name
The class
input variable targets the class name where the exception is present. Specify it in the format packageName.className
.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-jvm-modify-return
labels:
name: jvm-modify-return
spec:
jvmChaos/inputs:
duration: 30s
port: 9091
pid: 0
class: "org.framework.appName.system.WelcomeController"
method: ""
return: ""
startupCommand: "/usr/bin/pet-clinic.jar"
rampTime: ""
Startup command
The command used to start the Java process. A substring match is used with the given command for all processes. This is mutually exclusive with the pid
input variable.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-jvm-modify-return
labels:
name: jvm-modify-return
spec:
jvmChaos/inputs:
duration: 30s
port: 9091
pid: 0
class: ""
method: ""
return: ""
startupCommand: "/usr/bin/pet-clinic.jar"
rampTime: ""
Method
The method
whose return value you modify.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-jvm-modify-return
labels:
name: jvm-modify-return
spec:
jvmChaos/inputs:
duration: 30s
port: 9091
pid: 0
class: ""
method: "welcome"
return: ""
startupCommand: "/usr/bin/pet-clinic.jar"
rampTime: ""
Pid
The process ID used by Byteman to target the services of the Java application. This is mutually exclusive with the startupCommand
input variable.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-jvm-modify-return
labels:
name: jvm-modify-return
spec:
jvmChaos/inputs:
duration: 30s
port: 9091
pid: 1
class: "org.framework.appName.system.WelcomeController"
method: ""
return: ""
rampTime: ""
Return
The modified return value of the method in the form of a string. Tune it using the return
input variable.
The following YAML snippet illustrates the use of this input variable:
apiVersion: litmuchaos.io/v1alpha1
kind: LinuxFault
metadata:
name: linux-jvm-modify-return
labels:
name: jvm-modify-return
spec:
jvmChaos/inputs:
duration: 30s
port: 9091
pid: 1
class: ""
method: ""
return: "modified value"
startupCommand: ""
rampTime: ""