Skip to content

Instantly share code, notes, and snippets.

@rkoster
Last active August 29, 2015 14:03
Show Gist options
  • Save rkoster/36829669e501c786bf00 to your computer and use it in GitHub Desktop.
Save rkoster/36829669e501c786bf00 to your computer and use it in GitHub Desktop.
C3CI jenkins jobs
#!bash -e
GITHUB_BASE_URL="${GIT_URL}/tree/${GIT_COMMIT}"
GITHUB_INF_URL="${GITHUB_BASE_URL}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf"
echo "***********************"
export DESC="desc JOB_INFRASTRUCTURE_DIR: <a href='${GITHUB_INF_URL}'>$JOB_INFRASTRUCTURE_DIR</a>"
echo $DESC
echo "DESC=$DESC" > tmp.var
echo "***********************"
RUBY_VERSION=$(ruby -v | awk '{print $2}')
export GEM_HOME=/var/vcap/store/gems/$RUBY_VERSION/$JOB_NAME
export GEM_PATH=$GEM_HOME
export PATH=$PATH:$GEM_HOME/bin
gem install bundler -v 1.3.5
(
cd C3CI
bundle
bundle exec rake cf:delete_deployment[\
https://${BOSH_MICRO_IP}:25555,\
`pwd`/../infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf\
]
)
#!bash -e
GITHUB_BASE_URL="${GIT_URL}/tree/${GIT_COMMIT}"
GITHUB_INF_DIR_URL="${GITHUB_BASE_URL}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf"
GITHUB_MANIFEST_URL="${GITHUB_BASE_URL}/jobs/cf/${CF_MANIFEST}"
CF_RELEASE_VERSION=`echo ${CF_RELEASE} | awk -F "/" '{print $NF}'`
STEMCELL_DESC=`echo ${STEMCELL_URL} | sed 's/.*\///' | sed 's/.tgz//'`
echo "***********************"
export DESC="desc CF_RELEASE: <a href='${CF_RELEASE}'>${CF_RELEASE_VERSION}</a> JOB_INFRASTRUCTURE_DIR: <a href='${GITHUB_INF_DIR_URL}'>${JOB_INFRASTRUCTURE_DIR}</a> CF_MANIFEST: <a href='${GITHUB_MANIFEST_URL}'>${CF_MANIFEST}</a> STEMCELL: <a href='${STEMCELL_URL}'>${STEMCELL_DESC}</a>"
echo $DESC
echo "DESC=$DESC" > tmp.var
echo "***********************"
RUBY_VERSION=$(ruby -v | awk '{print $2}')
export GEM_HOME=/var/vcap/store/gems/$RUBY_VERSION/$JOB_NAME
export GEM_PATH=$GEM_HOME
export PATH=$PATH:$GEM_HOME/bin
gem install bundler -v 1.3.5
(
cd C3CI
rm -Rf cf-release
git clone https://github.com/cloudfoundry/cf-release.git
bundle
bundle exec rake cf:upload_and_deploy_release[\
${CF_RELEASE},\
`pwd`/../jobs/cf/${CF_MANIFEST},\
https://${BOSH_MICRO_IP}:25555,\
${STEMCELL_URL},\
`pwd`/../infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf\
]
)
#!bash -e
GITHUB_BASE_URL="${GIT_URL}/tree/${GIT_COMMIT}"
GITHUB_NYET_ENV_URL="${GITHUB_BASE_URL}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh"
echo "***********************"
echo "CUSTOM CRUD APPS TARGET: <a href='${GITHUB_NYET_ENV_URL}'>nyet_ci.sh</a>"
echo "***********************"
echo "${DESC}"
echo "***********************"
APPTESTUUID="test-crud-app-`date | md5sum | awk -F" " '{print $1}'`"
echo "USING ${APPTESTUUID} for tmp directories and space name"
echo "************************"
source infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh
echo "API Target: ${NYET_TARGET}"
mkdir ${APPTESTUUID}
cd ${APPTESTUUID}
echo "Cloning REPO: ${TEST_APP_REPO}"
git clone ${TEST_APP_REPO} build
echo "***************"
echo "***BUILDING***"
echo "**************"
cd build
${TEST_APP_BUILDSTEP}
echo "*************"
echo "TARGETING CF "
echo "*************"
echo "Removing existing manifest"
rm -fv manifest.yml
cf --version
cf api --skip-ssl-validation ${NYET_TARGET}
cf login -u ${NYET_ADMIN_USERNAME} -p ${NYET_ADMIN_PASSWORD}
echo "CREATING ORG ${APPTESTUUID}"
cf create-org ${APPTESTUUID}
echo "CREATING SPACE ${APPTESTUUID}"
cf create-space ${APPTESTUUID} -o ${APPTESTUUID}
cf target -o ${APPTESTUUID} -s ${APPTESTUUID}
echo "*************"
echo "PUSHING APP "
echo "*************"
cf push ${APPTESTUUID} -p ${TEST_APP_STARTPATH} -d `echo ${NYET_TARGET} | awk -F"api." '{print $2}'` -m 1G
echo "****************"
echo "BASIC APP TEST "
echo "****************"
export APPDNSNAME=${APPTESTUUID}.`echo ${NYET_TARGET} | awk -F"api." '{print $2}'`
if [ "\`wget http://${APPDNSNAME} -O /dev/null -S --quiet 2>&1 | grep '200 OK'\`" != "" ];
then
echo "WEB RESPONSE IS 200 OK!"
echo "cleaning up..."
cf delete -f ${APPTESTUUID}
cf delete-org ${APPTESTUUID}
exit 0
fi;
echo "WEB RESPONSE NOT 200! Check Deployment!!"
echo "APP UUID: ${APPDNSNAME}"
exit 1
#!bash -e
GITHUB_BASE_URL="${GIT_URL}/tree/${GIT_COMMIT}"
GITHUB_NYET_ENV_URL="${GITHUB_BASE_URL}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh"
echo "***********************"
echo "CUSTOM CRUD APPS TARGET: <a href='${GITHUB_NYET_ENV_URL}'>nyet_ci.sh</a>"
echo "***********************"
echo "${DESC}"
echo "***********************"
APPTESTUUID="disk-test-app-`date | md5sum | awk -F" " '{print $1}'`"
echo "USING ${APPTESTUUID} for tmp directories and space name"
source infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh
echo "API Target: ${NYET_TARGET}"
mkdir ${APPTESTUUID}
cd ${APPTESTUUID}
echo "Cloning REPO: ${TEST_APP_REPO}"
git clone ${TEST_APP_REPO} build
echo "***************"
echo "***BUILDING***"
echo "**************"
cd build
${TEST_APP_BUILDSTEP}
echo "*************"
echo "TARGETING CF "
echo "*************"
echo "Removing existing manifest"
rm -fv manifest.yml
cf --version
cf api --skip-ssl-validation ${NYET_TARGET}
cf login -u ${NYET_ADMIN_USERNAME} -p ${NYET_ADMIN_PASSWORD}
echo "CREATING ORG ${APPTESTUUID}"
cf create-org ${APPTESTUUID}
echo "CREATING SPACE ${APPTESTUUID}"
cf create-space ${APPTESTUUID} -o ${APPTESTUUID}
cf target -o ${APPTESTUUID} -s ${APPTESTUUID}
echo "*************"
echo "PUSHING APP "
echo "*************"
cf push ${APPTESTUUID} -p ${TEST_APP_STARTPATH} -d `echo ${NYET_TARGET} | awk -F"api." '{print $2}'` -m 2G
echo "****************"
echo "BASIC APP TEST "
echo "****************"
export APPDNSNAME=${APPTESTUUID}.`echo ${NYET_TARGET} | awk -F"api." '{print $2}'`
if [ "\`wget http://${APPDNSNAME} -O /dev/null -S --quiet 2>&1 | grep '200 OK'\`" != "" ];
then
echo "/ response 200 OK!"
else
echo "/ response not 200. Check Deployment!!"
exit 1
fi;
if [ "\`wget http://${APPDNSNAME}/data -O /dev/null -S --quiet 2>&1 | grep '200 OK'\`" != "" ];
then
echo "/data response 200 OK!"
else
echo "/data response not 200. Check Deployment!!"
exit 1
fi;
cf delete -f ${APPTESTUUID}
cf delete-org -f ${APPTESTUUID}
exit 0
#!bash -e
GITHUB_BASE_URL="${GIT_URL}/tree/${GIT_COMMIT}"
GITHUB_NYET_ENV_URL="${GITHUB_BASE_URL}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh"
echo "***********************"
echo "NYET TARGET: <a href='${GITHUB_NYET_ENV_URL}'>nyet_ci.sh</a>"
echo "***********************"
echo "${DESC}"
echo "***********************"
RUBY_VERSION=$(ruby -v | awk '{print $2}')
export GEM_HOME=/var/vcap/store/gems/$RUBY_VERSION/$JOB_NAME
export GEM_PATH=$GEM_HOME
export PATH=$PATH:$GEM_HOME/bin
gem install bundler -v 1.3.5
(
source infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh
echo "NYET Target: ${NYET_TARGET}"
cd C3CI/nyet
# Patch the NYET tests to work with self signed certs
sed -i 's/gcf api #{api_endpoint}/gcf api --skip-ssl-validation #{api_endpoint}/' spec/loggregator_spec.rb
bundle
bundle exec rspec
)
#!bash -e
# Generate a config file to run the cats tests
function generate_config_file() {
echo " "
echo "Creating config file to run cats tests..."
echo " - Docs: https://github.com/cloudfoundry/cf-acceptance-tests#test-setup"
echo " - File: ${JOB_URL}/ws/cats_config.json/*view*/"
if [ ! ${NYET_TARGET} ]; then
echo "NYET_TARGET missing from nyet_ci.sh." && exit 1
fi
if [ ! ${NYET_APPS_DOMAIN} ]; then
echo "NYET_APPS_DOMAIN missing from nyet_ci.sh." && exit 1
fi
if [ ! ${NYET_ADMIN_USERNAME} ]; then
echo "NYET_ADMIN_USERNAME missing from nyet_ci.sh." && exit 1
fi
if [ ! ${NYET_ADMIN_PASSWORD} ]; then
echo "NYET_ADMIN_PASSWORD missing from nyet_ci.sh." && exit 1
fi
cat > "${WORKSPACE}/cats_config.json" <<EOF
{
"api": "${NYET_TARGET}",
"admin_user": "${NYET_ADMIN_USERNAME}",
"admin_password": "${NYET_ADMIN_PASSWORD}",
"apps_domain": "${NYET_APPS_DOMAIN}",
"skip_ssl_validation": true
}
EOF
export CONFIG="${WORKSPACE}/cats_config.json"
}
echo " "
echo "Running setup tasks required before running tests..."
echo "***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****"
echo " "
# Setup golang
# Also make sure we do not have any old binaries in our GOPATH
which go
export GOROOT="/var/vcap/packages/golang"
echo "GOROOT is ${GOROOT}"
go version
echo "Setting up GOPATH..."
export GOPATH=${WORKSPACE}/gopath
if [[ -d ${GOPATH} ]]; then
rm -rf ${GOPATH}
fi
mkdir -p "${GOPATH}"
export GOPATH="${GOPATH}:${WORKSPACE}/cf-release/src/acceptance-tests/Godeps/_workspace"
echo "GOPATH is ${GOPATH}"
# Make sure we kill any old cf-release checkouts to make sure we get the correct tests.
if [[ -d ${WORKSPACE}/cf-release ]]; then
rm -rf ${WORKSPACE}/cf-release
fi
# Getting the appropriate copy of the cats tests
git clone https://github.com/cloudfoundry/cf-release
cd cf-release
git fetch origin
git checkout ${CATS_TEST_VERSION}
git submodule update --init src/acceptance-tests/
source ${WORKSPACE}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh
echo "NYET Target: ${NYET_TARGET}"
generate_config_file
export CF_TRACE_BASENAME="cf_trace_"
echo " "
echo "Performing setup for CATS tests, for details see:"
echo " - Setup: https://github.com/cloudfoundry/cf-acceptance-tests/blob/master/bin/goenv"
echo " - Run: https://github.com/cloudfoundry/cf-acceptance-tests/blob/master/bin/test"
cd "${WORKSPACE}/cf-release/src/acceptance-tests"
pwd
cats_dir="${WORKSPACE}/cf-release/src/acceptance-tests"
local_gopath="${cats_dir}/Godeps/_workspace"
mkdir -p "${local_gopath}/bin"
export GOPATH="${local_gopath}:${GOPATH}"
export PATH="${local_gopath}/bin:${PATH}"
go install -v github.com/onsi/ginkgo/ginkgo
# Make sure the libraries we need are in the GOPATH
# See: https://github.com/cloudfoundry/cf-acceptance-tests/issues/18
# Note this exits with non zero so we capture the return code.
go get -u github.com/cloudfoundry/cf-acceptance-tests || : # Capture error
# This patch is a hack to allow self signed certs.
# It is fixed in the master branch of the tests
# However still effects the releases we are using.
sso_helper_file="cf-release/src/acceptance-tests/services/helpers/sso.go"
echo " "
echo "Patching tests to allow self signed SSL certs (relevant only to CF170 & 171"
echo " - Issue: https://github.com/cloudfoundry/cf-acceptance-tests/issues/25"
echo " - Locally patched file: ${JOB_URL}ws/${sso_helper_file}/*view*/"
sed -i 's/curl := runner.Curl(url).Wait(DEFAULT_TIMEOUT)/curl := runner.Curl(url, `--insecure`).Wait(DEFAULT_TIMEOUT)/' "${WORKSPACE}/${sso_helper_file}"
echo " "
echo "Running CATS tests..."
echo "***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****"
echo " "
ginkgo -r -skipPackage=diego -skip=SSO -slowSpecThreshold=300
#!bash -e
# Generate a config file to run a particular smoke test suite
function generate_config_file() {
if [ ! ${NYET_TARGET} ]; then
echo "NYET_TARGET missing from nyet_ci.sh." && exit 1
fi
if [ ! ${NYET_APPS_DOMAIN} ]; then
echo "NYET_APPS_DOMAIN missing from nyet_ci.sh." && exit 1
fi
if [ ! ${NYET_ADMIN_USERNAME} ]; then
echo "NYET_ADMIN_USERNAME missing from nyet_ci.sh." && exit 1
fi
if [ ! ${NYET_ADMIN_PASSWORD} ]; then
echo "NYET_ADMIN_PASSWORD missing from nyet_ci.sh." && exit 1
fi
cat > "${WORKSPACE}/smoke_config.json" <<EOF
{
"suite_name": "CF-Smoke-Tests",
"api": "${NYET_TARGET}",
"apps_domain": "${NYET_APPS_DOMAIN}",
"user": "${NYET_ADMIN_USERNAME}",
"password": "${NYET_ADMIN_PASSWORD}",
"org": "smoke-test",
"space": "smoke-test",
"skip_ssl_validation": true
}
EOF
export CONFIG="${WORKSPACE}/smoke_config.json"
}
echo " "
echo "Running setup tasks required before running tests..."
echo "***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****"
echo " "
# Setup golang
# Also make sure we do not have any old binaries in our GOPATH
which go
export GOROOT="/var/vcap/packages/golang"
echo "GOROOT is ${GOROOT}"
go version
echo "Setting up GOPATH..."
export GOPATH=${WORKSPACE}/gopath
if [[ -d ${GOPATH} ]]; then
rm -rf ${GOPATH}
fi
mkdir -p "${GOPATH}"
export GOPATH="${GOPATH}:${WORKSPACE}/cf-release/src/acceptance-tests/Godeps/_workspace"
echo "GOPATH is ${GOPATH}"
# Use the version of the smoke tests pinned in C3CI
cd ${WORKSPACE}/C3CI/cf-smoke-tests
source ${WORKSPACE}/infrastructures/${JOB_INFRASTRUCTURE_DIR}/cf/nyet_ci.sh
echo " "
echo "Creating config file to run smoke tests..."
echo " - See: https://github.com/cloudfoundry-incubator/cf-smoke-tests/blob/master/smoke/config.go"
generate_config_file
export CF_TRACE_BASENAME="cf_trace_"
local_gopath=$PWD/Godeps/_workspace
mkdir -p $local_gopath/bin
export GOPATH=$local_gopath:$GOPATH
export PATH=$local_gopath/bin:$PATH
go install -v github.com/onsi/ginkgo/ginkgo
echo " "
echo "Running SMOKE tests..."
echo "***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****"
ginkgo -r -slowSpecThreshold=300
rm ${CONFIG}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment