milvus/tests/python_client/chaos
zhuwenxing 03ce8e9976
[skip e2e]Update etcd log level (#22475)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
2023-03-01 09:21:54 +08:00
..
chaos_objects [skip e2e]Add mixcoord component for chaos test (#18712) 2022-08-18 16:24:51 +08:00
config [skip e2e]Update multi replicas chaos test (#17739) 2022-06-24 12:06:14 +08:00
scripts [test]Test rolling update for operator (#22268) 2023-02-18 09:38:25 +08:00
testcases Add segment info and replicas in verify rg (#22366) 2023-02-24 08:55:49 +08:00
chaos_commons.py [test]Add rolling update test (#22144) 2023-02-14 10:06:34 +08:00
chaos_test.sh [skip e2e]Add all pods kill chaos test (#15761) 2022-02-25 18:41:53 +08:00
checker.py [test]Add rolling update test (#22144) 2023-02-14 10:06:34 +08:00
cluster-values.yaml [skip e2e]Update etcd log level (#22475) 2023-03-01 09:21:54 +08:00
conftest.py [test] Fix chaos duration is not updated and add target number option (#22346) 2023-02-23 16:41:45 +08:00
constants.py [test]Update index type (#19348) 2022-09-26 18:40:53 +08:00
README.md [skip e2e]Update README for chaos test (#14546) 2021-12-29 21:04:02 +08:00
run.sh [skip e2e]Update script to run all chaos test (#14004) 2021-12-22 20:31:20 +08:00
standalone-values.yaml [skip e2e]Update etcd log level (#22475) 2023-03-01 09:21:54 +08:00
test_chaos_apply.py [test] Fix chaos duration is not updated and add target number option (#22346) 2023-02-23 16:41:45 +08:00
test_chaos_bulk_insert.py [test]Fix bulk insert chaos test (#20341) 2022-11-08 16:37:05 +08:00
test_chaos_data_consist.py [skip e2e]Add wait pod ready function for chaos data consist test (#15898) 2022-03-07 16:25:58 +08:00
test_chaos_memory_stress.py [test] Add chaos memory stress test for multiple memory replicas (#17047) 2022-05-17 18:23:57 +08:00
test_chaos_multi_replicas.py [skip e2e]Get the number of replicas needed to load via get_replicas (#17872) 2022-06-28 20:02:22 +08:00
test_chaos.py [test]Add delete checker for chaos test (#17965) 2022-07-01 09:06:23 +08:00
test_load_with_checker.py [test]Update bulk insert test case and skip calc_distance testcases (#19855) 2022-10-18 17:21:26 +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

Limit the memory resource of pod and generate plenty of stresses over a group of pods

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 with replicas_num and run testcase
    bash chaos_test.sh ${pod} ${chaos_type} ${chaos_task} ${replicas_num}
    # example: bash chaos_test.sh querynode pod_kill chaos-test 2
    

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