Skip to content

Commit

Permalink
Merge pull request #875 from chandrams/manifest_build
Browse files Browse the repository at this point in the history
Updated scripts and workflows to test kruize docker image from the manifest yaml
  • Loading branch information
dinogun authored Nov 3, 2023
2 parents de9d6ef + 2d4514a commit 5444752
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 26 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test-on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,55 @@ jobs:
name: crc-results
path: ./crc_results.tar
retention-days: 2


test_crc_manifest_build:
# The type of runner that the job will run on
runs-on: ubuntu-20.04

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Setup Minikube
uses: manusa/[email protected]
with:
minikube version: 'v1.16.0'
kubernetes version: 'v1.19.2'

- name: Check cluster info on minikube
run: |
kubectl cluster-info
kubectl get pods -n kube-system
- name: Install Prometheus on minikube
run: |
echo Install Prometheus on minikube
cd scripts
./prometheus_on_minikube.sh -as
- name: Test with manifest kruize build in crc mode
run: |
echo Test with manifest kruize build in crc mode
echo "***************************************************************"
cd tests
./test_autotune.sh -c minikube --testsuite=remote_monitoring_tests --testcase=test_e2e --resultsdir=${GITHUB_WORKSPACE}
- name: Capture ffdc logs
if: always()
run: |
./scripts/ffdc.sh -m crc -d ${GITHUB_WORKSPACE}/kruize_test_results
- name: Archive results
if: always()
run: |
cd ${GITHUB_WORKSPACE}
tar cvf crc_manifest_results.tar kruize_test_results
- name: Upload results
if: always()
uses: actions/upload-artifact@v3
with:
name: crc-manifest-results
path: ./crc_manifest_results.tar
retention-days: 2

9 changes: 8 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ target="autotune"
# docker: loop timeout is turned off by default
timeout=-1

# Test with the kruize docker image specified in the deployment yaml
use_yaml_build=0

function ctrlc_handler() {
# Check if cluster type is docker
if [[ "$cluster_type" == "docker" ]]; then
Expand All @@ -103,6 +106,7 @@ function usage() {
echo " -n: Namespace to which autotune is deployed [Default - monitoring namespace for cluster type minikube]"
echo " -d: Config maps directory [Default - manifests/configmaps]"
echo " -m: Target mode selection [autotune | crc]"
echo " -b: Test with the kruize docker image in the deployment yaml"
exit -1
}

Expand All @@ -119,7 +123,7 @@ function check_cluster_type() {
}

# Iterate through the commandline options
while getopts ac:d:i:k:m:n:o:p:stu:-: gopts; do
while getopts ac:d:i:k:m:n:o:p:stub-: gopts; do
case ${gopts} in
-)
case "${OPTARG}" in
Expand Down Expand Up @@ -171,6 +175,9 @@ while getopts ac:d:i:k:m:n:o:p:stu:-: gopts; do
u)
KRUIZE_UI_DOCKER_IMAGE="${OPTARG}"
;;
b)
use_yaml_build=1
;;
[?])
usage
;;
Expand Down
40 changes: 22 additions & 18 deletions scripts/common_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,32 @@ kruize_crc_start() {
kubectl_cmd="kubectl -n ${autotune_ns}"
CRC_MANIFEST_FILE_OLD="${CRC_DIR}/${cluster_type}/kruize_${cluster_type}.yaml"

cp ${CRC_MANIFEST_FILE} ${CRC_MANIFEST_FILE_OLD}
awk -v image_name=${AUTOTUNE_DOCKER_IMAGE} -v ui_image_name=${KRUIZE_UI_DOCKER_IMAGE} '{
if ($2=="name:") {
prev=$3;
print
} else if ($1=="image:" && prev=="kruizecronjob") {
$2=image_name;
printf" %s %s\n", $1, $2;
} else if ($1=="image:" && prev=="kruize") {
$2=image_name;
printf" %s %s\n", $1, $2;
} else if ($1=="image:" && prev=="kruize-ui-nginx-container") {
$2=ui_image_name;
printf" %s %s\n", $1, $2;
} else { print }
}' ${CRC_MANIFEST_FILE_OLD} >${CRC_MANIFEST_FILE}
echo "use yaml build - $use_yaml_build"
if [ ${use_yaml_build} -eq 0 ]; then
cp ${CRC_MANIFEST_FILE} ${CRC_MANIFEST_FILE_OLD}
awk -v image_name=${AUTOTUNE_DOCKER_IMAGE} -v ui_image_name=${KRUIZE_UI_DOCKER_IMAGE} '{
if ($2=="name:") {
prev=$3;
print
} else if ($1=="image:" && prev=="kruize") {
$2=image_name;
printf" %s %s\n", $1, $2;
} else if ($1=="image:" && prev=="kruize-ui-nginx-container") {
$2=ui_image_name;
printf" %s %s\n", $1, $2;
} else { print }
}' ${CRC_MANIFEST_FILE_OLD} >${CRC_MANIFEST_FILE}
fi

${kubectl_cmd} apply -f ${CRC_MANIFEST_FILE}
check_running kruize ${autotune_ns} kruize-ui
if [ "${err}" != "0" ]; then
# Indicate deploy failed on error
exit 1
fi
cp ${CRC_MANIFEST_FILE_OLD} ${CRC_MANIFEST_FILE}
rm ${CRC_MANIFEST_FILE_OLD}

if [ ${use_yaml_build} -eq 0 ]; then
cp ${CRC_MANIFEST_FILE_OLD} ${CRC_MANIFEST_FILE}
rm ${CRC_MANIFEST_FILE_OLD}
fi
}
2 changes: 1 addition & 1 deletion tests/scripts/common/common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function deploy_autotune() {
if [ ${target} == "autotune" ]; then
cmd="./deploy.sh -c ${cluster_type} -d ${CONFIGMAP} -m ${target}"
elif [ ${target} == "crc" ]; then
cmd="./deploy.sh -c ${cluster_type} -m ${target}"
cmd="./deploy.sh -c ${cluster_type} -m ${target} -b"
fi
# if both autotune image and configmap is passed
elif [[ ! -z "${AUTOTUNE_IMAGE}" && ! -z "${CONFIGMAP_DIR}" ]]; then
Expand Down
18 changes: 12 additions & 6 deletions tests/test_autotune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ if [ ! -z "${testcase}" ]; then
fi
fi

if [ -z "${AUTOTUNE_DOCKER_IMAGE}" ]; then
AUTOTUNE_DOCKER_IMAGE="${AUTOTUNE_IMAGE}"
fi

# check for benchmarks directory path
if [ ! "${testsuite}" == "remote_monitoring_tests" ]; then
if [ -z "${APP_REPO}" ]; then
Expand All @@ -236,9 +232,19 @@ if [ "${setup}" -ne "0" ]; then
# Call the proper setup function based on the cluster_type
echo -n "############# Performing ${tctype} test for autotune #############"
if [ ${skip_setup} -eq 1 ]; then
${SCRIPTS_DIR}/${tctype}_tests.sh --cluster_type=${cluster_type} --tctype=${tctype} --testmodule=${testmodule} --testsuite=${testsuite} --testcase=${testcase} --resultsdir=${resultsdir} -i ${AUTOTUNE_DOCKER_IMAGE} -r ${APP_REPO} --skipsetup
#if [ ${testsuite} == "remote_monitoring_tests" ]; then
if [ -z "${AUTOTUNE_DOCKER_IMAGE}" ]; then
${SCRIPTS_DIR}/${tctype}_tests.sh --cluster_type=${cluster_type} --tctype=${tctype} --testmodule=${testmodule} --testsuite=${testsuite} --testcase=${testcase} --resultsdir=${resultsdir} -r ${APP_REPO} --skipsetup
else
${SCRIPTS_DIR}/${tctype}_tests.sh --cluster_type=${cluster_type} --tctype=${tctype} --testmodule=${testmodule} --testsuite=${testsuite} --testcase=${testcase} --resultsdir=${resultsdir} -i ${AUTOTUNE_DOCKER_IMAGE} -r ${APP_REPO} --skipsetup
fi
else
${SCRIPTS_DIR}/${tctype}_tests.sh --cluster_type=${cluster_type} --tctype=${tctype} --testmodule=${testmodule} --testsuite=${testsuite} --testcase=${testcase} --resultsdir=${resultsdir} -i ${AUTOTUNE_DOCKER_IMAGE} -r ${APP_REPO}
if [ -z "${AUTOTUNE_DOCKER_IMAGE}" ]; then
#if [ ${testsuite} == "remote_monitoring_tests" ]; then
${SCRIPTS_DIR}/${tctype}_tests.sh --cluster_type=${cluster_type} --tctype=${tctype} --testmodule=${testmodule} --testsuite=${testsuite} --testcase=${testcase} --resultsdir=${resultsdir} -r ${APP_REPO}
else
${SCRIPTS_DIR}/${tctype}_tests.sh --cluster_type=${cluster_type} --tctype=${tctype} --testmodule=${testmodule} --testsuite=${testsuite} --testcase=${testcase} --resultsdir=${resultsdir} -i ${AUTOTUNE_DOCKER_IMAGE} -r ${APP_REPO}
fi
fi

TEST_RESULT=$?
Expand Down

0 comments on commit 5444752

Please sign in to comment.