Created
May 27, 2020 18:11
-
-
Save fabianvf/d0627bf59ddde9ff0dc99db0caf5719d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
function setup() { | |
trap "(echo 'Cleaning up kind cluster' ; set -x ; kind delete cluster ; rm /tmp/kind-test-kubeconfig)" EXIT | |
make install | |
make setup-k8s | |
kind get kubeconfig --name=kind > /tmp/kind-test-kubeconfig | |
export KUBECONFIG="/tmp/kind-test-kubeconfig" | |
} | |
function reset() { | |
kubectl delete namespace default -w | |
kubectl create namespace default | |
} | |
function success() { | |
echo -e "\e[32m${1} tests succeeded" | |
} | |
function failure() { | |
echo -e "\e[31m${1} tests failed" | |
} | |
test_to_run=${1:-all} | |
case ${test_to_run} in | |
go|golang|Go|Golang) | |
setup | |
(make test-e2e-go test-integration && success go) || failure go | |
;; | |
ansible|Ansible) | |
setup | |
(make test-e2e-ansible test-e2e-ansible-molecule && success ansible) || failure ansible | |
;; | |
molecule|ansible-molecule) | |
setup | |
(make test-e2e-ansible-molecule && success molecule) || failure molecule | |
;; | |
helm|Helm) | |
setup | |
(make test-e2e-helm && success helm) || failure helm | |
;; | |
subcommand|Subcommand) | |
setup | |
(make test-subcommand && success subcommand) || failure subcommand | |
;; | |
sanity|Sanity) | |
(make test-sanity test-unit test-markdown && success sanity) || failure sanity | |
;; | |
all) | |
make test-sanity test-unit test-markdown | |
sanity=$? | |
setup | |
make test-subcommand | |
subcommand=$? | |
reset | |
make test-e2e-go test-integration | |
golang=$? | |
reset | |
make test-e2e-ansible test-e2e-ansible-molecule | |
ansible=$? | |
reset | |
make test-e2e-helm | |
helm=$? | |
if [[ "${sanity}" -ne 0 ]] ; then failure sanity ; else success sanity ; fi | |
if [[ "${subcommand}" -ne 0 ]] ; then failure subcommand ; else success subcommand ; fi | |
if [[ "${golang}" -ne 0 ]] ; then failure golang ; else success golang ; fi | |
if [[ "${ansible}" -ne 0 ]] ; then failure ansible ; else success ansible ; fi | |
if [[ "${molecule}" -ne 0 ]] ; then failure molecule ; else success molecule ; fi | |
if [[ "${helm}" -ne 0 ]] ; then failure helm ; else success helm ; fi | |
;; | |
*) | |
echo "Invalid argument" | |
echo "Usage: ${0} [go|ansible|molecule|helm|subcommand|sanity|all]" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment