diff --git a/daily_tests/daily_nightly_tests_report.py b/daily_tests/daily_nightly_tests_report.py index 20782f6..0f4c0da 100755 --- a/daily_tests/daily_nightly_tests_report.py +++ b/daily_tests/daily_nightly_tests_report.py @@ -78,7 +78,7 @@ } # The default directory used for nightly build -RESULT_DIR = "/var/tmp/daily_scl_tests" +RESULTS_DIR = "/var/tmp/daily_reports_dir" class NightlyTestsReport(object): @@ -148,7 +148,7 @@ def collect_data(self): self.data_dict["SUCCESS_DATA"] = [] failed_tests = False for test_case, plan, _ in self.available_test_case: - path_dir = Path(RESULT_DIR) / test_case + path_dir = Path(RESULTS_DIR) / test_case if not path_dir.is_dir(): print(f"The test case {path_dir} does not exists that is weird") self.data_dict["tmt"]["msg"].append( diff --git a/daily_tests/daily_scl_tests.sh b/daily_tests/daily_scl_tests.sh index 2fa0b4b..fe8b8f7 100755 --- a/daily_tests/daily_scl_tests.sh +++ b/daily_tests/daily_scl_tests.sh @@ -31,10 +31,8 @@ shift [[ -z "$1" ]] && { echo "You have to specify type of the test to run. test, test-openshift, test-openshift-pytest, test-openshift-4" && exit 1 ; } TESTS="$1" shift -SET_TEST="" -if [[ "${TESTS}" != "test-upstream" ]]; then - [[ -z "$1" ]] && { echo "You have to specify type of images S2I or NOS2I" && exit 1 ; } - SET_TEST="$1" +if [[ -z "$SET_TEST" ]]; then + SET_TEST="S2I" fi CUR_WD=$(pwd) echo "Current working directory is: ${CUR_WD}" diff --git a/prepare_machine.sh b/prepare_machine.sh index cc9b18d..7e1db75 100755 --- a/prepare_machine.sh +++ b/prepare_machine.sh @@ -5,6 +5,7 @@ set -x LOGS_DIR="/home/fedora/logs" DAILY_TEST_DIR="/var/tmp/daily_scl_tests" WORK_DIR=$(mktemp -d -p "/var/tmp") +REPORTS_DIR="/var/tmp/daily_reports_dir" if [ -d "${DAILY_TEST_DIR}" ]; then rm -rf "${DAILY_TEST_DIR}" @@ -17,3 +18,7 @@ fi if [ -d "${LOGS_DIR}" ]; then rm -rf "${LOGS_DIR}" fi + +if [ -d "${REPORTS_DIR}" ]; then + rm -rf "${REPORTS_DIR}" +fi diff --git a/run_nightly_tests.sh b/run_nightly_tests.sh index 56a49f8..5a60195 100755 --- a/run_nightly_tests.sh +++ b/run_nightly_tests.sh @@ -3,14 +3,21 @@ set -x LOGS_DIR="/home/fedora/logs" -[[ -z "$1" ]] && { echo "You have to specify target to build SCL images. c10s, c9s, c8s, rhel8, or fedora" && exit 1 ; } +[[ -z "$1" ]] && { echo "You have to specify target to build SCL images. rhel9, rhel8, or fedora" && exit 1 ; } TARGET="$1" shift -[[ -z "$1" ]] && { echo "You have to specify type of the test to run. test, test-openshift-pytest, test-openshift-4" && exit 1 ; } +[[ -z "$1" ]] && { echo "You have to specify type of the test to run. test, test-openshift, test-openshift-pytest, test-openshift-4" && exit 1 ; } TESTS="$1" +shift +SET_TEST="" +if [[ "${TESTS}" != "test-upstream" ]]; then + [[ -z "$1" ]] && { echo "You have to specify type of images S2I or NOS2I" && exit 1 ; } + SET_TEST="$1" +fi TMT_REPO="https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans" DAILY_TEST_DIR="/var/tmp/daily_scl_tests" +RESULTS_DIR="/var/tmp/daily_reports_dir" TMT_DIR="sclorg-tmt-plans" API_KEY="API_KEY_PRIVATE" TFT_PLAN="nightly-container-$TARGET" @@ -56,28 +63,41 @@ cd /home/fedora || { echo "Could not switch to /home/fedora"; exit 1; } if [[ ! -d "${LOGS_DIR}" ]]; then mkdir -p "${LOGS_DIR}" fi +if [[ ! -d "${REPORTS_DIR}" ]]; then + mkdir -p "${REPORTS_DIR}" +fi COMPOSE=$(tmt -q run provision -h minute --list-images | grep $COMPOSE | head -n 1 | tr -d '[:space:]') -mkdir -p "${DAILY_TEST_DIR}/${TARGET}-$TESTS" +DIR="${DAILY_TEST_DIR}/${TARGET}-${TESTS}-${SET_TEST}" +if [[ "$TESTS" == "test-upstream" ]]; then + DIR="${DAILY_TEST_DIR}/${TARGET}-${TESTS}" +fi +mkdir -p "${RESULTS_DIR}/${TARGET}-${TESTS}/plans/${TFT_PLAN}/data/results" +mkdir -p "$DIR" LOG="${LOGS_DIR}/$TARGET-$TESTS.log" + date > "${LOG}" curl --insecure -L https://url.corp.redhat.com/fmf-data > /tmp/fmf_data source /tmp/fmf_data cd "$WORK_DIR/$TMT_DIR" || { echo "Could not switch to $WORK_DIR/$TMT_DIR"; exit 1; } echo "TARGET is: ${TARGET} and test is: ${TESTS}" | tee -a "${LOG}" -touch "${DAILY_TEST_DIR}/$TARGET-$TESTS/tmt_running" -TMT_COMMAND="tmt run -v -v -d -d --all -e SCRIPT=$SCRIPT -e OS=$TARGET -e TEST=$TESTS --id ${DAILY_TEST_DIR}/$TARGET-$TESTS plan --name $TFT_PLAN provision --how minute --auto-select-network --image ${COMPOSE}" +touch "${RESULTS_DIR}/${TARGET}-${TESTS}/tmt_running" +TMT_COMMAND="tmt run -v -v -d -d --all -e SCRIPT=$SCRIPT -e OS=$TARGET -e SET_TEST=$SET_TEST -e TEST=$TESTS --id ${DIR} plan --name $TFT_PLAN provision --how minute --auto-select-network --image ${COMPOSE}" echo "TMT command is: $TMT_COMMAND" | tee -a "${LOG}" set -o pipefail $TMT_COMMAND | tee -a "${LOG}" if [[ $? -ne 0 ]]; then echo "TMT command $TMT_COMMAND has failed." - touch "${DAILY_TEST_DIR}/$TARGET-$TESTS/tmt_failed" + touch "${RESULTS_DIR}/${TARGET}-${TESTS}/tmt_failed" + if [[ -d "${DIR}/plans/${TFT_PLAN}/data/results" ]]; then + cp -rv "${DIR}/plans/${TFT_PLAN}/data/results/*" "${RESULTS_DIR}/${TARGET}-${TESTS}/plans/${TFT_PLAN}/data/results/" + fi + cp "${DIR}/log.txt" "${RESULTS_DIR}/${TARGET}-${TESTS}/" else - touch "${DAILY_TEST_DIR}/$TARGET-$TESTS/tmt_success" + touch "${RESULTS_DIR}/${TARGET}-${TESTS}/tmt_success" fi set +o pipefail -rm -f "${DAILY_TEST_DIR}/$TARGET-$TESTS/tmt_running" +rm -f "${RESULTS_DIR}/${TARGET}-${TESTS}/tmt_running" cd "$CWD" || exit 1 rm -rf "$WORK_DIR"