diff options
Diffstat (limited to 'jjb/apex')
-rwxr-xr-x | jjb/apex/apex-deploy.sh | 3 | ||||
-rw-r--r-- | jjb/apex/apex-snapshot-create.sh | 93 | ||||
-rw-r--r-- | jjb/apex/apex-snapshot-deploy.sh | 154 | ||||
-rwxr-xr-x | jjb/apex/apex-upload-artifact.sh | 12 | ||||
-rw-r--r-- | jjb/apex/apex.yml | 66 |
5 files changed, 327 insertions, 1 deletions
diff --git a/jjb/apex/apex-deploy.sh b/jjb/apex/apex-deploy.sh index 8d5c4cb13..776b76ed0 100755 --- a/jjb/apex/apex-deploy.sh +++ b/jjb/apex/apex-deploy.sh @@ -172,6 +172,9 @@ if [[ "$JOB_NAME" == *virtual* ]]; then NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings.yaml" fi DEPLOY_CMD="${DEPLOY_CMD} -v" + if [[ "$JOB_NAME" == *csit* ]]; then + DEPLOY_CMD="${DEPLOY_CMD} -e csit-environment.yaml --virtual-computes 2" + fi else # settings for bare metal deployment if [ "$IPV6_FLAG" == "True" ]; then diff --git a/jjb/apex/apex-snapshot-create.sh b/jjb/apex/apex-snapshot-create.sh new file mode 100644 index 000000000..09c6a1197 --- /dev/null +++ b/jjb/apex/apex-snapshot-create.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +############################################################################## +# Copyright (c) 2016 Tim Rozet (Red Hat) and others. +# +# 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 -o errexit +set -o nounset +set -o pipefail + +SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error) + +echo "Creating Apex snapshot..." +echo "-------------------------" +echo + +# create tmp directory +tmp_dir=$(pwd)/.tmp +mkdir -p ${tmp_dir} + +# TODO(trozet) remove this after fix goes in for tripleo_inspector to copy these +pushd ${tmp_dir} > /dev/null +echo "Copying overcloudrc and ssh key from Undercloud..." +# Store overcloudrc +UNDERCLOUD=$(sudo virsh domifaddr undercloud | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]') +scp ${SSH_OPTIONS[@]} stack@${UNDERCLOUD}:overcloudrc ./ +# Copy out ssh key of stack from undercloud +scp ${SSH_OPTIONS[@]} stack@${UNDERCLOUD}:.ssh/id_rsa ./ +popd > /dev/null + +echo "Gathering introspection information" +git clone https://gerrit.opnfv.org/gerrit/sdnvpn.git +pushd sdnvpn/odl-pipeline/lib > /dev/null +./tripleo_introspector.sh --out-file ${tmp_dir}/node.yaml +popd > /dev/null + +echo "Shutting down nodes" +# Shut down nodes +nodes=$(sudo virsh list | grep -Eo "baremetal[0-9]") +for node in $nodes; do + sudo virsh shutdown ${node} --mode acpi +done + +for node in $nodes; do + count=0 + while [ "$count" -lt 10 ]; do + sleep 10 + if sudo virsh list | grep ${node}; then + echo "Waiting for $node to shutdown, try $count" + else + break + fi + count=$((count+1)) + done + + if [ "$count" -ge 10 ]; then + echo "Node $node failed to shutdown" + exit 1 + fi +done + +echo "Gathering virsh definitions" +# copy qcow2s, virsh definitions +for node in $nodes; do + cp -f /var/lib/libvirt/images/${node}.qcow2 ./ + sudo virsh dumpxml ${node} > ${node}.xml +done + +# copy virsh net definitions +for net in admin api external storage tenant; do + sudo virsh net-dumpxml ${net} > ${net}.xml +done + +# tar up artifacts +DATE=`date +%Y-%m-%d` +tar czf ../apex-csit-snap-${DATE}.tar.gz . +popd > /dev/null +rm -rf ./.tmp +echo "Snapshot saved as apex-csit-snap-${DATE}.tar.gz" + +# update opnfv properties file +curl -O -L http://$GS_URL/snapshot.properties +sed -i '/^OPNFV_SNAP_URL=/{h;s#=.*#='${GS_URL}'/apex-csit-snap-'${DATE}'.tar.gz#};${x;/^$/{s##OPNFV_SNAP_URL='${GS_URL}'/apex-csit-snap-'${DATE}'.tar.gz#;H};x}' snapshot.properties +snap_sha=$(sha512sum apex-csit-snap-${DATE}.tar.gz | cut -d' ' -f1) +sed -i '/^OPNFV_SNAP_SHA512SUM=/{h;s/=.*/='${snap_sha}'/};${x;/^$/{s//OPNFV_SNAP_SHA512SUM='${snap_sha}'/;H};x}' snapshot.properties +echo "OPNFV_SNAP_URL=$GS_URL/apex-csit-snap-${DATE}.tar.gz" +echo "OPNFV_SNAP_SHA512SUM=$(sha512sum apex-csit-snap-${DATE}.tar.gz | cut -d' ' -f1)" +echo "Updated properties file: " +cat snapshot.properties diff --git a/jjb/apex/apex-snapshot-deploy.sh b/jjb/apex/apex-snapshot-deploy.sh new file mode 100644 index 000000000..3bb65a0b3 --- /dev/null +++ b/jjb/apex/apex-snapshot-deploy.sh @@ -0,0 +1,154 @@ +#!/usr/bin/env bash +############################################################################## +# Copyright (c) 2016 Tim Rozet (Red Hat) and others. +# +# 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 -o errexit +set -o nounset +set -o pipefail + +SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error) +SNAP_CACHE=$HOME/snap_cache + + +echo "Deploying Apex snapshot..." +echo "--------------------------" +echo + +echo "Cleaning server" +git clone https://gerrit.opnfv.org/gerrit/apex.git +pushd apex/ci > /dev/null +sudo CONFIG=../build/ LIB=../lib ./clean.sh +popd > /dev/null + +echo "Downloading latest snapshot properties file" +if ! wget -O $WORKSPACE/opnfv.properties http://$GS_URL/snapshot.properties; then + echo "ERROR: Unable to find snapshot.properties at ${GS_URL}...exiting" + exit 1 +fi + +# find latest check sum +latest_snap_checksum=$(cat opnfv.properties | grep OPNFV_SNAP_SHA512SUM | awk -F "=" '{print $2}') +if [ -z "$latest_snap_checksum" ]; then + echo "ERROR: checksum of latest snapshot from snapshot.properties is null!" + exit 1 +fi + +local_snap_checksum="" + +# check snap cache directory exists +if [ -d "$SNAP_CACHE" ]; then + latest_snap=$(ls -Art | grep tar.gz | tail -n 1) + if [ -n "$latest_snap" ]; then + local_snap_checksum=$(sha512sum ${latest_snap} | cut -d' ' -f1) + fi +else + mkdir -p ${SNAP_CACHE} +fi + +# compare check sum and download latest snap if not up to date +if [ "$local_snap_checksum" -ne "$latest_snap_checksum" ]; then + snap_url=$(cat opnfv.properties | grep OPNFV_SNAP_URL | awk -F "=" '{print $2}') + if [ -z "$snap_url" ]; then + echo "ERROR: Snap URL from snapshot.properties is null!" + exit 1 + fi + echo "INFO: SHA mismatch, will download latest snapshot" + wget --directory-prefix=${SNAP_CACHE}/ ${snap_url} + snap_tar=$(basename ${snap_url}) +else + snap_tar=${latest_snap} +fi + +echo "INFO: Snapshot to be used is ${snap_tar}" + +# create tmp directory and unpack snap +mkdir -p ./tmp +pushd ./tmp > /dev/null +tar xvf ${snap_tar} + +# create each network +virsh_networks=$(ls *.xml | grep -v baremetal) + +if [ -z "$virsh_networks" ]; then + echo "ERROR: no virsh networks found in snapshot unpack" + exit 1 +fi + +for network_def in ${virsh_networks}; do + sudo virsh net-create ${network_def} + network=$(echo ${network_def} | awk -F '.' '{print $1}') + if ! sudo virsh net-list | grep ${network}; then + sudo virsh net-start ${network} + fi + echo "Checking if OVS bridge is missing for network: ${network}" + if ! ovs-vsctl show | grep "br-${network}"; then + ovs-vsctl add-br br-${network} + echo "OVS Bridge created: br-${network}" + if [ "br-${network}" == 'br-admin' ]; then + echo "Configuring IP 192.0.2.99 on br-admin" + sudo ip addr add 192.0.2.99/24 dev br-admin + sudo ip link set up dev br-admin + elif [ "br-${network}" == 'br-external' ]; then + echo "Configuring IP 192.168.37.99 on br-external" + sudo ip addr add 192.168.37.99/24 dev br-external + sudo ip link set up dev br-external + fi + fi +done + +echo "Virsh networks up: $(virsh net-list)" +echo "Bringing up Overcloud VMs..." +virsh_vm_defs=$(ls baremetal*.xml) + +if [ -z "$virsh_vm_defs" ]; then + echo "ERROR: no virsh VMs found in snapshot unpack" + exit 1 +fi + +for node_def in ${virsh_vm_defs}; do + sudo virsh define ${node_def} + node=$(echo ${node_def} | awk -F '.' '{print $1}') + sudo cp -f ${node}.qcow2 /var/lib/libvirt/images/ + sudo virsh start ${node} + echo "Node: ${node} started" +done + +echo "Checking overcloudrc" +if ! stat overcloudrc; then + echo "ERROR: overcloudrc does not exist in snap unpack" + exit 1 +fi + +# copy overcloudrc for functest +mkdir -p $HOME/cloner-info +cp -f overcloudrc $HOME/cloner-info/ + +admin_controller_ip=$(cat overcloudrc | grep -Eo "192.0.2.[0-9]+") +netvirt_url="http://${admin_controller_ip}:8081/restconf/operational/network-topology:network-topology/topology/netvirt:1" + +source overcloudrc +counter=1 +while [ "$counter" -le 10 ]; do + if curl --fail ${admin_controller_ip}:80; then + echo "Overcloud Horizon is up...Checking if OpenDaylight NetVirt is up..." + if curl --fail ${netvirt_url} > /dev/null; then + echo "OpenDaylight is up. Overcloud deployment complete" + exit 0 + else + echo "OpenDaylight not yet up, try ${counter}" + fi + else + echo "Horizon/Apache not yet up, try ${counter}" + fi + counter=$((counter+1)) + sleep 60 +done + +echo "ERROR: Deployment not up after 10 minutes...exiting." +exit 1 diff --git a/jjb/apex/apex-upload-artifact.sh b/jjb/apex/apex-upload-artifact.sh index 64f13f4e6..89fd5ed36 100755 --- a/jjb/apex/apex-upload-artifact.sh +++ b/jjb/apex/apex-upload-artifact.sh @@ -73,7 +73,17 @@ gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log } -if gpg2 --list-keys | grep "opnfv-helpdesk@rt.linuxfoundation.org"; then +uploadsnap () { + # Uploads snapshot artifact and updated properties file + echo "Uploading snapshot artifacts" + gsutil cp $WORKSPACE/apex-csit-snap-`date +%Y-%m-%d`.tar.gz gs://$GS_URL/ > gsutil.iso.log + gsutil cp $WORKSPACE/snapshot.properties gs://$GS_URL/snapshot.properties > gsutil.latest.log + echo "Upload complete for Snapshot" +} + +if grep csit $WORKSPACE; then + uploadsnap +elif gpg2 --list-keys | grep "opnfv-helpdesk@rt.linuxfoundation.org"; then echo "Signing Key avaliable" signiso uploadiso diff --git a/jjb/apex/apex.yml b/jjb/apex/apex.yml index 710a5f42c..d028787cc 100644 --- a/jjb/apex/apex.yml +++ b/jjb/apex/apex.yml @@ -41,6 +41,7 @@ - 'os-odl_l3-fdio-ha' - 'os-odl_l3-fdio_dvr-noha' - 'os-odl_l3-fdio_dvr-ha' + - 'os-odl_l3-csit-noha' - 'os-onos-nofeature-ha' platform: @@ -721,6 +722,71 @@ failure-threshold: 'never' unstable-threshold: 'FAILURE' +# CSIT promote +- job-template: + name: 'apex-csit-promote-daily-{stream}' + + # Job template for promoting CSIT Snapshots + # + # Required Variables: + # stream: branch with - in place of / (eg. stable) + # branch: branch (eg. stable) + node: '{daily-slave}' + + disabled: false + + scm: + - git-scm: + credentials-id: '{ssh-credentials}' + refspec: '' + branch: '{branch}' + + parameters: + - project-parameter: + project: '{project}' + - apex-parameter: + gs-pathname: '{gs-pathname}' + + properties: + - build-blocker: + use-build-blocker: true + block-level: 'NODE' + blocking-jobs: + - 'apex-verify.*' + - 'apex-deploy.*' + - 'apex-build.*' + - 'apex-runner.*' + + triggers: + - timed: '0 12 * * 0' + + builders: + - trigger-builds: + - project: 'apex-build-{stream}' + git-revision: true + current-parameters: true + same-node: true + block: true + - trigger-builds: + - project: 'apex-deploy-virtual-os-odl_l3-csit-noha-{stream}' + predefined-parameters: | + BUILD_DIRECTORY=apex-build-{stream}/build + OPNFV_CLEAN=yes + git-revision: false + block: true + same-node: true + - trigger-builds: + - project: 'functest-apex-{verify-slave}-suite-{stream}' + predefined-parameters: | + DEPLOY_SCENARIO=os-odl_l3-nofeature-noha + FUNCTEST_SUITE_NAME=smoke + block: true + same-node: true + - shell: + !include-raw-escape: ./apex-snapshot-create.sh + - shell: + !include-raw-escape: ./apex-upload-artifact.sh + - job-template: name: 'apex-gs-clean-{stream}' |