Skip to content

Commit

Permalink
feat(actions): Update actions and add multiple experiment execution (#5)
Browse files Browse the repository at this point in the history
Signed-off-by: Udit Gaurav <[email protected]>
  • Loading branch information
uditgaurav authored Jun 15, 2020
1 parent bcde2b6 commit 649304a
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 46 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ LABEL com.github.actions.color="blue"

ENV GOPATH=/github/home/go
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
ARG HELM_VERSION=3.2.3
ARG RELEASE_ROOT="https://get.helm.sh"
ARG RELEASE_FILE="helm-v${HELM_VERSION}-linux-amd64.tar.gz"

ARG KUBECTL_VERSION=1.17.0
ADD https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl

RUN apt-get update && apt-get install -y git && \
apt-get install -y ssh && \
apt-get install curl -y && \
apt install ssh rsync

RUN apt-get update && \
curl -L ${RELEASE_ROOT}/${RELEASE_FILE} |tar xvz && \
mv linux-amd64/helm /usr/bin/helm && \
chmod +x /usr/bin/helm

COPY README.md /
COPY entrypoint.sh /entrypoint.sh
COPY experiments ./experiments
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,20 @@ Some comman environment variables used for running the `github-chaos-actions` ar
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td>We can provide cumstom image for running litmus chaos experiment </td>
<td> We can provide custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
19 changes: 16 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

set -e

TOTAL_CHAOS_DURATION=${TOTAL_CHAOS_DURATION:=60}
TEST_TIMEOUT=$((600 + $TOTAL_CHAOS_DURATION))
PARALLEL_EXECUTION=${PARALLEL_EXECUTION:=1}

##Extract the base64 encoded config data and write this to the KUBECONFIG
mkdir -p ${HOME}/.kube
echo "$KUBE_CONFIG_DATA" | base64 --decode > ${HOME}/.kube/config
Expand All @@ -11,9 +15,10 @@ export KUBECONFIG=${HOME}/.kube/config
mkdir -p $HOME/go/src/github.com/mayadata-io
cd ${GOPATH}/src/github.com/mayadata-io/
dir=${GOPATH}/src/github.com/mayadata-io/chaos-ci-lib

if [ ! -d $dir ]
then
git clone https://github.com/mayadata-io/chaos-ci-lib.git
git clone -b v0.1.1 --single-branch https://github.com/mayadata-io/chaos-ci-lib.git
fi
cd chaos-ci-lib

Expand All @@ -23,8 +28,16 @@ then
go test tests/install-litmus_test.go -v -count=1
fi

##Running the selected chaos experiment template
go test tests/${EXPERIMENT_NAME}_test.go -v -count=1
if [ "$EXPERIMENT_NAME" == "all" ]; then
## Run all BDDs
cd tests
ginkgo -nodes=${PARALLEL_EXECUTION}
cd ..

else
## Run the selected chaos experiment template
go test tests/${EXPERIMENT_NAME}_test.go -v -count=1 -timeout=${TEST_TIMEOUT}s
fi

##litmus cleanup
if [ "$LITMUS_CLEANUP" = "true" ]
Expand Down
22 changes: 18 additions & 4 deletions experiments/container-kill/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

- name: Running container kill chaos experiment
uses: mayadata-io/[email protected].0
uses: mayadata-io/[email protected].1
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
##If litmus is not installed
Expand All @@ -33,7 +33,9 @@ jobs:
APP_KIND: deployment
EXPERIMENT_NAME: container-kill
##Custom images can also be used
EXPERIMENT_IMAGE: litmuschaos/ansible-runner:latest
EXPERIMENT_IMAGE: litmuschaos/ansible-runner
EXPERIMENT_IMAGE_TAG: latest
IMAGE_PULL_POLICY: Always
TARGET_CONTAINER: nginx
TOTAL_CHAOS_DURATION: 20
CHAOS_INTERVAL: 10
Expand Down Expand Up @@ -109,8 +111,20 @@ The application pod for container-kill will be identified with the app info vari
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td> We can provide cumstom image for running litmus chaos experiment </td>
<td> We can provide custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
22 changes: 18 additions & 4 deletions experiments/disk-fill/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest

- name: Running disk-fill chaos experiment
uses: mayadata-io/[email protected].0
uses: mayadata-io/[email protected].1
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
##If litmus is not installed
Expand All @@ -37,7 +37,9 @@ jobs:
FILL_PERCENTAGE: 80
TARGET_CONTAINER: nginx
##Custom images can also be used
EXPERIMENT_IMAGE: litmuschaos/ansible-runner:latest
EXPERIMENT_IMAGE: litmuschaos/ansible-runner
EXPERIMENT_IMAGE_TAG: latest
IMAGE_PULL_POLICY: Always
##Select true if you want to uninstall litmus after chaos
LITMUS_CLEANUP: true
```
Expand Down Expand Up @@ -105,8 +107,20 @@ The application pod for disk-fill will be identified with the app info variables
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td>We can provide cumstom image for running litmus chaos experiment </td>
<td> We can provide custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
22 changes: 18 additions & 4 deletions experiments/node-cpu-hog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

- name: Running node-cpu-hog chaos experiment
uses: mayadata-io/[email protected].0
uses: mayadata-io/[email protected].1
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
##If litmus is not installed
Expand All @@ -32,7 +32,9 @@ jobs:
APP_KIND: deployment
EXPERIMENT_NAME: node-cpu-hog
##Custom images can also be used
EXPERIMENT_IMAGE: litmuschaos/ansible-runner:latest
EXPERIMENT_IMAGE: litmuschaos/ansible-runner
EXPERIMENT_IMAGE_TAG: latest
IMAGE_PULL_POLICY: Always
TOTAL_CHAOS_DURATION: 60
NODE_CPU_CORE: 2
##Select true if you want to uninstall litmus after chaos
Expand Down Expand Up @@ -102,8 +104,20 @@ The application pod for node-cpu-hog will be identified with the app info variab
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td>We can provide cumstom image for running litmus chaos experiment </td>
<td> We can provide custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
22 changes: 18 additions & 4 deletions experiments/node-memory-hog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

- name: Running node-memory-hog chaos experiment
uses: mayadata-io/[email protected].0
uses: mayadata-io/[email protected].1
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
##if litmus is not installed
Expand All @@ -32,7 +32,9 @@ jobs:
APP_KIND: deployment
EXPERIMENT_NAME: node-memory-hog
##Custom images can also be used
EXPERIMENT_IMAGE: litmuschaos/ansible-runner:latest
EXPERIMENT_IMAGE: litmuschaos/ansible-runner
EXPERIMENT_IMAGE_TAG: latest
IMAGE_PULL_POLICY: Always
TOTAL_CHAOS_DURATION: 120
MEMORY_PERCENTAGE: 90
##Select true if you want to uninstall litmus after chaos
Expand Down Expand Up @@ -102,8 +104,20 @@ The application pod for node-memory-hog will be identified with the app info var
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td>We can provide cumstom image for running litmus chaos experiment </td>
<td> We can provide custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
24 changes: 19 additions & 5 deletions experiments/pod-cpu-hog/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pod CPU hog Hog Experiment
# Pod CPU Hog Experiment

This experiment causes CPU resource consumption on specified application containers by starting one or more md5sum calculation process on the special file /dev/zero. It Can test the application's resilience to potential slowness/unavailability of some replicas due to high CPU load. Check <a href="https://docs.litmuschaos.io/docs/pod-cpu-hog/">pod cpu hog docs</a> for more info. To know more and get started with chaos-actions visit <a href="https://github.com/mayadata-io/github-chaos-actions/blob/master/README.md">github-chaos-actions</a>.

Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

- name: Running pod-cpu-hog chaos experiment
uses: mayadata-io/[email protected].0
uses: mayadata-io/[email protected].1
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
##If litmus is not installed
Expand All @@ -32,7 +32,9 @@ jobs:
APP_KIND: deployment
EXPERIMENT_NAME: pod-cpu-hog
##Custom images can also be used
EXPERIMENT_IMAGE: litmuschaos/ansible-runner:latest
EXPERIMENT_IMAGE: litmuschaos/ansible-runner
EXPERIMENT_IMAGE_TAG: latest
IMAGE_PULL_POLICY: Always
TARGET_CONTAINER: nginx
TOTAL_CHAOS_DURATION: 60
CPU_CORES: 1
Expand Down Expand Up @@ -109,8 +111,20 @@ The application pod for pod-cpu-hog will be identified with the app info variabl
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td>We can provide cumstom image for running litmus chaos experiment </td>
<td>We can provide custom image for running litmus chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
22 changes: 18 additions & 4 deletions experiments/pod-delete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

- name: Running pod delete chaos experiment
uses: mayadata-io/[email protected].0
uses: mayadata-io/[email protected].1
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
##If litmus is not installed
Expand All @@ -32,7 +32,9 @@ jobs:
APP_KIND: deployment
EXPERIMENT_NAME: pod-delete
##Custom images can also be used
EXPERIMENT_IMAGE: litmuschaos/ansible-runner:latest
EXPERIMENT_IMAGE: litmuschaos/ansible-runner
EXPERIMENT_IMAGE_TAG: latest
IMAGE_PULL_POLICY: Always
TOTAL_CHAOS_DURATION: 30
CHAOS_INTERVAL: 10
FORCE: false
Expand Down Expand Up @@ -116,8 +118,20 @@ The application pod for pod-delete will be identified with the app info variable
</tr>
<tr>
<td> EXPERIMENT_IMAGE </td>
<td> We can provide cumstom image for running litmus chaos experiment </td>
<td> We can provide custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is litmuschaos/ansible-runner:latest </td>
<td> Default value is litmuschaos/ansible-runner </td>
</tr>
<tr>
<td> EXPERIMENT_IMAGE_TAG </td>
<td> We can set the image tag while using custom image for the chaos experiment </td>
<td> Optional </td>
<td> Default value is latest </td>
</tr>
<tr>
<td>IMAGE_PULL_POLICY </td>
<td> We can set the image pull policy while using custom image for running chaos experiment </td>
<td> Optional </td>
<td> Default value is Always </td>
</tr>
</table>
Loading

0 comments on commit 649304a

Please sign in to comment.