|
2 | 2 |
|
3 | 3 | set -e |
4 | 4 |
|
5 | | -TOTAL_CHAOS_DURATION=${TOTAL_CHAOS_DURATION:=60} |
6 | | -TEST_TIMEOUT=$((600 + $TOTAL_CHAOS_DURATION)) |
7 | | -PARALLEL_EXECUTION=${PARALLEL_EXECUTION:=1} |
8 | | - |
9 | 5 | ##Extract the base64 encoded config data and write this to the KUBECONFIG |
10 | 6 | if [ ! -z "$KUBE_CONFIG_DATA" ] |
11 | 7 | then |
|
14 | 10 | export KUBECONFIG=${HOME}/.kube/config |
15 | 11 | fi |
16 | 12 |
|
17 | | -##Setup |
18 | | -mkdir -p $HOME/go/src/github.com/litmuschaos |
19 | | -cd ${GOPATH}/src/github.com/litmuschaos/ |
20 | | -dir=${GOPATH}/src/github.com/litmuschaos/chaos-ci-lib |
21 | | - |
| 13 | +##Setup AWS credentials if provided |
22 | 14 | if [[ ! -z $AWS_ACCESS_KEY_ID ]] && [[ ! -z $AWS_SECRET_ACCESS_KEY ]] && [[ ! -z $AWS_DEFAULT_REGION ]] |
23 | 15 | then |
24 | 16 | aws configure set default.region ${AWS_DEFAULT_REGION} |
25 | 17 | aws configure set aws_access_key_id ${AWS_ACCESS_KEY_ID} |
26 | 18 | aws configure set aws_secret_access_key ${AWS_SECRET_ACCESS_KEY} |
27 | 19 | fi |
28 | 20 |
|
29 | | -if [ ! -d $dir ] |
30 | | -then |
31 | | - git clone https://github.com/litmuschaos/chaos-ci-lib.git |
32 | | -fi |
33 | | -cd chaos-ci-lib |
| 21 | +# Set default values for experiment configuration |
| 22 | +EXPERIMENT_IMAGE=${EXPERIMENT_IMAGE:-"litmuschaos/go-runner"} |
| 23 | +EXPERIMENT_IMAGE_TAG=${EXPERIMENT_IMAGE_TAG:-"3.18.0"} |
| 24 | +TOTAL_CHAOS_DURATION=${TOTAL_CHAOS_DURATION:-60} |
34 | 25 |
|
35 | | -##Install litmus if it is not already installed |
36 | | -if [ "$INSTALL_LITMUS" == "true" ] |
37 | | -then |
38 | | - go test litmus/install-litmus_test.go -v -count=1 |
| 26 | +# Handle Litmus installation if requested |
| 27 | +if [ "$INSTALL_LITMUS" = "true" ]; then |
| 28 | + echo "Installing Litmus..." |
| 29 | + /app/install-litmus |
39 | 30 | fi |
40 | 31 |
|
41 | | -if [ "$EXPERIMENT_NAME" == "all" ]; then |
42 | | -## Run all BDDs |
43 | | - cd experiments |
44 | | - ginkgo -nodes=${PARALLEL_EXECUTION} |
45 | | - cd .. |
46 | | - |
47 | | -elif [ ! -z "$EXPERIMENT_NAME" ]; then |
48 | | -## Run the selected chaos experiment |
49 | | - go test experiments/${EXPERIMENT_NAME}_test.go -v -count=1 -timeout=${TEST_TIMEOUT}s |
| 32 | +# Handle Litmus cleanup if requested and no experiment is specified |
| 33 | +if [ "$LITMUS_CLEANUP" = "true" ] && [ -z "$EXPERIMENT_NAME" ]; then |
| 34 | + echo "Cleaning up Litmus..." |
| 35 | + /app/uninstall-litmus |
| 36 | + exit 0 |
50 | 37 | fi |
51 | 38 |
|
52 | | -##litmus cleanup |
53 | | -if [ "$LITMUS_CLEANUP" == "true" ] |
54 | | -then |
55 | | - go test litmus/uninstall-litmus_test.go -v -count=1 |
| 39 | +# Map experiment names to their corresponding scripts in chaos-ci-lib |
| 40 | +case "$EXPERIMENT_NAME" in |
| 41 | + "pod-delete") |
| 42 | + /app/pod-delete |
| 43 | + ;; |
| 44 | + "container-kill") |
| 45 | + /app/container-kill |
| 46 | + ;; |
| 47 | + "pod-cpu-hog") |
| 48 | + /app/pod-cpu-hog |
| 49 | + ;; |
| 50 | + "pod-memory-hog") |
| 51 | + /app/pod-memory-hog |
| 52 | + ;; |
| 53 | + "node-cpu-hog") |
| 54 | + /app/node-cpu-hog |
| 55 | + ;; |
| 56 | + "node-memory-hog") |
| 57 | + /app/node-memory-hog |
| 58 | + ;; |
| 59 | + "node-io-stress") |
| 60 | + /app/node-io-stress |
| 61 | + ;; |
| 62 | + "disk-fill") |
| 63 | + /app/disk-fill |
| 64 | + ;; |
| 65 | + "pod-network-latency") |
| 66 | + /app/pod-network-latency |
| 67 | + ;; |
| 68 | + "pod-network-loss") |
| 69 | + /app/pod-network-loss |
| 70 | + ;; |
| 71 | + "pod-network-corruption") |
| 72 | + /app/pod-network-corruption |
| 73 | + ;; |
| 74 | + "pod-network-duplication") |
| 75 | + /app/pod-network-duplication |
| 76 | + ;; |
| 77 | + "pod-autoscaler") |
| 78 | + /app/pod-autoscaler |
| 79 | + ;; |
| 80 | + "all") |
| 81 | + /app/all-experiments |
| 82 | + ;; |
| 83 | + *) |
| 84 | + echo "Unknown experiment: $EXPERIMENT_NAME" |
| 85 | + echo "Available experiments: pod-delete, container-kill, pod-cpu-hog, pod-memory-hog, node-cpu-hog, node-memory-hog, node-io-stress, disk-fill, pod-network-latency, pod-network-loss, pod-network-corruption, pod-network-duplication, pod-autoscaler, all" |
| 86 | + exit 1 |
| 87 | + ;; |
| 88 | +esac |
| 89 | + |
| 90 | +# Handle Litmus cleanup after experiment if requested |
| 91 | +if [ "$LITMUS_CLEANUP" = "true" ] && [ ! -z "$EXPERIMENT_NAME" ]; then |
| 92 | + echo "Cleaning up Litmus after experiment..." |
| 93 | + /app/uninstall-litmus |
56 | 94 | fi |
0 commit comments