Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-4152. Archive container logs for kubernetes check #1355

Merged
merged 2 commits into from Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion hadoop-ozone/dev-support/checks/kubernetes.sh
Expand Up @@ -31,6 +31,6 @@ mkdir -p "$REPORT_DIR"
cd "$DIST_DIR/kubernetes/examples" || exit 1
./test-all.sh
RES=$?
cp result/* "$REPORT_DIR/"
cp -r result/* "$REPORT_DIR/"
cp "$REPORT_DIR/log.html" "$REPORT_DIR/summary.html"
exit $RES
Expand Up @@ -32,6 +32,8 @@ execute_robot_test scm-0 smoketest/basic/basic.robot

combine_reports

get_logs

stop_k8s_env

revert_resources
2 changes: 2 additions & 0 deletions hadoop-ozone/dist/src/main/k8s/examples/minikube/test.sh
Expand Up @@ -32,6 +32,8 @@ execute_robot_test scm-0 smoketest/basic/basic.robot

combine_reports

get_logs

stop_k8s_env

revert_resources
2 changes: 2 additions & 0 deletions hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/test.sh
Expand Up @@ -32,6 +32,8 @@ execute_robot_test scm-0 smoketest/basic/basic.robot

combine_reports

get_logs

stop_k8s_env

revert_resources
2 changes: 2 additions & 0 deletions hadoop-ozone/dist/src/main/k8s/examples/ozone/test.sh
Expand Up @@ -32,6 +32,8 @@ execute_robot_test scm-0 smoketest/basic/basic.robot

combine_reports

get_logs

stop_k8s_env

revert_resources
11 changes: 8 additions & 3 deletions hadoop-ozone/dist/src/main/k8s/examples/test-all.sh
Expand Up @@ -31,13 +31,18 @@ RESULT=0
IFS=$'\n'
# shellcheck disable=SC2044
for test in $(find "$SCRIPT_DIR" -name test.sh | grep "${OZONE_TEST_SELECTOR:-""}" |sort); do
TEST_DIR="$(dirname $test)"
TEST_NAME="$(basename "$TEST_DIR")"

echo ""
echo "#### Executing tests of $(dirname "$test") #####"
echo "#### Executing tests of ${TEST_DIR} #####"
echo ""
TEST_DIR="$(dirname $test)"
cd "$TEST_DIR" || continue
./test.sh
cp "$TEST_DIR"/result/output.xml "$ALL_RESULT_DIR"/"$(basename "$TEST_DIR")".xml

cp "$TEST_DIR"/result/output.xml "$ALL_RESULT_DIR"/"${TEST_NAME}".xml
mkdir -p "$ALL_RESULT_DIR"/"${TEST_NAME}"
mv "$TEST_DIR"/logs/*log "$ALL_RESULT_DIR"/"${TEST_NAME}"/
done

rebot -N "smoketests" -d "$ALL_RESULT_DIR/" "$ALL_RESULT_DIR/*.xml"
Expand Down
7 changes: 7 additions & 0 deletions hadoop-ozone/dist/src/main/k8s/examples/testlib.sh
Expand Up @@ -77,6 +77,13 @@ start_k8s_env() {
wait_for_startup
}

get_logs() {
mkdir -p logs
for pod in $(kubectl get pods -o custom-columns=NAME:.metadata.name | tail -n +2); do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame that we have no better solution. We can do kubectl logs -l app=ozone but it will fail when we add setup with more apps (like ozone + spark).

FTR: locally I use https://github.com/wercker/stern and it works well (but this loop is easier.)

kubectl logs "${pod}" > "logs/pod-${pod}.log"
done
}

stop_k8s_env() {
if [ ! "$KEEP_RUNNING" ]; then
kubectl delete -f .
Expand Down