From debad343377e6c519b8a32a37bc1917387c1dbe5 Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Fri, 8 Mar 2024 13:00:47 -0600 Subject: [PATCH] rename test for k8s-labs --- .github/workflows/test.yaml | 4 +- modules/targets/k8s-labs.yml | 88 ++++++++++++++++++------------------ test/test-arrrspace.sh | 14 ------ test/test-k8s-labs.sh | 16 +++++++ 4 files changed, 62 insertions(+), 60 deletions(-) delete mode 100755 test/test-arrrspace.sh create mode 100755 test/test-k8s-labs.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 05d805d..d7d6c47 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -80,10 +80,10 @@ jobs: uses: ./.github/workflows/package-test.yaml with: package-name: dvga - test-arrrspace: + test-k8s-labs: uses: ./.github/workflows/package-test.yaml with: - package-name: arrrspace + package-name: k8s-labs test-amoksecurity: uses: ./.github/workflows/package-test.yaml with: diff --git a/modules/targets/k8s-labs.yml b/modules/targets/k8s-labs.yml index 18f5b39..7b32d42 100644 --- a/modules/targets/k8s-labs.yml +++ b/modules/targets/k8s-labs.yml @@ -12,7 +12,7 @@ - name: Get the k8s-labs repo git: - repo: https://github.com/ProfessionallyEvil/k8s-lab.git + repo: https://github.com/ProfessionallyEvil/k8s-labs.git dest: /opt/targets/k8s-labs - name: Download minikube bin @@ -50,14 +50,52 @@ dest: /etc/hosts line: '127.0.0.1 api.k8s-labs.wtf' + remove: + - name: Remove repo + rm: + path: /opt/targets/k8s-labs + - name: Delete cluster + command: + cmd: minikube delete + - name: Remove images + command: + unsafe: True + shell: True + cmd: docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'k8slabs') + - name: Cleanup .kube dir + rm: + path: /root/.kube + - name: Cleanup .minikube dir + rm: + path: /root/.minikube + - name: Remove minikube + rm: + path: /usr/bin/minikube + - name: Remove kubectl + rm: + path: /usr/bin/kubectl + - name: Remove nginx conf + rm: + path: /etc/nginx/conf.d/k8s-labs.conf + - name: Remove api.k8s-labs nginx conf + rm: + path: /etc/nginx/conf.d/api.k8s-labs.conf + + start: + - service: + name: docker + state: running + - command: + cmd: minikube start --force + # hacks to make this work more dynamically without supporting state in katana manifests - name: Write cluster IP to file command: unsafe: True shell: True cwd: /opt/targets/k8s-labs - cmd: "minikube ip > /opt/targets/k8s-labs/cluster_ip.txt" - + cmd: "/usr/bin/minikube ip > /opt/targets/k8s-labs/cluster_ip.txt" + - name: Set up web app nginx reverse-proxy config copy: dest: /etc/nginx/conf.d/k8s-labs.conf @@ -70,7 +108,7 @@ } } mode: 0644 - + - name: Set up api nginx reverse-proxy config copy: dest: /etc/nginx/conf.d/api.k8s-labs.conf @@ -83,7 +121,7 @@ } } mode: 0644 - + - name: Set cluster IP in nginx configs command: shell: True @@ -93,45 +131,7 @@ - service: name: nginx state: restarted - - remove: - - name: Remove repo - rm: - path: /opt/targets/k8s-labs - - name: Delete cluster - command: - cmd: minikube delete - - name: Remove images - command: - unsafe: True - shell: True - cmd: docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'k8slabs') - - name: Cleanup .kube dir - rm: - path: /root/.kube - - name: Cleanup .minikube dir - rm: - path: /root/.minikube - - name: Remove minikube - rm: - path: /usr/bin/minikube - - name: Remove kubectl - rm: - path: /usr/bin/kubectl - - name: Remove nginx conf - rm: - path: /etc/nginx/conf.d/k8s-labs.conf - - name: Remove api.k8s-labs nginx conf - rm: - path: /etc/nginx/conf.d/api.k8s-labs.conf - - start: - - service: - name: docker - state: running - - command: - cmd: minikube start --force - + stop: - service: name: docker diff --git a/test/test-arrrspace.sh b/test/test-arrrspace.sh deleted file mode 100755 index 6b743ca..0000000 --- a/test/test-arrrspace.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -e - -katana install arrrspace - -curl --fail -o /dev/null --retry 5 --retry-all-errors http://arrrspace.test:80/ -curl --fail -o /dev/null --retry 5 --retry-all-errors http://arrrspace.wtf:80/ -curl --fail -o /dev/null --retry 5 --retry-all-errors http://api.arrrspace.test:80/ -curl --fail -o /dev/null --retry 5 --retry-all-errors http://api.arrrspace.wtf:80/ - -katana remove arrrspace - -echo -e "\nPASSED\n" diff --git a/test/test-k8s-labs.sh b/test/test-k8s-labs.sh new file mode 100755 index 0000000..03e2502 --- /dev/null +++ b/test/test-k8s-labs.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e + +katana install k8s-labs +sleep 2 +katana start k8s-labs + +curl --fail -o /dev/null --retry 5 --retry-all-errors http://k8s-labs.wtf:80/ +curl --fail -o /dev/null --retry 5 --retry-all-errors http://api.k8s-labs.wtf:80/ + +katana stop k8s-labs +sleep 2 +katana remove k8s-labs + +echo -e "\nPASSED\n"