From 46aee71c60fa473dd33fcdcc208e5bfb42402859 Mon Sep 17 00:00:00 2001 From: Haotian Wu Date: Fri, 4 May 2018 12:21:48 -0700 Subject: [PATCH] Add travis CI along with some bug fixes (#56) * Add travis CI * fix a broken test on travis server * Fix pynamodb tests * add dummpy tox env vars * Fixed a pynamodb patcher encoding bug under python3.4 and 3.5 --- .travis.yml | 13 +++++++++++++ README.md | 2 ++ aws_xray_sdk/core/recorder.py | 3 +-- aws_xray_sdk/ext/pynamodb/patch.py | 4 ++-- tests/ext/pynamodb/test_pynamodb.py | 8 ++++++-- tox.ini | 2 ++ 6 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..317eb529 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: python + +python: + - "2.7" + - "3.4" + - "3.5" + - "3.6" + +install: + - pip install tox + +script: + - tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d .) \ No newline at end of file diff --git a/README.md b/README.md index 311603f5..6e69df1d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/aws/aws-xray-sdk-python.svg?branch=master)](https://travis-ci.org/aws/aws-xray-sdk-python) + # AWS X-Ray SDK for Python ![Screenshot of the AWS X-Ray console](/images/example_servicemap.png?raw=true) diff --git a/aws_xray_sdk/core/recorder.py b/aws_xray_sdk/core/recorder.py index b946b37d..cab70d6a 100644 --- a/aws_xray_sdk/core/recorder.py +++ b/aws_xray_sdk/core/recorder.py @@ -393,8 +393,7 @@ def record_subsegment(self, wrapped, instance, args, kwargs, name, stack=stack, ) elif exception: - if subsegment: - subsegment.add_exception(exception, stack) + subsegment.add_exception(exception, stack) self.end_subsegment(end_time) diff --git a/aws_xray_sdk/ext/pynamodb/patch.py b/aws_xray_sdk/ext/pynamodb/patch.py index 86a2396c..550d4600 100644 --- a/aws_xray_sdk/ext/pynamodb/patch.py +++ b/aws_xray_sdk/ext/pynamodb/patch.py @@ -56,8 +56,8 @@ def pynamodb_meta_processor(wrapped, instance, args, kwargs, return_value, subsegment.put_http_meta(http.STATUS, return_value.status_code) - _extract_whitelisted_params(subsegment.name, operation_name, - aws_meta, [None, json.loads(args[0].body)], + _extract_whitelisted_params(subsegment.name, operation_name, aws_meta, + [None, json.loads(args[0].body.decode('utf-8'))], None, return_value.json()) subsegment.set_aws(aws_meta) diff --git a/tests/ext/pynamodb/test_pynamodb.py b/tests/ext/pynamodb/test_pynamodb.py index 7366747f..c1d11bc8 100644 --- a/tests/ext/pynamodb/test_pynamodb.py +++ b/tests/ext/pynamodb/test_pynamodb.py @@ -1,5 +1,8 @@ -import botocore.session import pytest + +import botocore.session +from botocore import UNSIGNED +from botocore.client import Config from botocore.exceptions import ClientError from pynamodb.attributes import UnicodeAttribute from pynamodb.models import Model @@ -61,7 +64,8 @@ def test_only_dynamodb_calls_are_traced(): PynamoDB call. """ session = botocore.session.get_session() - s3 = session.create_client('s3', region_name='us-west-2') + s3 = session.create_client('s3', region_name='us-west-2', + config=Config(signature_version=UNSIGNED)) try: s3.get_bucket_location(Bucket='mybucket') except ClientError: diff --git a/tox.ini b/tox.ini index 7934409b..3dffe106 100644 --- a/tox.ini +++ b/tox.ini @@ -31,6 +31,8 @@ commands = setenv = DJANGO_SETTINGS_MODULE = tests.ext.django.app.settings + AWS_SECRET_ACCESS_KEY = fake_key + AWS_ACCESS_KEY_ID=fake_id [testenv:py35-aiohttp3] deps =