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

Add daily_helm_charts #140

Merged
merged 1 commit into from
Aug 13, 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
63 changes: 63 additions & 0 deletions daily_tests/daily_helm_charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

set -x

HELM_CHARTS="\
httpd
mariadb
mysql
nginx
postgresql
redis
php
perl
nodejs
ruby
python
"
TMP_DIR="${TMT_PLAN_DATA}"
RESULT_DIR="${TMP_DIR}/results/"
KUBECONFIG=/root/.kube/config
KUBEPASSWD=/root/.kube/ocp-kube

mkdir -p "${RESULT_DIR}"

function clone_repo() {
local repo_name="helm-charts"
# Sometimes cloning failed with an error
# The requested URL returned error: 500. Save it into log for info
git clone "https://github.com/sclorg/${repo_name}.git" || \
{ echo "Repository ${repo_name} was not cloned." > ${RESULT_DIR}/${repo_name}.log; return 1 ; }
cd "${repo_name}" || { echo "Repository ${repo_name} does not exist. Skipping." && return 1 ; }
}

function iterate_over_all_helm_charts() {

for helm in ${HELM_CHARTS}; do
# Do not shutting down OpenShift 3 cluster
export OS_CLUSTER_STARTED_BY_TEST=0
local log_name="${TMP_DIR}/helm-chart-${helm}.log"
make "test-${helm}" > "${log_name}" 2>&1
if [[ $? -ne 0 ]]; then
echo "Tests for helm $helm has failed."
cp "${log_name}" "${RESULT_DIR}/"
echo "Show the last 100 lines from file: ${RESULT_DIR}/${log_name}.log"
tail -100 "${RESULT_DIR}/${log_name}.log"
fi
done
}

git clone https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans /root/sclorg-tmt-plans
git clone https://github.com/sclorg/container-common-scripts.git /root/container-common-scripts

echo "Testing OpenShift 4 is enabled"
# Download kubeconfig
curl -L --insecure https://url.corp.redhat.com/sclorg-data-kubeconfig >$KUBECONFIG
# Download kubepasswd
curl -L --insecure https://url.corp.redhat.com/sclorg-data-kubepasswd >$KUBEPASSWD

clone_repo

iterate_over_all_helm_charts

cd "${CUR_WD}"
5 changes: 2 additions & 3 deletions daily_tests/daily_scl_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ git clone https://github.com/sclorg/container-common-scripts.git /root/container

if [[ "${TESTS}" == "test-openshift-4" ]]; then
echo "Testing OpenShift 4 is enabled"
# Download kubeconfig
curl -L --insecure https://url.corp.redhat.com/ocp4-kubeconfig >$KUBECONFIG
curl -L --insecure https://url.corp.redhat.com/sclorg-data-kubeconfig >$KUBECONFIG
# Download kubepasswd
curl -L --insecure https://url.corp.redhat.com/ocp4-kubepasswd >$KUBEPASSWD
curl -L --insecure https://url.corp.redhat.com/sclorg-data-kubepasswd >$KUBEPASSWD
fi

if [[ "${TESTS}" == "test-openshift" ]]; then
Expand Down
51 changes: 51 additions & 0 deletions run_nightly_helm_charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -x

LOGS_DIR="/home/fedora/logs"

TARGET="rhel8"
TMT_REPO="https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
DAILY_TEST_DIR="/var/tmp/daily_scl_tests"
TMT_DIR="sclorg-tmt-plans"
API_KEY="API_KEY_PRIVATE"
TFT_PLAN="nightly-container-rhel8"
COMPOSE="1MT-RHEL-8.10.0-updates"
TESTS="helm-charts"
SCRIPT="daily_helm_charts"

WORK_DIR=$(mktemp -d -p "/var/tmp")
git clone "$TMT_REPO" "$WORK_DIR/$TMT_DIR"
CWD=$(pwd)
cd /home/fedora || { echo "Could not switch to /home/fedora"; exit 1; }
if [[ ! -d "${LOGS_DIR}" ]]; then
mkdir -p "${LOGS_DIR}"
fi
COMPOSE=$(tmt -q run provision -h minute --list-images | grep $COMPOSE | head -n 1 | tr -d '[:space:]')
echo "COMPOSE is $COMPOSE" | tee -a ${LOG}
if [ -d "${DAILY_TEST_DIR}/${TARGET}-$TESTS" ]; then
rm -rf "${DAILY_TEST_DIR}/${TARGET}-$TESTS"
fi
mkdir -p "${DAILY_TEST_DIR}/${TARGET}-$TESTS"
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}"
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"
else
touch "${DAILY_TEST_DIR}/$TARGET-$TESTS/tmt_success"
fi
set +o pipefail
rm -f "${DAILY_TEST_DIR}/$TARGET-$TESTS/tmt_running"
cd "$CWD" || exit 1
rm -rf "$WORK_DIR"
3 changes: 2 additions & 1 deletion run_nightly_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ if [[ "$TESTS" != "test" ]] && [[ "$TESTS" != "test-upstream" ]] && [[ "$TESTS"
exit 1
fi

SCRIPT="daily_scl_tests"
WORK_DIR=$(mktemp -d -p "/var/tmp")
git clone "$TMT_REPO" "$WORK_DIR/$TMT_DIR"
CWD=$(pwd)
Expand All @@ -64,7 +65,7 @@ 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 OS=$TARGET -e TEST=$TESTS --id ${DAILY_TEST_DIR}/$TARGET-$TESTS plan --name $TFT_PLAN provision --how minute --auto-select-network --image ${COMPOSE}"
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}"
echo "TMT command is: $TMT_COMMAND" | tee -a "${LOG}"
set -o pipefail
$TMT_COMMAND | tee -a "${LOG}"
Expand Down
Loading