Add ci validation script 57/1657/10
authorvalentin.radulescu <valentin.radulescu@enea.com>
Thu, 26 Sep 2019 15:59:57 +0000 (08:59 -0700)
committervalentin.radulescu <valentin.radulescu@enea.com>
Mon, 28 Oct 2019 11:34:31 +0000 (04:34 -0700)
Add run_bluval.sh which triggers validation script.
Add jobs for iec.

Signed-off-by: valentin.radulescu <valentin.radulescu@enea.com>
Change-Id: I26338e7b6038149d4f122f7e5a4df978ca73d678

jjb/iec/iec.yaml
jjb/shell/run_bluval.sh [new file with mode: 0755]
jjb/validation/bluval.yaml [new file with mode: 0644]
jjb/validation/lab.yaml [new file with mode: 0644]

index ad662cb..dc47acf 100644 (file)
@@ -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
           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
       - string:
           <<: *k8s_ssh_key
 - parameter:
-    name: 'seba_on_arm-compass-ubuntu1604-defaults'
+    name: 'compass-ubuntu1604-defaults'
     parameters:
       - string:
           <<: *k8s_master_ip
           stream: '{stream}'
           branch: '{branch}'
       - '{project}-defaults'
+      - '{installer}-{os}-defaults'
       - string:
           name: DEPLOY_SCENARIO
           default: '{scenario}'
     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:
           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 (executable)
index 0000000..5f0c4db
--- /dev/null
@@ -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 <blueprint_name>" >&2
+    echo "[-r <results_dir> results dir">&2
+    echo "[-b <blueprint_yaml> blueprint definition">&2
+    echo "[-k <k8s_config_dir> k8s config dir">&2
+    echo "[-j <k8s_master> k8s master">&2
+    echo "[-u <ssh_user> ssh user">&2
+    echo "[-s <ssh_key>] path to ssh key">&2
+    echo "[-c <custmom_var_file> ] path to variables yaml file">&2
+    echo "[-l <layer> ] blueprint layer">&2
+    echo "[-o ] run optional tests">&2
+    echo "[-v <version> ] 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 (file)
index 0000000..5933498
--- /dev/null
@@ -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 (file)
index 0000000..1a00f9b
--- /dev/null
@@ -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