milvus/tests/python_client/chaos
zhuwenxing 8bb6e47868
[skip ci]Update chaos_test.sh (#12843)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
2021-12-07 14:16:42 +08:00
..
chaos_objects [skip ci] Add etcd memory stress yaml (#11296) 2021-11-05 14:01:18 +08:00
scripts [skip ci]Comment out collection.release() for deploy and chaos test (#12588) 2021-12-02 13:09:44 +08:00
chaos_commons.py [skip ci] Update thread in chaos to daemon (#11392) 2021-11-08 13:01:34 +08:00
chaos_test.sh [skip ci]Update chaos_test.sh (#12843) 2021-12-07 14:16:42 +08:00
checker.py [skip ci]Add load balance test case (#12661) 2021-12-02 22:49:52 +08:00
cluster-values.yaml [skip ci]Fix chaos test (#12031) 2021-11-17 20:31:14 +08:00
constants.py [skip ci]Fix pod failure chaos github action (#10208) 2021-10-19 21:08:44 +08:00
README.md [skip ci]Update doc of chaos test (#11754) 2021-11-12 19:41:10 +08:00
run.sh [skip ci]Update chaos test (#12206) 2021-11-24 11:57:15 +08:00
standalone-values.yaml [skip ci]Add standalone pod kill chaos for script (#11270) 2021-11-05 09:09:39 +08:00
test_chaos_data_consist.py [skip ci]Make sleep time greater than the pod kill time interval (#11144) 2021-11-03 14:55:16 +08:00
test_chaos_memory_stress.py [skip ci] Update chaos memory indexnode case (#12477) 2021-11-30 19:39:55 +08:00
test_chaos.py [skip ci]Organize wait pods ready function (#12642) 2021-12-02 22:28:55 +08:00

Chaos Tests

Goal

Chaos tests are designed to check the reliability of Milvus.

For instance, if one pod is killed:

  • verify that it restarts automatically
  • verify that the related operation fails, while the other operations keep working successfully during the absence of the pod
  • verify that all the operations work successfully after the pod back to running state
  • verify that no data lost

Prerequisite

Chaos tests run in pytest framework, same as e2e tests.

Please refer to Run E2E Tests

Flow Chart

Chaos Test Flow Chart

Test Scenarios

Milvus in cluster mode

pod kill

kill pod every 5s

pod network partition

two direction(to and from) network isolation between a pod and the rest of the pods

pod failure

Set the podquerynode, indexnode and datanodeas multiple replicas, make one of them failure, and test milvus's functionality

pod memory stress

Milvus in standalone mode

  1. standalone pod is killed

  2. minio pod is killed

How it works

  • Test scenarios are designed by different chaos objects
  • Every chaos object is defined in one yaml file locates in folder chaos_objects
  • Every chaos yaml file specified by ALL_CHAOS_YAMLS in constants.py would be parsed as a parameter and be passed into test_chaos.py
  • All expectations of every scenario are defined in testcases.yaml locates in folder chaos_objects
  • Chaos Mesh is used to inject chaos into Milvus in test_chaos.py

Run

Manually

Run a single test scenario manually(take query node pod is killed as instance):

  1. update ALL_CHAOS_YAMLS = 'chaos_querynode_podkill.yaml' in constants.py

  2. run the commands below:

    cd /milvus/tests/python_client/chaos
    
    pytest test_chaos.py --host ${Milvus_IP} -v
    

Run multiple test scenario in a category manually(take network partition chaos for all pods as instance):

  1. update ALL_CHAOS_YAMLS = 'chaos_*_network_partition.yaml' in constants.py

  2. run the commands below:

    cd /milvus/tests/python_client/chaos
    
    pytest test_chaos.py --host ${Milvus_IP} -v
    

Automation Scripts

Run test scenario automatically:

  1. update chaos type and pod in chaos_test.sh
  2. run the commands below:
    cd /milvus/tests/python_client/chaos
    # in this step, script will install milvus and run testcase
    bash chaos_test.sh
    

Github Action

Nightly

still in planning

Todo

  • network attack
  • clock skew
  • IO injection

How to contribute

  • Get familiar with chaos engineering and Chaos Mesh
  • Design chaos scenarios, preferring to pick from todo list
  • Generate yaml file for your chaos scenarios. You can create a chaos experiment in chaos-dashboard, then download the yaml file of it.
  • Add yaml file to chaos_objects dir and rename it as chaos_${component_name}_${chaos_type}.yaml. Make sure kubectl apply -f ${your_chaos_yaml_file} can take effect
  • Add testcase in testcases.yaml. You should figure out the expectation of milvus during the chaos
  • Run your added testcase according to Manually above and check whether it as your expectation