From 575d9ce7d6f95f15e4cfb91baa828774c5f53a18 Mon Sep 17 00:00:00 2001 From: Anand Kumar Singh Date: Mon, 7 Mar 2022 15:32:48 +0530 Subject: [PATCH] Fix windows script to use correct API KEY (#5512) * fix windows script to use correct API KEY Signed-off-by: anandrkskd * remove github login Signed-off-by: anandrkskd * k8s updated qe key Signed-off-by: anandrkskd * use serviceid API key Signed-off-by: anandrkskd * update save_log func Signed-off-by: anandrkskd * make script executable Signed-off-by: anandrkskd --- .ibm/pipelines/functions.sh | 14 ++++++-------- .ibm/pipelines/kubernetes-tests.sh | 2 +- .ibm/pipelines/openshift-tests.sh | 4 +--- .ibm/pipelines/unit-tests.sh | 2 +- .ibm/pipelines/validate.sh | 2 +- .ibm/pipelines/windows-test-script.ps1 | 2 +- .ibm/pipelines/windows-test.sh | 16 ++++++++-------- 7 files changed, 19 insertions(+), 23 deletions(-) mode change 100644 => 100755 .ibm/pipelines/kubernetes-tests.sh mode change 100644 => 100755 .ibm/pipelines/openshift-tests.sh mode change 100644 => 100755 .ibm/pipelines/unit-tests.sh mode change 100644 => 100755 .ibm/pipelines/validate.sh diff --git a/.ibm/pipelines/functions.sh b/.ibm/pipelines/functions.sh index e2a1e4380..16f6a6774 100644 --- a/.ibm/pipelines/functions.sh +++ b/.ibm/pipelines/functions.sh @@ -11,17 +11,17 @@ save_logs() { apt update apt install jq colorized-logs --yes - ansi2html < "/tmp/${LOGFILE}" > "/tmp/${LOGFILE}.html" - ansi2txt < "/tmp/${LOGFILE}" > "/tmp/${LOGFILE}.txt" + ansi2html <"/tmp/${LOGFILE}" >"/tmp/${LOGFILE}.html" + ansi2txt <"/tmp/${LOGFILE}" >"/tmp/${LOGFILE}.txt" - ibmcloud target -g "${IBM_RESOURCE_GROUP}" + ibmcloud login --apikey "${API_KEY}" + ibmcloud target -g "${IBM_RESOURCE_GROUP}" -r "${IBM_REGION}" CRN=$(ibmcloud resource service-instance ${IBM_COS} --output json | jq -r .[0].guid) ibmcloud cos config crn --crn "${CRN}" ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}.html" --file "/tmp/${LOGFILE}.html" ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}.txt" --file "/tmp/${LOGFILE}.txt" - echo -n ${GITHUB_TOKEN} | gh auth login --with-token BASE_URL="https://s3.${IBM_REGION}.cloud-object-storage.appdomain.cloud/${IBM_BUCKET}" if [[ $RESULT == "0" ]]; then STATUS="successfully" @@ -38,12 +38,10 @@ EOF # with values: "team: odo" and "type: testing" cleanup_namespaces() { PROJECTS=$(kubectl get cm -A | grep config-map-for-cleanup | awk '{ print $1 }') - for PROJECT in ${PROJECTS} - do + for PROJECT in ${PROJECTS}; do TEAM=$(kubectl get configmaps config-map-for-cleanup -n ${PROJECT} -o jsonpath='{.data.team}') TYPE=$(kubectl get configmaps config-map-for-cleanup -n ${PROJECT} -o jsonpath='{.data.type}') - if [[ "${TYPE}" -eq "testing" ]] && [[ "${TEAM}" -eq "odo" ]] - then + if [[ "${TYPE}" -eq "testing" ]] && [[ "${TEAM}" -eq "odo" ]]; then kubectl delete namespace ${PROJECT} --wait=false fi done diff --git a/.ibm/pipelines/kubernetes-tests.sh b/.ibm/pipelines/kubernetes-tests.sh old mode 100644 new mode 100755 index c5b1ed9dc..7f5209cde --- a/.ibm/pipelines/kubernetes-tests.sh +++ b/.ibm/pipelines/kubernetes-tests.sh @@ -4,7 +4,7 @@ LOGFILE="pr-${GIT_PR_NUMBER}-kubernetes-tests-${BUILD_NUMBER}" source .ibm/pipelines/functions.sh -ibmcloud login --apikey "${API_KEY}" +ibmcloud login --apikey "${API_KEY_QE}" ibmcloud target -r "${IBM_REGION}" ibmcloud ks cluster config --cluster "${IBM_KUBERNETES_ID}" --admin diff --git a/.ibm/pipelines/openshift-tests.sh b/.ibm/pipelines/openshift-tests.sh old mode 100644 new mode 100755 index 39fb5f16f..fca40c403 --- a/.ibm/pipelines/openshift-tests.sh +++ b/.ibm/pipelines/openshift-tests.sh @@ -4,7 +4,7 @@ LOGFILE="pr-${GIT_PR_NUMBER}-openshift-tests-${BUILD_NUMBER}" source .ibm/pipelines/functions.sh -oc login -u apikey -p "${API_KEY}" "${IBM_OPENSHIFT_ENDPOINT}" +oc login -u apikey -p "${API_KEY_QE}" "${IBM_OPENSHIFT_ENDPOINT}" cleanup_namespaces @@ -20,8 +20,6 @@ cleanup_namespaces ) |& tee "/tmp/${LOGFILE}" RESULT=${PIPESTATUS[0]} -ibmcloud login --apikey "${API_KEY}" -ibmcloud target -r "${IBM_REGION}" save_logs "${LOGFILE}" "OpenShift Tests" ${RESULT} exit ${RESULT} diff --git a/.ibm/pipelines/unit-tests.sh b/.ibm/pipelines/unit-tests.sh old mode 100644 new mode 100755 index 7742c9034..fa404d672 --- a/.ibm/pipelines/unit-tests.sh +++ b/.ibm/pipelines/unit-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Script to run unit test on IBM Cloud +# Script to run unit test on IBM Cloud # This script needs update if there is any change in the unit test make target command LOGFILE="pr-${GIT_PR_NUMBER}-unit-tests-${BUILD_NUMBER}" diff --git a/.ibm/pipelines/validate.sh b/.ibm/pipelines/validate.sh old mode 100644 new mode 100755 index 5fbe3de9e..53f2d51b6 --- a/.ibm/pipelines/validate.sh +++ b/.ibm/pipelines/validate.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Script to run validate test on IBM Cloud +# Script to run validate test on IBM Cloud # This script needs update if there is any change in steps of executing validate test LOGFILE="pr-${GIT_PR_NUMBER}-Validate-tests-${BUILD_NUMBER}" diff --git a/.ibm/pipelines/windows-test-script.ps1 b/.ibm/pipelines/windows-test-script.ps1 index d8f0edf18..f271d8830 100644 --- a/.ibm/pipelines/windows-test-script.ps1 +++ b/.ibm/pipelines/windows-test-script.ps1 @@ -57,7 +57,7 @@ function Run-Test { Shout "Login Openshift" - oc login -u apikey -p ${API_KEY_QE} ${IBM_OPENSHIFT_ENDPOINT} + oc login -u apikey -p ${API_KEY} ${IBM_OPENSHIFT_ENDPOINT} Shout "Create Binary" make install diff --git a/.ibm/pipelines/windows-test.sh b/.ibm/pipelines/windows-test.sh index dc1624041..8f8f552c3 100755 --- a/.ibm/pipelines/windows-test.sh +++ b/.ibm/pipelines/windows-test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash ################################################### # This script is used to run the test on windows @@ -10,20 +10,20 @@ set -x LOGFILE="pr-${GIT_PR_NUMBER}-windows-tests-${BUILD_NUMBER}" export REPO=${REPO:-"https://github.com/redhat-developer/odo"} #copy test script inside /tmp/ -sshpass -p $WINDOWS_PASSWORD scp -o StrictHostKeyChecking=no ./.ibm/pipelines/windows-test-script.ps1 Administrator@$WINDOWS_IP:/tmp/windows-test-script.ps1 +sshpass -p $WINDOWS_PASSWORD scp -o StrictHostKeyChecking=no ./.ibm/pipelines/windows-test-script.ps1 Administrator@$WINDOWS_IP:/tmp/windows-test-script.ps1 #execute test from the test script -sshpass -p $WINDOWS_PASSWORD ssh Administrator@$WINDOWS_IP -o StrictHostKeyChecking=no powershell /tmp/windows-test-script.ps1 "${GIT_PR_NUMBER}" "${BUILD_NUMBER}" "${API_KEY}" "${IBM_OPENSHIFT_ENDPOINT}" "${LOGFILE}" "${REPO}" +sshpass -p $WINDOWS_PASSWORD ssh Administrator@$WINDOWS_IP -o StrictHostKeyChecking=no powershell /tmp/windows-test-script.ps1 "${GIT_PR_NUMBER}" "${BUILD_NUMBER}" "${API_KEY_QE}" "${IBM_OPENSHIFT_ENDPOINT}" "${LOGFILE}" "${REPO}" RESULT=$? echo "RESULT: $RESULT" # save log source .ibm/pipelines/functions.sh ibmcloud login --apikey "${API_KEY}" -r "${IBM_REGION}" -sshpass -p $WINDOWS_PASSWORD scp -o StrictHostKeyChecking=no Administrator@$WINDOWS_IP:/tmp/${LOGFILE} /tmp/${LOGFILE} -save_logs "${LOGFILE}" "Windows Tests (OCP)" $RESULT +sshpass -p $WINDOWS_PASSWORD scp -o StrictHostKeyChecking=no Administrator@$WINDOWS_IP:/tmp/${LOGFILE} /tmp/${LOGFILE} +save_logs "${LOGFILE}" "Windows Tests (OCP)" $RESULT -# cleanup -sshpass -p $WINDOWS_PASSWORD ssh Administrator@$WINDOWS_IP -o StrictHostKeyChecking=no rm -rf /tmp/windows-test-script.ps1 +# cleanup +sshpass -p $WINDOWS_PASSWORD ssh Administrator@$WINDOWS_IP -o StrictHostKeyChecking=no rm -rf /tmp/windows-test-script.ps1 -exit ${RESULT} \ No newline at end of file +exit ${RESULT}