From 6162287a0ec6e4671c6552e2d10e2466ba5e408e Mon Sep 17 00:00:00 2001 From: Rafaela Maria Soares da Silva Date: Mon, 25 Nov 2024 12:07:12 +0000 Subject: [PATCH] test: KUBESAW-236 update ci scripts (#1065) * update ci scripts * clean OWNER_AND_BRANCH_LOCATION * delete collect_logs.sh --- scripts/ci/collect-logs.sh | 94 ---------------------------- scripts/ci/manage-host-operator.sh | 11 +--- scripts/ci/manage-member-operator.sh | 11 +--- scripts/ci/manage-operator.sh | 31 +-------- scripts/ci/setup-dev-sso.sh | 10 +-- 5 files changed, 5 insertions(+), 152 deletions(-) delete mode 100755 scripts/ci/collect-logs.sh diff --git a/scripts/ci/collect-logs.sh b/scripts/ci/collect-logs.sh deleted file mode 100755 index 0563c7963..000000000 --- a/scripts/ci/collect-logs.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash - - -user_help () { - echo "Collects all logs from the given namespace" - echo "options:" - echo "-n, --namespace The namespace the logs should be collected from." - echo "-h, --help To show this help text" - echo "" - exit 0 -} - -read_arguments() { - if [[ $# -lt 2 ]] - then - user_help - fi - - while test $# -gt 0; do - case "$1" in - -h|--help) - user_help - ;; - -n|--namespace) - shift - NAMESPACE=$1 - shift - ;; - *) - echo "$1 is not a recognized flag!" >> /dev/stderr - user_help - exit -1 - ;; - esac - done -} - - -start_collecting_logs() { - if [[ -n ${ARTIFACT_DIR} ]]; then - if [[ ! -d ${ARTIFACT_DIR} ]]; then - echo "ERROR: the ARTIFACT_DIR env var is set to ${ARTIFACT_DIR}, but the directory does not exist" - exit 1 - fi - COLLECTING_FILE="${ARTIFACT_DIR}/collecting_${NAMESPACE}" - - if [[ ! -f ${COLLECTING_FILE} ]]; then - touch ${COLLECTING_FILE} - echo "Collecting logs from namespace ${NAMESPACE}" - - LOGS_DIR=${ARTIFACT_DIR}/logs_${NAMESPACE} - mkdir ${LOGS_DIR} || true - - COUNTER=0 - PROCESSES="" - while [[ -n "$(oc whoami 2>/dev/null)" ]] && [[ -f ${COLLECTING_FILE} ]]; do - if [[ -z "${CI}" ]] && [[ $(( ${COUNTER} % 20 )) == 0 ]]; then - echo "Collecting logs from namespace ${NAMESPACE} - to stop the process please delete ${COLLECTING_FILE} file or log out from the cluster" - fi - - for POD in $(oc get pods -o name -n ${NAMESPACE}); - do - - for CONTAINER in $(oc get ${POD} -n ${NAMESPACE} -o jsonpath="{.spec.containers[*].name}"); - do - LOG_FILE_NAME=$(echo "${POD}-${CONTAINER}" | sed 's|/|-|g') - LOG_FILE=${LOGS_DIR}/${LOG_FILE_NAME} - - if [[ ! -f ${LOG_FILE} ]]; then - if [[ -n $(oc logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} 2>/dev/null || true) ]]; then - echo "collecting logs from container ${CONTAINER} in pod ${POD} in namespace ${NAMESPACE} to file ${LOG_FILE}" - oc logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} -f > ${LOG_FILE} & - PROCESSES="${PROCESSES}$! " - fi - fi - done - done - sleep 1 - COUNTER=$(( COUNTER + 1 )) - done - echo "killing the daemon processes ${PROCESSES}" - kill ${PROCESSES} - fi - else - if [[ -n "${CI}" ]]; then - echo "ARTIFACT_DIR env var is not set - no logs will be collected" - fi - fi -} - -set -e - -read_arguments $@ -start_collecting_logs \ No newline at end of file diff --git a/scripts/ci/manage-host-operator.sh b/scripts/ci/manage-host-operator.sh index 694197c1d..8918356c5 100755 --- a/scripts/ci/manage-host-operator.sh +++ b/scripts/ci/manage-host-operator.sh @@ -87,16 +87,7 @@ else set -e fi -MANAGE_OPERATOR_FILE=scripts/ci/manage-operator.sh -OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION:-codeready-toolchain/toolchain-cicd/master} -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -SCRIPT_NAME=$(basename ${MANAGE_OPERATOR_FILE}) - -if [[ -f ${SCRIPT_DIR}/${SCRIPT_NAME} ]]; then - source ${SCRIPT_DIR}/${SCRIPT_NAME} -else - source /dev/stdin <<< "$(curl -sSL https://raw.githubusercontent.com/${OWNER_AND_BRANCH_LOCATION}/${MANAGE_OPERATOR_FILE})" -fi +source scripts/ci/manage-operator.sh if [[ -n "${CI}${REG_REPO_PATH}${HOST_REPO_PATH}" ]] && [[ $(echo ${REPO_NAME} | sed 's/"//g') != "release" ]]; then REPOSITORY_NAME=registration-service diff --git a/scripts/ci/manage-member-operator.sh b/scripts/ci/manage-member-operator.sh index 7f666a14f..51584903f 100755 --- a/scripts/ci/manage-member-operator.sh +++ b/scripts/ci/manage-member-operator.sh @@ -86,16 +86,7 @@ else set -e fi -MANAGE_OPERATOR_FILE=scripts/ci/manage-operator.sh -OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION:-codeready-toolchain/toolchain-cicd/master} -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -SCRIPT_NAME=$(basename ${MANAGE_OPERATOR_FILE}) - -if [[ -f ${SCRIPT_DIR}/${SCRIPT_NAME} ]]; then - source ${SCRIPT_DIR}/${SCRIPT_NAME} -else - source /dev/stdin <<< "$(curl -sSL https://raw.githubusercontent.com/${OWNER_AND_BRANCH_LOCATION}/${MANAGE_OPERATOR_FILE})" -fi +source scripts/ci/manage-operator.sh if [[ -n "${CI}${MEMBER_REPO_PATH}" ]] && [[ $(echo ${REPO_NAME} | sed 's/"//g') != "release" ]]; then REPOSITORY_NAME=member-operator diff --git a/scripts/ci/manage-operator.sh b/scripts/ci/manage-operator.sh index d67a4b906..0a2bd7e29 100755 --- a/scripts/ci/manage-operator.sh +++ b/scripts/ci/manage-operator.sh @@ -7,7 +7,6 @@ else fi WAS_ALREADY_PAIRED_FILE=/tmp/toolchain_e2e_already_paired -OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION:-codeready-toolchain/toolchain-cicd/master} get_repo() { PAIRED=false @@ -204,8 +203,7 @@ install_operator() { sleep 1 done fi - -# start_collecting_logs + CATALOG_SOURCE_OBJECT=" apiVersion: operators.coreos.com/v1alpha1 @@ -272,32 +270,7 @@ EOF wait_until_is_installed } - -start_collecting_logs() { - COLLECT_LOGS=scripts/ci/collect-logs.sh - SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - SCRIPT_NAME=$(basename ${COLLECT_LOGS}) - - if [[ -f ${SCRIPT_DIR}/${SCRIPT_NAME} ]]; then - ${SCRIPT_DIR}/${SCRIPT_NAME} -n ${NAMESPACE} & - ${SCRIPT_DIR}/${SCRIPT_NAME} -n "openshift-operator-lifecycle-manager" & - else - SCRIPT_NAME=$(basename ${COLLECT_LOGS}) - curl -sSL https://raw.githubusercontent.com/${OWNER_AND_BRANCH_LOCATION}/${COLLECT_LOGS} > /tmp/${SCRIPT_NAME} && chmod +x /tmp/${SCRIPT_NAME} - OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION} /tmp/${SCRIPT_NAME} -n ${NAMESPACE} & - OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION} /tmp/${SCRIPT_NAME} -n "openshift-operator-lifecycle-manager" & - fi -} - wait_until_is_installed() { - WAIT_UNTIL_IS_INSTALLED=scripts/ci/wait-until-is-installed.sh PARAMS="-crd ${EXPECT_CRD} -cs ${CATALOGSOURCE_NAME} -n ${NAMESPACE} -s ${SUBSCRIPTION_NAME}" - SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - SCRIPT_NAME=$(basename ${WAIT_UNTIL_IS_INSTALLED}) - - if [[ -f ${SCRIPT_DIR}/${SCRIPT_NAME} ]]; then - ${SCRIPT_DIR}/${SCRIPT_NAME} ${PARAMS} - else - curl -sSL https://raw.githubusercontent.com/${OWNER_AND_BRANCH_LOCATION}/${WAIT_UNTIL_IS_INSTALLED} > /tmp/${SCRIPT_NAME} && chmod +x /tmp/${SCRIPT_NAME} && OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION} /tmp/${SCRIPT_NAME} ${PARAMS} - fi + scripts/ci/wait-until-is-installed.sh ${PARAMS} } \ No newline at end of file diff --git a/scripts/ci/setup-dev-sso.sh b/scripts/ci/setup-dev-sso.sh index 2112e7e63..be31ff2d0 100755 --- a/scripts/ci/setup-dev-sso.sh +++ b/scripts/ci/setup-dev-sso.sh @@ -60,16 +60,8 @@ check_command() } run_wait_until_is_installed() { - WAIT_UNTIL_IS_INSTALLED=scripts/ci/wait-until-is-installed.sh PARAMS="-crd keycloak.org -cs '' -n ${DEV_SSO_NS} -s ${SUBSCRIPTION_NAME}" - SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - SCRIPT_NAME=$(basename ${WAIT_UNTIL_IS_INSTALLED}) - - if [[ -f ${SCRIPT_DIR}/${SCRIPT_NAME} ]]; then - ${SCRIPT_DIR}/${SCRIPT_NAME} ${PARAMS} - else - curl -sSL https://raw.githubusercontent.com/${OWNER_AND_BRANCH_LOCATION}/${WAIT_UNTIL_IS_INSTALLED} > /tmp/${SCRIPT_NAME} && chmod +x /tmp/${SCRIPT_NAME} && OWNER_AND_BRANCH_LOCATION=${OWNER_AND_BRANCH_LOCATION} /tmp/${SCRIPT_NAME} ${PARAMS} - fi + scripts/ci/wait-until-is-installed.sh ${PARAMS} } setup_oauth_generic()