Skip to content
Merged
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
56 changes: 56 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.1

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/postgres:9.6.5-alpine-ram
- image: circleci/mysql:8.0.16
- image: circleci/redis:5.0.4
- image: rabbitmq:3.5.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -U pip
python setup.py install_egg_info
pip install -r requirements.txt
pip install -r requirements-test.txt

- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}

- run:
name: run tests
command: |
. venv/bin/activate
python runtests.py

- store_artifacts:
path: test-reports
destination: test-reports
File renamed without changes.
8 changes: 6 additions & 2 deletions tests/apps/app_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
from aiohttp import web

from ..helpers import testenv

testenv["aiohttp_server"] = "http://127.0.0.1:5002"

testenv["aiohttp_port"] = 10810
testenv["aiohttp_server"] = ("http://127.0.0.1:" + str(testenv["aiohttp_port"]))


def say_hello(request):
Expand All @@ -29,7 +33,7 @@ def run_server():

runner = web.AppRunner(app)
loop.run_until_complete(runner.setup())
site = web.TCPSite(runner, 'localhost', 5002)
site = web.TCPSite(runner, '127.0.0.1', testenv["aiohttp_port"])

loop.run_until_complete(site.start())
loop.run_forever()
2 changes: 2 additions & 0 deletions tests/apps/app_django.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import time
Expand Down
8 changes: 5 additions & 3 deletions tests/apps/flaskalino.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
from flask import Flask, redirect
from instana.wsgi import iWSGIMiddleware
from wsgiref.simple_server import make_server
from instana.singletons import tracer

from instana.singletons import tracer
from ..helpers import testenv

testenv["wsgi_server"] = "http://127.0.0.1:5000"

testenv["wsgi_port"] = 10811
testenv["wsgi_server"] = ("http://127.0.0.1:" + str(testenv["wsgi_port"]))

app = Flask(__name__)
app.debug = False
app.use_reloader = False

wsgi_app = iWSGIMiddleware(app.wsgi_app)
flask_server = make_server('127.0.0.1', 5000, wsgi_app)
flask_server = make_server('127.0.0.1', testenv["wsgi_port"], wsgi_app)


@app.route("/")
Expand Down
15 changes: 7 additions & 8 deletions tests/apps/soapserver4132.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# vim: set fileencoding=UTF-8 :
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
from wsgiref.simple_server import make_server

from spyne import (Application, Fault, Integer, Iterable, ServiceBase, Unicode,
rpc)
from spyne import (Application, Fault, Integer, Iterable, ServiceBase, Unicode, rpc)
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication

from instana.wsgi import iWSGIMiddleware

from ..helpers import testenv

testenv["soap_server"] = "http://127.0.0.1:4132"

testenv["soap_port"] = 10812
testenv["soap_server"] = ("http://127.0.0.1:" + str(testenv["soap_port"]))


# Simple in test suite SOAP server to test suds client instrumentation against.
# Configured to listen on localhost port 4132
# WSDL: http://localhost:4232/?wsdl


class StanSoapService(ServiceBase):
@rpc(Unicode, Integer, _returns=Iterable(Unicode))
def ask_question(ctx, question, answer):
Expand Down Expand Up @@ -59,7 +58,7 @@ def client_fault(ctx):

# Use Instana middleware so we can test context passing and Soap server traces.
wsgi_app = iWSGIMiddleware(WsgiApplication(app))
soapserver = make_server('127.0.0.1', 4132, wsgi_app)
soapserver = make_server('127.0.0.1', testenv["soap_port"], wsgi_app)

if __name__ == '__main__':
soapserver.serve_forever()
8 changes: 6 additions & 2 deletions tests/apps/tornado.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os.path
import tornado.auth
import tornado.escape
Expand All @@ -10,7 +12,9 @@

from ..helpers import testenv

testenv["tornado_server"] = "http://127.0.0.1:4133"

testenv["tornado_port"] = 10813
testenv["tornado_server"] = ("http://127.0.0.1:" + str(testenv["tornado_port"]))


class Application(tornado.web.Application):
Expand Down Expand Up @@ -68,5 +72,5 @@ def run_server():
asyncio.set_event_loop(loop)

http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(4133)
http_server.listen(testenv["tornado_port"])
tornado.ioloop.IOLoop.current().start()
6 changes: 3 additions & 3 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
testenv['mysql_host'] = '127.0.0.1'

testenv['mysql_port'] = int(os.environ.get('MYSQL_PORT', '3306'))
testenv['mysql_db'] = os.environ.get('MYSQL_DB', 'travis_ci_test')
testenv['mysql_db'] = os.environ.get('MYSQL_DB', 'circle_test')
testenv['mysql_user'] = os.environ.get('MYSQL_USER', 'root')

if 'MYSQL_PW' in os.environ:
Expand All @@ -34,8 +34,8 @@
testenv['postgresql_host'] = '127.0.0.1'

testenv['postgresql_port'] = int(os.environ.get('POSTGRESQL_PORT', '3306'))
testenv['postgresql_db'] = os.environ.get('POSTGRESQL_DB', 'travis_ci_test')
testenv['postgresql_user'] = os.environ.get('POSTGRESQL_USER', 'postgres')
testenv['postgresql_db'] = os.environ.get('POSTGRESQL_DB', 'circle_test')
testenv['postgresql_user'] = os.environ.get('POSTGRESQL_USER', 'root')

if 'POSTGRESQL_PW' in os.environ:
testenv['postgresql_pw'] = os.environ['POSTGRESQL_PW']
Expand Down
33 changes: 17 additions & 16 deletions tests/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class TestAiohttp(unittest.TestCase):

async def fetch(self, session, url, headers=None):
try:
async with session.get(url, headers=headers) as response:
Expand Down Expand Up @@ -65,7 +66,7 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(200, aiohttp_span.data.http.status)
self.assertEqual("http://127.0.0.1:5000/", aiohttp_span.data.http.url)
self.assertEqual(testenv["wsgi_server"] + "/", aiohttp_span.data.http.url)
self.assertEqual("GET", aiohttp_span.data.http.method)
self.assertIsNotNone(aiohttp_span.stack)
self.assertTrue(type(aiohttp_span.stack) is list)
Expand Down Expand Up @@ -121,7 +122,7 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(200, aiohttp_span.data.http.status)
self.assertEqual("http://127.0.0.1:5000/301", aiohttp_span.data.http.url)
self.assertEqual(testenv["wsgi_server"] + "/301", aiohttp_span.data.http.url)
self.assertEqual("GET", aiohttp_span.data.http.method)
self.assertIsNotNone(aiohttp_span.stack)
self.assertTrue(type(aiohttp_span.stack) is list)
Expand Down Expand Up @@ -172,7 +173,7 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(405, aiohttp_span.data.http.status)
self.assertEqual("http://127.0.0.1:5000/405", aiohttp_span.data.http.url)
self.assertEqual(testenv["wsgi_server"] + "/405", aiohttp_span.data.http.url)
self.assertEqual("GET", aiohttp_span.data.http.method)
self.assertIsNotNone(aiohttp_span.stack)
self.assertTrue(type(aiohttp_span.stack) is list)
Expand Down Expand Up @@ -224,7 +225,7 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(500, aiohttp_span.data.http.status)
self.assertEqual("http://127.0.0.1:5000/500", aiohttp_span.data.http.url)
self.assertEqual(testenv["wsgi_server"] + "/500", aiohttp_span.data.http.url)
self.assertEqual("GET", aiohttp_span.data.http.method)
self.assertEqual('INTERNAL SERVER ERROR', aiohttp_span.data.http.error)
self.assertIsNotNone(aiohttp_span.stack)
Expand Down Expand Up @@ -276,7 +277,7 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(504, aiohttp_span.data.http.status)
self.assertEqual("http://127.0.0.1:5000/504", aiohttp_span.data.http.url)
self.assertEqual(testenv["wsgi_server"] + "/504", aiohttp_span.data.http.url)
self.assertEqual("GET", aiohttp_span.data.http.method)
self.assertEqual('GATEWAY TIMEOUT', aiohttp_span.data.http.error)
self.assertIsNotNone(aiohttp_span.stack)
Expand Down Expand Up @@ -328,7 +329,7 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(200, aiohttp_span.data.http.status)
self.assertEqual("http://127.0.0.1:5000/", aiohttp_span.data.http.url)
self.assertEqual(testenv["wsgi_server"] + "/", aiohttp_span.data.http.url)
self.assertEqual("GET", aiohttp_span.data.http.method)
self.assertEqual("secret=<redacted>", aiohttp_span.data.http.params)
self.assertIsNotNone(aiohttp_span.stack)
Expand Down Expand Up @@ -425,15 +426,15 @@ async def test():

self.assertEqual("aiohttp-server", aioserver_span.n)
self.assertEqual(200, aioserver_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/", aioserver_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/", aioserver_span.data.http.url)
self.assertEqual("GET", aioserver_span.data.http.method)
self.assertIsNotNone(aioserver_span.stack)
self.assertTrue(type(aioserver_span.stack) is list)
self.assertTrue(len(aioserver_span.stack) > 1)

self.assertEqual("aiohttp-client", aioclient_span.n)
self.assertEqual(200, aioclient_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/", aioclient_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/", aioclient_span.data.http.url)
self.assertEqual("GET", aioclient_span.data.http.method)
self.assertIsNotNone(aioclient_span.stack)
self.assertTrue(type(aioclient_span.stack) is list)
Expand Down Expand Up @@ -484,7 +485,7 @@ async def test():

self.assertEqual("aiohttp-server", aioserver_span.n)
self.assertEqual(200, aioserver_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/", aioserver_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/", aioserver_span.data.http.url)
self.assertEqual("GET", aioserver_span.data.http.method)
self.assertEqual("secret=<redacted>", aioserver_span.data.http.params)
self.assertIsNotNone(aioserver_span.stack)
Expand All @@ -493,7 +494,7 @@ async def test():

self.assertEqual("aiohttp-client", aioclient_span.n)
self.assertEqual(200, aioclient_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/", aioclient_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/", aioclient_span.data.http.url)
self.assertEqual("GET", aioclient_span.data.http.method)
self.assertEqual("secret=<redacted>", aioclient_span.data.http.params)
self.assertIsNotNone(aioclient_span.stack)
Expand Down Expand Up @@ -553,7 +554,7 @@ async def test():

self.assertEqual("aiohttp-server", aioserver_span.n)
self.assertEqual(200, aioserver_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/", aioserver_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/", aioserver_span.data.http.url)
self.assertEqual("GET", aioserver_span.data.http.method)
self.assertEqual("secret=<redacted>", aioserver_span.data.http.params)
self.assertIsNotNone(aioserver_span.stack)
Expand All @@ -562,7 +563,7 @@ async def test():

self.assertEqual("aiohttp-client", aioclient_span.n)
self.assertEqual(200, aioclient_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/", aioclient_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/", aioclient_span.data.http.url)
self.assertEqual("GET", aioclient_span.data.http.method)
self.assertEqual("secret=<redacted>", aioclient_span.data.http.params)
self.assertIsNotNone(aioclient_span.stack)
Expand Down Expand Up @@ -619,15 +620,15 @@ async def test():

self.assertEqual("aiohttp-server", aioserver_span.n)
self.assertEqual(401, aioserver_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/401", aioserver_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/401", aioserver_span.data.http.url)
self.assertEqual("GET", aioserver_span.data.http.method)
self.assertIsNotNone(aioserver_span.stack)
self.assertTrue(type(aioserver_span.stack) is list)
self.assertTrue(len(aioserver_span.stack) > 1)

self.assertEqual("aiohttp-client", aioclient_span.n)
self.assertEqual(401, aioclient_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/401", aioclient_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/401", aioclient_span.data.http.url)
self.assertEqual("GET", aioclient_span.data.http.method)
self.assertIsNotNone(aioclient_span.stack)
self.assertTrue(type(aioclient_span.stack) is list)
Expand Down Expand Up @@ -678,15 +679,15 @@ async def test():

self.assertEqual("aiohttp-server", aioserver_span.n)
self.assertEqual(500, aioserver_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/500", aioserver_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/500", aioserver_span.data.http.url)
self.assertEqual("GET", aioserver_span.data.http.method)
self.assertIsNotNone(aioserver_span.stack)
self.assertTrue(type(aioserver_span.stack) is list)
self.assertTrue(len(aioserver_span.stack) > 1)

self.assertEqual("aiohttp-client", aioclient_span.n)
self.assertEqual(500, aioclient_span.data.http.status)
self.assertEqual("http://127.0.0.1:5002/500", aioclient_span.data.http.url)
self.assertEqual(testenv["aiohttp_server"] + "/500", aioclient_span.data.http.url)
self.assertEqual("GET", aioclient_span.data.http.method)
self.assertEqual('I must simulate errors.', aioclient_span.data.http.error)
self.assertIsNotNone(aioclient_span.stack)
Expand Down
12 changes: 7 additions & 5 deletions tests/test_sudsjurko.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

from instana.singletons import tracer

from .helpers import testenv


class TestSudsJurko:
def setUp(self):
""" Clear all spans before a test run """
self.client = Client('http://localhost:4132/?wsdl', cache=None)
self.client = Client(testenv["soap_server"] + '/?wsdl', cache=None)
self.recorder = tracer.recorder
self.recorder.clear_spans()
tracer.cur_ctx = None
Expand Down Expand Up @@ -53,7 +55,7 @@ def test_basic_request(self):
assert_equals(None, soap_span.ec)

assert_equals('ask_question', soap_span.data.soap.action)
assert_equals('http://localhost:4132/', soap_span.data.http.url)
assert_equals(testenv["soap_server"] + '/', soap_span.data.http.url)

def test_server_exception(self):
response = None
Expand Down Expand Up @@ -90,7 +92,7 @@ def test_server_exception(self):
soap_span.data.custom.logs[tskey]['message'])

assert_equals('server_exception', soap_span.data.soap.action)
assert_equals('http://localhost:4132/', soap_span.data.http.url)
assert_equals(testenv["soap_server"] + '/', soap_span.data.http.url)

def test_server_fault(self):
response = None
Expand Down Expand Up @@ -126,7 +128,7 @@ def test_server_fault(self):
soap_span.data.custom.logs[tskey]['message'])

assert_equals('server_fault', soap_span.data.soap.action)
assert_equals('http://localhost:4132/', soap_span.data.http.url)
assert_equals(testenv["soap_server"] + '/', soap_span.data.http.url)

def test_client_fault(self):
response = None
Expand Down Expand Up @@ -163,4 +165,4 @@ def test_client_fault(self):
soap_span.data.custom.logs[tskey]['message'])

assert_equals('client_fault', soap_span.data.soap.action)
assert_equals('http://localhost:4132/', soap_span.data.http.url)
assert_equals(testenv["soap_server"] + '/', soap_span.data.http.url)
Loading