Files
virtual-kubelet/vendor/github.com/vmware/vic/infra/scripts/ci-logs.sh
Loc Nguyen 513cebe7b7 VMware vSphere Integrated Containers provider (#206)
* Add Virtual Kubelet provider for VIC

Initial virtual kubelet provider for VMware VIC.  This provider currently
handles creating and starting of a pod VM via the VIC portlayer and persona
server.  Image store handling via the VIC persona server.  This provider
currently requires the feature/wolfpack branch of VIC.

* Added pod stop and delete.  Also added node capacity.

Added the ability to stop and delete pod VMs via VIC.  Also retrieve
node capacity information from the VCH.

* Cleanup and readme file

Some file clean up and added a Readme.md markdown file for the VIC
provider.

* Cleaned up errors, added function comments, moved operation code

1. Cleaned up error handling.  Set standard for creating errors.
2. Added method prototype comments for all interface functions.
3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder.

* Add mocking code and unit tests for podcache, podcreator, and podstarter

Used the unit test framework used in VIC to handle assertions in the provider's
unit test.  Mocking code generated using OSS project mockery, which is compatible
with the testify assertion framework.

* Vendored packages for the VIC provider

Requires feature/wolfpack branch of VIC and a few specific commit sha of
projects used within VIC.

* Implementation of POD Stopper and Deleter unit tests (#4)

* Updated files for initial PR
2018-06-04 15:41:32 -07:00

135 lines
3.4 KiB
Bash
Executable File

#!/bin/bash -e
# Copyright 2016 VMware, Inc. All Rights Reserved.
#
# 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.
#
# Requirements
# ############
# - gcloud SDK: https://cloud.google.com/sdk/docs/
# - drone cli 0.5: https://github.com/drone/drone#from-source
#
# Examples
# ########
# Grab the logs for your current branch:
# $ ./ci-logs.sh
#
# If the build is running you can stream the logs using the '-s' option:
# $ ./ci-logs.sh -s
#
# Grab logs for a specific build:
# $ ./ci-logs.sh 4835
#
# Grab logs for recent failures on the master branch:
# $ drone build list --format {{.Number}}-{{.Branch}}-{{.Status}} vmware/vic | grep master-failure | cut -d- -f1 | xargs -n1 ./ci-logs.sh
#
# Find container log zip files for failed tests:
# $ grep FAIL ci.log | grep Test-Cases.Group | grep :: | awk '{print $1}' | xargs -n1 -I% bash -c "ls %*.zip"
top=$(git rev-parse --show-toplevel)
repo="vmware/$(basename "$top")"
dir="$top/ci-logs"
drone=${DRONE_CLI:-drone}
while getopts s flag
do
case $flag in
d)
dir="$OPTARG"
;;
s)
stream=true
;;
*)
echo "invalid option '$flag'"
exit 1
;;
esac
done
shift $((OPTIND-1))
build="$1"
job="$2"
export DRONE_SERVER=${DRONE_SERVER:-https://ci-vic.vmware.com}
if [ -z "$DRONE_TOKEN" ] ; then
echo "DRONE_TOKEN not set (available at $DRONE_SERVER/settings/profile)"
fi
if [ -z "$build" ] ; then
commit=$(git rev-parse HEAD)
builds=$($drone build list --format "{{.Number}}-{{.Commit}}" "$repo" | grep "$commit")
build=$(cut -d- -f1 <<<"$builds")
fi
if [ -z "$job" ] ; then
job=1
fi
state=$($drone build info "$repo" "$build" --format {{.Status}})
echo "$state"
case "$state" in
running)
if [ -z "$stream" ] ; then
exit
fi
;;
success|failure|killed)
stream=""
;;
pending|error)
exit
;;
esac
if [ ! -d "$dir" ] ; then
mkdir "$dir"
fi
logs="$dir/$build"
mkdir "$logs"
if [ -n "$stream" ] ; then
echo "Streaming CI log..."
curl --silent "$DRONE_SERVER/api/stream/$repo/$build/$job?access_token=$DRONE_TOKEN" | \
grep data: | cut -d: -f2- | grep -v '^$' | tee "$logs/ci.log"
else
echo "Downloading CI log..."
curl --silent "$DRONE_SERVER/api/repos/$repo/logs/$build/$job?access_token=$DRONE_TOKEN" > "$logs/ci.log"
fi
url=$(grep https://console.cloud.google.com/ "$logs/ci.log")
if [ -z "$url" ] ; then
echo "No integration logs link found for build ${build}"
exit
fi
name=$(basename "$url" | cut -d? -f1)
bucket=$(basename "$(dirname "$(dirname "$url")")")
echo "Downloading integration logs ($name)..."
gsutil cp "gs://$bucket/$name" "$logs/$name"
unzip -d "$logs" "$logs/$name" >/dev/null
if [ "$state" = "failure" ] ; then
echo "Container logs for failed tests:"
grep FAIL "$logs/ci.log" | grep Test-Cases.Group | grep :: | awk '{print $1}' | xargs -n1 -I% bash -c "ls $logs/%*.zip" 2>/dev/null
fi