From ed9b8af98d36bd7aaaf706a13dccc528bb45630b Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Dec 01 2017 09:39:45 +0000 Subject: [PATCH 1/2] better artifacts handling --- diff --git a/run_mtf.sh b/run_mtf.sh index b7905c2..3eaf491 100755 --- a/run_mtf.sh +++ b/run_mtf.sh @@ -27,6 +27,9 @@ INDEX_VARS_FILE="$WORKDIR/index_vars.ini" MTF_EXIT_FAIL='125' MTF_EXIT_SKIP='126' +# Filename of stored raw output +LOG_FILE_NAME="raw-log.txt" + function save_outcome { # save outcome and note local EXITCODE="$1" @@ -55,26 +58,45 @@ function save_outcome { function save_artifacts { local EXITCODE="$1" local OUTDIR="$2" + local INDEXF="$OUTDIR/index.html" + local AVOCADOPATH="/root/avocado/job-results/latest" + mkdir -p $OUTDIR if [ "$EXITCODE" -eq "$MTF_EXIT_SKIP" ]; then # skipped execution, no logs saved return fi - # NOTE: Do not remove the trailing slash from 'latest/', it's a symlink - cp -r /root/avocado/job-results/latest/ "$OUTDIR" - # Fix issue that avocado expects debug logs of tests under html subdirectory. - # Just a symlink doesn't work with current libtaskotron. - mv "$OUTDIR"/test-results "$OUTDIR"/html/ + if [ -e "$AVOCADOPATH" ]; then + cp -r "$AVOCADOPATH/*" "$OUTDIR" + if [ -e "$OUTDIR/result.html" ]; then + mv "$OUTDIR/result.html" "$INDEXF" + # Fix issue that avocado expects debug logs of tests under html subdirectory. + # Just a symlink doesn't work with current libtaskotron. + mv "$OUTDIR/test-results" "$OUTDIR/html/" + else + echo "AVOCADO LOG:" > "$INDEXF" + cat "$AVOCADOPATH/job.log" >> "$INDEXF" + echo "RAW LOG:" >> "$INDEXF" + cat "$WORKDIR/$LOG_FILE_NAME" >> "$INDEXF" + fi + rm -f "$AVOCADOPATH" "$WORKDIR/$LOG_FILE_NAME" + else + if [ -e "$WORKDIR/$LOG_FILE_NAME" ]; then + echo "RAW LOG:" > "$INDEXF" + cat "$WORKDIR/$LOG_FILE_NAME" >> "$INDEXF" + rm -f "$WORKDIR/$LOG_FILE_NAME" + else + echo "!!!! UNABLE TO COLLECT ANY LOG !!!" > "$INDEXF" + fi + fi } function check_artifact { # return the artifact if it exists, otherwise the fallback - local ARTIFACT="$1" - local FALLBACK="$2" - if [ -e "$ARTIFACT" ]; then - echo -n "$ARTIFACT" - else - echo -n "$FALLBACK" - fi + for ARTIFACT in $@; do + if [ -e "$ARTIFACT" ]; then + echo -n "$ARTIFACT" + fi + done } function save_index_vars { @@ -103,10 +125,13 @@ function save_index_vars { echo "" >> "$OUTFILE" } + + # run module lint echo 'Running MTF with module lint...' pushd "$WORKDIR" -/usr/share/moduleframework/tools/run-them.sh "$MODULENAME" "$MODULENAME_STREAM_VERSION" pdc lint +/usr/share/moduleframework/tools/run-them.sh "$MODULENAME" "$MODULENAME_STREAM_VERSION" pdc lint \ + 2>&1 | tee "$LOG_FILE_NAME" EXITCODE="$?" popd @@ -118,7 +143,8 @@ save_index_vars "modulelint" "$EXITCODE" "../avocado-result.modulelint/html/resu # run module tests echo 'Running MTF with module tests...' pushd "$WORKDIR" -/usr/share/moduleframework/tools/run-them.sh "$MODULENAME" "$MODULENAME_STREAM_VERSION" pdc +/usr/share/moduleframework/tools/run-them.sh "$MODULENAME" "$MODULENAME_STREAM_VERSION" pdc \ + 2>&1 | tee "$LOG_FILE_NAME" EXITCODE="$?" popd @@ -153,7 +179,7 @@ taskotron_result \ --checkname "modularity-testing-framework.modulelint" \ --outcome "$(sed -n 1p "$WORKDIR/outcome.modulelint")" \ --note "$(sed -n 2p "$WORKDIR/outcome.modulelint")" \ - --artifact "$(check_artifact "$ARTIFACTSDIR/avocado-result.modulelint/html/results.html" "$ARTIFACTSDIR/html/index.html")" \ + --artifact "$(check_artifact "$ARTIFACTSDIR/avocado-result.modulelint/html/index.html" "$ARTIFACTSDIR/avocado-result.modulelint")" \ --file "$WORKDIR/results.yaml" taskotron_result \ --item "$MODULENAME_STREAM_VERSION" \ @@ -161,7 +187,7 @@ taskotron_result \ --checkname "modularity-testing-framework.tests" \ --outcome "$(sed -n 1p "$WORKDIR/outcome.tests")" \ --note "$(sed -n 2p "$WORKDIR/outcome.tests")" \ - --artifact "$(check_artifact "$ARTIFACTSDIR/avocado-result.tests/html/results.html" "$ARTIFACTSDIR/html/index.html")" \ + --artifact "$(check_artifact "$ARTIFACTSDIR/avocado-result.tests/html/results.html" "$ARTIFACTSDIR/avocado-result.tests")" \ --file "$WORKDIR/results.yaml" taskotron_result \ --item "$MODULENAME_STREAM_VERSION" \ From 3333649b843e8a414bd5a40fe14c50d378411c17 Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Dec 01 2017 09:42:36 +0000 Subject: [PATCH 2/2] mkdir after skipping --- diff --git a/run_mtf.sh b/run_mtf.sh index 3eaf491..e6b8780 100755 --- a/run_mtf.sh +++ b/run_mtf.sh @@ -60,11 +60,12 @@ function save_artifacts { local OUTDIR="$2" local INDEXF="$OUTDIR/index.html" local AVOCADOPATH="/root/avocado/job-results/latest" - mkdir -p $OUTDIR if [ "$EXITCODE" -eq "$MTF_EXIT_SKIP" ]; then # skipped execution, no logs saved return fi + + mkdir -p $OUTDIR if [ -e "$AVOCADOPATH" ]; then cp -r "$AVOCADOPATH/*" "$OUTDIR" if [ -e "$OUTDIR/result.html" ]; then