Skip to content

Commit da9e422

Browse files
authored
Merge pull request #384 from jj22ee/fix-ci-tests
Start MySQL from GH actions, upgrade ubuntu, and remove python versions for tests
2 parents 82cdf8d + 4138b2e commit da9e422

File tree

4 files changed

+64
-79
lines changed

4 files changed

+64
-79
lines changed

.github/workflows/UnitTesting.yaml

+11-9
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,31 @@ on:
99

1010
jobs:
1111
test:
12-
# "setup-python" action doesn't provide python 3.4 binaries for ubuntu-latest.
13-
# Sticking to Ubuntu 18.04 as recommended here:
14-
# https://github.com/actions/setup-python/issues/185#issuecomment-768232756
15-
runs-on: ubuntu-18.04
12+
runs-on: ubuntu-22.04
1613
env:
17-
py27: 2.7
18-
py34: 3.4
19-
py35: 3.5
20-
py36: 3.6
2114
py37: 3.7
2215
py38: 3.8
2316
py39: 3.9
2417
py310: '3.10'
2518
py311: '3.11'
19+
DB_DATABASE: test_db
20+
DB_USER: root
21+
DB_PASSWORD: root
2622
strategy:
2723
fail-fast: false
2824
matrix:
29-
python-version: [py27, py34, py35, py36, py37, py38, py39, py310, py311]
25+
python-version: [py37, py38, py39, py310, py311]
3026
testenv: [core, ext]
3127
steps:
3228
- name: Checkout repo
3329
uses: actions/checkout@v3
3430

31+
- name: Start MySQL
32+
if: ${{ matrix.testenv == 'ext' }}
33+
run: |
34+
sudo /etc/init.d/mysql start
35+
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
36+
3537
- name: Setup Python
3638
uses: actions/setup-python@v4
3739
with:

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ AWS X-Ray supports using OpenTelemetry Python and the AWS Distro for OpenTelemet
77

88
If you want additional features when tracing your Python applications, please [open an issue on the OpenTelemetry Python Instrumentation repository](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/new?labels=feature-request&template=feature_request.md&title=X-Ray%20Compatible%20Feature%20Request).
99

10+
### :mega: Python Versions End-of-Support Notice
11+
12+
AWS X-Ray SDK for Python versions `>2.11.0` has dropped support for Python 2.7, 3.4, 3.5, and 3.6.
13+
1014
# AWS X-Ray SDK for Python
1115

1216
![Screenshot of the AWS X-Ray console](/images/example_servicemap.png?raw=true)
1317

1418
## Installing
1519

16-
The AWS X-Ray SDK for Python is compatible with Python 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9.
20+
The AWS X-Ray SDK for Python is compatible with Python 3.7, 3.8, 3.9, 3.10, and 3.11.
1721

1822
Install the SDK using the following command (the SDK's non-testing dependencies will be installed).
1923

tests/ext/pymysql/test_pymysql.py

+25-26
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import pymysql
22

33
import pytest
4-
import testing.mysqld
54

65
from aws_xray_sdk.core import patch
76
from aws_xray_sdk.core import xray_recorder
87
from aws_xray_sdk.core.context import Context
98
from aws_xray_sdk.ext.pymysql import unpatch
109

10+
MYSQL_USER = "root"
11+
MYSQL_PASSWORD = "root"
12+
MYSQL_HOST = "localhost"
13+
MYSQL_PORT = 3306
14+
MYSQL_DB_NAME = "test_db"
1115

1216
@pytest.fixture(scope='module', autouse=True)
1317
def patch_module():
@@ -32,46 +36,41 @@ def construct_ctx():
3236

3337
def test_execute_dsn_kwargs():
3438
q = 'SELECT 1'
35-
with testing.mysqld.Mysqld() as mysqld:
36-
dsn = mysqld.dsn()
37-
conn = pymysql.connect(database=dsn['db'],
38-
user=dsn['user'],
39-
password='',
40-
host=dsn['host'],
41-
port=dsn['port'])
42-
cur = conn.cursor()
43-
cur.execute(q)
39+
conn = pymysql.connect(database=MYSQL_DB_NAME,
40+
user=MYSQL_USER,
41+
password=MYSQL_PASSWORD,
42+
host=MYSQL_HOST,
43+
port=MYSQL_PORT)
44+
cur = conn.cursor()
45+
cur.execute(q)
4446

4547
subsegment = xray_recorder.current_segment().subsegments[-1]
4648
assert subsegment.name == 'execute'
4749
sql = subsegment.sql
4850
assert sql['database_type'] == 'MySQL'
49-
assert sql['user'] == dsn['user']
51+
assert sql['user'] == MYSQL_USER
5052
assert sql['driver_version'] == 'PyMySQL'
5153
assert sql['database_version']
5254

5355

5456
def test_execute_bad_query():
5557
q = "SELECT blarg"
56-
with testing.mysqld.Mysqld() as mysqld:
57-
dsn = mysqld.dsn()
58-
conn = pymysql.connect(database=dsn['db'],
59-
user=dsn['user'],
60-
password='',
61-
host=dsn['host'],
62-
port=dsn['port'])
63-
64-
cur = conn.cursor()
65-
try:
66-
cur.execute(q)
67-
except Exception:
68-
pass
69-
58+
conn = pymysql.connect(database=MYSQL_DB_NAME,
59+
user=MYSQL_USER,
60+
password=MYSQL_PASSWORD,
61+
host=MYSQL_HOST,
62+
port=MYSQL_PORT)
63+
cur = conn.cursor()
64+
try:
65+
cur.execute(q)
66+
except Exception:
67+
pass
68+
7069
subsegment = xray_recorder.current_segment().subsegments[-1]
7170
assert subsegment.name == "execute"
7271
sql = subsegment.sql
7372
assert sql['database_type'] == 'MySQL'
74-
assert sql['user'] == dsn['user']
73+
assert sql['user'] == MYSQL_USER
7574
assert sql['driver_version'] == 'PyMySQL'
7675
assert sql['database_version']
7776

tox.ini

+23-43
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
11
[tox]
22
skip_missing_interpreters = True
33
envlist =
4-
py{27,34,35,36,37,38,39,310,311}-core
4+
py{37,38,39,310,311}-core
55

6-
; Unavailable for python 2.7 & 3.4
7-
py{35,36,37,38,39,310,311}-ext-aiobotocore
6+
py{37,38,39,310,311}-ext-aiobotocore
87

9-
; Unavailable for python 2.7 & 3.4
10-
py{35,36,37,38,39,310,311}-ext-aiohttp
8+
py{37,38,39,310,311}-ext-aiohttp
119

12-
py{27,34,35,36,37,38,39,310,311}-ext-botocore
10+
py{37,38,39,310,311}-ext-botocore
1311

14-
py{27,34,35,36,37,38,39,310,311}-ext-bottle
12+
py{37,38,39,310,311}-ext-bottle
1513

16-
; Django2 (2.2+) is only for python 3.5 +
17-
py{35,36,37,38,39}-ext-django-2
14+
py{37,38,39}-ext-django-2
1815

19-
; Django3 is only for python 3.6+
20-
py{36,37,38,39,310}-ext-django-3
16+
py{37,38,39,310}-ext-django-3
2117

2218
; Django4 is only for python 3.8+
2319
py{38,39,310,311}-ext-django-4
2420

25-
py{27,34,35,36,37,38,39,310,311}-ext-flask
21+
py{37,38,39,310,311}-ext-flask
2622

27-
py{27,34,35,36,37,38,39,310,311}-ext-flask_sqlalchemy
23+
py{37,38,39,310,311}-ext-flask_sqlalchemy
2824

29-
py{27,34,35,36,37,38,39,310,311}-ext-httplib
25+
py{37,38,39,310,311}-ext-httplib
3026

3127
py{37,38,39,310,311}-ext-httpx
3228

33-
py{27,34,35,36,37,38,39,310,311}-ext-pg8000
29+
py{37,38,39,310,311}-ext-pg8000
3430

35-
py{27,34,35,36,37,38,39,310,311}-ext-psycopg2
31+
py{37,38,39,310,311}-ext-psycopg2
3632

37-
py{27,34,35,36,37,38,39,310,311}-ext-pymysql
33+
py{37,38,39,310,311}-ext-pymysql
3834

39-
py{27,34,35,36,37,38,39,310,311}-ext-pynamodb
35+
py{37,38,39,310,311}-ext-pynamodb
4036

41-
py{27,34,35,36,37,38,39,310,311}-ext-requests
37+
py{37,38,39,310,311}-ext-requests
4238

43-
py{27,34,35,36,37,38,39,310,311}-ext-sqlalchemy
39+
py{37,38,39,310,311}-ext-sqlalchemy
4440

45-
py{27,34,35,36,37,38,39,310,311}-ext-sqlalchemy_core
41+
py{37,38,39,310,311}-ext-sqlalchemy_core
4642

47-
py{27,34,35,36,37,38,39,310,311}-ext-sqlite3
43+
py{37,38,39,310,311}-ext-sqlite3
4844

4945
[testenv]
5046
passenv = TOXENV CI CODECOV_*
@@ -59,16 +55,8 @@ deps =
5955
; Packages common to all test environments
6056
wrapt
6157

62-
; Python 2.7 only deps
63-
py{27}: enum34
64-
py{27}: mock
65-
py{27}: future
66-
67-
; Python 3.4 only deps
68-
py34: typing >= 3.7.4.3
69-
7058
; Python 3.5+ only deps
71-
py{35,36,37,38,39,310,311}: pytest-asyncio
59+
py{37,38,39,310,311}: pytest-asyncio
7260

7361
ext-aiobotocore: aiobotocore >= 0.10.0
7462
ext-aiobotocore: pytest-asyncio
@@ -101,19 +89,15 @@ deps =
10189
ext-django-4: Django >=4.0,<5.0
10290
ext-django: django-fake-model
10391

104-
py{27,34,35}-ext-pynamodb: pynamodb >=3.3.1,<4.4
105-
py{27,34,35}-ext-pynamodb: botocore <1.28
106-
py{36,37,38,39,310,311}-ext-pynamodb: pynamodb >=3.3.1
92+
py{37,38,39,310,311}-ext-pynamodb: pynamodb >=3.3.1
10793

10894
ext-psycopg2: psycopg2
10995
ext-psycopg2: testing.postgresql
11096

11197
ext-pg8000: pg8000 <= 1.20.0
11298
ext-pg8000: testing.postgresql
11399

114-
ext-pymysql: testing.mysqld
115-
py{27,34,35}-ext-pymysql: pymysql < 1.0.0
116-
py{36,37,38,39,310,311}-ext-pymysql: pymysql >= 1.0.0
100+
py{37,38,39,310,311}-ext-pymysql: pymysql >= 1.0.0
117101

118102
setenv =
119103
DJANGO_SETTINGS_MODULE = tests.ext.django.app.settings
@@ -123,9 +107,7 @@ setenv =
123107
commands =
124108
coverage erase
125109

126-
; Async methods are only available for python 3.5+
127-
py{27,34}-core: coverage run --append --source aws_xray_sdk -m pytest --ignore tests/ext --ignore tests/test_async_local_storage.py --ignore tests/test_async_recorder.py
128-
py{35,36,37,38,39,310,311}-core: coverage run --append --source aws_xray_sdk -m pytest --ignore tests/ext
110+
py{37,38,39,310,311}-core: coverage run --append --source aws_xray_sdk -m pytest --ignore tests/ext
129111

130112
ext-aiobotocore: coverage run --append --source aws_xray_sdk -m pytest tests/ext/aiobotocore
131113

@@ -157,9 +139,7 @@ commands =
157139

158140
ext-sqlalchemy: coverage run --append --source aws_xray_sdk -m pytest tests/ext/sqlalchemy
159141

160-
; sqlalchemy_core - 2.0 style execution is not supported for python 3.4 & 3.5
161-
py{27,36,37,38,39,310,311}-ext-sqlalchemy_core: coverage run --append --source aws_xray_sdk -m pytest tests/ext/sqlalchemy_core
162-
py{34,35}-ext-sqlalchemy_core: coverage run --append --source aws_xray_sdk -m pytest tests/ext/sqlalchemy_core --ignore tests/ext/sqlalchemy_core/test_sqlalchemy_core_2.py
142+
py{37,38,39,310,311}-ext-sqlalchemy_core: coverage run --append --source aws_xray_sdk -m pytest tests/ext/sqlalchemy_core
163143

164144
ext-sqlite3: coverage run --append --source aws_xray_sdk -m pytest tests/ext/sqlite3
165145

0 commit comments

Comments
 (0)