From: valentin.radulescu Date: Thu, 26 Sep 2019 15:59:57 +0000 (-0700) Subject: Add ci validation script X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ci-management.git;a=commitdiff_plain;h=7cb83b7f5818727f5293fc02b96d5e5f065a78a1 Add ci validation script Add run_bluval.sh which triggers validation script. Add jobs for iec. Signed-off-by: valentin.radulescu Change-Id: I26338e7b6038149d4f122f7e5a4df978ca73d678 --- diff --git a/jjb/iec/iec.yaml b/jjb/iec/iec.yaml index ad662cb..dc47acf 100644 --- a/jjb/iec/iec.yaml +++ b/jjb/iec/iec.yaml @@ -93,7 +93,7 @@ description: Artifacts to archive to the logs server. # Usecase params are both installer and OS specific - parameter: &k8s_fuel_ubuntu1604_parameter - name: 'seba_on_arm-fuel-ubuntu1604-defaults' + name: 'fuel-ubuntu1604-defaults' parameters: - string: &k8s_master_ip name: K8S_MASTER_IP @@ -113,9 +113,9 @@ description: 'SSH key to connect to the K8s master' - parameter: <<: *k8s_fuel_ubuntu1604_parameter - name: 'seba_on_arm-fuel-ubuntu1804-defaults' + name: 'fuel-ubuntu1804-defaults' - parameter: - name: 'seba_on_arm-fuel-centos7-defaults' + name: 'fuel-centos7-defaults' parameters: - string: <<: *k8s_master_ip @@ -127,7 +127,7 @@ - string: <<: *k8s_ssh_key - parameter: - name: 'seba_on_arm-compass-ubuntu1604-defaults' + name: 'compass-ubuntu1604-defaults' parameters: - string: <<: *k8s_master_ip @@ -175,6 +175,7 @@ stream: '{stream}' branch: '{branch}' - '{project}-defaults' + - '{installer}-{os}-defaults' - string: name: DEPLOY_SCENARIO default: '{scenario}' @@ -182,18 +183,27 @@ builders: - trigger-builds: - project: 'iec-deploy-{installer}-{deploy_type}-{os}-daily-{stream}' - current-parameters: false + current-parameters: true predefined-parameters: DEPLOY_SCENARIO={scenario} same-node: true block: true + - project: 'validation-enea-daily-{stream}' + same-node: true + current-parameters: true + predefined-parameters: | + BLUEPRINT={project-name} + LAYER=k8s + VERSION=master + OPTIONAL=yes + block: true - project: !j2: | {%- for uc in usecase -%} iec-install-{{ uc | first }}-{{ installer }}-{{ deploy_type }}-{{ os }}-daily-{{ stream }} {%- if not loop.last -%},{%- endif -%} {%- endfor %} - current-parameters: false + current-parameters: true same-node: true block: true block-thresholds: @@ -325,7 +335,6 @@ stream: '{stream}' branch: '{branch}' - '{project}-defaults' - - '{usecase}-{installer}-{os}-defaults' wrappers: - build-name: diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh new file mode 100755 index 0000000..5f0c4db --- /dev/null +++ b/jjb/shell/run_bluval.sh @@ -0,0 +1,138 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2019 ENEA and others. +# valentin.radulescu@enea.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -e +set -o errexit +set -o pipefail + +cwd=$(pwd) +is_optional="false" + +info () { + logger -s -t "run_blu_val.info" "$*" +} + +usage() { + echo "usage: $0 -n " >&2 + echo "[-r results dir">&2 + echo "[-b blueprint definition">&2 + echo "[-k k8s config dir">&2 + echo "[-j k8s master">&2 + echo "[-u ssh user">&2 + echo "[-s ] path to ssh key">&2 + echo "[-c ] path to variables yaml file">&2 + echo "[-l ] blueprint layer">&2 + echo "[-o ] run optional tests">&2 + echo "[-v ] version">&2 +} + +verify_connectivity() { + local ip=$1 + info "Verifying connectivity to $ip..." + for i in $(seq 0 10); do + if ping -c 1 -W 1 "$ip" > /dev/null; then + info "$ip is reachable!" + return 0 + fi + sleep 1 + done + error "Can not talk to $ip." +} + +error () { + logger -s -t "run_blu_val.error" "$*" + exit 1 +} + +# Get options from shell +while getopts "j:k:u:s:b:l:r:n:ov:" optchar; do + case "${optchar}" in + j) k8s_master=${OPTARG} ;; + k) k8s_config_dir=${OPTARG} ;; + s) ssh_key=${OPTARG} ;; + b) blueprint_yaml=${OPTARG} ;; + l) blueprint_layer=${OPTARG} ;; + r) results_dir=${OPTARG} ;; + n) blueprint_name=${OPTARG} ;; + u) sh_user=${OPTARG} ;; + o) is_optional="true" ;; + v) version=${OPTARG} ;; + *) echo "Non-option argument: '-${OPTARG}'" >&2 + usage + exit 2 + ;; + esac +done + +# Blueprint name is mandatory +if [ -z "$blueprint_name" ] +then + usage + error "Please specify blueprint name. " +fi + +# Use cwd/kube for k8s config +input="$cwd/kube" + +# Initialize ssh key used +ssh_key=${ssh_key:-$K8S_SSH_KEY} +# K8s config directory +k8s_config_dir=${k8s_config_dir:-$input} +mkdir -p "$k8s_config_dir" + +# Testing configuration +version=${version:-$VERSION} +results_dir=${results_dir:-$cwd/results} +k8s_master=${k8s_master:-$K8S_MASTER_IP} +ssh_user=${sh_user:-$K8S_SSH_USER} +blueprint_layer=${blueprint_layer:-$LAYER} + +# If blueprint layer is not defined use k8s by default +if [ "$blueprint_layer" == "k8s" ] +then + if [ -z "$k8s_master" ] + then + usage + error "Please provide valid k8s IP address." + fi + verify_connectivity "${k8s_master}" + if [[ -n $K8S_SSH_PASSWORD ]] + then + sshpass -p "${K8S_SSH_PASSWORD}" scp -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -r\ + "${ssh_user}@${k8s_master}:~/.kube/*" "$k8s_config_dir" + else + scp -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i"$ssh_key" -r\ + "${ssh_user}"@"${k8s_master}":~/.kube/* "$k8s_config_dir" + fi +fi + +if [ ! -d "$cwd/validation" ] +then + git clone http://gerrit.akraino.org/r/validation +fi + +if [[ -n $blueprint_yaml ]] +then + cp "$blueprint_yaml" ./validation/bluval/ +fi + +volumes_path="$cwd/validation/bluval/volumes.yaml" +#update information in volumes yaml +sed -i -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/validation/bluval/'@}" -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" "$volumes_path" + +if [[ -n $blueprint_layer ]] +then + options="-l$blueprint_layer" +fi +if [ "$is_optional" == "true" ] || [ "$OPTIONAL" == "yes" ] +then + options+=" -o" +fi +# shellcheck disable=SC2086 +python3 validation/bluval/blucon.py $options "$blueprint_name" diff --git a/jjb/validation/bluval.yaml b/jjb/validation/bluval.yaml new file mode 100644 index 0000000..5933498 --- /dev/null +++ b/jjb/validation/bluval.yaml @@ -0,0 +1,100 @@ +--- +# +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Enea +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +- project: + name: bluval + project-name: validation + project: validation + build-node: '{build-node}' + group-id: org.akraino.validation + refspec: refs/heads/master + branch: master + view: + - project-view + blueprint: + - iec + - rec + stream: + - master: + branch: '{stream}' + gs-pathname: '' + disabled: false + jobs: + - bluval-daily-{stream} + +############## +# PARAMETERS # +############## +- parameter: + name: 'bluval-defaults' + parameters: + - string: + <<: *k8s_master_ip + - string: + <<: *k8s_ssh_user + - string: + <<: *k8s_ssh_password + - string: + <<: *k8s_ssh_key + - string: &blueprint_name + name: BLUEPRINT + default: '' + description: 'Blueprint used' + - string: &layer + name: LAYER + default: '' + description: 'Layer' + - string: &version + name: VERSION + default: '' + description: 'Version' + - string: &optional + name: OPTIONAL + default: '' + description: 'If set to yes run optional tests' + +- job-template: + name: 'bluval-daily-{stream}' + concurrent: true + node: '{build-node}' + parameters: + - string: + name: DEPLOY_SCENARIO + default: '' + - {'bluval-defaults'} + + wrappers: *wrappers + scm: + - git: + credentials-id: '{jenkins-ssh-credential}' + url: '{git-url}/ci-management.git' + refspec: '' + branches: + - 'refs/heads/{branch}' + skip-tag: true + wipe-workspace: true + submodule: + disable: true + recursive: false + timeout: '{submodule-timeout}' + choosing-strategy: default + + + builders: + - description-setter: + description: "POD: $NODE_NAME" + - shell: ./jjb/shell/run_bluval.sh -n "$BLUEPRINT" diff --git a/jjb/validation/lab.yaml b/jjb/validation/lab.yaml new file mode 100644 index 0000000..1a00f9b --- /dev/null +++ b/jjb/validation/lab.yaml @@ -0,0 +1,64 @@ +--- +# +# copyright (c) 2019 at&t intellectual property. +# copyright (c) 2019 enea +# +# licensed under the apache license, version 2.0 (the "license"); you may +# not use this file except in compliance with the license. +# +# you may obtain a copy of the license at +# http://www.apache.org/licenses/license-2.0 +# +# unless required by applicable law or agreed to in writing, software +# distributed under the license is distributed on an "as is" basis, without +# warranties or conditions of any kind, either express or implied. +# see the license for the specific language governing permissions and +# limitations under the license. +# +- project: + name: lab + project-name: validation + project: validation + build-node: '{build-node}' + stream: + - master: + branch: '{stream}' + gs-pathname: '' + disabled: false + validation_lab: + - enea + jobs: + - validation-{validation_lab}-daily-{stream} + +############## +# PARAMETERS # +############## +- parameter: + name: 'lab_params' + parameters: + - string: + <<: *k8s_master_ip + - string: + <<: *k8s_ssh_user + - string: + <<: *k8s_ssh_password + - string: + <<: *k8s_ssh_key + - string: + <<: *blueprint_name + - string: + <<: *layer + - string: + <<: *version + - string: + <<: *optional + +- job-template: + name: 'validation-{validation_lab}-daily-{stream}' + parameters: + - {'lab_params'} + builders: + - trigger-builds: + - project: 'bluval-daily-{stream}' + same-node: true + current-parameters: true