From 493848da5c286a02ee83dc089416eaf0d4459fbf Mon Sep 17 00:00:00 2001 From: rajdas Date: Wed, 25 Sep 2019 16:45:06 +0530 Subject: [PATCH] added semver maker and two chaos experiments Signed-off-by: rajdas --- .travis.yml | 8 ++ Makefile | 16 ++++ .../experiments/openebs_nd.basetemplate.yaml | 55 ++++++++++++++ .../experiments/openebs_nd.version.yaml | 55 ++++++++++++++ .../experiments/openebs_nl.version.yaml | 54 +++++++++++++ .../experiments/openebs_nl_basetemplate.yaml | 54 +++++++++++++ .../openebs/openebs.chartserviceversion.yaml | 2 +- scripts/push.sh | 24 ++++++ scripts/semversion_checker.py | 11 +++ scripts/version_maker.sh | 75 +++++++++++++++++++ 10 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 Makefile create mode 100644 charts/openebs/network/experiments/openebs_nd.basetemplate.yaml create mode 100644 charts/openebs/network/experiments/openebs_nd.version.yaml create mode 100644 charts/openebs/network/experiments/openebs_nl.version.yaml create mode 100644 charts/openebs/network/experiments/openebs_nl_basetemplate.yaml create mode 100644 scripts/push.sh create mode 100644 scripts/semversion_checker.py create mode 100644 scripts/version_maker.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0d3c23d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +sudo: required +dist: xenial # ubuntu 16.04 distro +script: + # runs only when PR is merged + - if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then make versionmaker; fi +after_success: + # runs only when PR is merged and push the version file to master version + - if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then make push; fi diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..058dfa1 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +# Makefile for building Chaos Exporter +# Reference Guide - https://www.gnu.org/software/make/manual/make.html + +.PHONY: versionmaker +versionmaker: + @echo "version maker" + # dependency to run gem pkg manger + sudo apt-get install rubygems + bash ./scripts/version_maker.sh + +.PHONY: push +push: + @echo "---------git push to master-------" + bash ./scripts/push.sh + + \ No newline at end of file diff --git a/charts/openebs/network/experiments/openebs_nd.basetemplate.yaml b/charts/openebs/network/experiments/openebs_nd.basetemplate.yaml new file mode 100644 index 0000000..48f5e9d --- /dev/null +++ b/charts/openebs/network/experiments/openebs_nd.basetemplate.yaml @@ -0,0 +1,55 @@ +apiVersion: litmuschaos.io/v1alpha1 +description: + message: | + Network delay between Pod and PVC belonging to a deployment/statefulset/daemonset +kind: ChaosExperiment +metadata: + labels: + litmuschaos.io/name: kubernetes + name: pod-network-delay + namespace: litmus + version: {{ VERSION }} + +spec: + definition: + args: + - -c + - ansible-playbook ./experiments/chaos/openebs_target_network_delay/test.yml -i /etc/ansible/hosts -i /etc/ansible/hosts + -vv; exit 0 + command: + - /bin/bash + env: + - name: ANSIBLE_STDOUT_CALLBACK + value: "default" + + - name: OPERATOR_NAMESPACE + value: "openebs" + + - name: APP_NAMESPACE + value: "default" # NS of deployed app (Mandatory) + + - name: APP_LABEL + value: "" # deployed app label (Mandatory) + + - name: APP_PVC + value: "" # PVC name (Mandatory) + + - name: NETWORK_DELAY + value: "240000" # in milliseconds (Mandatory) + + - name: CHAOS_DURATION + value: "240" # in seconds (Mandatory) + + - name: LIVENESS_APP_LABEL + value: "" # (Optional) If Liveness probe enable, mention the app_label else skip + + - name: LIVENESS_APP_NAMESPACE + value: "" # (Optional) If Liveness probe enable, mention the app_label else skip + + - name: DATA_PERSISTENCY + value: "enable" + + image: "" # (Optional) + labels: + name: pod-network-delay + litmusbook: /experiments/chaos/openebs_target_network_delay/run_litmus_test.yml diff --git a/charts/openebs/network/experiments/openebs_nd.version.yaml b/charts/openebs/network/experiments/openebs_nd.version.yaml new file mode 100644 index 0000000..194d62d --- /dev/null +++ b/charts/openebs/network/experiments/openebs_nd.version.yaml @@ -0,0 +1,55 @@ +apiVersion: litmuschaos.io/v1alpha1 +description: + message: | + Network delay between Pod and PVC belonging to a deployment/statefulset/daemonset +kind: ChaosExperiment +metadata: + labels: + litmuschaos.io/name: kubernetes + name: pod-network-delay + namespace: litmus + version: 0.1.0 + +spec: + definition: + args: + - -c + - ansible-playbook ./experiments/chaos/openebs_target_network_delay/test.yml -i /etc/ansible/hosts -i /etc/ansible/hosts + -vv; exit 0 + command: + - /bin/bash + env: + - name: ANSIBLE_STDOUT_CALLBACK + value: "default" + + - name: OPERATOR_NAMESPACE + value: "openebs" + + - name: APP_NAMESPACE + value: "default" # NS of deployed app (Mandatory) + + - name: APP_LABEL + value: "" # deployed app label (Mandatory) + + - name: APP_PVC + value: "" # PVC name (Mandatory) + + - name: NETWORK_DELAY + value: "240000" # in milliseconds (Mandatory) + + - name: CHAOS_DURATION + value: "240" # in seconds (Mandatory) + + - name: LIVENESS_APP_LABEL + value: "" # (Optional) If Liveness probe enable, mention the app_label else skip + + - name: LIVENESS_APP_NAMESPACE + value: "" # (Optional) If Liveness probe enable, mention the app_label else skip + + - name: DATA_PERSISTENCY + value: "enable" + + image: "" # (Optional) + labels: + name: pod-network-delay + litmusbook: /experiments/chaos/openebs_target_network_delay/run_litmus_test.yml diff --git a/charts/openebs/network/experiments/openebs_nl.version.yaml b/charts/openebs/network/experiments/openebs_nl.version.yaml new file mode 100644 index 0000000..2e0ced6 --- /dev/null +++ b/charts/openebs/network/experiments/openebs_nl.version.yaml @@ -0,0 +1,54 @@ +apiVersion: litmuschaos.io/v1alpha1 +description: + message: | + Network loss between Pod and PVC belonging to a deployment/statefulset/daemonset +kind: ChaosExperiment +metadata: + labels: + litmuschaos.io/name: kubernetes + name: pod-network-loss + namespace: litmus + version: 0.1.0 +spec: + definition: + args: + - -c + - ansible-playbook ./experiments/chaos/openebs_target_network_loss/test.yml -i /etc/ansible/hosts -i /etc/ansible/hosts + -vv; exit 0 + command: + - /bin/bash + env: + - name: ANSIBLE_STDOUT_CALLBACK + value: "default" + + - name: OPERATOR_NAMESPACE + value: "openebs" + + - name: APP_NAMESPACE + value: "default" # NS of deployed app (Mandatory) + + - name: APP_LABEL + value: "" # deployed app label (Mandatory) + + - name: APP_PVC + value: "" # PVC name (Mandatory) + + - name: NETWORK_DELAY + value: "240000" # in milliseconds (Mandatory) + + - name: CHAOS_DURATION + value: "240" # in seconds (Mandatory) + + - name: LIVENESS_APP_LABEL + value: "" # (Optional) If Liveness probe is enable, mention the app_label else skip + + - name: LIVENESS_APP_NAMESPACE + value: "" # # (Optional) If Liveness probe is enable, mention the app_namespace else skip + + - name: DATA_PERSISTENCY + value: "enable" + + image: "" # (Optional) + labels: + name: pod-network-loss + litmusbook: /experiments/chaos/openebs_target_network_loss/run_litmus_test.yml diff --git a/charts/openebs/network/experiments/openebs_nl_basetemplate.yaml b/charts/openebs/network/experiments/openebs_nl_basetemplate.yaml new file mode 100644 index 0000000..9be5f57 --- /dev/null +++ b/charts/openebs/network/experiments/openebs_nl_basetemplate.yaml @@ -0,0 +1,54 @@ +apiVersion: litmuschaos.io/v1alpha1 +description: + message: | + Network loss between Pod and PVC belonging to a deployment/statefulset/daemonset +kind: ChaosExperiment +metadata: + labels: + litmuschaos.io/name: kubernetes + name: pod-network-loss + namespace: litmus + version: {{ VERSION }} +spec: + definition: + args: + - -c + - ansible-playbook ./experiments/chaos/openebs_target_network_loss/test.yml -i /etc/ansible/hosts -i /etc/ansible/hosts + -vv; exit 0 + command: + - /bin/bash + env: + - name: ANSIBLE_STDOUT_CALLBACK + value: "default" + + - name: OPERATOR_NAMESPACE + value: "openebs" + + - name: APP_NAMESPACE + value: "default" # NS of deployed app (Mandatory) + + - name: APP_LABEL + value: "" # deployed app label (Mandatory) + + - name: APP_PVC + value: "" # PVC name (Mandatory) + + - name: NETWORK_DELAY + value: "240000" # in milliseconds (Mandatory) + + - name: CHAOS_DURATION + value: "240" # in seconds (Mandatory) + + - name: LIVENESS_APP_LABEL + value: "" # (Optional) If Liveness probe is enable, mention the app_label else skip + + - name: LIVENESS_APP_NAMESPACE + value: "" # # (Optional) If Liveness probe is enable, mention the app_namespace else skip + + - name: DATA_PERSISTENCY + value: "enable" + + image: "" # (Optional) + labels: + name: pod-network-loss + litmusbook: /experiments/chaos/openebs_target_network_loss/run_litmus_test.yml diff --git a/charts/openebs/openebs.chartserviceversion.yaml b/charts/openebs/openebs.chartserviceversion.yaml index 5254d90..da97dda 100644 --- a/charts/openebs/openebs.chartserviceversion.yaml +++ b/charts/openebs/openebs.chartserviceversion.yaml @@ -22,7 +22,7 @@ spec: - OpenEBS - CAS - Storage - version: v0.1.0 + version: 0.1.0 maturity: alpha maintainers: - name: ksatchit diff --git a/scripts/push.sh b/scripts/push.sh new file mode 100644 index 0000000..086471f --- /dev/null +++ b/scripts/push.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +setup_git() { + git config --global user.email "travis@travis-ci.org" + git config --global user.name "Travis CI" + git remote set-url origin https://${GITHUB_TOKEN}@github.com/rajdas98/community-charts.git > /dev/null 2>&1 +} + +commit_website_files() { + git checkout master + git status + git add . + git commit --message "Travis build: $TRAVIS_BUILD_NUMBER" + git status +} + +upload_files() { + git remote -v + git push origin master +} + +setup_git +commit_website_files +upload_files diff --git a/scripts/semversion_checker.py b/scripts/semversion_checker.py new file mode 100644 index 0000000..d307848 --- /dev/null +++ b/scripts/semversion_checker.py @@ -0,0 +1,11 @@ +import re +import sys + +# semantic version regex +regex = "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" +result = re.search(regex, sys.argv[1]) + +if result: + sys.exit(0) # on success +else: + sys.exit(1) #on failure \ No newline at end of file diff --git a/scripts/version_maker.sh b/scripts/version_maker.sh new file mode 100644 index 0000000..44a3147 --- /dev/null +++ b/scripts/version_maker.sh @@ -0,0 +1,75 @@ +#! /bin/bash + +# parsing yaml file +function yaml() { + local prefix=$2 + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ + -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + awk -F$fs '{ + indent = length($1)/2; + vname[indent] = $2; + for (i in vname) {if (i > indent) {delete vname[i]}} + if (length($3) > 0) { + vn=""; for (i=0; i