Skip to content

chaosblade

ash i am edited this page Jun 3, 2019 · 1 revision

chaosblade

项目地址:https://github.com/chaosblade-io/chaosblade

流程简介:https://github.com/chaosblade-io/chaosblade/blob/master/docs/logic_flow_Introduction_CN.md#chaosblade-%E6%B5%81%E7%A8%8B%E7%AE%80%E4%BB%8B

快速开始:https://github.com/chaosblade-io/chaosblade/blob/master/docs/beginner_guide_CN.md

./blade [command]

Available Commands: create Create a chaos engineering experiment destroy Destroy a chaos experiment help Help about any command prepare Prepare to experiment query Query the parameter values required for chaos experiments revoke Undo chaos engineering experiment preparation status Query preparation stage or experiment status version Print version info

Examples:

执行实验

./blade create  [command1] [command2] ... --flag1 --flag2 ...

执行结果返回:

{"code":200,"success":true,"result":"id"}

停止实验

./blade destroy $id 

返回以下结果,表示停止实验成功

{"code":200,"success":true,"result":"command: ..."}

注:活用help或者-h, Commands相同的可以互相参考。

./blade create [command]

Examples:

 dubbo delay --time 3000 --offset 100 --service com.example.Service --consumer

Available Commands:

cpu Cpu experiment disk Disk experiment docker Execute a docker experiment druid Druid experiment dubbo dubbo experiment jvm method k8s Kubernetes experiment mysql mysql experiment network Network experiment process Process experiment script Script chaos experiment servlet java servlet experiment

Cpu experiment

Examples:

./blade create cpu fullload
  • Available Commands: fullload cpu fullload CPU 满载(CPU 使用率 100%)

  • Flags: ​ --cpu-count string Cpu count ​ --cpu-list string CPUs in which to allow burning (0-3 or 1,3)

    ​ --timeout string set timeout for experiment

Disk experiment

Examples:

./blade create disk fill --mount-point / --size 1000

You can execute blade query disk mount-point command to query the mount points查询挂载点

  • Available Commands: burn Burn io by read or write fill Fill the mounted disk
  • Flags: ​ --mount-point string the disk mount point

​ --timeout string set timeout for experiment

​ --size string fill size, unit is MB (required)

​ --mount-point string the disk mount point

burn

blade create disk burn

Flags: ​ --count string File count, default is 1024 ​ --read Burn io by read ​ --write Burn io by writeGlobal

docker experiment

Examples:

Create a remove container experiment

./blade create docker remove --container 1c8986a4f899

Create a docker container full cpu load experiment

./blade create docker cpu fullload --container 1c8986a4f899
  • Available Commands: cpu Cpu experiment disk Disk experiment network Network experiment process Process experiment remove remove a container script Script chaos experiment

  • Flags: ​ --container string container id or name (required)

remove

Flags: ​ --force force remove

Druid experiment

Examples:

./blade create druid connectionpoolfull
  • Available Commands: connectionpoolfull Connection pool full

  • flag:

    --process string Application process name\

dubbo experiment

Examples:

./blade create dubbo delay --time 3000 --consumer --service com.example.service.HelloService
  • Available Commands: delay delay time threadpoolfull Thread pool full throwCustomException throw custom exception
delay

Flags: ​ --appname string The consumer or provider application name ​ --consumer To tag consumer role experiment. ​ --methodname string The method name in service interface ​ --offset string delay offset for the time ​ --process string Application process name ​ --provider To tag provider experiment ​ --service string The service interface ​ --time string delay time (required) ​ --version string the service version

threadpoolfull

Aliases: threadpoolfull, tpf

Flags: -h, --help help for threadpoolfull ​ --process string Application process name ​ --provider To tag provider experiment ​ --timeout string set timeout for experiment

throwCustomException

Aliases: throwCustomException, tce

Flags: ​ --appname string The consumer or provider application name ​ --consumer To tag consumer role experiment. ​ --exception string Exception class inherit java.lang.Exception (required) ​ --methodname string The method name in service interface ​ --process string Application process name ​ --provider To tag provider experiment ​ --service string The service interface ​ --version string the service version

jvm experiment

Examples:

./blade prepare jvm --process tomcat
  • Available Commands: delay delay time outofmemoryerror JVM out of memory return Return the specify value throwCustomException throw custom exception throwDeclaredException Throw the first declared exception of method
  • Flags -p, --process string the java application process name (required)
delay

Flags: ​ --classname string The class name with package ​ --methodname string The method name ​ --offset string delay offset for the time ​ --process string Application process name ​ --time string delay time (required) ​ --timeout string set timeout for experiment

outofmemoryerror

Aliases: outofmemoryerror, oom

Flags: ​ --area string Jvm memory area you want to cause OutOfMemoryError,the options:[HEAP, NOHEAP, OFFHEAP] (required) ​ --enableSystemGc string Invoke System.gc() after stop injection,option value:[true,false],default value is true ​ --process string Application process name ​ --threads string Thread count to make oom error,if you want to speed up the oom.default value is :1 ​ --timeout string set timeout for experiment

return

Return the specify value

Flags: ​ --classname string The class name with package ​ --methodname string The method name ​ --process string Application process name ​ --timeout string set timeout for experiment ​ --value string Value returned, only support primitive type value. If you want return null, set --value null (required)

throwCustomException

Throw custom exception with --exception option

Aliases: throwCustomException, tce

Flags: ​ --classname string The class name with package ​ --exception string Exception class inherit java.lang.Exception (required) -h, --help help for throwCustomException ​ --methodname string The method name ​ --process string Application process name ​ --timeout string set timeout for experiment

throwDeclaredException

Throw the first declared exception of method

Aliases: throwDeclaredException, tde

Flags: ​ --classname string The class name with package ​ --methodname string The method name ​ --process string Application process name ​ --timeout string set timeout for experiment

k8s experiment

Examples:

./blade create k8s delete --pod <podname> --namespace default
  • Available Commands: delete delete pod or container

  • Flags: ​ --deployment string deployment name ​ --kubeconfig string kubeconfig file ​ --namespace string namespace

delete

delete pod by pod name or container by container id

Flags:

​ --force force remove ​ --pod string Pod name ​ --pods string Multiple pod names separated by commas ​ --timeout string set timeout for experiment

Global Flags: ​ --deployment string deployment name ​ --kubeconfig string kubeconfig file ​ --namespace string namespace

mysql experiment

Examples:

./blade create mysql --sqltype select --port 3306
  • Available Commands: delay delay time throwCustomException throw custom exception

network experiment

Examples:

./blade create network delay --interface eth0 --time 3000

You can execute blade query network interface command to query the interfaces

  • Available Commands: delay Delay experiment dns Dns experiment drop Drop experiment loss Loss network package
delay

Flags: ​ --exclude-port string Exclude one local port, for example 22 port. This flag is invalid when --local-port or --remote-port is specified ​ --interface string Network interface, for example, eth0 (required) ​ --local-port string Port for local service ​ --offset string Delay offset time, ms ​ --remote-port string Port for remote service ​ --time string Delay time, ms (required) ​ --timeout string set timeout for experiment

Dns

Flags: ​ --domain string Domain name (required) ​ --ip string Domain ip (required) ​ --timeout string set timeout for experiment

Drop

Drop network data

Flags: ​ --local-port string Port for local service ​ --remote-port string Port for remote service ​ --timeout string set timeout for experiment

Loss

Loss network package

Flags: ​ --exclude-port string Exclude one local port, for example 22 port. This flag is invalid when --local-port or --remote-port is specified ​ --interface string Network interface, for example, eth0 (required) ​ --local-port string Port for local service ​ --percent string loss percent, [0, 100] (required) ​ --remote-port string Port for remote service

process experiment

Examples:

./blade process kill --process tomcat

Available Commands: kill Kill process

Kill process by process id or process name ​ --process string Process name ​ --process-cmd string Process name in command ​ --timeout string set timeout for experiment

script experiment

Examples:

./blade create script delay --time 2000 --file xxx.sh --function-name start
blade create script exit --file xxx.sh --function-name offline --exit-message "error" --exit-code 2
  • Available Commands: delay Script executed delay exit Exit script

  • Flags: ​ --file string Script file full path (required) ​ --function-name string function name in shell (required)

delay

Sleep in script

Flags: ​ --time string sleep time, unit is millisecond (required) ​ --timeout string set timeout for experiment

Global Flags: ​ --file string Script file full path (required) ​ --function-name string function name in shell (required)

exit

Exit script with specify message and code

Flags: ​ --exit-code string Exit code ​ --exit-message string Exit message ​ --timeout string set timeout for experiment

Global Flags: ​ --file string Script file full path (required) ​ --function-name string function name in shell (required)

servlet experiment

Examples:

servlet --pathinfo hello --method post
  • Available Commands:

    delay delay time throwCustomException throw custom exception

./blade destroy

./blade destroy UID

Examples:

./blade  destroy 47cc0744f1bb

./blade prepare

Examples:

./blade prepare jvm --process tomcat

Available Commands: jvm Attach a type agent to the jvm process

-p, --process string the java application process name (required)

./blade query

./blade query TARGET TYPE

Examples:

command to query the interfaces

./blade query network interface

Available Commands: disk Query disk information network Query network information

  • blade query network interface

Query network information for chaos experiments of network

  • blade query disk device

    blade query disk mount-point

./blade revoke

./blade revoke [PREPARE UID]

Examples:

./blade revoke cc015e9bd9c68406

./blade status

./blade revoke [PREPARE UID]

Examples:

./blade status cc015e9bd9c68406
./blade status --type create

Flags:

​ --target string experiment target, for example: dubbo ​ --type string command type, attach|create|destroy|detach ​ --uid string prepare or experiment uid