diff --git a/.github/workflows/test-on-pr.yaml b/.github/workflows/test-on-pr.yaml index 93d339d60..0453557e7 100644 --- a/.github/workflows/test-on-pr.yaml +++ b/.github/workflows/test-on-pr.yaml @@ -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/actions-setup-minikube@v2.3.0 + 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 + diff --git a/deploy.sh b/deploy.sh index c687a5763..d67c027bb 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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 @@ -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 } @@ -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 @@ -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 ;; diff --git a/scripts/common_utils.sh b/scripts/common_utils.sh index ab4c2c0e7..f0908301f 100755 --- a/scripts/common_utils.sh +++ b/scripts/common_utils.sh @@ -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 } diff --git a/tests/scripts/common/common_functions.sh b/tests/scripts/common/common_functions.sh index cb7b15921..37f736475 100755 --- a/tests/scripts/common/common_functions.sh +++ b/tests/scripts/common/common_functions.sh @@ -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 diff --git a/tests/test_autotune.sh b/tests/test_autotune.sh index f6fe3f45c..5bf18e2e4 100755 --- a/tests/test_autotune.sh +++ b/tests/test_autotune.sh @@ -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 @@ -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=$?