-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply k8s-default-storage-class as sonobuoy plugin
Signed-off-by: Toni Finger <toni.finger@cloudandheat.com>
- Loading branch information
1 parent
586d291
commit 7628927
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
.idea | ||
.DS_Store | ||
node_modules | ||
Tests/kaas/results/ | ||
*.tar.gz |
21 changes: 21 additions & 0 deletions
21
Tests/kaas/k8s-default-storage-class/Dockerfile_sonobuoy_plugin
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM ubuntu | ||
|
||
# Install kubectl | ||
# Note: Latest version may be found on: | ||
# https://aur.archlinux.org/packages/kubectl-bin/ | ||
ADD https://storage.googleapis.com/kubernetes-release/release/v1.14.1/bin/linux/amd64/kubectl /usr/local/bin/kubectl | ||
|
||
ENV HOME=/config | ||
|
||
# Basic check it works. | ||
RUN apt-get update && \ | ||
apt-get -y install net-tools && \ | ||
apt-get -y install curl && \ | ||
chmod +x /usr/local/bin/kubectl && \ | ||
kubectl version --client | ||
|
||
|
||
COPY ./ ./ | ||
RUN chmod +x ./run_checks.sh | ||
|
||
ENTRYPOINT ["./run_checks.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import getopt | ||
import sys | ||
import time | ||
import json | ||
import logging | ||
import yaml | ||
|
||
manual_result_file_template = { | ||
'name': None, | ||
'status': None, | ||
'details':{ | ||
#'stdout': "stdout from the test" | ||
'messages': None | ||
# - message from the test | ||
# - another message | ||
} | ||
} | ||
|
||
def gen_sonobuoy_result_file(error_n: int, error_msg: str, test_file_name: str): | ||
|
||
test_name = test_file_name.replace(".py", "") | ||
|
||
test_status="passed" | ||
|
||
if error_n != 0 : | ||
test_status = test_name + "_" + str(error_n) | ||
|
||
result_file = manual_result_file_template | ||
|
||
result_file['name'] = test_name | ||
result_file['status'] = test_status | ||
result_file['details']['messages'] = error_msg | ||
|
||
with open(f'./{test_name}.result.yaml', 'w') as file: | ||
documents = yaml.dump(result_file, file) |
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
13 changes: 13 additions & 0 deletions
13
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-plugin.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sonobuoy-config: | ||
driver: Job | ||
plugin-name: k8s-default-storage-class | ||
result-format: manual | ||
resutl-file: k8s-default-storage-class-check.result.yaml | ||
|
||
spec: | ||
args: | ||
- k8s-default-storage-class-check | ||
command: | ||
- ./run_checks.sh | ||
image: ghcr.io/sovereigncloudstack/standars/k8s-default-storage-class:v0.1.2 | ||
name: k8s-default-storage-class |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/sh | ||
|
||
############################################################################### | ||
##### HELPERS ##### | ||
############################################################################### | ||
|
||
set -x | ||
|
||
# This is the entrypoint for the image and meant to wrap the | ||
# logic of gathering/reporting results to the Sonobuoy worker. | ||
|
||
results_dir="${RESULTS_DIR:-/tmp/results}" | ||
mkdir -p ${results_dir} | ||
|
||
# saveResults prepares the results for handoff to the Sonobuoy worker. | ||
# See: https://github.com/vmware-tanzu/sonobuoy/blob/main/site/content/docs/main/plugins.md | ||
saveResults() { | ||
cd ${results_dir} | ||
echo ${results_dir} | ||
|
||
# Sonobuoy worker expects a tar file. | ||
tar czf results.tar.gz * | ||
|
||
# Signal to the worker that we are done and where to find the results. | ||
printf ${results_dir}/results.tar.gz > ${results_dir}/done | ||
} | ||
|
||
# Ensure that we tell the Sonobuoy worker we are done regardless of results. | ||
trap saveResults EXIT | ||
|
||
|
||
############################################################################### | ||
##### RUN TEST SCRIPTS ##### | ||
############################################################################### | ||
|
||
# Each script name is expected to be given as an arg. If no args, error out | ||
# but print one result file for clarity in the results. | ||
if [ "$#" -eq "0" ]; then | ||
echo "No arguments; expects each argument to be script name" > ${results_dir}/out | ||
exit 1 | ||
fi | ||
|
||
# Iterate through the python tests passed as arguments | ||
i=0 | ||
while [ "$1" != "" ]; do | ||
# Run each arg as a command and save the output in the results directory. | ||
echo "run testscript: [$1.py]" | ||
|
||
python $1.py > ${results_dir}/out_$1 | ||
cp $1.result.yaml ${results_dir} | ||
i=$((i + 1)) | ||
|
||
# Shift all the parameters down by one | ||
shift | ||
done |