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

Define global variable for results and store tests here. #148

Merged
merged 1 commit into from
Oct 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions daily_tests/daily_nightly_tests_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions daily_tests/daily_scl_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
5 changes: 5 additions & 0 deletions prepare_machine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
36 changes: 28 additions & 8 deletions run_nightly_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Loading