Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/system: system test for Jaeger Thrift/HTTP #3114

Merged
merged 4 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added testdata/jaeger/span.thrift
Binary file not shown.
25 changes: 17 additions & 8 deletions tests/system/apmserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import time

from elasticsearch import Elasticsearch
from nose.tools import nottest
import requests

sys.path.append(os.path.join(os.path.dirname(__file__), '..',
Expand Down Expand Up @@ -112,10 +113,11 @@ def get_kibana_url(user="", password=""):
)

def get_payload_path(self, name):
return self._beat_path_join(
'testdata',
'intake-v2',
name)
return self.get_testdata_path('intake-v2', name)

@nottest
def get_testdata_path(self, *names):
return self._beat_path_join('testdata', *names)

def get_payload(self, name):
with open(self.get_payload_path(name)) as f:
Expand Down Expand Up @@ -164,9 +166,14 @@ class ServerSetUpBaseTest(BaseTest):
sourcemap_url = "{}/{}".format(host, 'assets/v1/sourcemaps')
expvar_url = "{}/{}".format(host, 'debug/vars')

jaeger_http_host = "localhost:14268"
axw marked this conversation as resolved.
Show resolved Hide resolved
jaeger_http_url = "http://{}/{}".format(jaeger_http_host, 'api/traces')

def config(self):
return {"ssl_enabled": "false",
"queue_flush": 0,
"jaeger_http_enabled": "true",
"jaeger_http_host": self.jaeger_http_host,
"path": os.path.abspath(self.working_dir) + "/log/*"}

def setUp(self):
Expand Down Expand Up @@ -308,15 +315,17 @@ def setUp(self):
super(ElasticTest, self).setUp()

def load_docs_with_template(self, data_path, url, endpoint, expected_events_count,
query_index=None, max_timeout=10):
query_index=None, max_timeout=10, extra_headers=None):

if query_index is None:
query_index = self.index_name_pattern

headers = {'content-type': 'application/x-ndjson'}
if extra_headers:
headers.update(extra_headers)

with open(data_path) as f:
r = requests.post(url,
data=f,
headers={'content-type': 'application/x-ndjson'})
r = requests.post(url, data=f, headers=headers)
assert r.status_code == 202, r.status_code

# Wait to give documents some time to be sent to the index
Expand Down
5 changes: 5 additions & 0 deletions tests/system/config/apm-server.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ apm-server:
host: "localhost:8200"
secret_token: {{ secret_token }}

{% if jaeger_http_enabled %}
jaeger.http.enabled: {{ jaeger_http_enabled }}
jaeger.http.host: {{ jaeger_http_host }}
{% endif %}

{% if api_key_enabled %}
api_key.enabled: {{ api_key_enabled }}
api_key.limit: {{ api_key_limit | default(100) }}
Expand Down
59 changes: 59 additions & 0 deletions tests/system/jaeger_span.approved.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"transaction": {
"sampled": true,
"name": "test_span",
"result": "Success",
"duration": {
"us": 2
},
"type": "custom",
"id": "5025e08c7fef6542"
},
"trace": {
"id": "00000000000000005025e08c7fef6542"
},
"observer": {
"ephemeral_id": "39dd6032-fa6c-4b9e-9fab-f35ea6ef8dfe",
"version_major": 8,
"hostname": "alloy",
"version": "8.0.0",
"type": "apm-server",
"id": "901ad5b3-b313-4c2d-a7a0-2d188005f25e"
},
"timestamp": {
"us": 1578451731616515
},
"@timestamp": "2020-01-08T02:48:51.616Z",
"labels": {
"sampler_type": "const",
"sampler_param": true
},
"agent": {
"ephemeral_id": "3a5c6b00dd41a605",
"name": "Jaeger/Go",
"version": "2.21.2-dev"
},
"host": {
"ip": "10.1.1.101",
"hostname": "alloy",
"name": "alloy"
},
"service": {
"node": {
"name": "alloy"
},
"name": "test_service",
"language": {
"name": "Go"
}
},
"ecs": {
"version": "1.2.0"
},
"processor": {
"name": "transaction",
"event": "transaction"
}
}
]
14 changes: 14 additions & 0 deletions tests/system/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ def test_load_docs_with_template_and_add_error(self):

self.check_backend_error_sourcemap(self.index_error, count=4)

def test_jaeger_http(self):
axw marked this conversation as resolved.
Show resolved Hide resolved
"""
This test sends a Jaeger span in Thrift encoding over HTTP, and verifies that it is indexed.
"""
jaeger_span_thrift = self.get_testdata_path('jaeger', 'span.thrift')
self.load_docs_with_template(jaeger_span_thrift, self.jaeger_http_url, 'transaction', 1,
extra_headers={"content-type": "application/vnd.apache.thrift.binary"})
self.assert_no_logged_warnings()

# compare existing ES documents for errors with new ones
axw marked this conversation as resolved.
Show resolved Hide resolved
rs = self.es.search(index=self.index_transaction)
assert rs['hits']['total']['value'] == 1, "found {} documents".format(rs['count'])
self.approve_docs('jaeger_span', rs['hits']['hits'], 'transaction')

def approve_docs(self, base_path, received, doc_type):
base_path = self._beat_path_join(os.path.dirname(__file__), base_path)
approved_path = base_path + '.approved.json'
Expand Down