Skip to content

Commit 8c40bbf

Browse files
committed
Update oracledb to test older major versions
1 parent 2ac8bfa commit 8c40bbf

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

newrelic/hooks/database_oracledb.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,8 @@ def instrument_oracledb(module):
136136
module, database_product="Oracle", quoting_style="single+oracle", instance_info=instance_info
137137
)
138138

139-
wrap_object(module, "connect", ConnectionFactory, (module,))
140-
wrap_object(module, "connect_async", AsyncConnectionFactory, (module,))
139+
if hasattr(module, "connect"):
140+
wrap_object(module, "connect", ConnectionFactory, (module,))
141+
142+
if hasattr(module, "connect_async"):
143+
wrap_object(module, "connect_async", AsyncConnectionFactory, (module,))

tests/datastore_oracledb/test_async_connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
# limitations under the License.
1414

1515
import oracledb
16+
import pytest
1617
from testing_support.db_settings import oracledb_settings
1718
from testing_support.util import instance_hostname
1819
from testing_support.validators.validate_database_trace_inputs import validate_database_trace_inputs
1920
from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics
2021

2122
from newrelic.api.background_task import background_task
23+
from newrelic.common.package_version_utils import get_package_version_tuple
24+
25+
ORACLEDB_VERSION = get_package_version_tuple("oracledb")
26+
if ORACLEDB_VERSION < (2,):
27+
pytest.skip(reason="OracleDB version does not contain async APIs.", allow_module_level=True)
2228

2329
DB_SETTINGS = oracledb_settings()[0]
2430
TABLE_NAME = DB_SETTINGS["table_name"]

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ envlist =
6767
mysql-datastore_mysql-mysqllatest-{py37,py38,py39,py310,py311,py312,py313},
6868
mysql-datastore_mysqldb-{py38,py39,py310,py311,py312,py313},
6969
mysql-datastore_pymysql-{py37,py38,py39,py310,py311,py312,py313,pypy310},
70-
oracledb-datastore_oracledb-{py39,py310,py311,py312,py313},
70+
oracledb-datastore_oracledb-{py39,py310,py311,py312,py313}-oracledblatest,
71+
oracledb-datastore_oracledb-{py39,py313}-oracledb02,
72+
oracledb-datastore_oracledb-{py39,py312}-oracledb01,
7173
nginx-external_httpx-{py37,py38,py39,py310,py311,py312,py313},
7274
postgres16-datastore_asyncpg-{py37,py38,py39,py310,py311,py312,py313},
7375
postgres16-datastore_psycopg-{py38,py39,py310,py311,py312,py313,pypy310}-psycopglatest,
@@ -280,7 +282,9 @@ deps =
280282
datastore_mysql: protobuf<4
281283
# mysqlclient is the Python 3 replacement for MySQLdb
282284
datastore_mysqldb: mysqlclient
283-
datastore_oracledb: oracledb
285+
datastore_oracledb-oracledblatest: oracledb
286+
datastore_oracledb-oracledb02: oracledb<3
287+
datastore_oracledb-oracledb01: oracledb<2
284288
datastore_postgresql: py-postgresql
285289
datastore_psycopg-psycopglatest: psycopg[binary]>=3
286290
datastore_psycopg-psycopg_purepython0301: psycopg<3.2

0 commit comments

Comments
 (0)