Files
troubleshoot/test/validate-support-bundle-e2e.sh
Diamon Wiggins a0fb06f0b9 E2E Tests for Support Bundle CLI (#761)
* adding e2e tests for support bundle cli

* update e2e.yaml
2022-10-07 14:43:16 +13:00

40 lines
994 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
bundle_archive_name="support-bundle.tar.gz"
bundle_directory_name="support-bundle"
./bin/support-bundle --interactive=false examples/support-bundle/e2e.yaml --output=$tmpdir/$bundle_archive_name
EXIT_STATUS=0
if ! tar -xvzf $tmpdir/$bundle_archive_name --directory $tmpdir; then
echo "A valid support bundle archive was not generated"
EXIT_STATUS=1
fi
echo "$(cat $tmpdir/$bundle_directory_name/analysis.json)"
if grep -q "No matching files" "$tmpdir/$bundle_directory_name/analysis.json"; then
echo "Some files were not collected"
EXIT_STATUS=1
fi
EXIT_STATUS=0
jq -r '.[].insight.severity' "$tmpdir/$bundle_directory_name/analysis.json" | while read i; do
if [ $i == "error" ]; then
EXIT_STATUS=1
echo "Analyzers with severity of \"error\" found"
fi
if [ $i == "warn" ]; then
EXIT_STATUS=1
echo "Analyzers with severity of \"warn\" found"
fi
done
rm -rf "$tmpdir"
exit $EXIT_STATUS