Created
March 20, 2018 17:46
-
-
Save kevinearls/b5e80f4c14c106133092ea0f1ff86309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
options { | |
disableConcurrentBuilds() | |
/*timeout(time: 8, unit: 'HOURS')*/ | |
} | |
environment { | |
JAEGER_AGENT_HOST = "localhost" | |
JAEGER_COLLECTOR_HOST = "jaeger-collector" | |
JAEGER_COLLECTOR_PORT = 14268 | |
ELASTICSEARCH_HOST = "elasticsearch" | |
ELASTICSEARCH_PORT = "9200" | |
CASSANDRA_CLUSTER_IP = "cassandra" | |
CASSANDRA_KEYSPACE_NAME="jaeger_v1_dc1" | |
DEPLOYMENT_PARAMETERS="-pIMAGE_VERSION=latest -pCOLLECTOR_QUEUE_SIZE=${COLLECTOR_QUEUE_SIZE} -pCOLLECTOR_PODS=${COLLECTOR_PODS}" | |
} | |
parameters { | |
choice(choices: 'COLLECTOR\nAGENT', name: 'USE_AGENT_OR_COLLECTOR') | |
choice(choices: 'elasticsearch\ncassandra', name: 'SPAN_STORAGE_TYPE') | |
string(name: 'DURATION_IN_MINUTES', defaultValue: '5', description: 'Amount of time each worker should run') | |
string(name: 'ES_BULK_SIZE', defaultValue: '10000000', description: '--es.bulk.size') | |
string(name: 'ES_BULK_WORKERS', defaultValue: '10', description: '--es.bulk.workers') | |
string(name: 'ES_BULK_FLUSH_INTERVAL', defaultValue: '1s', description: '--es.bulk.flush-interval') | |
string(name: 'THREAD_COUNT', defaultValue: '100', description: 'The number of client threads to run') | |
string(name: 'WORKER_PODS', defaultValue: '1', description: 'The number of pods to run client threads in') | |
string(name: 'DELAY', defaultValue: '100', description: 'delay in milliseconds between each span creation') | |
string(name: 'COLLECTOR_PODS', defaultValue: '1') | |
string(name: 'COLLECTOR_QUEUE_SIZE', defaultValue: '3000000') | |
string(name: 'PROJECT_NAME', defaultValue: 'myproject') | |
booleanParam(name: 'DELETE_JAEGER_AT_END', defaultValue: true, description: 'Delete Jaeger instance at end of the test') | |
string(name: 'JAEGER_SAMPLING_RATE', defaultValue: '1.0', description: '0.0 to 1.0 percent of spans to record') | |
} | |
stages { | |
stage('Set name and description') { | |
steps { | |
script { | |
currentBuild.displayName =params.SPAN_STORAGE_TYPE + " " + params.USE_AGENT_OR_COLLECTOR + " " + params.WORKER_PODS + " pods " + " " + params.THREAD_COUNT + " threads " + params.DURATION_IN_MINUTES + " min; delay " + params.DELAY | |
currentBuild.description = currentBuild.displayName | |
} | |
} | |
} | |
stage('Delete Jaeger') { | |
steps { | |
sh 'oc delete -f https://raw.githubusercontent.com/RHsyseng/docker-rhel-elasticsearch/5.x/es-cluster-deployment.yml --grace-period=1 || true' | |
sh 'oc delete all,template,daemonset,configmap -l jaeger-infra' | |
sh 'env | sort' | |
} | |
} | |
stage('Delete Old Job') { | |
steps { | |
sh 'oc delete job jaeger-standalone-performance-tests || true' | |
sh 'oc get project' | |
} | |
} | |
stage('Cleanup, checkout, build') { | |
/* FIXME restore checkout scm */ | |
steps { | |
deleteDir() | |
git 'https://github.com/jaegertracing/jaeger-performance.git' | |
sh 'ls -alF' | |
} | |
} | |
stage('deploy Cassandra') { | |
when { | |
expression { params.SPAN_STORAGE_TYPE == 'cassandra'} | |
} | |
steps { | |
sh ''' | |
curl https://raw.githubusercontent.com/jaegertracing/jaeger-openshift/master/production/cassandra.yml --output cassandra.yml | |
oc create --filename cassandra.yml | |
''' | |
} | |
} | |
stage('deploy ElasticSearch') { | |
when { | |
expression { params.SPAN_STORAGE_TYPE == 'elasticsearch'} | |
} | |
steps { | |
sh ''' | |
curl https://raw.githubusercontent.com/RHsyseng/docker-rhel-elasticsearch/5.x/es-cluster-deployment.yml --output es-cluster-deployment.yml | |
oc create -f es-cluster-deployment.yml | |
while true; do | |
replicas=$(oc get statefulset/elasticsearch -o=jsonpath='{.status.readyReplicas}') | |
((replicas > 1)) && break | |
sleep 1 | |
done | |
''' | |
sh 'oc env statefulset/elasticsearch NAMESPACE=${PROJECT_NAME} -n ${PROJECT_NAME}' | |
sh 'oc adm policy add-role-to-user view -z elasticsearch' | |
/* Restart to apply changes */ | |
sh 'oc delete po -l app=elasticsearch' | |
} | |
} | |
stage('deploy Jaeger with Cassandra') { | |
when { | |
expression { params.SPAN_STORAGE_TYPE == 'cassandra'} | |
} | |
steps { | |
sh ''' | |
curl https://raw.githubusercontent.com/jaegertracing/jaeger-openshift/master/production/configmap-cassandra.yml --output configmap-cassandra.yml | |
sh 'oc create -f configmap-cassandra.yml' | |
curl https://raw.githubusercontent.com/jaegertracing/jaeger-openshift/master/production/jaeger-production-template.yml --output jaeger-production-template.yml | |
./standalone/updateTemplateForCassandra.sh | |
oc process ${DEPLOYMENT_PARAMETERS} -f jaeger-production-template.yml | oc create -n ${PROJECT_NAME} -f - | |
''' | |
} | |
} | |
stage('deploy Jaeger with ElasticSearch') { | |
when { | |
expression { params.SPAN_STORAGE_TYPE == 'elasticsearch'} | |
} | |
steps { | |
sh ''' | |
curl https://raw.githubusercontent.com/jaegertracing/jaeger-openshift/master/production/configmap-elasticsearch.yml --output configmap-elasticsearch.yml | |
oc create -f configmap-elasticsearch.yml | |
curl https://raw.githubusercontent.com/kevinearls/jaeger-openshift/working/production/jaeger-production-template.yml --output jaeger-production-template.yml | |
./standalone/updateTemplateForElasticSearch.sh | |
oc process ${DEPLOYMENT_PARAMETERS} -pES_BULK_SIZE=${ES_BULK_SIZE} -pES_BULK_WORKERS=${ES_BULK_WORKERS} -pES_BULK_FLUSH_INTERVAL=${ES_BULK_FLUSH_INTERVAL} -f jaeger-production-template.yml | oc create -n ${PROJECT_NAME} -f - | |
''' | |
} | |
} | |
stage('Wait for Jaeger Deployment') { | |
steps { | |
openshiftVerifyService apiURL: '', authToken: '', namespace: '', svcName: 'jaeger-query', verbose: 'false' | |
openshiftVerifyService apiURL: '', authToken: '', namespace: '', svcName: 'jaeger-collector', verbose: 'false' | |
} | |
} | |
/* For Agent we need to deploy */ | |
stage('Run tests'){ | |
steps{ | |
withEnv(["JAVA_HOME=${ tool 'jdk8' }", "PATH+MAVEN=${tool 'maven-3.5.2'}/bin:${env.JAVA_HOME}/bin"]) { | |
sh ''' | |
git status | |
cd standalone | |
mvn clean install | |
oc get pods | |
mvn --activate-profiles openshift clean install fabric8:deploy -Dpod.count=${WORKER_PODS} -Dduration.in.minutes=${DURATION_IN_MINUTES} -Ddelay=${DELAY} -Djaeger.sampling.rate=${JAEGER_SAMPLING_RATE} -Djaeger.agent.host=${JAEGER_AGENT_HOST} -Duser.agent.or.collector=${USE_AGENT_OR_COLLECTOR} -Djaeger.collector.port=${JAEGER_COLLECTOR_PORT} -Djaeger.collector.host=${JAEGER_COLLECTOR_HOST} | |
mvn --activate-profiles validate clean verify | |
''' | |
} | |
} | |
} | |
stage('Delete Jaeger at end') { | |
when { | |
expression { params.DELETE_JAEGER_AT_END } | |
} | |
steps { | |
script { | |
sh 'oc delete -f https://raw.githubusercontent.com/RHsyseng/docker-rhel-elasticsearch/5.x/es-cluster-deployment.yml --grace-period=1' | |
sh 'oc delete all,template,daemonset,configmap -l jaeger-infra' | |
} | |
} | |
} | |
stage('Delete Job at end') { | |
steps { | |
sh 'oc delete job jaeger-standalone-performance-tests || true' | |
} | |
} | |
stage('Cleanup pods') { | |
steps { | |
script { | |
sh 'oc get pods | grep Completed | awk {"print \\$1"} | xargs oc delete pod || true' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment