Skip to content

Commit f545ab7

Browse files
xrmxFiery-Fenix
authored andcommitted
docker-tests: use docker from the system (#4478)
* docker-tests: use docker from the system Stop using the ancient docker-compose and docker packaged in Python and rely on the one available in the system. * Add missing -y to docker install * This now requires docker * it's not additive * Drop version from docker-compose.yml * Move system dependencies intall to workflow And make ms sql odbc driver optional so you can run tests locally without accepting the EULA. * Add changelog * Rebuild misc.yml manually * Apply suggestions from code review Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> * Apply suggestions from code review Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> * Apply suggestion from @xrmx * Apply suggestions from code review Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent c4672e1 commit f545ab7

8 files changed

Lines changed: 29 additions & 20 deletions

File tree

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/misc.yml.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ jobs:
6868
- name: Install tox
6969
run: pip install tox-uv
7070

71+
{%- if job_data == "docker-tests" %}
72+
73+
- name: Install Microsoft SQL ODBC driver
74+
run: sudo apt update -y && ACCEPT_EULA=Y sudo apt install -y msodbcsql18 unixodbc-dev unixodbc
75+
{%- endif %}
76+
7177
- name: Run tests
7278
run: tox -e {{ job_data }}
7379
{%- if job_data == "generate-workflows" %}

.github/workflows/misc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
- name: Install tox
6060
run: pip install tox-uv
6161

62+
- name: Install Microsoft SQL ODBC driver
63+
run: sudo apt update -y && ACCEPT_EULA=Y sudo apt install -y msodbcsql18 unixodbc-dev unixodbc
64+
6265
- name: Run tests
6366
run: tox -e docker-tests
6467

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4848
([#4360](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4360))
4949
- `opentelemetry-instrumentation-aiohttp-server`: Use `canonical` attribute of the `Resource` as a span name
5050
([#3896](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3896))
51+
- `docker-tests`: Don't require sudo, debian based distro and MS SQL ODBC driver to run locally. Instead require docker and unixodbc
52+
([#4478](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4478))
5153
- Refactor unit tests to allow for population of the random trace id flag in the `traceparent` header
5254
([#4030](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4030))
5355
- `opentelemetry-instrumentation-fastapi`: Fix `FastAPI` instrumentation to correctly trace `BackgroundTasks` by wrapping their execution in a dedicated span, ensuring proper parent-child relationships and accurate trace timing

tests/opentelemetry-docker-tests/tests/check_availability.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ def check_docker_services_availability():
130130
check_mysql_connection()
131131
check_postgres_connection()
132132
check_redis_connection()
133-
check_mssql_connection()
134-
setup_mssql_db()
133+
134+
# make accepting EULA for ms sql odbc driver optional
135+
if "ODBC Driver 18 for SQL Server" in pyodbc.drivers():
136+
check_mssql_connection()
137+
setup_mssql_db()
135138

136139

137140
check_docker_services_availability()

tests/opentelemetry-docker-tests/tests/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3'
2-
31
services:
42
otmongo:
53
ports:

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mssql.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os
55

6+
import pyodbc
67
import pytest
78
from sqlalchemy.exc import ProgrammingError
89

@@ -30,6 +31,10 @@
3031
}
3132

3233

34+
@pytest.mark.skipif(
35+
"ODBC Driver 18 for SQL Server" not in pyodbc.drivers(),
36+
reason="No MS SQL ODBC driver installed",
37+
)
3338
class MssqlConnectorTestCase(SQLAlchemyTestMixin):
3439
"""TestCase for pyodbc engine"""
3540

tests/opentelemetry-docker-tests/tests/test-requirements.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ amqp==5.2.0
33
asgiref==3.8.1
44
async-timeout==4.0.3
55
asyncpg==0.29.0
6-
attrs==23.2.0
76
bcrypt==5.0.0
87
billiard==4.2.0
98
celery==5.3.6
@@ -15,21 +14,15 @@ click-didyoumean==0.3.0
1514
click-plugins==1.1.1
1615
click-repl==0.3.0
1716
cryptography==46.0.7
18-
distro==1.9.0
1917
Django==4.2.30
2018
dnspython==2.6.1
21-
docker==5.0.3
22-
docker-compose==1.29.2
23-
dockerpty==0.4.1
24-
docopt==0.6.2
2519
exceptiongroup==1.2.0
2620
flaky==3.7.0
2721
flask==3.1.3
2822
greenlet==3.0.3
2923
grpcio==1.63.2
3024
idna==3.7
3125
iniconfig==2.0.0
32-
jsonschema==3.2.0
3326
kombu==5.3.5
3427
mysql-connector-python==8.3.0
3528
mysqlclient==2.1.1
@@ -50,24 +43,19 @@ PyMySQL==1.1.1
5043
PyNaCl==1.6.2
5144
# prerequisite: install unixodbc
5245
pyodbc==5.0.1
53-
pyrsistent==0.20.0
5446
pytest==8.0.2
5547
pytest-celery==0.0.0
5648
python-dateutil==2.9.0.post0
57-
python-dotenv==0.21.1
5849
pytz==2024.1
59-
PyYAML==5.3.1
6050
redis==5.0.1
6151
requests==2.31.0
6252
six==1.16.0
6353
SQLAlchemy==1.4.52
64-
texttable==1.7.0
6554
tomli==2.0.1
6655
typing_extensions==4.12.2
6756
tzdata==2024.1
6857
urllib3==1.26.19
6958
vine==5.1.0
7059
wcwidth==0.2.13
71-
websocket-client==0.59.0
7260
wrapt==1.16.0
7361
zipp==3.19.1

tox.ini

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,17 +1082,21 @@ deps =
10821082
changedir =
10831083
tests/opentelemetry-docker-tests/tests
10841084

1085+
allowlist_externals =
1086+
docker
1087+
pytest
1088+
10851089
commands_pre =
1086-
sh -c "sudo apt update -y && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev unixodbc"
1087-
python -c "import pyodbc; print(pyodbc.drivers())"
1088-
docker-compose up -d
1090+
docker --version || echo 'Docker with compose subcommand is required' && /bin/false
1091+
python -c 'import pyodbc; print(pyodbc.drivers())' || echo 'You need to install unixODBC' && /bin/false
1092+
docker compose up -d
10891093
python check_availability.py
10901094

10911095
commands =
10921096
pytest {posargs}
10931097

10941098
commands_post =
1095-
docker-compose down -v
1099+
docker compose down -v
10961100

10971101
[testenv:generate]
10981102
deps =

0 commit comments

Comments
 (0)