mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-27 20:18:57 +00:00
tests/k8s: split and save bats outputs in files
Currently run_kubernetes_tests.sh sends all the bats outputs to stdout which can be very difficult to browse to find a problem, mainly on CI. With this change, each bats execution have its output sent to 'reports/yyy-mm-dd-hh:mm:ss/<status>-<bats file>.log' where <status> is either 'ok' (tests passed) or 'not_ok' (some tests failed). Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
parent
f8c5aa6df6
commit
5e3b8a019a
1
tests/integration/kubernetes/.gitignore
vendored
Normal file
1
tests/integration/kubernetes/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
reports/
|
@ -6,6 +6,7 @@
|
||||
#
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
kubernetes_dir=$(dirname "$(readlink -f "$0")")
|
||||
source "${kubernetes_dir}/../../common.bash"
|
||||
@ -131,7 +132,10 @@ fi
|
||||
|
||||
ensure_yq
|
||||
|
||||
info "Running tests with bats version: $(bats --version)"
|
||||
report_dir="${kubernetes_dir}/reports/$(date +'%F-%T')"
|
||||
mkdir -p "${report_dir}"
|
||||
|
||||
info "Running tests with bats version: $(bats --version). Save outputs to ${report_dir}"
|
||||
|
||||
tests_fail=()
|
||||
for K8S_TEST_ENTRY in "${K8S_TEST_UNION[@]}"
|
||||
@ -139,9 +143,14 @@ do
|
||||
K8S_TEST_ENTRY=$(echo "$K8S_TEST_ENTRY" | tr -d '[:space:][:cntrl:]')
|
||||
info "$(kubectl get pods --all-namespaces 2>&1)"
|
||||
info "Executing ${K8S_TEST_ENTRY}"
|
||||
if ! bats --show-output-of-passing-tests "${K8S_TEST_ENTRY}"; then
|
||||
# Output file will be prefixed with "ok" or "not_ok" based on the result
|
||||
out_file="${report_dir}/${K8S_TEST_ENTRY}.out"
|
||||
if ! bats --show-output-of-passing-tests "${K8S_TEST_ENTRY}" | tee "${out_file}"; then
|
||||
tests_fail+=("${K8S_TEST_ENTRY}")
|
||||
mv "${out_file}" "$(dirname "${out_file}")/not_ok-$(basename "${out_file}")"
|
||||
[ "${K8S_TEST_FAIL_FAST}" = "yes" ] && break
|
||||
else
|
||||
mv "${out_file}" "$(dirname "${out_file}")/ok-$(basename "${out_file}")"
|
||||
fi
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user