pipeline { agent { label 'maven-slave' } options { disableConcurrentBuilds() /*timeout(time: 8, unit: 'HOURS')*/ } environment { DEPLOYMENT_PARAMETERS="-pIMAGE_VERSION=latest -pCOLLECTOR_PODS=${COLLECTOR_PODS}" LOGS_COLLECTED="false" RUNNING_ON_OPENSHIFT="true" } parameters { string(name: 'JOB_REFERENCE', defaultValue: '', description: 'Jenkins job reference') string(name: 'OS_URL', defaultValue: '', description: 'Openshift url') string(name: 'OS_USERNAME', defaultValue: '', description: 'Openshift login username') password(name: 'OS_PASSWORD', defaultValue: '', description: 'Openshift login password') string(name: 'OS_NAMESPACE', defaultValue: 'jaeger-test2', description: 'Openshift namespace') booleanParam(name: 'INSTALL_JAEGER_SERVICES', defaultValue: true, description: 'Install Jaeger services') choice(choices: 'performance,smoke\nperformance\nsmoke', name: 'TESTS_TO_RUN', description: 'Tests to run') string(name: 'PERFORMANCE_TEST_DATA', defaultValue: 'quick,165', description: 'Performance test data[type,data]: type can be:"quick" or "long", for "quick": delay in miliseconds, for "long": duration in seconds') string(name: 'NUMBER_OF_TRACERS', defaultValue: '100', description: 'Number of tracers') string(name: 'NUMBER_OF_SPANS', defaultValue: '4000', description: 'Number of spans per tracer') string(name: 'QUERY_LIMIT', defaultValue: '20000', description: 'Maximum items limit on query execution') string(name: 'QUERY_SAMPLES', defaultValue: '5', description: 'Number of times the same should be executed') string(name: 'QUERY_INTERVAL', defaultValue: '-1', description: 'Query sets will be executed in this interval. If you want to only once at the end, pass it as -1') choice(choices: 'http\nudp', name: 'SENDER', description: 'In which mode spans should be sent. http - collector, udp - agent') choice(choices: 'elasticsearch\ncassandra', name: 'STORAGE_TYPE', description: 'Type of backend should be used to store spans') choice(choices: 'storage\njaeger-query', name: 'SPANS_COUNT_FROM', description: 'how to check spans count from backend. direct storage access or via jaeger query service?') string(name: 'STORAGE_HOST', defaultValue: 'elasticsearch', description: 'Storage hostname, for cassandra: cassandra') string(name: 'STORAGE_PORT', defaultValue: '9200', description: 'Storage host port number') string(name: 'STORAGE_KEYSPACE', defaultValue: 'jaeger_v1_dc1', description: 'Applicable for cassandra') string(name: 'JAEGER_QUERY_HOST', defaultValue: 'jaeger-query', description: 'Jaeger query service hostname') string(name: 'JAEGER_QUERY_PORT', defaultValue: '80', description: 'Jaeger query service host port number') string(name: 'JAEGER_COLLECTOR_HOST', defaultValue: 'jaeger-collector', description: 'Jaeger collector service hostname') string(name: 'JAEGER_COLLECTOR_PORT', defaultValue: '14268', description: 'Jaeger collector service host port number') string(name: 'JAEGER_AGENT_HOST', defaultValue: 'localhost', description: 'Jaeger agent service hostname') string(name: 'JAEGER_AGENT_PORT', defaultValue: '6831', description: 'Jaeger agent service host port number') string(name: 'JAEGER_AGENT_QUEUE_SIZE', defaultValue: '1000', description: 'Jaeger agent, length of the queue for the UDP server') string(name: 'JAEGER_AGENT_WORKERS', defaultValue: '10', description: 'Jaeger agent, how many workers the processor should run') string(name: 'JAEGER_FLUSH_INTERVAL', defaultValue: '200', description: 'Jaeger java client library flush interval') string(name: 'JAEGER_MAX_POCKET_SIZE', defaultValue: '0', description: 'Jaeger java client library max pocket size') string(name: 'JAEGER_MAX_QUEUE_SIZE', defaultValue: '10000', description: 'Jaeger java client library max queue size') string(name: 'COLLECTOR_PODS', defaultValue: '1', description: 'The number of collector pods') string(name: 'COLLECTOR_QUEUE_SIZE', defaultValue: '2000', description: '--collector.queue-size') string(name: 'COLLECTOR_NUM_WORKERS', defaultValue: '50', description: '--collector.num-workers') string(name: 'QUERY_STATIC_FILES', defaultValue: '', description: '--query.static-files') string(name: 'ES_MEMORY', defaultValue: '1Gi', description: 'Memory for each elasticsearch pod') string(name: 'ES_BULK_SIZE', defaultValue: '5000000', description: '--es.bulk.size') string(name: 'ES_BULK_WORKERS', defaultValue: '1', description: '--es.bulk.workers') string(name: 'ES_BULK_FLUSH_INTERVAL', defaultValue: '200ms', description: '--es.bulk.flush-interval') string(name: 'STORAGE_IMAGE', defaultValue: 'registry.centos.org/rhsyseng/elasticsearch:5.6.10', description: 'Storage image, can be ElasticSearch or cassandra.') booleanParam(name: 'STORAGE_IMAGE_INSECURE', defaultValue: false, description: 'If image location not-secured(HTTP), check this box') string(name: 'JAEGER_AGENT_IMAGE', defaultValue: 'jaegertracing/jaeger-agent:latest', description: 'Jaeger agent Image') string(name: 'JAEGER_COLLECTOR_IMAGE', defaultValue: 'jaegertracing/jaeger-collector:latest', description: 'Jaeger collector image') string(name: 'JAEGER_QUERY_IMAGE', defaultValue: 'jaegertracing/jaeger-query:latest', description: 'Jaeger query image') string(name: 'PERFORMANCE_TEST_IMAGE', defaultValue: 'jkandasa/jaeger-performance-test:1.0.0', description: 'Jaeger performance test docker image') booleanParam(name: 'DELETE_JAEGER_AT_END', defaultValue: true, description: 'Delete Jaeger instance at end of the test') booleanParam(name: 'DELETE_JOB_AT_END', defaultValue: true, description: 'Delete test pods at end of the test') } stages { stage('Set name and description') { steps { script { displayName=params.SENDER + " " + params.COLLECTOR_PODS + " collectors pods" } } } stage('Mandatory fields check and login') { steps { sh ''' ./openshift/scripts/oc_login.sh ''' } } stage('Delete Old Job') { steps { sh 'oc delete job,template,pod -l group=jaeger-performance-test -n ${OS_NAMESPACE} || true' sh 'oc delete job jaeger-standalone-performance-tests -n ${OS_NAMESPACE} || true' } } stage('Delete Jaeger') { when { expression { params.INSTALL_JAEGER_SERVICES } } steps { sh 'oc delete all,template,daemonset,configmap -l jaeger-infra -n ${OS_NAMESPACE} || true' sh 'oc delete -f https://raw.githubusercontent.com/RHsyseng/docker-rhel-elasticsearch/5.x/es-cluster-deployment.yml --grace-period=1 -n ${OS_NAMESPACE} || true' } } stage('Cleanup, checkout, build') { steps { deleteDir() checkout scm sh 'ls -alF' } } stage('deploy Cassandra') { when { expression { params.STORAGE_TYPE == 'cassandra' && params.INSTALL_JAEGER_SERVICES } } steps { sh ''' curl https://raw.githubusercontent.com/jaegertracing/jaeger-openshift/master/production/cassandra.yml --output cassandra.yml oc create --filename cassandra.yml -n ${OS_NAMESPACE} ''' } } stage('deploy ElasticSearch') { when { expression { params.STORAGE_TYPE == 'elasticsearch' && params.INSTALL_JAEGER_SERVICES } } steps { sh ' ./openshift/scripts/execute-es-cluster-deployment.sh ${OS_NAMESPACE}' } } stage('deploy Jaeger with Cassandra') { when { expression { params.STORAGE_TYPE == 'cassandra' && params.INSTALL_JAEGER_SERVICES } } steps { sh ''' curl https://raw.githubusercontent.com/jaegertracing/jaeger-openshift/master/production/configmap-cassandra.yml --output configmap-cassandra.yml 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 sed -i 's/jaegertracing\\/jaeger-collector:${IMAGE_VERSION}/'${JAEGER_COLLECTOR_IMAGE}'/g' jaeger-production-template.yml sed -i 's/jaegertracing\\/jaeger-query:${IMAGE_VERSION}/'${JAEGER_QUERY_IMAGE}'/g' jaeger-production-template.yml grep "image:" jaeger-production-template.yml ./openshift/scripts/updateTemplateForCassandra.sh ${OS_NAMESPACE} oc process ${DEPLOYMENT_PARAMETERS} -f jaeger-production-template.yml | oc create -n ${PROJECT_NAME} -f - ''' } } stage('deploy Jaeger with ElasticSearch') { when { expression { params.STORAGE_TYPE == 'elasticsearch' && params.INSTALL_JAEGER_SERVICES } } steps { sh './openshift/scripts/deploy_jaeger_elasticsearch.sh ${OS_NAMESPACE}' } } stage('Wait for Jaeger Deployment') { when { expression { params.INSTALL_JAEGER_SERVICES } } steps { sh ''' # NAMESPACE SERVICE_NAME MAX_WAIT_TIME ./openshift/scripts/wait_for_service.sh ${OS_NAMESPACE} jaeger-query 60 ./openshift/scripts/wait_for_service.sh ${OS_NAMESPACE} jaeger-collector 60 ''' } } stage('Run performance tests') { steps{ sh ''' # logs will be stored in this location export LOGS_DIRECTORY=$PWD/logs ./openshift/scripts/run_performance_test.sh sleep 30 # wait for 30 seconds to create container # wait_for_pods_status.sh NAMESPACE POD_FILTER WAIT_FOR_STATUS MAX_WAIT_TIME # add extra 5 minutes on maximum wait time # get test type and duration _TEST_DATA=(${PERFORMANCE_TEST_DATA//,/ }) if [ ${_TEST_DATA[0]} == 'long' ];then _TEST_DURATION=${_TEST_DATA[1]} else # if it is a qucik run define duration as 30 minutes maximum _TEST_DURATION=1800 fi ./openshift/scripts/wait_for_pods_status.sh ${OS_NAMESPACE} "app=jaeger-performance-test-job" "Running" `expr ${_TEST_DURATION} + 1800` # copy log files ./openshift/scripts/copy-log-file.sh ${OS_NAMESPACE} "app=jaeger-performance-test-job" "jaeger-performance-test" ./openshift/scripts/copy-log-file.sh ${OS_NAMESPACE} "app=jaeger-performance-test-job" "jaeger-agent" ls -lh logs/ mvn clean test ''' } } stage('Collect logs'){ steps{ sh ''' ./openshift/scripts/collect_logs.sh ${OS_NAMESPACE} export LOGS_COLLECTED="true" ''' } } stage('Delete Jaeger at end') { when { expression { params.DELETE_JAEGER_AT_END && params.INSTALL_JAEGER_SERVICES } } steps { script { sh 'oc delete -f https://raw.githubusercontent.com/RHsyseng/docker-rhel-elasticsearch/5.x/es-cluster-deployment.yml --grace-period=1 -n ${OS_NAMESPACE} || true' sh 'oc delete all,template,daemonset,configmap -l jaeger-infra -n ${OS_NAMESPACE} || true' } } } stage('Delete Job at end') { when { expression { params.DELETE_JOB_AT_END } } steps { sh 'oc delete job,template,pod -l group=jaeger-performance-test -n ${OS_NAMESPACE}' sh 'oc delete job jaeger-standalone-performance-tests -n ${OS_NAMESPACE} || true' } } } post { always { script { if (env.LOGS_COLLECTED == 'false') { sh './openshift/scripts/collect_logs.sh ${OS_NAMESPACE}' } } archiveArtifacts artifacts: 'logs/*.*' } } }