From: Ciprian Barbu Date: Fri, 10 Apr 2020 14:17:30 +0000 (+0300) Subject: iec: Add jobs for testing usecases X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=dea121ae9ba14e57d44454c81847d068e444116f;p=ci-management.git iec: Add jobs for testing usecases Also rework the iec-seba-on-arm.sh script to reuse the existing facilities which deal with installer and OS specifics JIRA: IEC-14 Signed-off-by: Ciprian Barbu Change-Id: Ida04b93030751b4dbdfc929107d0f30d644974fa --- diff --git a/jjb/akraino-templates/akraino-iec-macros.yaml b/jjb/akraino-templates/akraino-iec-macros.yaml index 8b21f63..7553f9a 100644 --- a/jjb/akraino-templates/akraino-iec-macros.yaml +++ b/jjb/akraino-templates/akraino-iec-macros.yaml @@ -78,6 +78,14 @@ - string: <<: *k8s_ssh_key +# IEC usecase(s) parameters +- parameter: + name: 'seba_on_arm-defaults' + parameters: + - string: + name: PON_TYPE + default: 'ponsim' + ######################## # trigger macros ######################## diff --git a/jjb/akraino-templates/akraino-iec-templates.yaml b/jjb/akraino-templates/akraino-iec-templates.yaml index df14cbe..72f331c 100644 --- a/jjb/akraino-templates/akraino-iec-templates.yaml +++ b/jjb/akraino-templates/akraino-iec-templates.yaml @@ -62,7 +62,10 @@ - project: !j2: | {%- for uc in usecase -%} - iec-{{ iecType }}-install-{{ uc }}-{{ installer }}-{{ deploy_type }}-{{ os }}-daily-{{ stream }} + {%- for ph in phase -%} + iec-{{ iecType }}-{{ ph }}-{{ uc }}-{{ installer }}-{{ deploy_type }}-{{ os }}-daily-{{ stream }} + {%- if not loop.last -%},{%- endif -%} + {%- endfor %} {%- if not loop.last -%},{%- endif -%} {%- endfor %} current-parameters: true @@ -196,8 +199,8 @@ publishers: *publishers - job-template: - id: akraino-iec-install-usecase - name: 'iec-{iecType}-install-{usecase}-{installer}-{deploy_type}-{os}-daily-{stream}' + id: akraino-iec-phase-usecase + name: 'iec-{iecType}-{phase}-{usecase}-{installer}-{deploy_type}-{os}-daily-{stream}' concurrent: true node: '{slave-label}' properties: *properties @@ -209,6 +212,7 @@ branch: '{branch}' - '{project}-defaults' - '{installer}-{os}-defaults' + - '{usecase}-defaults' wrappers: - build-name: @@ -221,4 +225,3 @@ !include-raw-escape: ../iec/iec-{usecase}.sh publishers: *publishers - diff --git a/jjb/iec/iec-seba_on_arm.sh b/jjb/iec/iec-seba_on_arm.sh index 3f1e2e5..87b5189 100755 --- a/jjb/iec/iec-seba_on_arm.sh +++ b/jjb/iec/iec-seba_on_arm.sh @@ -9,9 +9,52 @@ ############################################################################## export TERM="vt220" +set -x echo "JOB_NAME=${JOB_NAME}" +# Run either ssh or scp on the K8S master +run_on_k8s_master () { + case "${1}" in + ssh) + _c="${1}" + shift + _s=" " + ;; + scp) + _c="${1} -r" + shift + _s=":${1}" + shift + ;; + *) + echo "Use either ssh or scp to run on K8S master" + exit 1 + ;; + esac + + if [ -n "${K8S_SSH_PASSWORD}" ] + then + eval sshpass -p "${K8S_SSH_PASSWORD}" "${_c}" \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + ${_o} "${K8S_SSH_USER}"@"${K8S_MASTER_IP}${_s}" "$@" + elif [ -n "${K8S_SSH_KEY}" ] + then + eval ${_c} -i "${K8S_SSH_KEY}" \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + ${_o} "${K8S_SSH_USER}"@"${K8S_MASTER_IP}${_s}" "$@" + else + echo "Neither K8S_SSH_PASSWORD nor K8S_SSH_KEY are set" + exit 1 + fi +} + +if [ -z "$K8S_SSH_USER" ] +then + echo "K8S_SSH_USER not set, cannot ssh to K8S master, aborting" + exit 1 +fi + case "${JOB_NAME}" in *fuel*) K8S_MASTER_IP=$(docker exec fuel cat /etc/hosts | grep iec01 \ @@ -19,10 +62,12 @@ case "${JOB_NAME}" in # On Fuel deployements the K8s ssh key is the one used by the deploy job K8S_SSH_KEY=${SSH_KEY} IEC_DIR="/var/lib/akraino/iec" + KUBE_DIR="~${K8S_SSH_USER}/.kube" ;; *compass*) # K8S_{MASTER_IP,SSH_USER,SSH_PASSWORD} are already set by job params IEC_DIR="/${K8S_SSH_USER}/iec" + KUBE_DIR="~${K8S_SSH_USER}/.kube" ;; *) echo "Cannot determine installer from ${JOB_NAME}" @@ -30,25 +75,38 @@ case "${JOB_NAME}" in ;; esac -if [ -z "$K8S_SSH_USER" ] -then - echo "K8S_SSH_USER not set, cannot ssh to install SEBA" - exit 1 -fi +case "${JOB_NAME}" in + iec-*-install-seba_on_arm*) + INSTALL_CMD="'cd ${IEC_DIR}/src/use_cases/seba_on_arm/install; ./install.sh'" + run_on_k8s_master ssh "${INSTALL_CMD}" + ;; + iec-*-test-seba_on_arm*) -INSTALL_CMD="cd ${IEC_DIR}/src/use_cases/seba_on_arm/install; ./install.sh" + case "${PON_TYPE}" in + *ponsim*) + ;; + *) + echo "Unknown PON_TYPE ${PON_TYPE}" + exit + ;; + esac -if [ -n "${K8S_SSH_PASSWORD}" ] -then - sshpass -p "${K8S_SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no \ - "${K8S_SSH_USER}"@"${K8S_MASTER_IP}" "${INSTALL_CMD}" -elif [ -n "${K8S_SSH_KEY}" ] -then - ssh -o StrictHostKeyChecking=no -i "${K8S_SSH_KEY}" \ - "${K8S_SSH_USER}"@"${K8S_MASTER_IP}" "${INSTALL_CMD}" -else - echo "Neither K8S_SSH_USER or K8S_SSH_KEY set. Cannot ssh to K8S Master" - exit 1 -fi + # After the installation, copy the .kube dir from the K8S master + cd "${WORKSPACE}" || exit 1 + run_on_k8s_master scp "${KUBE_DIR}" "${WORKSPACE}" + + SEBA_TEST_DIR="src/use_cases/seba_on_arm/test" + TEST_CMD="${SEBA_TEST_DIR}/${PON_TYPE}/test.sh" + echo "Issuing command" + echo "${TEST_CMD}" + + eval ${TEST_CMD} + exit_code=$? + ;; + *) + echo "Cannot determine what to do for seba_on_arm from ${JOB_NAME}" + exit 1 + ;; +esac exit 0 diff --git a/jjb/iec/iec.yaml b/jjb/iec/iec.yaml index d7a5e1e..7d01dda 100644 --- a/jjb/iec/iec.yaml +++ b/jjb/iec/iec.yaml @@ -73,11 +73,15 @@ usecase: - seba_on_arm + phase: + - install + - test + jobs: - akraino-iec-install - akraino-iec-deploy - akraino-iec-destroy - - akraino-iec-install-usecase + - akraino-iec-phase-usecase - gerrit-sonar: sonar-project-file: "" build-node: centos7-builder-2c-1g