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

Adds conformance test #61

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ proto:
protoc --proto_path "$(PWD)/../googleapis:$(PWD)/../lightstep-tracer-common/" \
--python_out="$(PWD)/lightstep" \
collector.proto

conformance: build cloudbuild.yaml
gcloud builds submit --config cloudbuild.yaml .
9 changes: 9 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'gcr.io/cloud-builders/git'
args: ['clone', 'https://github.com/lightstep/conformance.git']
- name: 'gcr.io/cloud-builders/go:debian'
args: ['install', 'github.com/lightstep/conformance/ls_conformance_runner']
env: ['PROJECT_ROOT=github.com/lightstep']
- name: 'python:2'
entrypoint: 'sh'
args: ['-c', 'pip install -r requirements.txt && gopath/bin/ls_conformance_runner python tests/conformance/conformance_client.py']
Empty file added tests/conformance/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions tests/conformance/conformance_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import json
import sys
import base64

import lightstep.tracer
from lightstep.propagation import LightStepFormat
from opentracing import Format


def main():
tracer = lightstep.Tracer(periodic_flush_seconds=0, collector_host='localhost')
body = json.load(sys.stdin)

text_context = extract_http_headers(body, tracer)
text_carrier = {}
tracer.inject(text_context, Format.TEXT_MAP, text_carrier)

binary_context = extract_binary(body, tracer)
binary_carrier = bytearray()
tracer.inject(binary_context, LightStepFormat.LIGHTSTEP_BINARY, binary_carrier)
json.dump({"text_map": text_carrier, "binary": base64.b64encode(binary_carrier)}, sys.stdout)



def extract_http_headers(body, tracer):
span_context = tracer.extract(Format.TEXT_MAP, body['text_map'])
return span_context

def extract_binary(body, tracer):
bin64 = bytearray(base64.b64decode(body['binary']))
span_context = tracer.extract(LightStepFormat.LIGHTSTEP_BINARY, bin64)
return span_context

if __name__ == "__main__":
# execute only if run as a script
main()