├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── build_push_docker.sh
├── license_header.txt
├── lombok.config
├── openshift
├── Jenkinsfile
├── scripts
│ ├── collect_logs.sh
│ ├── copy-log-file.sh
│ ├── deploy_es_cluster.sh
│ ├── deploy_jaeger_operator.sh
│ ├── deploy_jaeger_services.sh
│ ├── oc_login.sh
│ ├── run_performance_test.sh
│ ├── wait_for_performance_run.sh
│ ├── wait_for_pods_status.sh
│ ├── wait_for_pods_status_with_ha.sh
│ ├── wait_for_project.sh
│ └── wait_for_service.sh
└── templates
│ ├── jaeger-services-all-in-one.yaml
│ ├── jaeger-services-deploy-es.yaml
│ ├── jaeger-services-es-url.yaml
│ └── performance-test.yaml
├── pom.xml
├── src
├── main
│ ├── java
│ │ └── io
│ │ │ └── jaegertracing
│ │ │ └── tests
│ │ │ ├── CreateSpansRunnable.java
│ │ │ ├── ElasticsearchSpanCounter.java
│ │ │ ├── ElasticsearchStatsGetter.java
│ │ │ ├── ISpanCounter.java
│ │ │ ├── JaegerQueryRunnable.java
│ │ │ ├── JaegerQuerySpanCounter.java
│ │ │ ├── JsonUtils.java
│ │ │ ├── Main.java
│ │ │ ├── ReportEngineUtils.java
│ │ │ ├── TestUtils.java
│ │ │ ├── UntilNoChangeCounter.java
│ │ │ ├── clients
│ │ │ ├── ClientUtils.java
│ │ │ ├── GenericRestClient.java
│ │ │ ├── JaegerQEControllerClient.java
│ │ │ └── ReportEngineClient.java
│ │ │ ├── junitxml
│ │ │ ├── DescriptionAsTest.java
│ │ │ └── JUnitResultFormatterAsRunListener.java
│ │ │ ├── model
│ │ │ ├── Data.java
│ │ │ ├── Jenkins.java
│ │ │ ├── Result.java
│ │ │ ├── Span.java
│ │ │ ├── TestConfig.java
│ │ │ └── TestSuiteStatus.java
│ │ │ ├── osutils
│ │ │ ├── OSCommandExecuter.java
│ │ │ └── OSResponse.java
│ │ │ ├── report
│ │ │ ├── JsonReporter.java
│ │ │ ├── ReportFactory.java
│ │ │ └── model
│ │ │ │ ├── BaseModel.java
│ │ │ │ ├── HistogramModel.java
│ │ │ │ ├── JaegerMetrics.java
│ │ │ │ ├── JaegerTestReport.java
│ │ │ │ ├── MeterModel.java
│ │ │ │ ├── MetricReport.java
│ │ │ │ ├── TestData.java
│ │ │ │ └── TimerModel.java
│ │ │ ├── resourcemonitor
│ │ │ ├── MetricUtils.java
│ │ │ ├── ReMetric.java
│ │ │ └── Runner.java
│ │ │ └── smoke
│ │ │ ├── QESpan.java
│ │ │ ├── SimpleRestClient.java
│ │ │ ├── TestBase.java
│ │ │ ├── TestSuiteSmoke.java
│ │ │ └── tests
│ │ │ ├── BasicSpanTest.java
│ │ │ ├── FirstJaegerTest.java
│ │ │ ├── IndexCleanerTest.java
│ │ │ ├── SimpleUITest.java
│ │ │ └── TagAndDurationTest.java
│ └── resources
│ │ └── logback.xml
└── test
│ └── java
│ └── io
│ └── jaegertracing
│ └── tests
│ ├── ParseReport.java
│ ├── TestEnabled.java
│ ├── TestSuite.java
│ └── run
│ ├── PerformanceTest.java
│ └── SmokeTest.java
├── start.sh
└── test_config.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 |
3 | # Compiled class file
4 | *.class
5 |
6 | # Log file
7 | *.log
8 |
9 | # BlueJ files
10 | *.ctxt
11 |
12 | # Mobile Tools for Java (J2ME)
13 | .mtj.tmp/
14 |
15 | # Package Files #
16 | *.jar
17 | *.war
18 | *.ear
19 | *.zip
20 | *.tar.gz
21 | *.rar
22 |
23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24 | hs_err_pid*
25 |
26 | # IDEA stuff
27 | *.iml
28 | .idea
29 |
30 | # Generated code
31 | gen-java
32 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | FROM openjdk:alpine
16 |
17 | RUN apk add --no-cache openssl curl
18 |
19 | ENV APP_HOME /app/
20 |
21 | COPY start.sh ${APP_HOME}/start.sh
22 | COPY target/performance-tests*-jar-with-dependencies.jar ${APP_HOME}/performance-tests-jar-with-dependencies.jar
23 |
24 | WORKDIR ${APP_HOME}
25 | CMD ${APP_HOME}/start.sh
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Jaeger Performance Test
2 |
3 | This project is designed to do basic smoke and performance testing of [JaegerTracing](https://www.jaegertracing.io/). The primary target for these tests is OpenShift, where they can be run using the Jenkinsfile in this directory.
4 |
5 | ## License
6 |
7 | [Apache 2.0 License](./LICENSE).
8 |
9 | ### Overview of tests
10 | This test can be executed locally with this source code or can be executed on OpenShift with Jenkins pipeline file.
11 |
12 | ### Running on the Local environment
13 | To run this tests on your local environment, jaeger services should be installed manually on your local machine.
14 |
15 | * Follow [these steps](https://www.jaegertracing.io/docs/1.7/getting-started/) to install locally on your machine.
16 | * Clone this repository `git clone https://github.com/jkandasa/jaeger-performance-new`
17 | * Test configurations can be set via the environment variable [or] pass it via YAML file.
18 |
19 |
20 | #### Run test by passing YAML configuration file
21 | This is the easy way to running the test. We can keep all our test configurations on a YAML file and pass this YAML file to the test.
22 |
23 | Sample yaml file is [available here](/test_config.yaml)
24 |
25 | ```yaml
26 | # what are all the tests need to be executed
27 | testsToRun: 'performance,smoke'
28 |
29 | # performance test data, two type of performance test can be executed
30 | # data format: [type,data]
31 | # 1. quick run example, 'quick,50', data: delay between spans in milliseconds
32 | # 2. long run example, 'long,600', data: test duration in seconds
33 | performanceTestData: 'quick,10'
34 |
35 | # tracers count, number of tracers should send spans
36 | tracersCount: 10
37 |
38 | # spans count for per tracer.
39 | spansCount: 50000
40 |
41 | # maximum spans/data limit on Jaeger query test
42 | queryLimit: 20000
43 |
44 | # Number of times the query to be executed repetitively.
45 | # To get the average time
46 | querySamples: 5
47 |
48 | # How long once repeat the query test? '-1' indicates only at final
49 | # values in seconds
50 | queryInterval: -1
51 |
52 | # where to send spans, options: http, udp
53 | # 'http' will send spans to 'collector'
54 | # 'udp' will send spans to 'agent'
55 | sender: http
56 |
57 | # storage type, options: elasticsearch, cassandra
58 | storageType: elasticsearch
59 |
60 | # Get a number of spans count from storage at the end of the test
61 | # options: storage, jaeger-query
62 | # Type 'storage' will be used direct storage query API
63 | # Type 'jaeger-query' will be used jaeger query API
64 | spansCountFrom: jaeger-query
65 |
66 | # storage hostname and port number
67 | storageHost: localhost
68 | storagePort: 9200
69 |
70 | # storage keyspace, used in Cassandra storage
71 | storageKeyspace: keyspace
72 |
73 | # jaeger query hostname and port number
74 | jaegerQueryHost: localhost
75 | jaegerQueryPort: 16686
76 |
77 | # jaeger collector hostname and port number
78 | jaegerCollectorHost: localhost
79 | jaegerCollectorPort: 14268
80 |
81 | # jaeger agent hostname and port number
82 | jaegerAgentHost: localhost
83 | jaegerAgentPort: 6831
84 |
85 | # jaeger client java library configurations
86 | jaegerFlushInterval: 100
87 | jaegerMaxPocketSize: 0
88 | jaegerMaxQueueSize: 10000
89 | ```
90 |
91 | Running test
92 | ```bash
93 | # pass configuration file as system properties and running tests
94 | mvn clean test -DTEST_CONFIG_FILE=test_config.yaml
95 |
96 | # [OR]
97 |
98 | # set test configuration file in the environment and running tests
99 | export TEST_CONFIG_FILE=test_config.yaml
100 | mvn clean test
101 | ```
102 |
103 | #### Run test by Setting environment variables
104 | Here environment variables are listed with default values on `[]`
105 |
106 | * `TESTS_TO_RUN` ["performance,smoke"] - what are all the tests need to be executed
107 | * `PERFORMANCE_TEST_DATA` ["quick,10"] - performance test data, two type of performance test can be executed. data format: [type,data]
108 |
109 | 1. quick run example, 'quick,10', data: delay between spans in milliseconds
110 | 2. long run example, 'long,600', data: test duration in seconds
111 | * `NUMBER_OF_TRACERS` [5] - Number of tracers should be created
112 | * `NUMBER_OF_SPANS` [10] - Number of spans per tracer. *Spans per second = NUMBER_OF_TRACERS * NUMBER_OF_SPANS*
113 | * `QUERY_LIMIT` [20000] - maximum records limit, when run query test
114 | * `QUERY_SAMPLES` [5] - number of times the same query should be repeated (we will get average query execution time)
115 | * `QUERY_INTERVAL` [-1] - if you want to run query tests on multiple intervals, specify the values in seconds. `-1` indicates run only at the end of the test
116 | * `SENDER` [http] - Where program wants to send spans? `http` - to collector. `udp` - to agent
117 | * `STORAGE_TYPE` [elasticsearch] - Storage type will be used, options: elasticsearch, cassandra
118 | * `SPANS_COUNT_FROM` [storage] - how to get spans count from jaeger tracing? via storage api or jaeger query api? options: storage, jaeger-query
119 | * `STORAGE_HOST` [localhost] - storage hostname
120 | * `STORAGE_PORT` [9200] - storage host port number
121 | * `STORAGE_KEYSPACE` [keyspace] - keyspace name, used in cassandra storage type
122 | * `JAEGER_QUERY_HOST` [localhost] - jaeger query service hostname
123 | * `JAEGER_QUERY_PORT` [16686] - jaeger query service port number
124 | * `JAEGER_COLLECTOR_HOST` [localhost] - jaeger collector service hostname
125 | * `JAEGER_COLLECTOR_PORT` [14268] - jaeger collector service port number
126 | * `JAEGER_AGENT_HOST` [localhost] - jaeger agent service hostname
127 | * `JAEGER_AGENT_PORT` [6831] - jaeger agent service port number
128 | * `JAEGER_FLUSH_INTERVAL` [100] - flush interval will be used in jaeger java client library
129 | * `JAEGER_MAX_POCKET_SIZE` [0] - maximum udp pocket size used in jaeger client library(when `SENDER` == `udp`)
130 | * `JAEGER_MAX_QUEUE_SIZE` [10000] - queue size in jaeger java client library
131 |
132 | Some of the environment variables not listed here, which is used to setup storage and jaeger services on OpenShift environment via Jenkins.
133 |
134 | All environment variables are [listed here](/src/main/java/io/jaegertracing/tests/model/TestConfig.java)
135 |
136 | ##### Running test
137 | ```bash
138 | mvn clean test
139 | ```
140 |
141 |
142 |
143 | ### Running on OpenShift
144 | The [Jenkinsfile pipeline file](/openshift/Jenkinsfile) is designed to be running tests on OpenShift environment. This test will deploy performance test as a container on OpenShift on the same namespace where jaeger services are running. This is required to be able to connect to Jaeger Agent or Connector ports, which are not accessible outside of the cluster.
145 |
146 | The following dependencies need to run this job on Jenkins,
147 | * maven
148 | * java
149 | * git
150 | * oc (OpenShift client)
151 |
152 | Jenkins pipeline will be looking `jaeger-qe-java` labeled slave. This slave should be running with the dependencies.
153 | ```
154 | agent { label 'jaeger-qe-java' }
155 | ```
--------------------------------------------------------------------------------
/build_push_docker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018-2020 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # docker organization
18 | DOCKER_ORG='docker.io/jkandasa'
19 |
20 | # tag version
21 | TAG='3.6'
22 |
23 | # compile java project
24 | mvn clean package -Dmaven.test.skip=true
25 |
26 | # build docker image
27 | podman build -t ${DOCKER_ORG}/jaeger-performance-test:${TAG} .
28 |
29 | # push new image to docker hub
30 | podman push ${DOCKER_ORG}/jaeger-performance-test:${TAG}
31 |
--------------------------------------------------------------------------------
/license_header.txt:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} The Jaeger Authors
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4 | in compliance with the License. You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software distributed under the License
9 | is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10 | or implied. See the License for the specific language governing permissions and limitations under
11 | the License.
12 |
--------------------------------------------------------------------------------
/lombok.config:
--------------------------------------------------------------------------------
1 | lombok.log.fieldName = logger
2 |
--------------------------------------------------------------------------------
/openshift/scripts/collect_logs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018-2019 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # pass following arguments in the same order,
18 | # NAMESPACE
19 |
20 | # update namespace name
21 | OS_NAMESPACE=$1
22 |
23 | # metric port details
24 | JAGENT=14271
25 | JCOLLECTOR=14269
26 | JQUERY=16687
27 |
28 | # enable set -x if you want to print commands on console
29 | #set -x
30 |
31 | # set metrics file extension
32 | METRICS_EXTENSION="txt"
33 | if [ ${METRICS_BACKEND} = "prometheus" ]; then
34 | METRICS_EXTENSION="prom"
35 | # download prometheus-scraper
36 | curl https://search.maven.org/remotecontent?filepath=org/hawkular/agent/prometheus-scraper/0.23.0.Final/prometheus-scraper-0.23.0.Final-cli.jar -o prometheus-scraper-0.23.0.Final-cli.jar
37 | elif [ ${METRICS_BACKEND} = "expvar" ]; then
38 | METRICS_EXTENSION="json"
39 | fi
40 | echo "DEBUG: Metric backend: ${METRICS_BACKEND}, selected file extension:${METRICS_EXTENSION}"
41 |
42 | # copy log files
43 |
44 | # collect elasticsearch logs
45 | ./openshift/scripts/copy-log-file.sh ${OS_NAMESPACE} "app=elasticsearch"
46 |
47 | # collect jaeger services logs
48 | # PODS=`oc get pods -n ${OS_NAMESPACE} --no-headers -l app=jaeger | awk '{print $1}'`
49 | # disabline to get spans reporter pods
50 | PODS=`oc get pods -n ${OS_NAMESPACE} --no-headers | awk '{print $1}'`
51 |
52 | PODS_LIST=$(echo ${PODS} | tr " " "\n")
53 | for _pod in ${PODS_LIST}; do
54 | _pod_ip=$(oc get pod ${_pod} --template={{.status.podIP}} -n ${OS_NAMESPACE})
55 | if [[ ${_pod_ip} == "" ]];then
56 | echo "DEBUG: Trying IP with jsonpath option"
57 | _pod_ip=$(oc get pod ${_pod} -o=jsonpath='{.status.podIP}' -n ${OS_NAMESPACE})
58 | fi
59 |
60 | echo "INFO: Copying log file from ${_pod}, IP:${_pod_ip}"
61 | if [[ ${_pod} = *"query"* ]]; then
62 | oc logs ${_pod} -c "jaeger-query" -n ${OS_NAMESPACE} > logs/${OS_NAMESPACE}_${_pod}_jaeger-query.log
63 | oc logs ${_pod} -c "jaeger-agent" -n ${OS_NAMESPACE} > logs/${OS_NAMESPACE}_${_pod}_jaeger-agent.log
64 | # metrics - query and agent
65 | if [[ ${METRICS_BACKEND} == "DONOTRUN" ]]; then
66 | curl http://${_pod_ip}:${JQUERY}/metrics --output logs/${OS_NAMESPACE}_${_pod}_metrics-query.${METRICS_EXTENSION}
67 | curl http://${_pod_ip}:${JAGENT}/metrics --output logs/${OS_NAMESPACE}_${_pod}_metrics-agent.${METRICS_EXTENSION}
68 | # convert prometheus logs to json
69 | if [ ${METRICS_BACKEND} = "prometheus" ]; then
70 | java -jar prometheus-scraper*-cli.jar --json http://${_pod_ip}:${JQUERY}/metrics > logs/${OS_NAMESPACE}_${_pod}_metrics-query.json
71 | java -jar prometheus-scraper*-cli.jar --json http://${_pod_ip}:${JAGENT}/metrics > logs/${OS_NAMESPACE}_${_pod}_metrics-agent.json
72 | fi
73 | fi
74 | elif [[ ${_pod} = *"collector"* ]]; then
75 | oc logs ${_pod} -n ${OS_NAMESPACE} > logs/${OS_NAMESPACE}_${_pod}.log
76 | # metrics - collector
77 | if [[ ${METRICS_BACKEND} == "DONOTRUN" ]]; then
78 | curl http://${_pod_ip}:${JCOLLECTOR}/metrics --output logs/${OS_NAMESPACE}_${_pod}_metrics-collector.${METRICS_EXTENSION}
79 | # convert prometheus logs to json
80 | if [ ${METRICS_BACKEND} = "prometheus" ]; then
81 | java -jar prometheus-scraper*-cli.jar --json http://${_pod_ip}:${JCOLLECTOR}/metrics > logs/${OS_NAMESPACE}_${_pod}_metrics-collector.json
82 | fi
83 | fi
84 | elif [[ ${_pod} = *"spans-reporter"* ]]; then
85 | # metrics - spans-reporter, jaeger agent
86 | if [[ ${METRICS_BACKEND} == "DONOTRUN" ]]; then
87 | curl http://${_pod_ip}:${JAGENT}/metrics --output logs/${OS_NAMESPACE}_${_pod}_metrics-agent.${METRICS_EXTENSION}
88 | # convert prometheus logs to json
89 | if [ ${METRICS_BACKEND} = "prometheus" ]; then
90 | java -jar prometheus-scraper*-cli.jar --json http://${_pod_ip}:${JAGENT}/metrics > logs/${OS_NAMESPACE}_${_pod}_metrics-agent.json
91 | fi
92 | fi
93 | fi
94 | done
95 |
96 | # collect describe logs
97 | oc describe pods,services,events,configmaps,deployments -l name!=jenkins -n ${OS_NAMESPACE} >> logs/describe.log
98 | oc get pods -n ${OS_NAMESPACE} >> logs/pods.log
99 |
100 | # collect performance test xml logs
101 | ls -alh
102 | cp target/surefire-reports/* logs/ -R | true
--------------------------------------------------------------------------------
/openshift/scripts/copy-log-file.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # pass following arguments in the same order,
18 | # NAMESPACE POD_FILTER CONTAINER_NAME
19 |
20 | # this script copy files from inside pod. We can filter pods with POD_FILTER option
21 |
22 | # update namespace name
23 | OS_NAMESPACE=$1
24 |
25 | # update pod filters. ie: app=jaeger-performance-test-job
26 | POD_FILTER=$2
27 |
28 | # update container name
29 | CONTAINER_NAME=$3
30 |
31 | # create logs directory
32 | mkdir -p logs
33 |
34 | # get pods
35 | PODS=`oc get pods -n ${OS_NAMESPACE} --no-headers -l ${POD_FILTER} | awk '{print $1}'`
36 | NUMBER_OF_PODS=`echo ${PODS} | wc -w`
37 | PODS_LIST=$(echo ${PODS} | tr " " "\n")
38 | echo "INFO: Pods list: ${PODS}"
39 | for _pod in ${PODS_LIST}; do
40 | echo "INFO: Copying log file from ${_pod}"
41 | if [ -n "$CONTAINER_NAME" ]; then
42 | oc logs ${_pod} -c ${CONTAINER_NAME} -n ${OS_NAMESPACE} > logs/${OS_NAMESPACE}_${_pod}_${CONTAINER_NAME}.log
43 | else
44 | oc logs ${_pod} -n ${OS_NAMESPACE} > logs/${OS_NAMESPACE}_${_pod}.log
45 | fi
46 | done
47 |
--------------------------------------------------------------------------------
/openshift/scripts/deploy_es_cluster.sh:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | # Unable to add multiline sed replace with Jenkins pipeline file, hence created this script as a workaround,
16 | # and moved all the commands to this file.
17 |
18 | # pass following arguments in the same order,
19 | # NAMESPACE
20 |
21 | # update namespace name
22 | OS_NAMESPACE=$1
23 |
24 | set -x
25 |
26 | STORAGE_IMAGE_INSECURE="true"
27 |
28 | curl https://raw.githubusercontent.com/RHsyseng/docker-rhel-elasticsearch/5.x/es-cluster-deployment.yml --output es-cluster-deployment.yaml
29 | sed -i 's/512Mi/'${ES_MEMORY}'/g' es-cluster-deployment.yaml
30 | sed -i 's/registry.centos.org\/rhsyseng\/elasticsearch:5.6.10/'${IMAGE_ELASTICSEARCH//\//\\/}' \
31 | importPolicy: \
32 | insecure: '${STORAGE_IMAGE_INSECURE}'/g' es-cluster-deployment.yaml
33 | # update node selector label
34 | #sed -i 's;securityContext: {}.*;securityContext: {} \
35 | # nodeSelector: \
36 | # storagetype: elasticsearch;g' es-cluster-deployment.yaml
37 |
38 | # remove old deployments
39 | oc delete -f es-cluster-deployment.yaml --grace-period=1 -n ${OS_NAMESPACE} || true
40 | # sleep for a while
41 | sleep 10
42 | # deploy ES cluster
43 | oc create -f es-cluster-deployment.yaml -n ${OS_NAMESPACE}
44 | while true; do
45 | replicas=$(oc get statefulset/elasticsearch -o=jsonpath='{.status.readyReplicas}' -n ${OS_NAMESPACE})
46 | ((replicas > 1)) && break
47 | sleep 5
48 | done
49 |
50 | # move deployment file to logs directory
51 | mkdir -p logs
52 | mv es-cluster-deployment.yaml logs/
53 |
--------------------------------------------------------------------------------
/openshift/scripts/deploy_jaeger_operator.sh:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | # pass following arguments in the same order,
16 | # NAMESPACE
17 |
18 | # update namespace details
19 | JO_NAMESPACE=observability
20 | # TODO: we have an issue with ES Operator, it works only on "openshift-logging" namespace
21 | ESO_NAMESPACE="openshift-logging"
22 |
23 | set -x
24 |
25 | # download yaml files
26 | curl https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/operator.yaml --output operator.yaml
27 | curl https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role_binding.yaml --output role_binding.yaml
28 | curl https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role.yaml --output role.yaml
29 | curl https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/service_account.yaml --output service_account.yaml
30 | curl https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/crds/jaegertracing_v1_jaeger_crd.yaml --output jaegertracing_v1_jaeger_crd.yaml
31 |
32 | # update jaeger operator image
33 | sed -i 's;jaegertracing/jaeger-operator.*;'${IMAGE_JAEGER_OPERATOR}';g' operator.yaml
34 | # enable debug for jaeger operator
35 | sed -i 's;\["start"\];["start", "--log-level='${LOG_LEVEL_JAEGER_OPERATOR}'"];g' operator.yaml
36 |
37 | # delete jaeger operator
38 | oc delete -f operator.yaml -n ${JO_NAMESPACE}
39 | oc delete -f role_binding.yaml -n ${JO_NAMESPACE}
40 | oc delete -f role.yaml -n ${JO_NAMESPACE}
41 | oc delete -f service_account.yaml -n ${JO_NAMESPACE}
42 | oc delete -f jaegertracing_v1_jaeger_crd.yaml -n ${JO_NAMESPACE}
43 |
44 | # elasticsearch operator
45 | if [ ${ELASTICSEARCH_PROVIDER} == 'es-operator' ]; then
46 | curl https://raw.githubusercontent.com/openshift/elasticsearch-operator/master/manifests/01-service-account.yaml --output es_01-service-account.yaml
47 | curl https://raw.githubusercontent.com/openshift/elasticsearch-operator/master/manifests/02-role.yaml --output es_02-role.yaml
48 | curl https://raw.githubusercontent.com/openshift/elasticsearch-operator/master/manifests/03-role-bindings.yaml --output es_03-role-bindings.yaml
49 | curl https://raw.githubusercontent.com/openshift/elasticsearch-operator/master/manifests/04-crd.yaml --output es_04-crd.yaml
50 | curl https://raw.githubusercontent.com/openshift/elasticsearch-operator/master/manifests/05-deployment.yaml --output es_05-deployment.yaml
51 |
52 | # update ES operator image
53 | sed -i 's;quay.io/openshift/origin-elasticsearch-operator.*;'${IMAGE_ELASTICSEARCH_OPERATOR}';g' es_05-deployment.yaml
54 | sed -i 's;imagePullPolicy: IfNotPresent.*;imagePullPolicy: Always;g' es_05-deployment.yaml
55 |
56 | # delete ES operator
57 | oc delete -f es_05-deployment.yaml -n ${ESO_NAMESPACE}
58 | oc delete -f es_04-crd.yaml -n ${ESO_NAMESPACE}
59 | oc delete -f es_03-role-bindings.yaml -n ${ESO_NAMESPACE}
60 | oc delete -f es_02-role.yaml -n ${ESO_NAMESPACE}
61 | oc delete -f es_01-service-account.yaml -n ${ESO_NAMESPACE}
62 | fi
63 |
64 | # delete and wait to complete the process: NAMESPACE ACTION TIMEOUT
65 | ./openshift/scripts/wait_for_project.sh ${JO_NAMESPACE} delete 60
66 |
67 | # create and wait to complete the process: NAMESPACE ACTION TIMEOUT
68 | ./openshift/scripts/wait_for_project.sh ${JO_NAMESPACE} create 60
69 |
70 | # deploy jaeger operator
71 | oc create -f jaegertracing_v1_jaeger_crd.yaml -n ${JO_NAMESPACE}
72 | oc create -f service_account.yaml -n ${JO_NAMESPACE}
73 | oc create -f role.yaml -n ${JO_NAMESPACE}
74 | oc create -f role_binding.yaml -n ${JO_NAMESPACE}
75 | oc create -f operator.yaml -n ${JO_NAMESPACE}
76 |
77 | # deploy elasticsearch operator
78 | if [ ${ELASTICSEARCH_PROVIDER} == 'es-operator' ]; then
79 | oc create -f es_01-service-account.yaml -n ${ESO_NAMESPACE}
80 | oc create -f es_02-role.yaml -n ${ESO_NAMESPACE}
81 | oc create -f es_03-role-bindings.yaml -n ${ESO_NAMESPACE}
82 | oc create -f es_04-crd.yaml -n ${ESO_NAMESPACE}
83 | oc create -f es_05-deployment.yaml -n ${ESO_NAMESPACE}
84 | fi
85 |
86 | # move files to logs directory
87 | mkdir -p logs
88 | mv jaegertracing_v1_jaeger_crd.yaml logs/
89 | mv service_account.yaml logs/
90 | mv role.yaml logs/
91 | mv role_binding.yaml logs/
92 | mv operator.yaml logs/
93 | if [ ${ELASTICSEARCH_PROVIDER} == 'es-operator' ]; then
94 | mv es_01-service-account.yaml logs/
95 | mv es_02-role.yaml logs/
96 | mv es_03-role-bindings.yaml logs/
97 | mv es_04-crd.yaml logs/
98 | mv es_05-deployment.yaml logs/
99 | fi
100 |
101 | # wait for jaeger operator to come up
102 | ./openshift/scripts/wait_for_service.sh ${JO_NAMESPACE} jaeger-operator 60
--------------------------------------------------------------------------------
/openshift/scripts/deploy_jaeger_services.sh:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | #
16 | # Need to add // --collector.num-workers=50 --collector.queue-size=2000
17 | #
18 |
19 | # pass following arguments in the same order,
20 | # NAMESPACE
21 |
22 | # update namespace name
23 | OS_NAMESPACE=$1
24 |
25 | set -x
26 |
27 | # copy jaeger services template
28 | # "es-operator": install elastic search es operator based
29 | # "template": ES cluster will be installed with template
30 | # "external": external ES cluster url will be provides
31 | # "none": Use all-in-one jaeger services template
32 | if [ ${ELASTICSEARCH_PROVIDER} == 'es-operator' ]; then
33 | cp openshift/templates/jaeger-services-deploy-es.yaml jaeger-services-final.yaml
34 | elif [ ${ELASTICSEARCH_PROVIDER} == 'none' ]; then
35 | cp openshift/templates/jaeger-services-all-in-one.yaml jaeger-services-final.yaml
36 | else
37 | cp openshift/templates/jaeger-services-es-url.yaml jaeger-services-final.yaml
38 | fi
39 |
40 | # update variables
41 | sed -i 's;${JAEGER_SERVICE_NAME};'${JAEGER_SERVICE_NAME}';g' jaeger-services-final.yaml
42 | sed -i 's;${METRICS_BACKEND};'${METRICS_BACKEND}';g' jaeger-services-final.yaml
43 | sed -i 's;${COLLECTOR_REPLICA_COUNT};'${COLLECTOR_REPLICA_COUNT}';g' jaeger-services-final.yaml
44 | sed -i 's;${COLLECTOR_NUM_WORKERS};'${COLLECTOR_NUM_WORKERS}';g' jaeger-services-final.yaml
45 | sed -i 's;${COLLECTOR_QUEUE_SIZE};'${COLLECTOR_QUEUE_SIZE}';g' jaeger-services-final.yaml
46 | sed -i 's;${COLLECTOR_ES_BULK_SIZE};'${COLLECTOR_ES_BULK_SIZE}';g' jaeger-services-final.yaml
47 | sed -i 's;${COLLECTOR_ES_BULK_WORKERS};'${COLLECTOR_ES_BULK_WORKERS}';g' jaeger-services-final.yaml
48 | sed -i 's;${COLLECTOR_ES_BULK_FLUSH_INTERVAL};'${COLLECTOR_ES_BULK_FLUSH_INTERVAL}';g' jaeger-services-final.yaml
49 | sed -i 's;${COLLECTOR_ES_TAGS_AS_FIELDS};'${COLLECTOR_ES_TAGS_AS_FIELDS}';g' jaeger-services-final.yaml
50 | sed -i 's;${STORAGE_HOST};'${STORAGE_HOST}';g' jaeger-services-final.yaml
51 | sed -i 's;${STORAGE_PORT};'${STORAGE_PORT}';g' jaeger-services-final.yaml
52 | sed -i 's;${IMAGE_ELASTICSEARCH};'${IMAGE_ELASTICSEARCH}';g' jaeger-services-final.yaml
53 | sed -i 's;${IMAGE_JAEGER_ALL_IN_ONE};'${IMAGE_JAEGER_ALL_IN_ONE}';g' jaeger-services-final.yaml
54 | sed -i 's;${IMAGE_JAEGER_AGENT};'${IMAGE_JAEGER_AGENT}';g' jaeger-services-final.yaml
55 | sed -i 's;${IMAGE_JAEGER_COLLECTOR};'${IMAGE_JAEGER_COLLECTOR}';g' jaeger-services-final.yaml
56 | sed -i 's;${IMAGE_JAEGER_QUERY};'${IMAGE_JAEGER_QUERY}';g' jaeger-services-final.yaml
57 | sed -i 's;${IMAGE_JAEGER_ES_INDEX_CLEANER};'${IMAGE_JAEGER_ES_INDEX_CLEANER}';g' jaeger-services-final.yaml
58 | sed -i 's;${LOG_LEVEL_JAEGER_AGENT};'${LOG_LEVEL_JAEGER_AGENT}';g' jaeger-services-final.yaml
59 | sed -i 's;${LOG_LEVEL_JAEGER_COLLECTOR};'${LOG_LEVEL_JAEGER_COLLECTOR}';g' jaeger-services-final.yaml
60 | sed -i 's;${LOG_LEVEL_JAEGER_QUERY};'${LOG_LEVEL_JAEGER_QUERY}';g' jaeger-services-final.yaml
61 | sed -i 's;${RESO_LMT_AGENT_CPU};'${RESO_LMT_AGENT_CPU}';g' jaeger-services-final.yaml
62 | sed -i 's;${RESO_LMT_AGENT_MEM};'${RESO_LMT_AGENT_MEM}';g' jaeger-services-final.yaml
63 | sed -i 's;${RESO_LMT_COLLECTOR_CPU};'${RESO_LMT_COLLECTOR_CPU}';g' jaeger-services-final.yaml
64 | sed -i 's;${RESO_LMT_COLLECTOR_MEM};'${RESO_LMT_COLLECTOR_MEM}';g' jaeger-services-final.yaml
65 | sed -i 's;${RESO_LMT_QUERY_CPU};'${RESO_LMT_QUERY_CPU}';g' jaeger-services-final.yaml
66 | sed -i 's;${RESO_LMT_QUERY_MEM};'${RESO_LMT_QUERY_MEM}';g' jaeger-services-final.yaml
67 | sed -i 's;${JAEGER_AGENT_QUEUE_SIZE};'${JAEGER_AGENT_QUEUE_SIZE}';g' jaeger-services-final.yaml
68 | sed -i 's;${JAEGER_AGENT_WORKERS};'${JAEGER_AGENT_WORKERS}';g' jaeger-services-final.yaml
69 |
70 |
71 | if [ ${#QUERY_STATIC_FILES} -gt 0 ]
72 | then
73 | sed -i 's;${QUERY_STATIC_FILES};'${QUERY_STATIC_FILES}';g' jaeger-services-final.yaml
74 | else
75 | sed -i '/${QUERY_STATIC_FILES}/d' jaeger-services-final.yaml
76 | fi
77 |
78 | # update jaeger images
79 | sed -i 's;jaegertracing/jaeger-agent.*;'${IMAGE_JAEGER_AGENT}';g' jaeger-services-final.yaml
80 | sed -i 's;jaegertracing/jaeger-collector.*;'${IMAGE_JAEGER_COLLECTOR}';g' jaeger-services-final.yaml
81 | sed -i 's;jaegertracing/jaeger-query.*;'${IMAGE_JAEGER_QUERY}';g' jaeger-services-final.yaml
82 |
83 | # delete old deployments
84 | oc delete -f jaeger-services-final.yaml -n ${OS_NAMESPACE}
85 |
86 | # sleep for a while
87 | sleep 20
88 |
89 | # deploy jaeger services
90 | oc create -f jaeger-services-final.yaml -n ${OS_NAMESPACE}
91 |
92 | # wait for jaeger collector service to come up
93 | ./openshift/scripts/wait_for_service.sh ${OS_NAMESPACE} ${JAEGER_SERVICE_NAME}-collector 60
94 | # ./openshift/scripts/wait_for_pods_status.sh ${OS_NAMESPACE} "app.kubernetes.io/name=${JAEGER_SERVICE_NAME}-collector" "Running" 60
95 |
96 | # move jaeger services template file to logs directory
97 | mkdir -p logs
98 | mv jaeger-services-final.yaml logs/
99 |
100 |
101 | # There is a blocking issue with jaeger operator
102 | # For now as a workaround we have to remove jaeger operator service,
103 | # once we deployed jaeger services.
104 | # ISSUE: https://github.com/jaegertracing/jaeger-operator/issues/307
105 | # https://github.com/jaegertracing/jaeger-operator/issues/334
106 | # TODO: once this issue fixed, remove this workaround.
107 | #if [ -f "./logs/operator.yaml" ]; then
108 | # echo "WARN: Running workaround for the jaeger operator issue"
109 | # echo "GitHub issue: https://github.com/jaegertracing/jaeger-operator/issues/307"
110 | # echo "Jaeger Operator will be deleted now!"
111 | # # give some time to deploy jaeger services
112 | # sleep 20
113 | # oc delete -f ./logs/operator.yaml -n observability
114 | # # wait for a while
115 | # sleep 30
116 | #fi
--------------------------------------------------------------------------------
/openshift/scripts/oc_login.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # checks mandatory fields and do login
18 |
19 | if [ -z "${OS_URL}" ]; then
20 | echo "Field OS_URL is missing!"
21 | exit 1
22 | fi
23 |
24 | if [ -z "${OS_USERNAME}" ]; then
25 | echo "Field OS_USERNAME is missing!"
26 | exit 1
27 | fi
28 |
29 | if [ -z "${OS_PASSWORD}" ]; then
30 | echo "Field OS_PASSWORD is missing!"
31 | exit 1
32 | fi
33 |
34 | if [ -z "${OS_NAMESPACE}" ]; then
35 | echo "Field OS_NAMESPACE is missing!"
36 | exit 1
37 | fi
38 |
39 | # do oc login for further actions
40 | oc login ${OS_URL} --username=${OS_USERNAME} --password=${OS_PASSWORD} -n ${OS_NAMESPACE} --insecure-skip-tls-verify=true
41 |
--------------------------------------------------------------------------------
/openshift/scripts/run_performance_test.sh:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | set -x
16 |
17 | # download config map from master branch
18 | cp openshift/templates/performance-test.yaml performance-test.yaml
19 |
20 | # update tchannel, grpc port. http:14268, tchannel:14267, grpc:14250
21 | if [ ${REPORTER_TYPE} == 'grpc' ]; then
22 | export JAEGER_COLLECTOR_PORT_POD="14250"
23 | export JCH_PREFIX="dns:///" # Jaeger collector host prefix
24 | else
25 | export JAEGER_COLLECTOR_PORT_POD="14267"
26 | export JCH_PREFIX=""
27 | fi
28 |
29 | # update references
30 | RUNNING_ON_OPENSHIFT=true
31 | LOGS_DIRECTORY=${PWD}/logs
32 | JAEGER_AGENT_HOST="localhost"
33 | JAEGER_AGENT_PORT=6831
34 | JAEGER_COLLECTOR_HOST=${JAEGER_SERVICE_NAME}-collector
35 | JAEGER_COLLECTOR_PORT=14268
36 | JAEGER_QUERY_HOST=${JAEGER_SERVICE_NAME}-query
37 | JAEGER_QUERY_PORT=16686
38 |
39 | # update environment variables
40 | sed -i 's;${JOB_REFERENCE};'${JOB_REFERENCE}';g' performance-test.yaml
41 | sed -i 's;${JAEGER_SERVICE_NAME};'${JAEGER_SERVICE_NAME}';g' performance-test.yaml
42 | sed -i 's;${OS_URL};'${OS_URL}';g' performance-test.yaml
43 | sed -i 's;${OS_USERNAME};'${OS_USERNAME}';g' performance-test.yaml
44 | sed -i 's;${OS_NAMESPACE};'${OS_NAMESPACE}';g' performance-test.yaml
45 | sed -i 's;${TESTS_TO_RUN};'${TESTS_TO_RUN}';g' performance-test.yaml
46 | sed -i 's;${ELASTICSEARCH_PROVIDER};'${ELASTICSEARCH_PROVIDER}';g' performance-test.yaml
47 | sed -i 's;${STORAGE_HOST};'${STORAGE_HOST}';g' performance-test.yaml
48 | sed -i 's;${STORAGE_PORT};'${STORAGE_PORT}';g' performance-test.yaml
49 | sed -i 's;${PRE_INSTALL_JAEGER_OPERATOR};'${PRE_INSTALL_JAEGER_OPERATOR}';g' performance-test.yaml
50 | sed -i 's;${PRE_INSTALL_JAEGER_SERVICES};'${PRE_INSTALL_JAEGER_SERVICES}';g' performance-test.yaml
51 | sed -i 's;${PRE_INSTALL_REPORTER_NODES};'${PRE_INSTALL_REPORTER_NODES}';g' performance-test.yaml
52 | sed -i 's;${REPORTER_NODE_REPLICA_COUNT};'${REPORTER_NODE_REPLICA_COUNT}';g' performance-test.yaml
53 | sed -i 's;${REPORTER_REFERENCE};'${REPORTER_REFERENCE}';g' performance-test.yaml
54 | sed -i 's;${POST_DELETE_JAEGER_SERVICES};'${POST_DELETE_JAEGER_SERVICES}';g' performance-test.yaml
55 | sed -i 's;${POST_DELETE_TEST_JOBS};'${POST_DELETE_TEST_JOBS}';g' performance-test.yaml
56 | sed -i 's;${POST_DELETE_REPORTER_NODES};'${POST_DELETE_REPORTER_NODES}';g' performance-test.yaml
57 | sed -i 's;${TEST_HA_SETUP};'${TEST_HA_SETUP}';g' performance-test.yaml
58 | sed -i 's;${JAEGERQE_CONTROLLER_URL};'${JAEGERQE_CONTROLLER_URL}';g' performance-test.yaml
59 | sed -i 's;${REPORT_ENGINE_URL};'${REPORT_ENGINE_URL}';g' performance-test.yaml
60 | sed -i 's;${REPORT_ENGINE_LABELS};'${REPORT_ENGINE_LABELS}';g' performance-test.yaml
61 | sed -i 's;${REPORT_ENGINE_AGENT_REFERENCE};'${REPORT_ENGINE_AGENT_REFERENCE}';g' performance-test.yaml
62 | sed -i 's;${IMAGE_PERFORMANCE_TEST};'${IMAGE_PERFORMANCE_TEST}';g' performance-test.yaml
63 | sed -i 's;${IMAGE_ELASTICSEARCH_OPERATOR};'${IMAGE_ELASTICSEARCH_OPERATOR}';g' performance-test.yaml
64 | sed -i 's;${IMAGE_ELASTICSEARCH};'${IMAGE_ELASTICSEARCH}';g' performance-test.yaml
65 | sed -i 's;${IMAGE_JAEGER_OPERATOR};'${IMAGE_JAEGER_OPERATOR}';g' performance-test.yaml
66 | sed -i 's;${IMAGE_JAEGER_ALL_IN_ONE};'${IMAGE_JAEGER_ALL_IN_ONE}';g' performance-test.yaml
67 | sed -i 's;${IMAGE_JAEGER_AGENT};'${IMAGE_JAEGER_AGENT}';g' performance-test.yaml
68 | sed -i 's;${IMAGE_JAEGER_COLLECTOR};'${IMAGE_JAEGER_COLLECTOR}';g' performance-test.yaml
69 | sed -i 's;${IMAGE_JAEGER_QUERY};'${IMAGE_JAEGER_QUERY}';g' performance-test.yaml
70 | sed -i 's;${IMAGE_JAEGER_ES_INDEX_CLEANER};'${IMAGE_JAEGER_ES_INDEX_CLEANER}';g' performance-test.yaml
71 | sed -i 's;${USE_INTERNAL_REPORTER};'${USE_INTERNAL_REPORTER}';g' performance-test.yaml
72 | sed -i 's;${NODE_COUNT_SPANS_REPORTER};'${NODE_COUNT_SPANS_REPORTER}';g' performance-test.yaml
73 | sed -i 's;${NODE_COUNT_QUERY_RUNNER};'${NODE_COUNT_QUERY_RUNNER}';g' performance-test.yaml
74 | sed -i 's;${MSG_BROKER_HOST};'${MSG_BROKER_HOST}';g' performance-test.yaml
75 | sed -i 's;${MSG_BROKER_PORT};'${MSG_BROKER_PORT}';g' performance-test.yaml
76 | sed -i 's;${MSG_BROKER_USER};'${MSG_BROKER_USER}';g' performance-test.yaml
77 | sed -i 's;${NUMBER_OF_TRACERS};'${NUMBER_OF_TRACERS}';g' performance-test.yaml
78 | sed -i 's;${NUMBER_OF_SPANS};'${NUMBER_OF_SPANS}';g' performance-test.yaml
79 | sed -i 's;${REPORT_SPANS_DURATION};'${REPORT_SPANS_DURATION}';g' performance-test.yaml
80 | sed -i 's;${SPANS_COUNT_FROM};'${SPANS_COUNT_FROM}';g' performance-test.yaml
81 | sed -i 's;${QUERY_LIMIT};'${QUERY_LIMIT}';g' performance-test.yaml
82 | sed -i 's;${QUERY_SAMPLES};'${QUERY_SAMPLES}';g' performance-test.yaml
83 | sed -i 's;${QUERY_INTERVAL};'${QUERY_INTERVAL}';g' performance-test.yaml
84 | sed -i 's;${SENDER};'${SENDER}';g' performance-test.yaml
85 | sed -i 's;${REPORTER_TYPE};'${REPORTER_TYPE}';g' performance-test.yaml
86 | sed -i 's;${METRICS_BACKEND};'${METRICS_BACKEND}';g' performance-test.yaml
87 | sed -i 's;${RESOURCE_MONITOR_ENABLED};'${RESOURCE_MONITOR_ENABLED}';g' performance-test.yaml
88 | sed -i 's;${JAEGER_AGENT_QUEUE_SIZE};'${JAEGER_AGENT_QUEUE_SIZE}';g' performance-test.yaml
89 | sed -i 's;${JAEGER_AGENT_WORKERS};'${JAEGER_AGENT_WORKERS}';g' performance-test.yaml
90 | sed -i 's;${JAEGER_CLIENT_FLUSH_INTERVAL};'${JAEGER_CLIENT_FLUSH_INTERVAL}';g' performance-test.yaml
91 | sed -i 's;${JAEGER_CLIENT_MAX_POCKET_SIZE};'${JAEGER_CLIENT_MAX_POCKET_SIZE}';g' performance-test.yaml
92 | sed -i 's;${JAEGER_CLIENT_MAX_QUEUE_SIZE};'${JAEGER_CLIENT_MAX_QUEUE_SIZE}';g' performance-test.yaml
93 | sed -i 's;${COLLECTOR_REPLICA_COUNT};'${COLLECTOR_REPLICA_COUNT}';g' performance-test.yaml
94 | sed -i 's;${COLLECTOR_QUEUE_SIZE};'${COLLECTOR_QUEUE_SIZE}';g' performance-test.yaml
95 | sed -i 's;${COLLECTOR_NUM_WORKERS};'${COLLECTOR_NUM_WORKERS}';g' performance-test.yaml
96 | sed -i 's;${COLLECTOR_ES_BULK_SIZE};'${COLLECTOR_ES_BULK_SIZE}';g' performance-test.yaml
97 | sed -i 's;${COLLECTOR_ES_BULK_WORKERS};'${COLLECTOR_ES_BULK_WORKERS}';g' performance-test.yaml
98 | sed -i 's;${COLLECTOR_ES_BULK_FLUSH_INTERVAL};'${COLLECTOR_ES_BULK_FLUSH_INTERVAL}';g' performance-test.yaml
99 | sed -i 's;${COLLECTOR_ES_TAGS_AS_FIELDS};'${COLLECTOR_ES_TAGS_AS_FIELDS}';g' performance-test.yaml
100 | sed -i 's;${JAEGER_QUERY_STATIC_FILES};'${JAEGER_QUERY_STATIC_FILES}';g' performance-test.yaml
101 | sed -i 's;${ES_MEMORY};'${ES_MEMORY}';g' performance-test.yaml
102 | sed -i 's;${LOG_LEVEL_JAEGER_AGENT};'${LOG_LEVEL_JAEGER_AGENT}';g' performance-test.yaml
103 | sed -i 's;${LOG_LEVEL_JAEGER_COLLECTOR};'${LOG_LEVEL_JAEGER_COLLECTOR}';g' performance-test.yaml
104 | sed -i 's;${LOG_LEVEL_JAEGER_OPERATOR};'${LOG_LEVEL_JAEGER_OPERATOR}';g' performance-test.yaml
105 | sed -i 's;${LOG_LEVEL_JAEGER_QUERY};'${LOG_LEVEL_JAEGER_QUERY}';g' performance-test.yaml
106 | sed -i 's;${RUNNING_ON_OPENSHIFT};'${RUNNING_ON_OPENSHIFT}';g' performance-test.yaml
107 | sed -i 's;${LOGS_DIRECTORY};'${LOGS_DIRECTORY}';g' performance-test.yaml
108 | sed -i 's;${JAEGER_AGENT_HOST};'${JAEGER_AGENT_HOST}';g' performance-test.yaml
109 | sed -i 's;${JAEGER_AGENT_PORT};'${JAEGER_AGENT_PORT}';g' performance-test.yaml
110 | sed -i 's;${JAEGER_AGENT_COLLECTOR_PORT};'${JAEGER_COLLECTOR_PORT_POD}';g' performance-test.yaml
111 | sed -i 's;${JAEGER_COLLECTOR_HOST_PREFIX};'${JCH_PREFIX}';g' performance-test.yaml
112 | sed -i 's;${JAEGER_COLLECTOR_HOST};'${JAEGER_COLLECTOR_HOST}';g' performance-test.yaml
113 | sed -i 's;${JAEGER_COLLECTOR_PORT};'${JAEGER_COLLECTOR_PORT}';g' performance-test.yaml
114 | sed -i 's;${JAEGER_QUERY_HOST};'${JAEGER_QUERY_HOST}';g' performance-test.yaml
115 | sed -i 's;${JAEGER_QUERY_PORT};'${JAEGER_QUERY_PORT}';g' performance-test.yaml
116 | sed -i 's;${RESO_LMT_AGENT_CPU};'${RESO_LMT_AGENT_CPU}';g' performance-test.yaml
117 | sed -i 's;${RESO_LMT_AGENT_MEM};'${RESO_LMT_AGENT_MEM}';g' performance-test.yaml
118 | sed -i 's;${RESO_LMT_COLLECTOR_CPU};'${RESO_LMT_COLLECTOR_CPU}';g' performance-test.yaml
119 | sed -i 's;${RESO_LMT_COLLECTOR_MEM};'${RESO_LMT_COLLECTOR_MEM}';g' performance-test.yaml
120 | sed -i 's;${RESO_LMT_QUERY_CPU};'${RESO_LMT_QUERY_CPU}';g' performance-test.yaml
121 | sed -i 's;${RESO_LMT_QUERY_MEM};'${RESO_LMT_QUERY_MEM}';g' performance-test.yaml
122 |
123 | # deploy jaeger performance test
124 | oc create -n ${OS_NAMESPACE} -f performance-test.yaml
125 |
126 | # move configmap file to logs directory
127 | mkdir -p logs
128 | mv performance-test.yaml logs/
--------------------------------------------------------------------------------
/openshift/scripts/wait_for_performance_run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018-2019 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # pass following arguments in the same order,
18 | # NAMESPACE POD_FILTER MAX_WAIT_TIME
19 |
20 | # this script keep on monitoring performance test pod status
21 | # exit if the performence completes [or] loop terminates on MAX_WAIT_TIME
22 |
23 | # update namespace name
24 | OS_NAMESPACE=$1
25 | # update pod filters. ie: app=jaeger-performance-test-job
26 | POD_FILTER=$2
27 | # update maximum wait time in seconds, ie: 10
28 | MAX_WAIT_TIME=$3 # in seconds
29 |
30 | # starting timestamp
31 | TIMESTAMP_START=$(date +%s)
32 |
33 | # convert maximum wait time to maximum timstamp
34 | MAX_TIMESTAMP=`expr ${TIMESTAMP_START} + ${MAX_WAIT_TIME}`
35 |
36 | while [ $(date +%s) -lt ${MAX_TIMESTAMP} ]
37 | do
38 | # read pod status from OpenShift
39 | POD_STATUS=`oc get pods -n ${OS_NAMESPACE} -l ${POD_FILTER} -o jsonpath="{.items[*].status.containerStatuses[*].state.terminated.reason}"`
40 | if [ -z "${POD_STATUS}" ]; then
41 | sleep 5
42 | else
43 | echo "INFO: Performencae test pod status: ${POD_STATUS}"
44 | echo "INFO: Overall time taken: `expr $(date +%s) - ${TIMESTAMP_START}` seconds."
45 | break
46 | fi
47 | done
48 |
49 | # display pods details
50 | echo "INFO: Pods detail: ${POD_STATUS}"
51 |
52 | # check we reached maximum timeout [or] completed in time.
53 | if [ ${POD_STATUS} == "" ]; then
54 | echo "WARNING: Reached maximum wait time and still performance test not completed"
55 | fi
56 |
--------------------------------------------------------------------------------
/openshift/scripts/wait_for_pods_status.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # pass following arguments in the same order,
18 | # NAMESPACE POD_FILTER WAIT_FOR_STATUS MAX_WAIT_TIME
19 |
20 | # this script keep on monitoring pod status
21 | # exit if there is no pods in WAIT_FOR_STATUS status [or] loop terminates on MAX_WAIT_TIME
22 |
23 | # update namespace name
24 | OS_NAMESPACE=$1
25 | # update pod filters. ie: app=jaeger-performance-test-job
26 | POD_FILTER=$2
27 | # update wait for a pod state, ie: Running
28 | WAIT_FOR_STATUS=$3
29 | # update maximum wait time in seconds, ie: 10
30 | MAX_WAIT_TIME=$4 # in seconds
31 |
32 | # starting timestamp
33 | TIMESTAMP_START=$(date +%s)
34 |
35 | # convert maximum wait time to maximum timstamp
36 | MAX_TIMESTAMP=`expr ${TIMESTAMP_START} + ${MAX_WAIT_TIME}`
37 |
38 | while [ $(date +%s) -lt ${MAX_TIMESTAMP} ]
39 | do
40 | # read pod status from OpenShift
41 | FINAL_STATUS="-"
42 | POD_STATUS=`oc get pods -n ${OS_NAMESPACE} --no-headers -l ${POD_FILTER} | awk '{print $1 "=" $3}'`
43 | NUMBER_OF_PODS=`echo ${POD_STATUS} | wc -w`
44 | PODS=$(echo ${POD_STATUS} | tr " " "\n")
45 | for _pod in ${PODS}
46 | do
47 | _status=(${_pod//=/ })
48 | if [ ${_status[1]} == ${WAIT_FOR_STATUS} ] || [ ${_status[1]} == 'ContainerCreating' ] || [ ${_status[1]} == 'Pending' ]; then
49 | FINAL_STATUS=${_status[1]}
50 | fi
51 | done
52 | if [ ${FINAL_STATUS} != ${WAIT_FOR_STATUS} ] && [ ${FINAL_STATUS} != 'ContainerCreating' ] || [ ${_status[1]} == 'Pending' ];then
53 | echo "INFO: There is no pods in '${WAIT_FOR_STATUS}' or 'ContainerCreating' or 'Pending' state."
54 | echo "INFO: Overall time taken: `expr $(date +%s) - ${TIMESTAMP_START}` seconds, Number of pod(s): ${NUMBER_OF_PODS}"
55 | break
56 | else
57 | sleep 5
58 | fi
59 | done
60 |
61 | # display pods details
62 | echo "INFO: Pods detail: ${POD_STATUS}"
63 |
64 | # check we reached maximum timeout [or] completed in time.
65 | if [ ${FINAL_STATUS} == ${WAIT_FOR_STATUS} ]; then
66 | echo "WARNING: Reached maximum wait time and still some of pod(s) are in '${WAIT_FOR_STATUS}' state."
67 | fi
68 |
--------------------------------------------------------------------------------
/openshift/scripts/wait_for_pods_status_with_ha.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 | # Executes HA setup tests. Kills ES pods and collector pods
17 |
18 | # pass following arguments in the same order,
19 | # NAMESPACE POD_FILTER WAIT_FOR_STATUS MAX_WAIT_TIME
20 |
21 | # this script keep on monitoring pod status
22 | # exit if there is no pods in WAIT_FOR_STATUS status [or] loop terminates on MAX_WAIT_TIME
23 |
24 | # update namespace name
25 | OS_NAMESPACE=$1
26 | # update pod filters. ie: app=jaeger-performance-test-job
27 | POD_FILTER=$2
28 | # update wait for a pod state, ie: Running
29 | WAIT_FOR_STATUS=$3
30 | # update maximum wait time in seconds, ie: 10
31 | MAX_WAIT_TIME=$4 # in seconds
32 |
33 | # starting timestamp
34 | TIMESTAMP_START=$(date +%s)
35 |
36 | # convert maximum wait time to maximum timstamp
37 | MAX_TIMESTAMP=`expr ${TIMESTAMP_START} + ${MAX_WAIT_TIME}`
38 |
39 | # ES pod kill timestamp
40 | POD_KILL_TS_ES=`expr ${TIMESTAMP_START} + 30`
41 |
42 | # Collector pod kill timestamp
43 | POD_KILL_TS_COLLECTOR=`expr ${TIMESTAMP_START} + 60`
44 |
45 | POD_KILL_STATUS_ES=true
46 | POD_KILL_STATUS_COLLECTOR=true
47 |
48 | while [ $(date +%s) -lt ${MAX_TIMESTAMP} ]
49 | do
50 | # read pod status from OpenShift
51 | FINAL_STATUS="-"
52 | POD_STATUS=`oc get pods -n ${OS_NAMESPACE} --no-headers -l ${POD_FILTER} | awk '{print $1 "=" $3}'`
53 | NUMBER_OF_PODS=`echo ${POD_STATUS} | wc -w`
54 | PODS=$(echo ${POD_STATUS} | tr " " "\n")
55 | for _pod in ${PODS}
56 | do
57 | _status=(${_pod//=/ })
58 | if [ ${_status[1]} == ${WAIT_FOR_STATUS} ] || [ ${_status[1]} == 'ContainerCreating' ] || [ ${_status[1]} == 'Pending' ]; then
59 | FINAL_STATUS=${_status[1]}
60 | fi
61 | done
62 | if [ ${FINAL_STATUS} != ${WAIT_FOR_STATUS} ] && [ ${FINAL_STATUS} != 'ContainerCreating' ] || [ ${_status[1]} == 'Pending' ];then
63 | echo "INFO: There is no pods in '${WAIT_FOR_STATUS}' or 'ContainerCreating' or 'Pending' state."
64 | echo "INFO: Overall time taken: `expr $(date +%s) - ${TIMESTAMP_START}` seconds, Number of pod(s): ${NUMBER_OF_PODS}"
65 | break
66 | else
67 | # terminate ES pod
68 | if [ $(date +%s) -gt ${POD_KILL_TS_ES} ] && ${POD_KILL_STATUS_ES};then
69 | echo "Terminating ES pod..."
70 | POD_KILL_STATUS_ES=false
71 | _ES_POD=`oc get pods -n ${OS_NAMESPACE} --no-headers -l app=elasticsearch | awk '{print $1}' | tail -n1`
72 | oc delete pod ${_ES_POD} -n ${OS_NAMESPACE}
73 | oc get pods -n ${OS_NAMESPACE} --no-headers -l app=elasticsearch
74 | echo "ES pod termination done."
75 | fi
76 | # terminate collector pod
77 | if [ $(date +%s) -gt ${POD_KILL_TS_COLLECTOR} ] && ${POD_KILL_STATUS_COLLECTOR};then
78 | echo "Terminating Collector pod..."
79 | POD_KILL_STATUS_COLLECTOR=false
80 | _COLLECTOR_POD=`oc get pods -n ${OS_NAMESPACE} --no-headers -l jaeger-infra=collector-pod | awk '{print $1}' | tail -n1`
81 | oc delete pod ${_COLLECTOR_POD} -n ${OS_NAMESPACE}
82 | oc get pods -n ${OS_NAMESPACE} --no-headers -l jaeger-infra=collector-pod
83 | echo "Collector pod termination done."
84 | fi
85 | sleep 5
86 | fi
87 | done
88 |
89 | # display pods details
90 | echo "INFO: Pods detail: ${POD_STATUS}"
91 |
92 | # check we reached maximum timeout [or] completed in time.
93 | if [ ${FINAL_STATUS} == ${WAIT_FOR_STATUS} ]; then
94 | echo "WARNING: Reached maximum wait time and still some of pod(s) are in '${WAIT_FOR_STATUS}' state."
95 | fi
96 |
--------------------------------------------------------------------------------
/openshift/scripts/wait_for_project.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018-2019 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # pass following arguments in the same order,
18 | # NAMESPACE ACTION MAX_WAIT_TIME
19 |
20 | # this script delete or create and keep on monitoring project status, until it gets deleted or created
21 |
22 | # update namespace name
23 | NAMESPACE=$1
24 |
25 | # delete or create?
26 | ACTION=$2
27 |
28 | # update maximum wait time in seconds, ie: 10
29 | MAX_WAIT_TIME=$3 # in seconds
30 |
31 | # starting timestamp
32 | TIMESTAMP_START=$(date +%s)
33 |
34 | # convert maximum wait time to maximum timstamp
35 | MAX_TIMESTAMP=`expr ${TIMESTAMP_START} + ${MAX_WAIT_TIME}`
36 |
37 | # run the specified action
38 | if [ ${ACTION} == 'delete' ]; then
39 | oc delete project ${NAMESPACE}
40 | elif [ ${ACTION} == 'create' ]; then
41 | oc new-project ${NAMESPACE}
42 | else
43 | echo "WARN: Unkown action[${ACTION}] specified!"
44 | # TODO: return from here
45 | fi
46 |
47 | ACTION_STATUS=""
48 |
49 | while [ $(date +%s) -lt ${MAX_TIMESTAMP} ]
50 | do
51 | NAMESPACES=$(oc get namespaces -o=jsonpath='{.items[*].metadata.name}')
52 | if [ ${ACTION} == 'delete' ]; then
53 | if [ "${NAMESPACES/$NAMESPACE}" == "$NAMESPACES" ]; then
54 | ACTION_STATUS="done"
55 | break
56 | fi
57 | elif [ ${ACTION} == 'create' ]; then
58 | if [ "${NAMESPACES/$NAMESPACE}" != "$NAMESPACES" ]; then
59 | ACTION_STATUS="done"
60 | break
61 | fi
62 | else
63 | echo "WARN: Unkown action[${ACTION}] specified!"
64 | break
65 | fi
66 | # sleep for a while
67 | sleep 5
68 | ACTION_STATUS="max"
69 | done
70 |
71 | # check we reached maximum timeout [or] completed in time.
72 | if [ ${ACTION_STATUS} == "max" ]; then
73 | echo "WARNING: Reached maximum wait time! Namespace: ${NAMESPACE}, Action: ${ACTION}"
74 | fi
75 |
--------------------------------------------------------------------------------
/openshift/scripts/wait_for_service.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2018 The Jaeger Authors
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | # in compliance with the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software distributed under the License
11 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | # or implied. See the License for the specific language governing permissions and limitations under
13 | # the License.
14 | #
15 |
16 |
17 | # pass following arguments in the same order,
18 | # NAMESPACE SERVICE_NAME MAX_WAIT_TIME
19 |
20 | # wait for a service
21 |
22 | # update namespace name
23 | OS_NAMESPACE=$1
24 |
25 | # service name
26 | SERVICE_NAME=$2
27 |
28 | # update maximum wait time in seconds, ie: 10
29 | MAX_WAIT_TIME=$3 # in seconds
30 |
31 | # starting timestamp
32 | TIMESTAMP_START=$(date +%s)
33 |
34 | # convert maximum wait time to maximum timstamp
35 | MAX_TIMESTAMP=`expr ${TIMESTAMP_START} + ${MAX_WAIT_TIME}`
36 |
37 | FINAL_STATUS="false"
38 |
39 | while [ $(date +%s) -lt ${MAX_TIMESTAMP} ]
40 | do
41 | # read service status from OpenShift
42 | if SERVICE_STATUS=$(oc get service ${SERVICE_NAME} -n ${OS_NAMESPACE} --no-headers 2>&1); then
43 | echo "INFO: ${SERVICE_STATUS}"
44 | echo "INFO: Overall time taken: `expr $(date +%s) - ${TIMESTAMP_START}` seconds"
45 | FINAL_STATUS="true"
46 | break
47 | else
48 | sleep 2
49 | fi
50 | done
51 |
52 | if [ "false" == ${FINAL_STATUS} ];then
53 | echo "WARNING: Reached maximum wait time and still service not up! status: ${SERVICE_STATUS}"
54 | fi
55 |
--------------------------------------------------------------------------------
/openshift/templates/jaeger-services-all-in-one.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | apiVersion: jaegertracing.io/v1
16 | kind: Jaeger
17 | metadata:
18 | name: ${JAEGER_SERVICE_NAME}
19 | spec:
20 | ingress:
21 | security: none
22 | strategy: allInOne
23 | allInOne:
24 | image: ${IMAGE_JAEGER_ALL_IN_ONE}
25 | options:
26 | log-level: ${LOG_LEVEL_JAEGER_COLLECTOR}
27 | metrics-backend: ${METRICS_BACKEND}
28 | collector:
29 | num-workers: ${COLLECTOR_NUM_WORKERS}
30 | queue-size: ${COLLECTOR_QUEUE_SIZE}
31 | query:
32 | port: 16686
33 | static-files: ${QUERY_STATIC_FILES}
34 | processor:
35 | jaeger-compact:
36 | server-queue-size: ${JAEGER_AGENT_QUEUE_SIZE}
37 | workers: ${JAEGER_AGENT_WORKERS}
38 | storage:
39 | options:
40 | memory:
41 | max-traces: 300000
--------------------------------------------------------------------------------
/openshift/templates/jaeger-services-deploy-es.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2020 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | apiVersion: jaegertracing.io/v1
16 | kind: Jaeger
17 | metadata:
18 | name: ${JAEGER_SERVICE_NAME}
19 | spec:
20 | ingress:
21 | security: none
22 | strategy: production
23 | collector:
24 | replicas: ${COLLECTOR_REPLICA_COUNT}
25 | image: ${IMAGE_JAEGER_COLLECTOR}
26 | resources:
27 | requests:
28 | memory: "${RESO_LMT_COLLECTOR_MEM}"
29 | cpu: "${RESO_LMT_COLLECTOR_CPU}"
30 | limits:
31 | memory: "${RESO_LMT_COLLECTOR_MEM}"
32 | cpu: "${RESO_LMT_COLLECTOR_CPU}"
33 | options:
34 | log-level: ${LOG_LEVEL_JAEGER_COLLECTOR}
35 | metrics-backend: ${METRICS_BACKEND}
36 | collector:
37 | num-workers: ${COLLECTOR_NUM_WORKERS}
38 | queue-size: ${COLLECTOR_QUEUE_SIZE}
39 | es:
40 | bulk:
41 | size: ${COLLECTOR_ES_BULK_SIZE}
42 | workers: ${COLLECTOR_ES_BULK_WORKERS}
43 | flush-interval: ${COLLECTOR_ES_BULK_FLUSH_INTERVAL}
44 | tags-as-fields:
45 | all: ${COLLECTOR_ES_TAGS_AS_FIELDS}
46 | query:
47 | replicas: 1
48 | image: ${IMAGE_JAEGER_QUERY}
49 | resources:
50 | requests:
51 | cpu: "${RESO_LMT_QUERY_CPU}"
52 | memory: "${RESO_LMT_QUERY_MEM}"
53 | limits:
54 | cpu: "${RESO_LMT_QUERY_CPU}"
55 | memory: "${RESO_LMT_QUERY_MEM}"
56 | options:
57 | log-level: ${LOG_LEVEL_JAEGER_QUERY}
58 | metrics-backend: ${METRICS_BACKEND}
59 | query:
60 | port: 16686
61 | static-files: ${QUERY_STATIC_FILES}
62 | es:
63 | timeout: 10s
64 | agent:
65 | strategy: sidecar
66 | image: ${IMAGE_JAEGER_AGENT}
67 | resources:
68 | requests:
69 | cpu: "${RESO_LMT_AGENT_CPU}"
70 | memory: "${RESO_LMT_AGENT_MEM}"
71 | limits:
72 | cpu: "${RESO_LMT_AGENT_CPU}"
73 | memory: "${RESO_LMT_AGENT_MEM}"
74 | options:
75 | log-level: ${LOG_LEVEL_JAEGER_AGENT}
76 | metrics-backend: ${METRICS_BACKEND}
77 | processor:
78 | jaeger-compact:
79 | server-queue-size: ${JAEGER_AGENT_QUEUE_SIZE}
80 | workers: ${JAEGER_AGENT_WORKERS}
81 | storage:
82 | type: elasticsearch
83 | esIndexCleaner:
84 | enabled: false
85 | image: ${IMAGE_JAEGER_ES_INDEX_CLEANER}
86 | schedule: "*/3 * * * *"
87 | dependencies:
88 | enabled: false
89 | elasticsearch:
90 | image: ${IMAGE_ELASTICSEARCH}
91 | nodeCount: 3
92 | resources:
93 | limits:
94 | memory: 1Gi
95 | requests:
96 | memory: 1Gi
97 |
--------------------------------------------------------------------------------
/openshift/templates/jaeger-services-es-url.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | apiVersion: jaegertracing.io/v1
16 | kind: Jaeger
17 | metadata:
18 | name: ${JAEGER_SERVICE_NAME}
19 | spec:
20 | ingress:
21 | security: none
22 | strategy: production
23 | collector:
24 | replicas: ${COLLECTOR_REPLICA_COUNT}
25 | image: ${IMAGE_JAEGER_COLLECTOR}
26 | resources:
27 | requests:
28 | cpu: "${RESO_LMT_COLLECTOR_CPU}"
29 | memory: "${RESO_LMT_COLLECTOR_MEM}"
30 | limits:
31 | cpu: "${RESO_LMT_COLLECTOR_CPU}"
32 | memory: "${RESO_LMT_COLLECTOR_MEM}"
33 | options:
34 | log-level: ${LOG_LEVEL_JAEGER_COLLECTOR}
35 | metrics-backend: ${METRICS_BACKEND}
36 | collector:
37 | num-workers: ${COLLECTOR_NUM_WORKERS}
38 | queue-size: ${COLLECTOR_QUEUE_SIZE}
39 | es:
40 | bulk:
41 | size: ${COLLECTOR_ES_BULK_SIZE}
42 | workers: ${COLLECTOR_ES_BULK_WORKERS}
43 | flush-interval: ${COLLECTOR_ES_BULK_FLUSH_INTERVAL}
44 | tags-as-fields:
45 | all: ${COLLECTOR_ES_TAGS_AS_FIELDS}
46 | query:
47 | replicas: 1
48 | image: ${IMAGE_JAEGER_QUERY}
49 | resources:
50 | requests:
51 | cpu: "${RESO_LMT_QUERY_CPU}"
52 | memory: "${RESO_LMT_QUERY_MEM}"
53 | limits:
54 | cpu: "${RESO_LMT_QUERY_CPU}"
55 | memory: "${RESO_LMT_QUERY_MEM}"
56 | options:
57 | log-level: ${LOG_LEVEL_JAEGER_QUERY}
58 | metrics-backend: ${METRICS_BACKEND}
59 | query:
60 | port: 16686
61 | static-files: ${QUERY_STATIC_FILES}
62 | agent:
63 | strategy: sidecar
64 | image: ${IMAGE_JAEGER_AGENT}
65 | resources:
66 | requests:
67 | cpu: "${RESO_LMT_AGENT_CPU}"
68 | memory: "${RESO_LMT_AGENT_MEM}"
69 | limits:
70 | cpu: "${RESO_LMT_AGENT_CPU}"
71 | memory: "${RESO_LMT_AGENT_MEM}"
72 | options:
73 | log-level: ${LOG_LEVEL_JAEGER_AGENT}
74 | metrics-backend: ${METRICS_BACKEND}
75 | processor:
76 | jaeger-compact:
77 | server-queue-size: ${JAEGER_AGENT_QUEUE_SIZE}
78 | workers: ${JAEGER_AGENT_WORKERS}
79 | storage:
80 | type: elasticsearch
81 | esIndexCleaner:
82 | enabled: false
83 | dependencies:
84 | enabled: false
85 | options:
86 | es:
87 | server-urls: http://${STORAGE_HOST}:${STORAGE_PORT}
--------------------------------------------------------------------------------
/openshift/templates/performance-test.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2018-2019 The Jaeger Authors
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | # in compliance with the License. You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software distributed under the License
10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | # or implied. See the License for the specific language governing permissions and limitations under
12 | # the License.
13 | #
14 |
15 | apiVersion: v1
16 | kind: List
17 | items:
18 | - apiVersion: batch/v1
19 | kind: Job
20 | metadata:
21 | name: jaeger-performance-test-job
22 | labels:
23 | app: jaeger-performance-test-job
24 | group: jaeger-performance-test
25 | spec:
26 | template:
27 | metadata:
28 | labels:
29 | app: jaeger-performance-test-job
30 | group: jaeger-performance-test
31 | spec:
32 | containers:
33 | - image: ${IMAGE_JAEGER_AGENT}
34 | imagePullPolicy: Always
35 | args: ["--reporter.type=${REPORTER_TYPE}",
36 | "--reporter.${REPORTER_TYPE}.host-port=${JAEGER_COLLECTOR_HOST_PREFIX}${JAEGER_COLLECTOR_HOST}:${JAEGER_AGENT_COLLECTOR_PORT}",
37 | "--processor.jaeger-compact.server-queue-size=${JAEGER_AGENT_QUEUE_SIZE}",
38 | "--processor.jaeger-compact.workers=${JAEGER_AGENT_WORKERS}",
39 | "--metrics-backend=${METRICS_BACKEND}"]
40 | name: jaeger-agent
41 | ports:
42 | - containerPort: 6831
43 | protocol: UDP
44 | - image: ${IMAGE_PERFORMANCE_TEST}
45 | imagePullPolicy: Always
46 | name: jaeger-performance-test
47 | ports:
48 | - containerPort: 8080
49 | name: http
50 | protocol: TCP
51 | securityContext:
52 | privileged: false
53 | volumeMounts:
54 | - mountPath: /certs
55 | name: certs
56 | readOnly: true
57 | env:
58 | - name: KUBERNETES_NAMESPACE
59 | valueFrom:
60 | fieldRef:
61 | fieldPath: metadata.namespace
62 | - name: JOB_REFERENCE
63 | value: "${JOB_REFERENCE}"
64 | - name: JAEGER_SERVICE_NAME
65 | value: "${JAEGER_SERVICE_NAME}"
66 | - name: OS_URL
67 | value: "${OS_URL}"
68 | - name: OS_USERNAME
69 | value: "${OS_USERNAME}"
70 | - name: OS_NAMESPACE
71 | value: "${OS_NAMESPACE}"
72 | - name: TESTS_TO_RUN
73 | value: "${TESTS_TO_RUN}"
74 | - name: ELASTICSEARCH_PROVIDER
75 | value: "${ELASTICSEARCH_PROVIDER}"
76 | - name: STORAGE_HOST
77 | value: "${STORAGE_HOST}"
78 | - name: STORAGE_PORT
79 | value: "${STORAGE_PORT}"
80 | - name: PRE_INSTALL_JAEGER_OPERATOR
81 | value: "${PRE_INSTALL_JAEGER_OPERATOR}"
82 | - name: PRE_INSTALL_JAEGER_SERVICES
83 | value: "${PRE_INSTALL_JAEGER_SERVICES}"
84 | - name: PRE_INSTALL_REPORTER_NODES
85 | value: "${PRE_INSTALL_REPORTER_NODES}"
86 | - name: REPORTER_NODE_REPLICA_COUNT
87 | value: "${REPORTER_NODE_REPLICA_COUNT}"
88 | - name: REPORTER_REFERENCE
89 | value: "${REPORTER_REFERENCE}"
90 | - name: POST_DELETE_JAEGER_SERVICES
91 | value: "${POST_DELETE_JAEGER_SERVICES}"
92 | - name: POST_DELETE_TEST_JOBS
93 | value: "${POST_DELETE_TEST_JOBS}"
94 | - name: POST_DELETE_REPORTER_NODES
95 | value: "${POST_DELETE_REPORTER_NODES}"
96 | - name: TEST_HA_SETUP
97 | value: "${TEST_HA_SETUP}"
98 | - name: JAEGERQE_CONTROLLER_URL
99 | value: "${JAEGERQE_CONTROLLER_URL}"
100 | - name: REPORT_ENGINE_URL
101 | value: "${REPORT_ENGINE_URL}"
102 | - name: REPORT_ENGINE_LABELS
103 | value: '${REPORT_ENGINE_LABELS}'
104 | - name: REPORT_ENGINE_AGENT_REFERENCE
105 | value: '${REPORT_ENGINE_AGENT_REFERENCE}'
106 | - name: IMAGE_PERFORMANCE_TEST
107 | value: "${IMAGE_PERFORMANCE_TEST}"
108 | - name: IMAGE_ELASTICSEARCH_OPERATOR
109 | value: "${IMAGE_ELASTICSEARCH_OPERATOR}"
110 | - name: IMAGE_ELASTICSEARCH
111 | value: "${IMAGE_ELASTICSEARCH}"
112 | - name: IMAGE_JAEGER_OPERATOR
113 | value: "${IMAGE_JAEGER_OPERATOR}"
114 | - name: IMAGE_JAEGER_ALL_IN_ONE
115 | value: "${IMAGE_JAEGER_ALL_IN_ONE}"
116 | - name: IMAGE_JAEGER_AGENT
117 | value: "${IMAGE_JAEGER_AGENT}"
118 | - name: IMAGE_JAEGER_COLLECTOR
119 | value: "${IMAGE_JAEGER_COLLECTOR}"
120 | - name: IMAGE_JAEGER_QUERY
121 | value: "${IMAGE_JAEGER_QUERY}"
122 | - name: IMAGE_JAEGER_ES_INDEX_CLEANER
123 | value: "${IMAGE_JAEGER_ES_INDEX_CLEANER}"
124 | - name: USE_INTERNAL_REPORTER
125 | value: "${USE_INTERNAL_REPORTER}"
126 | - name: NODE_COUNT_SPANS_REPORTER
127 | value: "${NODE_COUNT_SPANS_REPORTER}"
128 | - name: NODE_COUNT_QUERY_RUNNER
129 | value: "${NODE_COUNT_QUERY_RUNNER}"
130 | - name: MSG_BROKER_HOST
131 | value: "${MSG_BROKER_HOST}"
132 | - name: MSG_BROKER_PORT
133 | value: "${MSG_BROKER_PORT}"
134 | - name: MSG_BROKER_USER
135 | value: "${MSG_BROKER_USER}"
136 | - name: NUMBER_OF_TRACERS
137 | value: "${NUMBER_OF_TRACERS}"
138 | - name: NUMBER_OF_SPANS
139 | value: "${NUMBER_OF_SPANS}"
140 | - name: REPORT_SPANS_DURATION
141 | value: "${REPORT_SPANS_DURATION}"
142 | - name: QUERY_LIMIT
143 | value: "${QUERY_LIMIT}"
144 | - name: QUERY_SAMPLES
145 | value: "${QUERY_SAMPLES}"
146 | - name: QUERY_INTERVAL
147 | value: "${QUERY_INTERVAL}"
148 | - name: SENDER
149 | value: "${SENDER}"
150 | - name: REPORTER_TYPE
151 | value: "${REPORTER_TYPE}"
152 | - name: METRICS_BACKEND
153 | value: "${METRICS_BACKEND}"
154 | - name: RESOURCE_MONITOR_ENABLED
155 | value: "${RESOURCE_MONITOR_ENABLED}"
156 | - name: JAEGER_AGENT_QUEUE_SIZE
157 | value: "${JAEGER_AGENT_QUEUE_SIZE}"
158 | - name: JAEGER_AGENT_WORKERS
159 | value: "${JAEGER_AGENT_WORKERS}"
160 | - name: JAEGER_CLIENT_FLUSH_INTERVAL
161 | value: "${JAEGER_CLIENT_FLUSH_INTERVAL}"
162 | - name: JAEGER_CLIENT_MAX_POCKET_SIZE
163 | value: "${JAEGER_CLIENT_MAX_POCKET_SIZE}"
164 | - name: JAEGER_CLIENT_MAX_QUEUE_SIZE
165 | value: "${JAEGER_CLIENT_MAX_QUEUE_SIZE}"
166 | - name: COLLECTOR_REPLICA_COUNT
167 | value: "${COLLECTOR_REPLICA_COUNT}"
168 | - name: COLLECTOR_QUEUE_SIZE
169 | value: "${COLLECTOR_QUEUE_SIZE}"
170 | - name: COLLECTOR_NUM_WORKERS
171 | value: "${COLLECTOR_NUM_WORKERS}"
172 | - name: COLLECTOR_ES_BULK_SIZE
173 | value: "${COLLECTOR_ES_BULK_SIZE}"
174 | - name: COLLECTOR_ES_BULK_WORKERS
175 | value: "${COLLECTOR_ES_BULK_WORKERS}"
176 | - name: COLLECTOR_ES_BULK_FLUSH_INTERVAL
177 | value: "${COLLECTOR_ES_BULK_FLUSH_INTERVAL}"
178 | - name: JAEGER_QUERY_STATIC_FILES
179 | value: "${JAEGER_QUERY_STATIC_FILES}"
180 | - name: ES_MEMORY
181 | value: "${ES_MEMORY}"
182 | - name: LOG_LEVEL_JAEGER_AGENT
183 | value: "${LOG_LEVEL_JAEGER_AGENT}"
184 | - name: LOG_LEVEL_JAEGER_COLLECTOR
185 | value: "${LOG_LEVEL_JAEGER_COLLECTOR}"
186 | - name: LOG_LEVEL_JAEGER_OPERATOR
187 | value: "${LOG_LEVEL_JAEGER_OPERATOR}"
188 | - name: LOG_LEVEL_JAEGER_QUERY
189 | value: "${LOG_LEVEL_JAEGER_QUERY}"
190 | - name: RESO_LMT_AGENT_CPU
191 | value: "${RESO_LMT_AGENT_CPU}"
192 | - name: RESO_LMT_AGENT_MEM
193 | value: "${RESO_LMT_AGENT_MEM}"
194 | - name: RESO_LMT_COLLECTOR_CPU
195 | value: "${RESO_LMT_COLLECTOR_CPU}"
196 | - name: RESO_LMT_COLLECTOR_MEM
197 | value: "${RESO_LMT_COLLECTOR_MEM}"
198 | - name: RESO_LMT_QUERY_CPU
199 | value: "${RESO_LMT_QUERY_CPU}"
200 | - name: RESO_LMT_QUERY_MEM
201 | value: "${RESO_LMT_QUERY_MEM}"
202 | - name: RUNNING_ON_OPENSHIFT
203 | value: "${RUNNING_ON_OPENSHIFT}"
204 | - name: LOGS_DIRECTORY
205 | value: "${LOGS_DIRECTORY}"
206 | - name: JAEGER_AGENT_HOST
207 | value: "${JAEGER_AGENT_HOST}"
208 | - name: JAEGER_AGENT_PORT
209 | value: "${JAEGER_AGENT_PORT}"
210 | - name: JAEGER_AGENT_COLLECTOR_PORT
211 | value: "${JAEGER_AGENT_COLLECTOR_PORT}"
212 | - name: JAEGER_COLLECTOR_HOST
213 | value: "${JAEGER_COLLECTOR_HOST}"
214 | - name: JAEGER_COLLECTOR_PORT
215 | value: "${JAEGER_COLLECTOR_PORT}"
216 | - name: JAEGER_QUERY_HOST
217 | value: "${JAEGER_QUERY_HOST}"
218 | - name: JAEGER_QUERY_PORT
219 | value: "${JAEGER_QUERY_PORT}"
220 | restartPolicy: Never
221 | volumes:
222 | - name: certs
223 | secret:
224 | defaultMode: 420
225 | secretName: ${JAEGER_SERVICE_NAME}-jaeger-elasticsearch
226 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
16 |
18 | 4.0.0
19 | io.jaegertracing.tests
20 | performance-tests
21 | 3.6.0
22 |
23 | 2018
24 |
25 |
26 |
27 | UTF-8
28 |
29 | 1.8
30 | 1.8
31 | true
32 |
33 |
34 | 3.1.2
35 | 3.3.0
36 | 3.2.2
37 | 6.1.1
38 | 2.12.1
39 | 1.1.0
40 | 3.8
41 | 1.2.3
42 | 1.18.6
43 | 1.7.25
44 | 4.13.1
45 | 2.37.0
46 | 1.10.6
47 |
48 | 3.1.0
49 | 2.22.0
50 | 3.0
51 |
52 |
53 |
54 |
55 |
56 | org.awaitility
57 | awaitility
58 | ${version.awaitility}
59 |
60 |
61 |
62 | com.datastax.cassandra
63 | cassandra-driver-core
64 | ${version.cassandra-driver}
65 |
66 |
67 |
68 | io.dropwizard.metrics
69 | metrics-core
70 | ${version.dropwizard}
71 |
72 |
73 |
74 | org.elasticsearch.client
75 | elasticsearch-rest-client
76 | ${version.elasticsearch}
77 |
78 |
79 |
80 | com.fasterxml.jackson.core
81 | jackson-databind
82 | ${version.jackson}
83 |
84 |
85 |
86 |
87 | com.fasterxml.jackson.dataformat
88 | jackson-dataformat-yaml
89 | ${version.jackson}
90 |
91 |
92 |
93 | io.jaegertracing
94 | jaeger-client
95 | ${version.jaeger}
96 |
97 |
98 |
99 |
100 | org.slf4j
101 | slf4j-api
102 | ${version.slf4j}
103 |
104 |
105 |
106 | ch.qos.logback
107 | logback-core
108 | ${version.logback}
109 |
110 |
111 |
112 | ch.qos.logback
113 | logback-classic
114 | ${version.logback}
115 |
116 |
117 |
118 | org.apache.commons
119 | commons-lang3
120 | ${version.lang3}
121 |
122 |
123 |
124 | commons-io
125 | commons-io
126 | 2.6
127 |
128 |
129 |
130 | junit
131 | junit
132 | ${version.junit}
133 |
134 |
135 |
136 | net.sourceforge.htmlunit
137 | htmlunit
138 | ${version.htmlunit}
139 |
140 |
141 |
142 | org.projectlombok
143 | lombok
144 | ${version.projectlombok}
145 |
146 |
147 |
148 | org.hawkular.agent
149 | prometheus-scraper
150 | 0.23.0.Final
151 |
152 |
153 |
154 | org.apache.ant
155 | ant-junit
156 | ${version.ant-junit}
157 |
158 |
159 | junit
160 | junit
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 | com.mycila
174 | license-maven-plugin
175 | ${version.license-maven-plugin}
176 |
177 | ${project.basedir}/license_header.txt
178 |
179 | **/*.md
180 | **/logs/*
181 | **/lombok.config
182 | openshift/Jenkinsfile
183 | LICENSE
184 | license_header.txt
185 |
186 | true
187 | true
188 |
189 |
190 |
191 |
192 | com.mycila
193 | license-maven-plugin-git
194 | ${version.license-maven-plugin}
195 |
196 |
197 |
198 |
199 |
200 | check
201 |
202 | compile
203 |
204 |
205 |
206 |
207 |
208 |
209 | org.apache.maven.plugins
210 | maven-assembly-plugin
211 | ${version.maven-assembly-plugin}
212 |
213 |
214 | jar-with-dependencies
215 |
216 |
217 |
218 | io.jaegertracing.tests.Main
219 |
220 |
221 |
222 |
223 |
224 | make-assembly
225 | package
226 |
227 | single
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/CreateSpansRunnable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 | import java.util.Timer;
19 | import java.util.TimerTask;
20 | import java.util.concurrent.TimeUnit;
21 |
22 | import io.jaegertracing.internal.JaegerTracer;
23 | import io.jaegertracing.tests.model.TestConfig;
24 | import io.opentracing.Span;
25 | import io.opentracing.tag.Tags;
26 | import lombok.extern.slf4j.Slf4j;
27 |
28 | @Slf4j
29 | public class CreateSpansRunnable implements Runnable {
30 | private boolean _printed = false;
31 | private long reporterEndTime;
32 |
33 | private boolean isValid() {
34 | return System.currentTimeMillis() < reporterEndTime;
35 | }
36 |
37 | class SpansReporer extends TimerTask {
38 |
39 | private long delay = 0;
40 |
41 | public SpansReporer() {
42 | delay = (1000L / config.getNumberOfSpans()); // delay in milliseconds
43 | if (delay > 10) {
44 | delay -= 1L; // remove 1ms delay from the actual delay
45 | }
46 | }
47 |
48 | @Override
49 | public void run() {
50 | if (!_printed) {
51 | _printed = true;
52 | logger.trace("Started sending spans, tracer:{}", name);
53 | }
54 | Map logs = new HashMap<>();
55 | logs.put("event", Tags.ERROR);
56 | logs.put("error.object", new RuntimeException());
57 | logs.put("class", this.getClass().getName());
58 | int count = 0;
59 | long startTime = System.currentTimeMillis();
60 | do {
61 | if (!isValid()) {
62 | break;
63 | }
64 | count++;
65 | // emulate client spans
66 | Span span = tracer.buildSpan(name)
67 | .withTag(Tags.COMPONENT.getKey(), "perf-test")
68 | .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
69 | .withTag(Tags.HTTP_METHOD.getKey(), "get")
70 | .withTag(Tags.HTTP_STATUS.getKey(), 200)
71 | .withTag(Tags.HTTP_URL.getKey(), "http://www.example.com/foo/bar?q=bar")
72 | .start();
73 | span.log(logs);
74 | span.finish();
75 | try {
76 | TimeUnit.MILLISECONDS.sleep(delay);
77 | } catch (InterruptedException ex) {
78 | logger.error("exception, ", ex);
79 | }
80 | } while (count < config.getNumberOfSpans());
81 |
82 | logger.trace("Reporting spans done, duration:{}ms, Tracer:{}",
83 | System.currentTimeMillis() - startTime, name);
84 | }
85 |
86 | }
87 |
88 | private JaegerTracer tracer;
89 | private String name;
90 | private TestConfig config;
91 | private boolean close;
92 |
93 | public CreateSpansRunnable(JaegerTracer tracer, String name, TestConfig config, boolean close) {
94 | this.tracer = tracer;
95 | this.name = name;
96 | this.config = config;
97 | this.close = close;
98 | }
99 |
100 | @Override
101 | public void run() {
102 | logger.debug("Sending spans triggered for the tracer: {}", name);
103 | // update end time
104 | reporterEndTime = System.currentTimeMillis() + config.getSpansReportDurationInMillisecond();
105 |
106 | logger.debug("Sending spans triggered for the tracer: {}", name);
107 | Timer timer = new Timer();
108 | timer.scheduleAtFixedRate(new SpansReporer(), 0L, 1000L);
109 | try {
110 | while (isValid()) {
111 | TimeUnit.MILLISECONDS.sleep(500L);
112 | }
113 | timer.cancel();
114 | } catch (Exception ex) {
115 | logger.error("Exception,", ex);
116 | }
117 |
118 | if (close) {
119 | tracer.close();
120 | }
121 | }
122 |
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/ElasticsearchSpanCounter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.io.IOException;
17 | import java.time.LocalDateTime;
18 | import java.time.format.DateTimeFormatter;
19 |
20 | import org.apache.http.HttpHost;
21 | import org.apache.http.util.EntityUtils;
22 | import org.elasticsearch.client.Response;
23 | import org.elasticsearch.client.RestClient;
24 |
25 | import com.fasterxml.jackson.databind.JsonNode;
26 | import com.fasterxml.jackson.databind.ObjectMapper;
27 |
28 | import io.jaegertracing.tests.osutils.OSCommandExecuter;
29 | import io.jaegertracing.tests.model.TestConfig;
30 | import lombok.extern.slf4j.Slf4j;
31 |
32 | @Slf4j
33 | public class ElasticsearchSpanCounter extends UntilNoChangeCounter {
34 |
35 | static RestClient getESRestClient(String esProvider, String host, int port) {
36 | return RestClient.builder(
37 | new HttpHost(host, port, esProvider.equals("es-operator") ? "https" : "http"))
38 | .build();
39 | }
40 |
41 | static String getSpanIndex() {
42 | String formattedDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
43 | String spanIndex = "jaeger-span-" + formattedDate;
44 | logger.info("Using ElasticSearch index : [" + spanIndex + "]");
45 | return spanIndex;
46 | }
47 |
48 | private final String spanIndex;
49 |
50 | private final RestClient restClient;
51 |
52 | private final String esProvider;
53 |
54 | private final String esHost;
55 |
56 | private final Integer esPort;
57 |
58 | private final OSCommandExecuter cmdExecuter = new OSCommandExecuter();
59 |
60 | private final ObjectMapper objectMapper;
61 |
62 | public ElasticsearchSpanCounter(TestConfig config) {
63 | super();
64 | this.esProvider = config.getElasticsearchProvider();
65 | this.esHost = config.getStorageHost();
66 | this.esPort = config.getStoragePort();
67 | this.restClient = getESRestClient(this.esProvider, this.esHost, this.esPort);
68 | this.objectMapper = new ObjectMapper();
69 | this.spanIndex = getSpanIndex();
70 | }
71 |
72 | @Override
73 | public void close() throws IOException {
74 | restClient.close();
75 | }
76 |
77 | @Override
78 | public int count() {
79 | refreshSpanIndex();
80 | try {
81 | //Response response = restClient.performRequest("GET", "/" + spanIndex + "/_count");
82 | //String responseBody = EntityUtils.toString(response.getEntity());
83 | JsonNode jsonPayload = objectMapper.readTree(execute("/" + spanIndex + "/_count"));
84 | JsonNode count = jsonPayload.get("count");
85 | int spansCount = count.asInt();
86 | logger.info("found {} traces in ES", spansCount);
87 | return spansCount;
88 | } catch (IOException ex) {
89 | logger.error("Could not make request to count span index", ex);
90 | return -1;
91 | }
92 | }
93 |
94 | public void refreshSpanIndex() {
95 | try {
96 | /*Response response = restClient.performRequest("GET", "/" + spanIndex + "/_refresh");
97 | if (response.getStatusLine().getStatusCode() >= 400) {
98 | throw new RuntimeException("Could not refresh span index");
99 | }*/
100 | execute("/" + spanIndex + "/_refresh");
101 | } catch (IOException ex) {
102 | logger.error("Could not make request to refresh span index", ex);
103 | // throw new
104 | // RuntimeException("Could not make request to refresh span index",
105 | // ex);
106 | }
107 | }
108 |
109 | private String execute(String request) throws IOException {
110 | if (esProvider.equals("es-operator")) {
111 | return cmdExecuter.executeElasticsearchCmd(esHost, esPort, request).getResult();
112 | } else {
113 | Response response = restClient.performRequest("GET", request);
114 | return EntityUtils.toString(response.getEntity());
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/ElasticsearchStatsGetter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import static io.jaegertracing.tests.ElasticsearchSpanCounter.getSpanIndex;
17 |
18 | import java.io.Closeable;
19 | import java.io.IOException;
20 |
21 | import org.apache.http.util.EntityUtils;
22 | import org.elasticsearch.client.Response;
23 | import org.elasticsearch.client.RestClient;
24 |
25 | import io.jaegertracing.tests.osutils.OSCommandExecuter;
26 |
27 | import io.jaegertracing.tests.osutils.OSResponse;
28 | import lombok.extern.slf4j.Slf4j;
29 |
30 | @Slf4j
31 | public class ElasticsearchStatsGetter implements Closeable {
32 |
33 | private static final String INDEX_STATS = "/_stats?pretty";
34 | private static final String NODES = "/_cat/nodes?v&h=hm,hc,rm,rc,iiti,iito,sqti,sqto";
35 | private static final String THREAD_POOL = "/_cat/thread_pool/generic?v&h=id,name,active,rejected,completed";
36 |
37 | private final String esProvider;
38 | private final String esHost;
39 | private final int esPort;
40 | private final RestClient restClient;
41 | private final String spanIndex;
42 | private final OSCommandExecuter cmdExecuter = new OSCommandExecuter();
43 |
44 | public ElasticsearchStatsGetter(String esProvider, String esHost, int esPort) {
45 | this.esProvider = esProvider;
46 | this.esHost = esHost;
47 | this.esPort = esPort;
48 | this.restClient = ElasticsearchSpanCounter.getESRestClient(esProvider, esHost, esPort);
49 | this.spanIndex = getSpanIndex();
50 |
51 | }
52 |
53 | @Override
54 | public void close() throws IOException {
55 | restClient.close();
56 | }
57 |
58 | private String execute(String request) {
59 | String command = String.format(
60 | "curl --cacert /certs/ca --key /certs/key --cert /certs/cert https://%s:%d%s",
61 | esHost, esPort, request);
62 | OSResponse response = cmdExecuter.executeLinuxCommand(command);
63 | logger.debug("Command:{}, {}", command, response);
64 | return response.getResult();
65 | }
66 |
67 | public void printStats() {
68 | try {
69 | if (esProvider.equals("es-operator")) {
70 | String indexStats = "/" + spanIndex + INDEX_STATS;
71 | logger.debug("{}: {}", indexStats, execute(indexStats));
72 | logger.debug("{}: {}", NODES, execute(NODES));
73 | logger.debug("{}: {}", THREAD_POOL, execute(THREAD_POOL));
74 | } else {
75 | Response indexStats = restClient.performRequest("GET", "/" + spanIndex + INDEX_STATS);
76 | // https://www.elastic.co/guide/en/elasticsearch/reference/6.3/cat-nodes.html
77 | Response nodeCat = restClient.performRequest("GET", NODES);
78 | // https://www.elastic.co/guide/en/elasticsearch/reference/6.3/cat-thread-pool.html
79 | Response threadPool = restClient.performRequest("GET", THREAD_POOL);
80 |
81 | logger.debug("{} --> {}",
82 | nodeCat.getRequestLine().getUri(), EntityUtils.toString(nodeCat.getEntity()));
83 | logger.debug("{} --> {}",
84 | threadPool.getRequestLine().getUri(), EntityUtils.toString(threadPool.getEntity()));
85 | logger.debug("{} --> {}",
86 | indexStats.getRequestLine().getUri(), EntityUtils.toString(indexStats.getEntity()));
87 | }
88 |
89 | } catch (IOException ex) {
90 | logger.error("Exception,", ex);
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/ISpanCounter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.io.Closeable;
17 |
18 | public interface ISpanCounter extends Closeable {
19 |
20 | int count();
21 |
22 | int countUntilNoChange(int expected);
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/JaegerQuerySpanCounter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.io.IOException;
17 | import java.util.LinkedHashSet;
18 | import java.util.Set;
19 | import java.util.concurrent.CountDownLatch;
20 | import java.util.concurrent.TimeUnit;
21 | import java.util.concurrent.atomic.AtomicInteger;
22 |
23 | import com.codahale.metrics.Timer;
24 | import com.fasterxml.jackson.databind.DeserializationFeature;
25 | import com.fasterxml.jackson.databind.ObjectMapper;
26 |
27 | import io.jaegertracing.tests.model.Result;
28 | import io.jaegertracing.tests.model.TestConfig;
29 | import io.jaegertracing.tests.report.ReportFactory;
30 | import lombok.extern.slf4j.Slf4j;
31 | import okhttp3.Call;
32 | import okhttp3.Callback;
33 | import okhttp3.OkHttpClient;
34 | import okhttp3.Request;
35 | import okhttp3.Response;
36 |
37 | @Slf4j
38 | public class JaegerQuerySpanCounter extends UntilNoChangeCounter {
39 |
40 | private OkHttpClient okClient;
41 | private ObjectMapper objectMapper;
42 | private Set requests = new LinkedHashSet<>();
43 | private boolean async;
44 |
45 | public JaegerQuerySpanCounter(
46 | TestConfig config,
47 | Set serviceNames,
48 | boolean async) {
49 | super();
50 |
51 | String queryUrl = "http://" + config.getJaegerQueryHost() + ":" + config.getJaegerQueryPort();
52 | long limit = -1;
53 |
54 | limit = config.getNumberOfSpans() * config.getSpansReportDurationInSecond();
55 |
56 | Timer jaegerQueryTimer = ReportFactory.timer("jaeger-query-span-counter");
57 |
58 | this.okClient = new OkHttpClient.Builder()
59 | .readTimeout(10, TimeUnit.MINUTES)
60 | .addInterceptor(chain -> {
61 | long start = System.currentTimeMillis();
62 | Response response = chain.proceed(chain.request());
63 | long duration = System.currentTimeMillis() - start;
64 | jaegerQueryTimer.update(duration, TimeUnit.MILLISECONDS);
65 | logger.trace("{} --> in {}s", response.body(), TimeUnit.MILLISECONDS.toSeconds(duration));
66 | return response;
67 | })
68 | .build();
69 | this.objectMapper = new ObjectMapper();
70 | this.objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
71 |
72 | for (String service : serviceNames) {
73 | Request request = new Request.Builder()
74 | .url(String.format("%s/api/traces?service=%s&limit=%d", queryUrl, service, limit)).build();
75 | this.requests.add(request);
76 | }
77 | this.async = async;
78 | }
79 |
80 | @Override
81 | public void close() {
82 | okClient.dispatcher().executorService().shutdown();
83 | okClient.connectionPool().evictAll();
84 | }
85 |
86 | @Override
87 | public int count() {
88 | return async ? getAsync() : getSync();
89 | }
90 |
91 | private int getAsync() {
92 | AtomicInteger totalCount = new AtomicInteger(0);
93 | CountDownLatch latch = new CountDownLatch(requests.size());
94 | for (Request request : requests) {
95 | okClient.newCall(request).enqueue(new Callback() {
96 | @Override
97 | public void onFailure(Call call, IOException e) {
98 | e.printStackTrace();
99 | latch.countDown();
100 | }
101 |
102 | @Override
103 | public void onResponse(Call call, Response response) throws IOException {
104 | Result result = parseResult(response);
105 | totalCount.addAndGet(result.getData().size());
106 | logger.debug("---> {} spans", result.getData().size());
107 | response.close();
108 | latch.countDown();
109 | }
110 | });
111 | }
112 | try {
113 | latch.await();
114 | } catch (InterruptedException e) {
115 | e.printStackTrace();
116 | }
117 | return totalCount.get();
118 |
119 | }
120 |
121 | private int getSync() {
122 | int totalCount = 0;
123 | for (Request request : requests) {
124 | try {
125 | Response response = okClient.newCall(request).execute();
126 | String body = response.body().string();
127 | Result result = objectMapper.readValue(body, Result.class);
128 | logger.debug("{} >> spans found: {}", request, result.getData().size());
129 | totalCount += result.getData().size();
130 | response.close();
131 | } catch (IOException e) {
132 | e.printStackTrace();
133 | return 0;
134 | }
135 | }
136 | return totalCount;
137 | }
138 |
139 | private Result parseResult(Response response) throws IOException {
140 | String body = response.body().string();
141 | return objectMapper.readValue(body, Result.class);
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/JsonUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.io.File;
17 | import java.io.IOException;
18 |
19 | import org.apache.commons.io.FileUtils;
20 |
21 | import com.fasterxml.jackson.core.JsonProcessingException;
22 | import com.fasterxml.jackson.databind.DeserializationFeature;
23 | import com.fasterxml.jackson.databind.ObjectMapper;
24 | import com.fasterxml.jackson.databind.SerializationFeature;
25 |
26 | import lombok.extern.slf4j.Slf4j;
27 |
28 | @Slf4j
29 | public class JsonUtils {
30 | private static final String ENCODING = "UTF-8";
31 | private static final ObjectMapper MAPPER = new ObjectMapper()
32 | .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
33 |
34 | public static String asString(Object data) {
35 | MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
36 | try {
37 | return MAPPER.writeValueAsString(data);
38 | } catch (JsonProcessingException ex) {
39 | logger.error("Exception,", ex);
40 | return null;
41 | }
42 | }
43 |
44 | public static void dumps(Object data, String... names) {
45 | MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
46 | try {
47 | String stringData = MAPPER.writeValueAsString(data);
48 | File file = FileUtils.getFile(names);
49 | FileUtils.write(file, stringData, ENCODING);
50 | logger.trace("Json saved: {}", file.getAbsolutePath());
51 | } catch (IOException ex) {
52 | logger.error("Exception,", ex);
53 | }
54 | }
55 |
56 | public static Object loads(Class> clazz, File file) {
57 | try {
58 | String content = FileUtils.readFileToString(file, ENCODING);
59 | return MAPPER.readValue(content, clazz);
60 | } catch (IOException ex) {
61 | logger.error("Exception when loading {}", file.getAbsolutePath(), ex);
62 | }
63 | return null;
64 | }
65 |
66 | public static Object loads(Class> clazz, String... names) {
67 | return loads(clazz, FileUtils.getFile(names));
68 | }
69 |
70 | public static Object loadFromString(String content, Class> clazz) {
71 | try {
72 | MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
73 | return MAPPER.readValue(content, clazz);
74 | } catch (IOException ex) {
75 | logger.error("Exception when loading [{}]", content, ex);
76 | }
77 | return null;
78 | }
79 |
80 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/ReportEngineUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | import lombok.extern.slf4j.Slf4j;
20 |
21 | import lombok.AccessLevel;
22 | import lombok.NoArgsConstructor;
23 |
24 | @Slf4j
25 | @NoArgsConstructor(access = AccessLevel.PRIVATE)
26 | public class ReportEngineUtils {
27 |
28 | public static HashMap labels(String stringLabels) {
29 | HashMap labels = new HashMap<>();
30 | try {
31 | @SuppressWarnings("unchecked")
32 | Map custom = (Map) JsonUtils.loadFromString(stringLabels, Map.class);
33 | for (String key : custom.keySet()) {
34 | labels.put(key, String.valueOf(custom.get(key)));
35 | }
36 | } catch (Exception ex) {
37 | logger.error("Exception,", ex);
38 | }
39 |
40 | return labels;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/TestUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import org.apache.commons.lang3.time.DurationFormatUtils;
17 |
18 | public class TestUtils {
19 |
20 | public static Boolean getBooleanEnv(String key, String defaultValue) {
21 | return Boolean.valueOf(getStringEnv(key, defaultValue));
22 | }
23 |
24 | public static Float getFloatEnv(String key, String defaultValue) {
25 | return Float.valueOf(getStringEnv(key, defaultValue));
26 | }
27 |
28 | public static Integer getIntegerEnv(String key, String defaultValue) {
29 | return Integer.valueOf(getStringEnv(key, defaultValue));
30 | }
31 |
32 | public static Long getLongEnv(String key, String defaultValue) {
33 | return Long.valueOf(getStringEnv(key, defaultValue));
34 | }
35 |
36 | public static String getStringEnv(String key, String defaultValue) {
37 | return System.getenv().getOrDefault(key, defaultValue);
38 | }
39 |
40 | public static String timeTaken(long durationMillis) {
41 | return DurationFormatUtils.formatDurationHMS(durationMillis);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/UntilNoChangeCounter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests;
15 |
16 | import java.util.concurrent.TimeUnit;
17 |
18 | import com.codahale.metrics.Timer;
19 |
20 | import io.jaegertracing.tests.report.ReportFactory;
21 | import lombok.extern.slf4j.Slf4j;
22 |
23 | @Slf4j
24 | public abstract class UntilNoChangeCounter implements ISpanCounter {
25 |
26 | private Timer queryTimer;
27 | private Timer queryUntilNoChangeTimer;
28 |
29 | private static final int MAX_ITERATION = 5;
30 | private static final long ITERATION_DELAY = 5 * 1000L;
31 |
32 | public UntilNoChangeCounter() {
33 | this.queryTimer = ReportFactory.timer("until-no-change-single-span-counter");
34 | this.queryUntilNoChangeTimer = ReportFactory.timer("until-no-change-span-counter");
35 | }
36 |
37 | @Override
38 | public int countUntilNoChange(int expected) {
39 | long startUntilNoChange = System.currentTimeMillis();
40 | int spansCountOld = 0;
41 | int spansCountFinal = 0;
42 |
43 | try {
44 | int iteration = 1;
45 | while (iteration <= MAX_ITERATION) {
46 | long start = System.currentTimeMillis();
47 | spansCountFinal = count();
48 | long duration = System.currentTimeMillis() - start;
49 | queryTimer.update(duration, TimeUnit.MILLISECONDS);
50 | logger.debug("Count took: {}ms, spans status[returned:{}, expected:{}]",
51 | duration, spansCountFinal, expected);
52 | if (spansCountOld != spansCountFinal) {
53 | iteration = 1;
54 | spansCountOld = spansCountFinal;
55 | } else if (expected <= spansCountFinal) {
56 | break;
57 | } else {
58 | iteration++;
59 | }
60 | Thread.sleep(ITERATION_DELAY);
61 | }
62 | } catch (Exception ex) {
63 | logger.error("Exception,", ex);
64 | }
65 | queryUntilNoChangeTimer.update(System.currentTimeMillis() - startUntilNoChange, TimeUnit.MILLISECONDS);
66 | return spansCountFinal;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/clients/ClientUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.clients;
15 |
16 | import io.jaegertracing.tests.report.ReportFactory;
17 |
18 | import lombok.AccessLevel;
19 | import lombok.NoArgsConstructor;
20 |
21 | @NoArgsConstructor(access = AccessLevel.PRIVATE)
22 | public class ClientUtils {
23 |
24 | private static ReportEngineClient reClient = null;
25 | private static JaegerQEControllerClient qeControllerClient = null;
26 |
27 | public static ReportEngineClient reClient() {
28 | if (reClient == null) {
29 | reClient = newReClient();
30 | }
31 | return reClient;
32 | }
33 |
34 | public static JaegerQEControllerClient qeCtlClient() {
35 | if (qeControllerClient == null) {
36 | qeControllerClient = new JaegerQEControllerClient(ReportFactory.testConfig().getJaegerqeControllerUrl());
37 | }
38 | return qeControllerClient;
39 | }
40 |
41 | public static ReportEngineClient newReClient() {
42 | return new ReportEngineClient(ReportFactory.testConfig().getReportEngineUrl());
43 | }
44 |
45 | public static GenericRestClient newGenericClient(String hostUrl) {
46 | return new GenericRestClient(hostUrl);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/clients/GenericRestClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.clients;
15 |
16 | import java.io.IOException;
17 | import java.util.concurrent.TimeUnit;
18 |
19 | import com.fasterxml.jackson.core.JsonProcessingException;
20 | import com.fasterxml.jackson.databind.ObjectMapper;
21 |
22 | import lombok.Getter;
23 |
24 | import lombok.extern.slf4j.Slf4j;
25 | import okhttp3.MediaType;
26 | import okhttp3.OkHttpClient;
27 | import okhttp3.Request;
28 | import okhttp3.RequestBody;
29 | import okhttp3.Response;
30 |
31 | @Slf4j
32 | @Getter
33 | public class GenericRestClient {
34 |
35 | private final ObjectMapper mapper = new ObjectMapper();
36 |
37 | private String hostUrl;
38 | private final OkHttpClient okClient;
39 |
40 | protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
41 | protected static final MediaType FORM_DATA = MediaType.parse("multipart/form-data; charset=utf-8");
42 |
43 | public void sethostUrl(String hostUrl) {
44 | if (hostUrl.endsWith("/")) {
45 | this.hostUrl = hostUrl.substring(0, hostUrl.length() - 1);
46 | } else {
47 | this.hostUrl = hostUrl;
48 | }
49 | }
50 |
51 | public GenericRestClient(String hostUrl, OkHttpClient okClient) {
52 | sethostUrl(hostUrl);
53 | this.okClient = okClient;
54 | }
55 |
56 | public GenericRestClient(String hostUrl) {
57 | sethostUrl(hostUrl);
58 | this.okClient = new OkHttpClient.Builder()
59 | .readTimeout(10, TimeUnit.MINUTES)
60 | .addInterceptor(chain -> {
61 | long start = System.currentTimeMillis();
62 | Response response = chain.proceed(chain.request());
63 | long duration = System.currentTimeMillis() - start;
64 | logger.trace("{} --> in {}s", response.body(), TimeUnit.MILLISECONDS.toSeconds(duration));
65 | return response;
66 | })
67 | .build();
68 | }
69 |
70 | private String getUrl(String api) {
71 | if (api.startsWith("/")) {
72 | return String.format("%s%s", this.hostUrl, api);
73 | } else {
74 | return String.format("%s/%s", this.hostUrl, api);
75 | }
76 | }
77 |
78 | public Object get(String api, Class> clazz) {
79 | try {
80 | Request request = new Request.Builder()
81 | .url(getUrl(api))
82 | .get()
83 | .build();
84 | Response response = execute(request);
85 | if (response.isSuccessful()) {
86 | String jsonContent = response.body().string();
87 | return getMapper().readValue(jsonContent, clazz);
88 | }
89 | } catch (IOException ex) {
90 | logger.error("Exception,", ex);
91 | }
92 | return null;
93 | }
94 |
95 | public void post(String api, Object data) {
96 | try {
97 | RequestBody body = RequestBody.create(JSON, getMapper().writeValueAsString(data));
98 | Request request = new Request.Builder()
99 | .url(getUrl(api))
100 | .post(body)
101 | .build();
102 | execute(request);
103 | } catch (JsonProcessingException ex) {
104 | logger.error("Exception,", ex);
105 | }
106 | }
107 |
108 | public void put(String api, Object data) {
109 | try {
110 | RequestBody body = RequestBody.create(JSON, getMapper().writeValueAsString(data));
111 | Request request = new Request.Builder()
112 | .url(getUrl(api))
113 | .put(body)
114 | .build();
115 | execute(request);
116 | } catch (JsonProcessingException ex) {
117 | logger.error("Exception,", ex);
118 | }
119 | }
120 |
121 | public Response execute(Request request) {
122 | try {
123 | Response response = okClient.newCall(request).execute();
124 | if (!response.isSuccessful()) {
125 | logger.debug("{}, responseBody:{}", response, response.body().string());
126 | }
127 | return response;
128 | } catch (IOException ex) {
129 | logger.error("Exception,", ex);
130 | }
131 | return null;
132 | }
133 |
134 | public void close() {
135 | if (okClient != null) {
136 | okClient.dispatcher().executorService().shutdown();
137 | okClient.connectionPool().evictAll();
138 | }
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/clients/JaegerQEControllerClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.clients;
15 |
16 | import java.util.Map;
17 |
18 | public class JaegerQEControllerClient extends GenericRestClient {
19 |
20 | private boolean available = false;
21 |
22 | public JaegerQEControllerClient(String hostUrl) {
23 | super(hostUrl);
24 | // update available
25 | status();
26 | }
27 |
28 | public boolean isAvailable() {
29 | return available;
30 | }
31 |
32 | public void startSpansReporter(Map data) {
33 | post("/api/spansreporter/start", data);
34 | }
35 |
36 | public void runSpansQuery(Map data) {
37 | post("/api/spansquery/trigger", data);
38 | }
39 |
40 | public void postMqttTopic(Map data) {
41 | post("/api/mqtt/post", data);
42 | }
43 |
44 | @SuppressWarnings("unchecked")
45 | public Map status() {
46 | Map status = (Map) get("/api/status", Map.class);
47 | available = status != null ? true : false;
48 | return status;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/clients/ReportEngineClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.clients;
15 |
16 | import java.io.File;
17 | import java.util.List;
18 | import java.util.Map;
19 |
20 | import io.jaegertracing.tests.resourcemonitor.ReMetric;
21 | import okhttp3.MultipartBody;
22 | import io.jaegertracing.tests.report.model.JaegerTestReport;
23 | import lombok.extern.slf4j.Slf4j;
24 | import okhttp3.MediaType;
25 | import okhttp3.Request;
26 | import okhttp3.RequestBody;
27 |
28 | @Slf4j
29 | public class ReportEngineClient extends GenericRestClient {
30 |
31 | private boolean available = false;
32 |
33 | public ReportEngineClient(String hostUrl) {
34 | super(hostUrl);
35 | // update available
36 | status();
37 | }
38 |
39 | public boolean isAvailable() {
40 | return available;
41 | }
42 |
43 | public void addTestData(JaegerTestReport jaegerTestReport) {
44 | this.post("/suites", jaegerTestReport);
45 | }
46 |
47 | public void updateTestData(JaegerTestReport jaegerTestReport) {
48 | this.put("/suites", jaegerTestReport);
49 | }
50 |
51 | public void postMetric(ReMetric metric) {
52 | post("/metrics/single", metric);
53 | }
54 |
55 | public void postMetrics(List metrics) {
56 | post("/metrics/multiple", metrics);
57 | }
58 |
59 | public void uploadFile(String suiteId, File file) {
60 | RequestBody requestBody = new MultipartBody.Builder()
61 | .setType(FORM_DATA)
62 | .addFormDataPart("file", file.getName(),
63 | RequestBody.create(MediaType.parse("application/octet-stream"), file))
64 | .build();
65 |
66 | Request request = new Request.Builder()
67 | .url(String.format("%s/suites/files/uploadSingle/%s", getHostUrl(), suiteId))
68 | .post(requestBody)
69 | .build();
70 | execute(request);
71 | logger.debug("File uploaded: {}", file.getAbsolutePath());
72 | }
73 |
74 | @SuppressWarnings("unchecked")
75 | public Map status() {
76 | Map status = (Map) get("/system/status", Map.class);
77 | available = status != null ? true : false;
78 | return status;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/junitxml/DescriptionAsTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.junitxml;
15 |
16 | import org.junit.runner.Description;
17 |
18 | import junit.framework.TestResult;
19 | import junit.framework.Test;
20 |
21 | // copied from: https://github.com/cloudbees/junit-standalone-runner/blob/
22 | // 9f969beb818fa842938b90b17e82101427ed91b4/src/main/java/com/cloudbees/junit/runner/App.java
23 | /**
24 | * Wraps {@link Description} into {@link Test} enough to fake {@link JUnitResultFormatter}.
25 | */
26 | public class DescriptionAsTest implements Test {
27 | private final Description description;
28 | private final String IGNORE_CLASSNAME_PART = "io.jaegertracing.tests.smoke.tests.";
29 |
30 | public DescriptionAsTest(Description description) {
31 | this.description = description;
32 | }
33 |
34 | public int countTestCases() {
35 | return 1;
36 | }
37 |
38 | public void run(TestResult result) {
39 | throw new UnsupportedOperationException();
40 | }
41 |
42 | /**
43 | * {@link JUnitResultFormatter} determines the test name by reflection.
44 | */
45 | public String getName() {
46 | return description.getClassName().replace(IGNORE_CLASSNAME_PART, "") + "."
47 | + description.getMethodName();
48 | }
49 |
50 | @Override
51 | public boolean equals(Object o) {
52 | if (this == o)
53 | return true;
54 | if (o == null || getClass() != o.getClass())
55 | return false;
56 |
57 | DescriptionAsTest that = (DescriptionAsTest) o;
58 |
59 | if (!description.equals(that.description))
60 | return false;
61 |
62 | return true;
63 | }
64 |
65 | @Override
66 | public int hashCode() {
67 | return description.hashCode();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/junitxml/JUnitResultFormatterAsRunListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.junitxml;
15 |
16 | import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
17 | import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
18 | import org.junit.runner.Description;
19 | import org.junit.runner.Result;
20 | import org.junit.runner.notification.Failure;
21 | import org.junit.runner.notification.RunListener;
22 |
23 | // copied from: https://github.com/cloudbees/junit-standalone-runner/blob/master
24 | // /src/main/java/com/cloudbees/junit/runner/App.java#L189-L260
25 | public class JUnitResultFormatterAsRunListener extends RunListener {
26 | protected final JUnitResultFormatter formatter;
27 | private String suiteName;
28 |
29 | public JUnitResultFormatterAsRunListener(JUnitResultFormatter formatter) {
30 | this.formatter = formatter;
31 | }
32 |
33 | @Override
34 | public void testRunStarted(Description description) throws Exception {
35 | suiteName = description.getDisplayName();
36 | formatter.startTestSuite(new JUnitTest(suiteName));
37 | }
38 |
39 | @Override
40 | public void testRunFinished(Result result) throws Exception {
41 | JUnitTest suite = new JUnitTest(suiteName);
42 | suite.setCounts(result.getRunCount(), result.getFailureCount(), 0);
43 | suite.setRunTime(result.getRunTime());
44 | formatter.endTestSuite(suite);
45 | }
46 |
47 | @Override
48 | public void testStarted(Description description) throws Exception {
49 | formatter.startTest(new DescriptionAsTest(description));
50 | }
51 |
52 | @Override
53 | public void testFinished(Description description) throws Exception {
54 | formatter.endTest(new DescriptionAsTest(description));
55 | }
56 |
57 | @Override
58 | public void testFailure(Failure failure) throws Exception {
59 | testAssumptionFailure(failure);
60 | }
61 |
62 | @Override
63 | public void testAssumptionFailure(Failure failure) {
64 | formatter.addError(new DescriptionAsTest(failure.getDescription()), failure.getException());
65 | }
66 |
67 | @Override
68 | public void testIgnored(Description description) throws Exception {
69 | super.testIgnored(description);
70 | }
71 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/model/Data.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.model;
15 |
16 | import java.util.List;
17 |
18 | public class Data {
19 |
20 | private List spans;
21 | private String traceID;
22 |
23 | public List getSpans() {
24 | return spans;
25 | }
26 |
27 | public String getTraceID() {
28 | return traceID;
29 | }
30 |
31 | public void setSpans(List spans) {
32 | this.spans = spans;
33 | }
34 |
35 | public void setTraceID(String traceID) {
36 | this.traceID = traceID;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/model/Jenkins.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.model;
15 |
16 | import java.text.SimpleDateFormat;
17 | import java.util.Date;
18 |
19 | import lombok.ToString;
20 |
21 | import lombok.Data;
22 |
23 | @Data
24 | @ToString
25 | public class Jenkins {
26 | private String buildDate;
27 | private String buildNumber;
28 | private String buildId;
29 | private String buildUrl;
30 | private String nodeName;
31 | private String jobName;
32 |
33 | public Jenkins() {
34 | update();
35 | }
36 |
37 | public void update() {
38 | buildDate = new SimpleDateFormat("YYYYMMdd").format(new Date());
39 | buildNumber = System.getenv("BUILD_NUMBER");
40 | buildId = System.getenv("BUILD_ID");
41 | buildUrl = System.getenv("BUILD_URL");
42 | nodeName = System.getenv("NODE_NAME");
43 | jobName = System.getenv("JOB_NAME");
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/model/Result.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.model;
15 |
16 | import java.util.List;
17 |
18 | public class Result {
19 |
20 | private List data;
21 |
22 | public List getData() {
23 | return data;
24 | }
25 |
26 | public void setData(List data) {
27 | this.data = data;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/model/Span.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.model;
15 |
16 | public class Span {
17 |
18 | private String operationName;
19 | private String spanID;
20 | private String traceID;
21 |
22 | public String getOperationName() {
23 | return operationName;
24 | }
25 |
26 | public String getSpanID() {
27 | return spanID;
28 | }
29 |
30 | public String getTraceID() {
31 | return traceID;
32 | }
33 |
34 | public void setOperationName(String operationName) {
35 | this.operationName = operationName;
36 | }
37 |
38 | public void setSpanID(String spanID) {
39 | this.spanID = spanID;
40 | }
41 |
42 | public void setTraceID(String traceID) {
43 | this.traceID = traceID;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/model/TestSuiteStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.model;
15 |
16 | import java.util.List;
17 |
18 | import org.junit.runner.Result;
19 | import org.junit.runner.notification.Failure;
20 |
21 | import lombok.AllArgsConstructor;
22 | import lombok.Builder;
23 | import lombok.Data;
24 | import lombok.NoArgsConstructor;
25 |
26 | @Builder
27 | @AllArgsConstructor
28 | @NoArgsConstructor
29 | @Data
30 | public class TestSuiteStatus {
31 | private String name;
32 | private Boolean wasSuccessful;
33 | private Integer failureCount;
34 | private Integer runCount;
35 | private Integer ignoreCount;
36 | private Long runTime;
37 | private List failures;
38 |
39 | public static TestSuiteStatus get(String name, Result testResult) {
40 | return TestSuiteStatus.builder()
41 | .name(name)
42 | .wasSuccessful(testResult.wasSuccessful())
43 | .runCount(testResult.getRunCount())
44 | .failureCount(testResult.getFailureCount())
45 | .ignoreCount(testResult.getIgnoreCount())
46 | .runTime(testResult.getRunTime())
47 | .failures(testResult.getFailures())
48 | .build();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/osutils/OSCommandExecuter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.osutils;
15 |
16 | import java.io.IOException;
17 | import java.nio.charset.StandardCharsets;
18 |
19 | import org.apache.commons.io.IOUtils;
20 | import org.apache.commons.lang3.exception.ExceptionUtils;
21 |
22 | import lombok.extern.slf4j.Slf4j;
23 |
24 | @Slf4j
25 | public class OSCommandExecuter {
26 |
27 | private OSResponse executeCommand(String... command) {
28 | OSResponse result = null;
29 | try {
30 | Process process = Runtime.getRuntime().exec(command);
31 | String input = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8.name());
32 | String error = IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8.name());
33 | result = OSResponse.builder()
34 | .result(input.length() > 0 ? input : null)
35 | .error(error.length() > 0 ? error : null)
36 | .build();
37 | } catch (Exception ex) {
38 | result = OSResponse.builder()
39 | .error(ExceptionUtils.getMessage(ex))
40 | .stackTrace(ExceptionUtils.getStackTrace(ex))
41 | .build();
42 | }
43 | return result;
44 | }
45 |
46 | public OSResponse executeLinuxCommand(String command) {
47 | return executeCommand("/bin/sh", "-c", command);
48 | }
49 |
50 | public OSResponse executeElasticsearchCmd(String esHost, Integer esPort, String request) throws IOException {
51 | String command = String.format(
52 | "curl --cacert /certs/ca --key /certs/key --cert /certs/cert https://%s:%d%s",
53 | esHost, esPort, request);
54 | OSResponse response = this.executeLinuxCommand(command);
55 | logger.debug("Command:{}, {}", command, response);
56 | return response;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/osutils/OSResponse.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.osutils;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Builder;
18 | import lombok.Data;
19 | import lombok.NoArgsConstructor;
20 | import lombok.ToString;
21 |
22 | @Data
23 | @Builder
24 | @NoArgsConstructor
25 | @AllArgsConstructor
26 | @ToString
27 | public class OSResponse {
28 | private String result;
29 | private String error;
30 | private String stackTrace;
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/ReportFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report;
15 |
16 | import java.util.HashMap;
17 | import java.util.HashSet;
18 | import java.util.Set;
19 | import java.util.concurrent.TimeUnit;
20 |
21 | import org.junit.runner.Result;
22 |
23 | import com.codahale.metrics.MetricAttribute;
24 | import com.codahale.metrics.MetricRegistry;
25 | import com.codahale.metrics.Timer;
26 |
27 | import io.jaegertracing.tests.ReportEngineUtils;
28 |
29 | import io.jaegertracing.client.Version;
30 | import io.jaegertracing.tests.JsonUtils;
31 | import io.jaegertracing.tests.model.TestConfig;
32 | import io.jaegertracing.tests.model.TestSuiteStatus;
33 | import io.jaegertracing.tests.report.model.JaegerTestReport;
34 |
35 | public class ReportFactory {
36 | // final report
37 | private static final JaegerTestReport TEST_REPORT = JaegerTestReport.builder().build();
38 |
39 | private static final MetricRegistry METRICS_REGISTRY = new MetricRegistry();
40 |
41 | private static TestConfig testConfig = null;
42 |
43 | private static long spanCountSent = -1;
44 | private static long spanCountFound = -1;
45 | private static long spanCountSentByQuery = 0;
46 | private static long spansLatency = 0;
47 |
48 | public static TestConfig testConfig() {
49 | if (testConfig == null) {
50 | testConfig = TestConfig.get();
51 | }
52 | return testConfig;
53 | }
54 |
55 | public static JaegerTestReport getFinalReport(TestConfig config) {
56 | updateReport(config);
57 | return TEST_REPORT;
58 | }
59 |
60 | public static String getReSuiteId() {
61 | return TEST_REPORT.getId();
62 | }
63 |
64 | public static String getReporterReference() {
65 | return System.getenv("REPORTER_REFERENCE");
66 | }
67 |
68 | public static String getFinalReportAsString(TestConfig config) {
69 | updateReport(config);
70 | return JsonUtils.asString(TEST_REPORT);
71 | }
72 |
73 | public static void saveFinalReport(TestConfig config, String filename) {
74 | updateReport(config);
75 | // save it in file
76 | JsonUtils.dumps(TEST_REPORT, filename);
77 | }
78 |
79 | public static Timer timer(String name) {
80 | return METRICS_REGISTRY.timer(name);
81 | }
82 |
83 | public static void triggeredJaegerApiQuery() {
84 | long spansCount = 0;
85 | if (TEST_REPORT.getData().getConfig().getUseInternalReporter()) {
86 | // number of samples * number of spans for per trigger * spans per query
87 | spansCount = TEST_REPORT.getData().getConfig().getQuerySamples() * 12L * 5L;
88 | } else {
89 | // number of query host * number of samples * number of spans for per trigger * spans per query
90 | spansCount = TEST_REPORT.getData().getConfig().getNodeCountQueryRunner()
91 | * TEST_REPORT.getData().getConfig().getQuerySamples() * 12L * 5L;
92 | }
93 | spanCountSentByQuery += spansCount;
94 | }
95 |
96 | private static void updateReport(TestConfig config) {
97 | // add test configurations
98 | TEST_REPORT.getData().setConfig(config);
99 |
100 | // update custom labels
101 | TEST_REPORT.getLabels().putAll(ReportEngineUtils.labels(config.getReportEngineLabel()));
102 |
103 | // update Jaeger java client version
104 | TEST_REPORT.getData().getConfig().setJaegerClientVersion(Version.get());
105 |
106 | // disable metric attributes
107 | Set disabledMetric = new HashSet<>();
108 | disabledMetric.add(MetricAttribute.MEAN_RATE);
109 | disabledMetric.add(MetricAttribute.M1_RATE);
110 | disabledMetric.add(MetricAttribute.M5_RATE);
111 | disabledMetric.add(MetricAttribute.M15_RATE);
112 |
113 | // update metrics
114 | TEST_REPORT.getData().setMetric(
115 | JsonReporter.forRegistry(METRICS_REGISTRY)
116 | .convertDurationsTo(TimeUnit.MILLISECONDS)
117 | .convertRatesTo(TimeUnit.SECONDS)
118 | .disabledMetricAttributes(disabledMetric)
119 | .build().getReport());
120 |
121 | // update count statistics
122 | TEST_REPORT.getData().setSpansCountStatistics(new HashMap());
123 | TEST_REPORT.getData().getSpansCountStatistics().put("sent", getSpansSent());
124 | TEST_REPORT.getData().getSpansCountStatistics().put("sent_by_reporer", spanCountSent);
125 | TEST_REPORT.getData().getSpansCountStatistics().put("sent_by_query", spanCountSentByQuery);
126 | TEST_REPORT.getData().getSpansCountStatistics().put("found", spanCountFound);
127 |
128 | TEST_REPORT.getData().getSpansCountStatistics().put("spansLatency", spansLatency);
129 |
130 | long dropped_count = getDroupCount();
131 | double dropped_percentage = getDroupPercentage();
132 |
133 | TEST_REPORT.getData().getSpansCountStatistics().put("dropped_count", dropped_count);
134 | TEST_REPORT.getData().getSpansCountStatistics().put("dropped_percentage",
135 | dropped_percentage < 0 ? 0 : Math.round(dropped_percentage * 100.0) / 100.0);
136 |
137 | final int spansPersecond = getSpansPerSecond(config);
138 | TEST_REPORT.getData().getSpansCountStatistics().put("per_second", spansPersecond);
139 | TEST_REPORT.getData().getSpansCountStatistics()
140 | .put("per_minute", spansPersecond != -1 ? spansPersecond * 60 : -1);
141 | }
142 |
143 | public static int getSpansPerSecond(TestConfig config) {
144 | final int spansPersecond;
145 | if (config.getUseInternalReporter()) {
146 | spansPersecond = config.getNumberOfTracers() * config.getNumberOfSpans();
147 | } else {
148 | spansPersecond = config.getNodeCountSpansReporter() * config.getNumberOfTracers()
149 | * config.getNumberOfSpans();
150 | }
151 | return spansPersecond;
152 | }
153 |
154 | public static void updateSpansCountByReporter(long expected) {
155 | spanCountSent = expected;
156 | }
157 |
158 | public static void updateSpansCount(long sent, long found) {
159 | spanCountSent = sent;
160 | spanCountFound = found;
161 | }
162 |
163 | public static void updateSpansLatency(long latency) {
164 | spansLatency = latency;
165 | }
166 |
167 | public static long getDroupCount() {
168 | return getSpansSent() - spanCountFound;
169 | }
170 |
171 | public static double getDroupPercentage() {
172 | return ((double) getDroupCount() / getSpansSent()) * 100.0;
173 | }
174 |
175 | public static long getSpansSent() {
176 | return spanCountSent + spanCountSentByQuery;
177 | }
178 |
179 | public static long getSpansFound() {
180 | return spanCountFound;
181 | }
182 |
183 | public static void updateTestSuiteStatus(String name, Result testResult) {
184 | if (TEST_REPORT.getData().getTestSuiteStatus() == null) {
185 | TEST_REPORT.getData().setTestSuiteStatus(new HashMap<>());
186 | }
187 | TEST_REPORT.getData().getTestSuiteStatus().put(name, TestSuiteStatus.get(name, testResult));
188 | }
189 |
190 | public static TestSuiteStatus gettestSuiteStatus(String name) {
191 | if (TEST_REPORT.getData().getTestSuiteStatus() == null) {
192 | TEST_REPORT.getData().setTestSuiteStatus(new HashMap<>());
193 | }
194 | return TEST_REPORT.getData().getTestSuiteStatus().get(name);
195 | }
196 | }
197 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/BaseModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Builder;
18 | import lombok.Data;
19 | import lombok.NoArgsConstructor;
20 | import lombok.ToString;
21 |
22 | @Builder
23 | @NoArgsConstructor
24 | @AllArgsConstructor
25 | @Data
26 | @ToString
27 | public class BaseModel {
28 | private String name;
29 | private String key;
30 | private Object value;
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/HistogramModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import java.util.Map;
17 |
18 | import lombok.AllArgsConstructor;
19 | import lombok.Builder;
20 | import lombok.Data;
21 | import lombok.NoArgsConstructor;
22 | import lombok.ToString;
23 |
24 | @Builder
25 | @NoArgsConstructor
26 | @AllArgsConstructor
27 | @Data
28 | @ToString
29 | public class HistogramModel {
30 | private String name;
31 | private Long count;
32 | private Map histogram;
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/JaegerTestReport.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 | import java.util.UUID;
19 |
20 | import lombok.Builder.Default;
21 | import lombok.AllArgsConstructor;
22 | import lombok.Builder;
23 | import lombok.Data;
24 | import lombok.NoArgsConstructor;
25 | import lombok.ToString;
26 |
27 | @Builder
28 | @NoArgsConstructor
29 | @AllArgsConstructor
30 | @ToString
31 | @Data
32 | public class JaegerTestReport {
33 | private String id;
34 | @Default
35 | private String name = "jaegerqe-performance-data";
36 | @Default
37 | private String type = "jaegerqe-performance-test";
38 | @Default
39 | private Boolean ready = false;
40 | @Default
41 | private Map labels = new HashMap<>();
42 | @Default
43 | private TestData data = new TestData();
44 |
45 | public String getId() {
46 | if (id == null) {
47 | id = UUID.randomUUID().toString();
48 | }
49 | return id;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/MeterModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import java.util.Map;
17 |
18 | import lombok.AllArgsConstructor;
19 | import lombok.Builder;
20 | import lombok.Data;
21 | import lombok.NoArgsConstructor;
22 | import lombok.ToString;
23 |
24 | @Builder
25 | @NoArgsConstructor
26 | @AllArgsConstructor
27 | @Data
28 | @ToString
29 | public class MeterModel {
30 | private String name;
31 | private Long count;
32 | private Map meter;
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/MetricReport.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import lombok.Data;
20 |
21 | import lombok.NoArgsConstructor;
22 | import lombok.ToString;
23 |
24 | @ToString
25 | @Data
26 | @NoArgsConstructor
27 | public class MetricReport {
28 | private List timers = new ArrayList<>();
29 | private List meters = new ArrayList<>();
30 | private List histograms = new ArrayList<>();
31 | private List counters = new ArrayList<>();
32 | private List gauges = new ArrayList<>();
33 | private JaegerMetrics jaegerMetrics = new JaegerMetrics();
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/TestData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | import lombok.Builder.Default;
20 |
21 | import lombok.ToString;
22 | import lombok.AllArgsConstructor;
23 | import lombok.NoArgsConstructor;
24 | import lombok.Builder;
25 | import lombok.Data;
26 | import io.jaegertracing.tests.model.TestConfig;
27 | import io.jaegertracing.tests.model.TestSuiteStatus;
28 |
29 | @Data
30 | @Builder
31 | @NoArgsConstructor
32 | @AllArgsConstructor
33 | @ToString
34 | public class TestData {
35 | private TestConfig config;
36 | @Default
37 | private Map esData = new HashMap<>();
38 | private MetricReport metric;
39 | private Map spansCountStatistics;
40 | private Map testSuiteStatus;
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/report/model/TimerModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.report.model;
15 |
16 | import java.util.Map;
17 |
18 | import lombok.AllArgsConstructor;
19 | import lombok.Builder;
20 | import lombok.Data;
21 | import lombok.NoArgsConstructor;
22 | import lombok.ToString;
23 |
24 | @Builder
25 | @NoArgsConstructor
26 | @AllArgsConstructor
27 | @Data
28 | @ToString
29 | public class TimerModel {
30 | private String name;
31 | private Long count;
32 | private Map rate;
33 | private Map duration;
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/resourcemonitor/MetricUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.resourcemonitor;
15 |
16 | import java.util.List;
17 | import java.util.Map;
18 |
19 | import org.hawkular.agent.prometheus.types.Counter;
20 | import org.hawkular.agent.prometheus.types.Gauge;
21 | import org.hawkular.agent.prometheus.types.Metric;
22 | import org.hawkular.agent.prometheus.types.MetricFamily;
23 | import org.hawkular.agent.prometheus.types.MetricType;
24 |
25 | import lombok.AccessLevel;
26 | import lombok.NoArgsConstructor;
27 |
28 | @NoArgsConstructor(access = AccessLevel.PRIVATE)
29 | public class MetricUtils {
30 |
31 | public static long getCounterValue(List families, String prefix) {
32 | return getCounterValue(families, prefix, null);
33 | }
34 |
35 | public static long getCounterValue(List families, String prefix, Map labelFilter) {
36 | Double value = 0.0;
37 | for (MetricFamily family : families) {
38 | if (family.getName().equals(prefix) && family.getType() == MetricType.COUNTER) {
39 | for (Metric metric : family.getMetrics()) {
40 | Counter counter = (Counter) metric;
41 | if (labelFilter != null) {
42 | boolean include = true;
43 | Map labels = metric.getLabels();
44 | for (String key : labelFilter.keySet()) {
45 | if (labels.get(key) == null || !labels.get(key).equals(labelFilter.get(key))) {
46 | include = false;
47 | break;
48 | }
49 | }
50 | if (include) {
51 | value += counter.getValue();
52 | }
53 | } else {
54 | value += counter.getValue();
55 | }
56 | }
57 | break;
58 | }
59 | }
60 | return value.longValue();
61 | }
62 |
63 | public static Double getGaugeValue(List families, String prefix) {
64 | return getGaugeValue(families, prefix, null);
65 | }
66 |
67 | public static Double getGaugeValue(List families, String prefix, Map labelFilter) {
68 | for (MetricFamily family : families) {
69 | if (family.getName().equals(prefix) && family.getType() == MetricType.GAUGE) {
70 | for (Metric metric : family.getMetrics()) {
71 | Gauge gauge = (Gauge) metric;
72 | if (labelFilter != null) {
73 | Map labels = metric.getLabels();
74 | for (String key : labelFilter.keySet()) {
75 | if (labels.get(key) == null || !labels.get(key).equals(labelFilter.get(key))) {
76 | return gauge.getValue();
77 | }
78 | }
79 | } else {
80 | return gauge.getValue();
81 | }
82 | }
83 | break;
84 | }
85 | }
86 | return new Double(0.0);
87 | }
88 |
89 | public static String getLabel(List families, String prefix, String labelKey) {
90 | for (MetricFamily family : families) {
91 | if (family.getName().equals(prefix)) {
92 | for (Metric metric : family.getMetrics()) {
93 | if (metric.getLabels().containsKey(labelKey)) {
94 | return metric.getLabels().get(labelKey);
95 | }
96 | }
97 | }
98 | }
99 | return null;
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/resourcemonitor/ReMetric.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.resourcemonitor;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | import lombok.ToString;
20 | import lombok.Getter;
21 | import lombok.Builder;
22 | import lombok.Builder.Default;
23 |
24 | @Builder
25 | @Getter
26 | @ToString
27 | public class ReMetric {
28 | private String suiteId;
29 | private String measurementSuffix;
30 | private Long timestamp;
31 | @Default
32 | private Map labels = new HashMap<>();
33 | @Default
34 | private Map data = new HashMap<>();
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/QESpan.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke;
15 |
16 | import java.time.Instant;
17 | import java.util.HashMap;
18 | import java.util.Map;
19 | import java.util.concurrent.TimeUnit;
20 |
21 | import com.fasterxml.jackson.databind.JsonNode;
22 |
23 | import io.opentracing.tag.Tag;
24 |
25 | import io.opentracing.Span;
26 | import io.opentracing.SpanContext;
27 |
28 | public class QESpan implements Span {
29 | private Map tags = new HashMap();
30 | private Long start;
31 | private Long duration;
32 | private String operation;
33 | private String id;
34 | private QESpan parent;
35 | private Span span;
36 | private JsonNode json;
37 |
38 | private QESpan(Builder builder) {
39 | this.tags = builder.tags;
40 | this.start = builder.start;
41 | this.duration = builder.duration;
42 | this.operation = builder.operation;
43 | this.id = builder.id;
44 | this.parent = builder.parent;
45 | this.span = builder.span;
46 | this.json = builder.json;
47 | }
48 |
49 | public static class Builder {
50 | // Required parameters
51 | private Map tags = new HashMap();
52 | private Long start;
53 | private Long duration;
54 | private String operation;
55 | private String id;
56 |
57 | // Optional
58 | private Span span;
59 | private QESpan parent;
60 | private JsonNode json;
61 |
62 | public Builder(Map tags, Long start, Long duration, String operation, String id) {
63 | this.tags = tags;
64 | this.start = start;
65 | this.duration = duration;
66 | this.operation = operation;
67 | this.id = id;
68 | }
69 |
70 | public Builder parent(QESpan parent) {
71 | this.parent = parent;
72 | return this;
73 | }
74 |
75 | public Builder span(Span span) {
76 | this.span = span;
77 | return this;
78 | }
79 |
80 | public Builder json(JsonNode json) {
81 | this.json = json;
82 | return this;
83 | }
84 |
85 | public QESpan build() {
86 | return new QESpan(this);
87 | }
88 |
89 | }
90 |
91 | public Span setOperationName(String operation) {
92 | this.operation = operation;
93 | return this;
94 | }
95 |
96 | public Span setTag(String name, String value) {
97 | this.tags.put(name, value);
98 | return this;
99 | }
100 |
101 | public Span setTag(String name, boolean value) {
102 | this.tags.put(name, value);
103 | return this;
104 | }
105 |
106 | public Span setTag(String name, Number value) {
107 | this.tags.put(name, value);
108 | return this;
109 | }
110 |
111 | @Override
112 | public Span log(Map fields) {
113 | span.log(fields);
114 | return this;
115 | }
116 |
117 | @Override
118 | public Span log(long timestampMicroseconds, Map fields) {
119 | span.log(timestampMicroseconds, fields);
120 | return this;
121 | }
122 |
123 | @Override
124 | public Span log(String event) {
125 | span.log(event);
126 | return this;
127 | }
128 |
129 | @Override
130 | public Span log(long timestampMicroseconds, String event) {
131 | span.log(timestampMicroseconds, event);
132 | return this;
133 | }
134 |
135 | @Override
136 | public Span setBaggageItem(String key, String value) {
137 | span.setBaggageItem(key, value);
138 | return this;
139 | }
140 |
141 | @Override
142 | public String getBaggageItem(String key) {
143 | return span.getBaggageItem(key);
144 | }
145 |
146 | @Override
147 | public void finish(long end) {
148 | if (span != null) {
149 | span.finish(end);
150 | }
151 | }
152 |
153 | @Override
154 | public void finish() {
155 | finish(TimeUnit.MILLISECONDS.toMicros(Instant.now().toEpochMilli()));
156 | }
157 |
158 | @Override
159 | public SpanContext context() {
160 | return span.context();
161 | }
162 |
163 | public Long getDuration() {
164 | return duration;
165 | }
166 |
167 | public JsonNode getJson() {
168 | return json;
169 | }
170 |
171 | public Map getTags() {
172 | return tags;
173 | }
174 |
175 | public Long getStart() {
176 | return start;
177 | }
178 |
179 | public String getOperation() {
180 | return operation;
181 | }
182 |
183 | public String getId() {
184 | return id;
185 | }
186 |
187 | public QESpan getParent() {
188 | return parent;
189 | }
190 |
191 | public Span getspan() {
192 | return span;
193 | }
194 |
195 | @Override
196 | public boolean equals(Object obj) {
197 | if (obj == null || !QESpan.class.isAssignableFrom(obj.getClass())) {
198 | return false;
199 | }
200 | final QESpan other = (QESpan) obj;
201 | if (!getOperation().equals(other.getOperation())) {
202 | return false;
203 | }
204 | if (getStart().compareTo(other.getStart()) != 0) {
205 | return false;
206 | }
207 | if (getDuration().compareTo(other.getDuration()) != 0) {
208 | return false;
209 | }
210 | if (!getTags().keySet().equals(other.getTags().keySet())) {
211 | return false;
212 | }
213 | for (String name : getTags().keySet()) {
214 | if (getTags().get(name) instanceof Number) {
215 | if (!getTags().get(name).toString().equals(other.getTags().get(name).toString())) {
216 | return false;
217 | }
218 | } else if (tags.get(name) instanceof Boolean) {
219 | if (getTags().get(name) != other.getTags().get(name)) {
220 | return false;
221 | }
222 | } else {
223 | if (!getTags().get(name).equals(other.getTags().get(name))) {
224 | return false;
225 | }
226 | }
227 | }
228 | return true;
229 | }
230 |
231 | @Override
232 | public int hashCode() {
233 | int result = 17;
234 | result = 31 * result + operation.hashCode();
235 | return result;
236 | }
237 |
238 | @Override
239 | public String toString() {
240 | return "QESpan{" +
241 | "tags=" + tags +
242 | ", start=" + start +
243 | ", duration=" + duration +
244 | ", operation='" + operation + '\'' +
245 | ", id='" + id + '\'' +
246 | ", parent=" + parent +
247 | ", span=" + span +
248 | ", json=" + json +
249 | '}';
250 | }
251 |
252 | @Override
253 | public Span setTag(Tag arg0, T arg1) {
254 | // TODO Auto-generated method stub
255 | return null;
256 | }
257 |
258 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/SimpleRestClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke;
15 |
16 | import static org.awaitility.Awaitility.await;
17 |
18 | import java.io.Closeable;
19 | import java.io.IOException;
20 | import java.time.Instant;
21 | import java.util.ArrayList;
22 | import java.util.Iterator;
23 | import java.util.List;
24 | import java.util.concurrent.TimeUnit;
25 |
26 | import com.fasterxml.jackson.core.JsonProcessingException;
27 | import com.fasterxml.jackson.databind.JsonNode;
28 | import com.fasterxml.jackson.databind.ObjectMapper;
29 | import com.fasterxml.jackson.databind.ObjectWriter;
30 |
31 | import io.jaegertracing.tests.model.TestConfig;
32 | import lombok.extern.slf4j.Slf4j;
33 | import okhttp3.OkHttpClient;
34 | import okhttp3.Request;
35 | import okhttp3.Response;
36 |
37 | @Slf4j
38 | public class SimpleRestClient implements Closeable {
39 |
40 | TestConfig config = TestConfig.get();
41 | private ObjectMapper jsonObjectMapper = new ObjectMapper();
42 | private OkHttpClient okClient;
43 |
44 | public SimpleRestClient() {
45 | okClient = new OkHttpClient.Builder()
46 | .readTimeout(60, TimeUnit.SECONDS)
47 | .build();
48 | }
49 |
50 | /**
51 | * GET all traces for a service: http://localhost:3001/api/traces?service=something
52 | * GET a Trace by id: http://localhost:3001/api/traces/23652df68bd54e15
53 | * GET services http://localhost:3001/api/services
54 | *
55 | * GET after a specific time: http://localhost:3001/api/traces?service=something&start=1492098196598
56 | * NOTE: time is in MICROseconds.
57 | *
58 | */
59 | private List getTraces(String parameters) {
60 | List traces = new ArrayList<>();
61 | String targetUrl = "http://" + config.getJaegerQueryHost() + ":"
62 | + config.getJaegerQueryPort() + "/api/traces?service="
63 | + TestBase.SMOKE_TEST_SERVICE_NAME;
64 | if (parameters != null && !parameters.trim().isEmpty()) {
65 | targetUrl = targetUrl + "&" + parameters;
66 | }
67 |
68 | logger.debug("GETTING TRACES: " + targetUrl);
69 | try {
70 | Request request = new Request.Builder().url(targetUrl).build();
71 | Response response = okClient.newCall(request).execute();
72 | String result = response.body().string();
73 |
74 | JsonNode jsonPayload = jsonObjectMapper.readTree(result);
75 | JsonNode data = jsonPayload.get("data");
76 | Iterator traceIterator = data.iterator();
77 | while (traceIterator.hasNext()) {
78 | traces.add(traceIterator.next());
79 | }
80 | } catch (IOException ex) {
81 | // TODO what is the best thing to do here
82 | throw new RuntimeException(ex);
83 | }
84 |
85 | return traces;
86 | }
87 |
88 | /**
89 | *
90 | * @param parameters Parameter string to be appended to REST call
91 | * @param expectedTraceCount expected number of traces
92 | * @return a List of traces returned from the Jaeger Query API
93 | */
94 | public List getTraces(final String parameters, final int expectedTraceCount) {
95 | waitForFlush();
96 | List traces = new ArrayList<>();
97 | try {
98 | await().atMost(60, TimeUnit.SECONDS)
99 | .pollInterval(2, TimeUnit.SECONDS)
100 | .pollDelay(0, TimeUnit.SECONDS)
101 | .until(() -> {
102 | List _traces = getTraces(parameters);
103 | logger.debug("Number of traces:{}, parameters:{}", _traces.size(), parameters);
104 | return (_traces.size() >= expectedTraceCount);
105 | });
106 | return getTraces(parameters);
107 | } catch (Exception ex) {
108 | logger.error("Exception,", ex);
109 | }
110 |
111 | return traces;
112 | }
113 |
114 | /**
115 | * Return all of the traces created since the start time given. NOTE: The Jaeger Rest API
116 | * requires a time in microseconds.
117 | *
118 | * @param testStartTime time the test started
119 | * @return A List of Traces created after the time specified.
120 | */
121 | public List getTracesSinceTestStart(Instant testStartTime, int expectedTraceCount) {
122 | long startTime = TimeUnit.MILLISECONDS.toMicros(testStartTime.toEpochMilli());
123 | List traces = getTraces("start=" + startTime, expectedTraceCount);
124 | return traces;
125 | }
126 |
127 | /**
128 | * Return all of the traces created between the start and end times given. NOTE: The Jaeger Rest API requires times
129 | * in microseconds.
130 | *
131 | * @param testStartTime start time
132 | * @param testEndTime end time
133 | * @return A List of traces created between the times specified.
134 | */
135 | public List getTracesBetween(Instant testStartTime, Instant testEndTime, int expectedTraceCount) {
136 | long startTime = TimeUnit.MILLISECONDS.toMicros(testStartTime.toEpochMilli());
137 | long endTime = TimeUnit.MILLISECONDS.toMicros(testEndTime.toEpochMilli());
138 | String parameters = "start=" + startTime + "&end=" + endTime;
139 | List traces = getTraces(parameters, expectedTraceCount);
140 | return traces;
141 | }
142 |
143 | /**
144 | * Make sure spans are flushed before trying to retrieve them
145 | */
146 | public void waitForFlush() {
147 | try {
148 | Thread.sleep(config.getJaegerClientFlushInterval());
149 | } catch (InterruptedException e) {
150 | logger.warn("Sleep interrupted", e);
151 | }
152 | }
153 |
154 | /**
155 | * Return a formatted JSON String
156 | * @param json Some json that you want to format
157 | * @return pretty formatted json
158 | */
159 | public String prettyPrintJson(JsonNode json) {
160 | String pretty = "";
161 | try {
162 | ObjectWriter writer = jsonObjectMapper.writerWithDefaultPrettyPrinter();
163 | pretty = writer.writeValueAsString(json);
164 | } catch (JsonProcessingException jpe) {
165 | logger.error("prettyPrintJson Failed", jpe);
166 | }
167 |
168 | return pretty;
169 | }
170 |
171 | /**
172 | * Debugging method
173 | *
174 | * @param traces A list of traces to print
175 | */
176 | protected void dumpAllTraces(List traces) {
177 | logger.info("Got " + traces.size() + " traces");
178 |
179 | for (JsonNode trace : traces) {
180 | logger.info("------------------ Trace {} ------------------", trace.get("traceID"));
181 | Iterator spanIterator = trace.get("spans").iterator();
182 | while (spanIterator.hasNext()) {
183 | JsonNode span = spanIterator.next();
184 | logger.debug(prettyPrintJson(span)); // TODO does this work?
185 | }
186 | }
187 | }
188 |
189 | @Override
190 | public void close() throws IOException {
191 | if (okClient != null) {
192 | okClient.dispatcher().executorService().shutdown();
193 | okClient.connectionPool().evictAll();
194 | }
195 | }
196 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/TestBase.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 |
19 | import java.time.Instant;
20 | import java.util.ArrayList;
21 | import java.util.HashMap;
22 | import java.util.Iterator;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.concurrent.ThreadLocalRandom;
26 |
27 | import org.junit.AssumptionViolatedException;
28 | import org.junit.Before;
29 | import org.junit.Rule;
30 | import org.junit.rules.TestRule;
31 | import org.junit.rules.TestWatcher;
32 | import org.junit.runner.Description;
33 |
34 | import com.fasterxml.jackson.databind.JsonNode;
35 |
36 | import io.jaegertracing.Configuration.SenderConfiguration;
37 | import io.jaegertracing.internal.JaegerTracer;
38 | import io.jaegertracing.internal.reporters.RemoteReporter;
39 | import io.jaegertracing.internal.samplers.ProbabilisticSampler;
40 | import io.jaegertracing.spi.Sampler;
41 | import io.jaegertracing.tests.model.TestConfig;
42 | import io.opentracing.Tracer;
43 | import lombok.extern.slf4j.Slf4j;
44 |
45 | @Slf4j
46 | public class TestBase {
47 | public SimpleRestClient simpleRestClient = new SimpleRestClient();
48 | protected Instant testStartTime = null;
49 | private static Tracer tracer = null;
50 | private static String endpoint = null;
51 | public static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();
52 |
53 | protected TestConfig config = TestConfig.get();
54 |
55 | public static final String SMOKE_TEST_SERVICE_NAME = "smoke_test";
56 |
57 | @Rule
58 | public TestRule watcher = new TestWatcher() {
59 | protected void failed(Throwable ex, Description description) {
60 | logger.info("*** Test[FAILED]: {} ***", ex, description.getMethodName());
61 | }
62 |
63 | protected void finished(Description description) {
64 | logger.info("*** Test[FINISHED]: {} ***", description.getMethodName());
65 | }
66 |
67 | protected void skipped(AssumptionViolatedException ex, Description description) {
68 | logger.info("*** Test[SKIPPED]: {} ***", ex, description.getMethodName());
69 | }
70 |
71 | protected void starting(Description description) {
72 | logger.info("*** Test[STARTING]: {} ***", description.getMethodName());
73 | }
74 |
75 | protected void succeeded(Description description) {
76 | logger.info("*** Test[SUCCEEDED]: {} ***", description.getMethodName());
77 | }
78 | };
79 |
80 | @Before
81 | public void updateTestStartTime() {
82 | testStartTime = Instant.now();
83 | sleep(10);
84 | }
85 |
86 | /**
87 | *
88 | * @param tags Map of tags from a span
89 | * @param key name of the tag we want to check
90 | * @param expectedValue expected value of that tag
91 | */
92 | public void myAssertTag(Map tags, String key, Object expectedValue) {
93 | assertTrue("Could not find key: " + key, tags.containsKey(key));
94 | Object actualValue = tags.get(key);
95 | assertEquals("Wrong value for key " + key + " expected " + expectedValue.toString(), expectedValue,
96 | actualValue);
97 | }
98 |
99 | public Tracer tracer() {
100 | String _endpoint = System.getProperty("ENDPOINT");
101 | if (_endpoint == null) {
102 | _endpoint = config.getSender().equalsIgnoreCase("http") ? "collector" : "agent";
103 | }
104 | if (tracer == null || endpoint == null || !endpoint.equalsIgnoreCase(_endpoint)) {
105 | SenderConfiguration conf = null;
106 | endpoint = _endpoint;
107 |
108 | if (endpoint.equalsIgnoreCase("collector")) {
109 | String httpEndpoint = "http://" + config.getJaegerCollectorHost() + ":"
110 | + config.getJaegerCollectorPort() + "/api/traces";
111 | logger.info("Using collector endpoint [" + httpEndpoint + "]");
112 | conf = new SenderConfiguration()
113 | .withEndpoint(httpEndpoint);
114 | } else {
115 | logger.info("Using JAEGER agent on host " + config.getJaegerAgentHost() + " port "
116 | + config.getJaegerAgentPort());
117 | conf = new SenderConfiguration()
118 | .withAgentHost(config.getJaegerAgentHost())
119 | .withAgentPort(config.getJaegerAgentPort());
120 | }
121 | RemoteReporter remoteReporter = new RemoteReporter.Builder()
122 | .withSender(conf.getSender())
123 | .withFlushInterval(config.getJaegerClientFlushInterval())
124 | .build();
125 |
126 | Sampler sampler = new ProbabilisticSampler(config.getJaegerSamplingRate());
127 | tracer = new JaegerTracer.Builder(SMOKE_TEST_SERVICE_NAME)
128 | .withReporter(remoteReporter)
129 | .withSampler(sampler)
130 | .build();
131 | }
132 | return tracer;
133 | }
134 |
135 | public void waitForFlush() {
136 | sleep(config.getJaegerClientFlushInterval() + 1000L);
137 | }
138 |
139 | public void sleep(long milliseconds) {
140 | try {
141 | //logger.debug("Sleeping {} ms", milliseconds);
142 | Thread.sleep(milliseconds);
143 | } catch (InterruptedException ex) {
144 | logger.error("Exception,", ex);
145 | }
146 | }
147 |
148 | /**
149 | *
150 | * @param spans List of spans from a given trace
151 | * @param targetOperationName the operation name of the span we're looking for
152 | * @return A Span with the specified operation name
153 | */
154 | public QESpan getSpanByOperationName(List spans, String targetOperationName) {
155 | for (QESpan s : spans) {
156 | if (s.getOperation().equals(targetOperationName)) {
157 | return s;
158 | }
159 | }
160 | return null;
161 | }
162 |
163 | /**
164 | * Convert all JSON Spans in the trace returned by the Jaeeger Rest API to QESpans
165 | **
166 | * @param trace A single trace
167 | * @return A list of all spans contained in this trace
168 | */
169 | public List getSpansFromTrace(JsonNode trace) {
170 | List spans = new ArrayList<>();
171 | Iterator spanIterator = trace.get("spans").iterator();
172 |
173 | while (spanIterator.hasNext()) {
174 | JsonNode jsonSpan = spanIterator.next();
175 | QESpan span = createSpanFromJsonNode(jsonSpan);
176 | spans.add(span);
177 | }
178 | return spans;
179 | }
180 |
181 | /**
182 | * Convert a Span in JSON returned from the Jaeger REST API to a QESpan
183 | * @param jsonSpan JSON representation of a span from a trace
184 | * @return A QESpan build from the given json
185 | */
186 | public QESpan createSpanFromJsonNode(JsonNode jsonSpan) {
187 | Map tags = new HashMap<>();
188 |
189 | JsonNode jsonTags = jsonSpan.get("tags");
190 | Iterator jsonTagsIterator = jsonTags.iterator();
191 | while (jsonTagsIterator.hasNext()) {
192 | JsonNode jsonTag = jsonTagsIterator.next();
193 | String key = jsonTag.get("key").asText();
194 | String tagType = jsonTag.get("type").asText();
195 | switch (tagType) {
196 | case "bool":
197 | boolean b = jsonTag.get("value").asBoolean();
198 | tags.put(key, b);
199 | break;
200 | case "float64":
201 | Number n = jsonTag.get("value").asDouble();
202 | tags.put(key, n);
203 | break;
204 | case "int64":
205 | Integer i = jsonTag.get("value").asInt();
206 | tags.put(key, i);
207 | break;
208 | case "string":
209 | String s = jsonTag.get("value").asText();
210 | tags.put(key, s);
211 | break;
212 | default:
213 | throw new RuntimeException("Unknown tag type [" + tagType + "[");
214 | }
215 | }
216 |
217 | Long start = jsonSpan.get("startTime").asLong();
218 | Long duration = jsonSpan.get("duration").asLong();
219 | String operation = jsonSpan.get("operationName").textValue();
220 | String id = jsonSpan.get("spanID").textValue();
221 |
222 | QESpan qeSpan = new QESpan.Builder(tags, start, duration, operation, id)
223 | .json(jsonSpan)
224 | .build();
225 | return qeSpan;
226 | }
227 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/TestSuiteSmoke.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke;
15 |
16 | import org.junit.AfterClass;
17 | import org.junit.BeforeClass;
18 | import org.junit.runner.RunWith;
19 | import org.junit.runners.Suite;
20 | import org.junit.runners.Suite.SuiteClasses;
21 |
22 | import io.jaegertracing.tests.smoke.tests.IndexCleanerTest;
23 |
24 | import io.jaegertracing.tests.smoke.tests.BasicSpanTest;
25 | import io.jaegertracing.tests.smoke.tests.FirstJaegerTest;
26 | import io.jaegertracing.tests.smoke.tests.SimpleUITest;
27 | import io.jaegertracing.tests.smoke.tests.TagAndDurationTest;
28 |
29 | @RunWith(Suite.class)
30 | @SuiteClasses({
31 | BasicSpanTest.class,
32 | FirstJaegerTest.class,
33 | SimpleUITest.class,
34 | TagAndDurationTest.class,
35 | IndexCleanerTest.class
36 | })
37 | public class TestSuiteSmoke {
38 |
39 | public static final String SUITE_NAME = "smoke_test";
40 |
41 | @BeforeClass
42 | public static void setUp() throws Exception {
43 | // setting up
44 | }
45 |
46 | @AfterClass
47 | public static void tearDown() {
48 | // tearing down
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/tests/BasicSpanTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke.tests;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertNotNull;
18 |
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | import org.junit.Test;
23 |
24 | import com.fasterxml.jackson.databind.JsonNode;
25 |
26 | import io.jaegertracing.tests.smoke.QESpan;
27 | import io.jaegertracing.tests.smoke.TestBase;
28 | import io.opentracing.Span;
29 | import lombok.extern.slf4j.Slf4j;
30 |
31 | /**
32 | * @author Jeeva Kandasamy (jkandasa)
33 | * @since 1.0.0
34 | */
35 | @Slf4j
36 | public class BasicSpanTest extends TestBase {
37 |
38 | /*
39 | * Test: Create single span, send it to server and do validate it via query
40 | * api. Steps: 1. Create a span 2. send it to server 3. validate from server
41 | */
42 | @Test
43 | public void singleSpanTest() {
44 | Span span = tracer().buildSpan("simple-span").start();
45 | span.setTag("testType", "singleSpanTest");
46 | int random = RANDOM.nextInt(100000);
47 | span.setTag("random", random);
48 | span.finish();
49 | waitForFlush();
50 |
51 | // Validation
52 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 1);
53 | assertEquals("Expected 1 trace", 1, traces.size());
54 |
55 | List spans = getSpansFromTrace(traces.get(0));
56 | assertEquals("Expected 1 span", 1, spans.size());
57 | QESpan receivedSpan = spans.get(0);
58 | assertEquals("simple-span", receivedSpan.getOperation());
59 | Map tags = receivedSpan.getTags();
60 | myAssertTag(tags, "testType", "singleSpanTest");
61 | myAssertTag(tags, "random", random);
62 | }
63 |
64 | /*
65 | * Test: Create parent span and child span Steps: 1. Create parent span and
66 | * child span 2. validate from server
67 | */
68 | @Test
69 | public void spanWithChildTest() {
70 | long randomSleep = RANDOM.nextInt(1000 * 2);
71 | Span parentSpan = tracer().buildSpan("parent-span").start();
72 | parentSpan.setTag("sentFrom", "automation code");
73 | Span childSpan = tracer().buildSpan("child-span")
74 | .asChildOf(parentSpan)
75 | .start();
76 | sleep(randomSleep);
77 | childSpan.finish();
78 | sleep(50L);
79 | parentSpan.finish();
80 | waitForFlush();
81 |
82 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 1);
83 | assertEquals("Expected 1 trace", 1, traces.size());
84 |
85 | List spans = getSpansFromTrace(traces.get(0));
86 | assertEquals("Expected 2 spans", 2, spans.size());
87 |
88 | QESpan receivedParentSpan = getSpanByOperationName(spans, "parent-span");
89 | assertNotNull(receivedParentSpan);
90 | logger.debug(simpleRestClient.prettyPrintJson(receivedParentSpan.getJson()));
91 | myAssertTag(receivedParentSpan.getTags(), "sentFrom", "automation code");
92 |
93 | QESpan receivedChildSpan = getSpanByOperationName(spans, "child-span");
94 | assertNotNull(receivedChildSpan);
95 | }
96 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/tests/FirstJaegerTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke.tests;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 |
19 | import java.time.Instant;
20 | import java.util.HashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.concurrent.atomic.AtomicInteger;
24 |
25 | import org.junit.Before;
26 | import org.junit.Ignore;
27 | import org.junit.Test;
28 |
29 | import com.fasterxml.jackson.databind.JsonNode;
30 |
31 | import io.jaegertracing.tests.smoke.QESpan;
32 | import io.jaegertracing.tests.smoke.TestBase;
33 | import io.opentracing.Span;
34 | import lombok.extern.slf4j.Slf4j;
35 |
36 | /**
37 | * Created by Kevin Earls on 14/04/2017.
38 | *
39 | */
40 | @Slf4j
41 | public class FirstJaegerTest extends TestBase {
42 | AtomicInteger operationId = new AtomicInteger(0);
43 |
44 | @Before
45 | public void beforeMethod() {
46 | operationId.incrementAndGet();
47 | }
48 |
49 | /**
50 | * A simple test that just creates one span, and verifies that it was created correctly.
51 | *
52 | */
53 | @Test
54 | public void writeASingleSpanTest() throws Exception {
55 | String operationName = "writeASingleSpanTest" + operationId.getAndIncrement();
56 | Span span = tracer().buildSpan(operationName)
57 | .withTag("simple", true)
58 | .start();
59 | span.finish();
60 | waitForFlush();
61 |
62 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 1);
63 | assertEquals("Expected 1 trace", 1, traces.size());
64 |
65 | List spans = getSpansFromTrace(traces.get(0));
66 | assertEquals("Expected 1 span", 1, spans.size());
67 | QESpan receivedSpan = spans.get(0);
68 | assertEquals(operationName, receivedSpan.getOperation());
69 | //logger.debug(simpleRestClient.prettyPrintJson(receivedSpan.getJson()));
70 |
71 | assertTrue(receivedSpan.getTags().size() >= 3);
72 | myAssertTag(receivedSpan.getTags(), "simple", true);
73 | }
74 |
75 | /**
76 | * Simple test of creating a span with children
77 | *
78 | */
79 | @Test
80 | public void spanWithChildrenTest() {
81 | String operationName = "spanWithChildrenTest" + operationId.getAndIncrement();
82 | Span parentSpan = tracer().buildSpan(operationName)
83 | .withTag("parent", true)
84 | .start();
85 |
86 | Span childSpan1 = tracer().buildSpan(operationName + "-child1")
87 | .asChildOf(parentSpan)
88 | .withTag("child", 1)
89 | .start();
90 | sleep(100);
91 |
92 | Span childSpan2 = tracer().buildSpan(operationName + "-child2")
93 | .asChildOf(parentSpan)
94 | .withTag("child", 2)
95 | .start();
96 | sleep(50);
97 |
98 | childSpan1.finish();
99 | childSpan2.finish();
100 | parentSpan.finish();
101 |
102 | List spans;
103 | int iteration = 0;
104 | do {
105 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 1);
106 | assertEquals("Expected 1 trace", 1, traces.size());
107 | spans = getSpansFromTrace(traces.get(0));
108 | iteration++;
109 | } while (iteration < 10 && spans.size() < 3);
110 |
111 | assertEquals(3, spans.size());
112 |
113 | // TODO validate parent child structure, operationNames, etc.
114 | }
115 |
116 | /**
117 | * A simple test of the start and end options when fetching traces.
118 | *
119 | */
120 | @Ignore("See https://github.com/Hawkular-QE/jaeger-java-test/issues/14")
121 | @Test
122 | public void testStartEndTest() {
123 | String operationName = "startEndTest" + operationId.getAndIncrement();
124 | Instant testEndTime = Instant.now();
125 | int expectedTraceCount = 3;
126 | for (int i = 0; i < 5; i++) {
127 | if (i == expectedTraceCount) {
128 | testEndTime = Instant.now();
129 | sleep(50);
130 | }
131 | Span testSpan = tracer().buildSpan(operationName)
132 | .withTag("startEndTestSpan", i)
133 | .start();
134 | testSpan.finish();
135 | }
136 |
137 | List traces = simpleRestClient.getTracesBetween(testStartTime, testEndTime, expectedTraceCount);
138 | assertEquals("Expected " + expectedTraceCount + " traces", expectedTraceCount, traces.size());
139 | // TODO add more assertions
140 | }
141 |
142 | /**
143 | * This should create 2 traces as Jaeger closes a trace when finish() is called
144 | * on the top-level span
145 | *
146 | */
147 | @Test
148 | public void successiveSpansTest() {
149 | String operationName = "successiveSpansTest" + operationId.getAndIncrement();
150 | Span firstSpan = tracer().buildSpan(operationName)
151 | .withTag("firstSpan", true)
152 | .start();
153 | sleep(50);
154 | firstSpan.finish();
155 |
156 | operationName = "successiveSpansTest" + operationId.getAndIncrement();
157 | Span secondSpan = tracer().buildSpan(operationName)
158 | .withTag("secondSpan", true)
159 | .start();
160 | sleep(75);
161 | secondSpan.finish();
162 |
163 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 2);
164 | assertEquals("Expected 2 traces", 2, traces.size());
165 | List spans = getSpansFromTrace(traces.get(0));
166 | assertEquals("Expected 1 span", 1, spans.size());
167 | }
168 |
169 | /**
170 | * Test span log
171 | */
172 | @Test
173 | public void spanDotLogIsBrokenTest() {
174 | String operationName = "spanDotLogIsBrokenTest";
175 | Span span = tracer().buildSpan(operationName).start();
176 | Map logFields = new HashMap<>();
177 | logFields.put("something", "happened");
178 | logFields.put("event", "occured");
179 | span.log(logFields);
180 | //span.log("event");
181 | span.finish();
182 |
183 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 1);
184 | assertEquals("Expected 1 trace", 1, traces.size());
185 |
186 | //TODO: validate log; need to update QESpan to add log fields, or get them directly from Json
187 | List spans = getSpansFromTrace(traces.get(0));
188 | QESpan receivedSpan = spans.get(0);
189 | assertEquals(operationName, receivedSpan.getOperation());
190 | //logger.debug(simpleRestClient.prettyPrintJson(receivedSpan.getJson()));
191 | }
192 |
193 | /**
194 | * According to the OpenTracing spec tags can be String, Number, or Boolean
195 | *
196 | */
197 | @Test
198 | public void tagsShouldBeTypedTest() {
199 | String operationName = "tagsShouldBeTypedTest";
200 | Span span = tracer().buildSpan(operationName)
201 | .withTag("booleanTag", true)
202 | .withTag("numberTag", 42)
203 | .withTag("floatTag", Math.PI)
204 | .withTag("stringTag", "I am a tag")
205 | .start();
206 | span.finish();
207 | waitForFlush();
208 |
209 | List traces = simpleRestClient.getTracesSinceTestStart(testStartTime, 1);
210 | assertEquals("Expected 1 trace", 1, traces.size());
211 | List spans = getSpansFromTrace(traces.get(0));
212 | assertEquals("Expected 1 span", 1, spans.size());
213 | Map tags = spans.get(0).getTags();
214 |
215 | // TODO do we need to validate the tag type in the Json?
216 | myAssertTag(tags, "booleanTag", true);
217 | myAssertTag(tags, "numberTag", 42);
218 | myAssertTag(tags, "stringTag", "I am a tag");
219 |
220 | // Workaround for https://github.com/jaegertracing/jaeger/issues/685
221 | // WAS: myAssertTag(tags, "floatTag", Math.PI);
222 | assertTrue("Could not find key: " + "floatTag", tags.containsKey("floatTag"));
223 | Object actualValue = tags.get("floatTag");
224 | logger.info("Actual Value is a " + actualValue.getClass().getCanonicalName() + " " + actualValue);
225 | assertTrue("Put a message here", actualValue.equals(Math.PI) || actualValue.equals(3.141592654));
226 | }
227 | }
--------------------------------------------------------------------------------
/src/main/java/io/jaegertracing/tests/smoke/tests/IndexCleanerTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2019 The Jaeger Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.jaegertracing.tests.smoke.tests;
15 |
16 | import java.util.List;
17 | import java.util.Map;
18 | import java.util.concurrent.TimeUnit;
19 | import java.util.concurrent.atomic.AtomicInteger;
20 |
21 | import org.junit.Before;
22 | import org.junit.Ignore;
23 | import org.junit.Test;
24 |
25 | import io.jaegertracing.tests.JsonUtils;
26 | import io.jaegertracing.tests.osutils.OSResponse;
27 | import io.jaegertracing.tests.osutils.OSCommandExecuter;
28 | import io.jaegertracing.tests.smoke.TestBase;
29 | import io.opentracing.Span;
30 | import lombok.extern.slf4j.Slf4j;
31 |
32 | @Slf4j
33 | public class IndexCleanerTest extends TestBase {
34 | AtomicInteger operationId = new AtomicInteger(0);
35 |
36 | @Before
37 | public void beforeMethod() {
38 | operationId.incrementAndGet();
39 | }
40 |
41 | /**
42 | * Create spans on different dates
43 | *
44 | */
45 | @Test
46 | @Ignore
47 | public void createSpansOnDifferentDatesTest() throws Exception {
48 | long numberOfDays = 30L; // create spans for last N days
49 | logger.debug("creating spans for {} days", numberOfDays);
50 | long spanTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(numberOfDays);
51 | String operationName = "index_cleaner_test_" + operationId.getAndIncrement();
52 | for (long day = 1; day > numberOfDays; day++) {
53 | spanTimestamp += TimeUnit.DAYS.toMillis(1L); // increment one day
54 | Span span = tracer().buildSpan(operationName)
55 | .withTag("simple", true)
56 | .withStartTimestamp(spanTimestamp)
57 | .start();
58 | span.finish(spanTimestamp + 1000L); // finish on the same day
59 | }
60 | // get elasticsearch indices
61 | if (config.getElasticsearchProvider().equals("es-operator")) {
62 | OSCommandExecuter cmdExecuter = new OSCommandExecuter();
63 | OSResponse response = cmdExecuter.executeElasticsearchCmd(
64 | config.getStorageHost(), config.getStoragePort(), "/_cat/indices?h=index&format=json");
65 | logger.debug("{}", response);
66 | @SuppressWarnings("unchecked")
67 | List