Open2
testcontainers-oracle を試してみる
エラー吐いた
❯ poetry run pytest -v tests
========================================================= test session starts =========================================================
platform darwin -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0 -- /dev/sandbox/pydev/test-testcontainers/.venv/bin/python
cachedir: .pytest_cache
rootdir: /dev/sandbox/pydev/test-testcontainers
collected 1 item
tests/test_version.py::test_version FAILED [100%]
============================================================== FAILURES ===============================================================
____________________________________________________________ test_version _____________________________________________________________
def test_version():
> with OracleDbContainer() as oracle:
tests/test_version.py:7:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.11/site-packages/testcontainers/core/container.py:77: in __enter__
return self.start()
.venv/lib/python3.11/site-packages/testcontainers/core/generic.py:55: in start
self._connect()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
wrapped = <bound method DbContainer._connect of <testcontainers.oracle.OracleDbContainer object at 0x10312a350>>
instance = <testcontainers.oracle.OracleDbContainer object at 0x10312a350>, args = (), kwargs = {}
@wrapt.decorator
def wrapper(wrapped, instance, args, kwargs):
exception = None
logger.info("Waiting to be ready...")
for attempt_no in range(config.MAX_TRIES):
try:
return wrapped(*args, **kwargs)
except transient_exceptions as e:
logger.debug(f"Connection attempt '{attempt_no + 1}' of '{config.MAX_TRIES + 1}' "
f"failed: {traceback.format_exc()}")
time.sleep(config.SLEEP_TIME)
exception = e
> raise TimeoutException(
f'Wait time ({config.MAX_TRIES * config.SLEEP_TIME}s) exceeded for {wrapped.__name__}'
f'(args: {args}, kwargs {kwargs}). Exception: {exception}'
)
E testcontainers.core.exceptions.TimeoutException: Wait time (120s) exceeded for _connect(args: (), kwargs {}). Exception: (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 0x0001): tried: '/opt/homebrew/lib/libclntsh.dylib' (no such file), 'libclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file), '/dev/sandbox/pydev/test-testcontainers/libclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file)". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
E (Background on this error at: https://sqlalche.me/e/20/4xp6)
.venv/lib/python3.11/site-packages/testcontainers/core/waiting_utils.py:55: TimeoutException
内部でデフォルトで呼ばれている docker image を確認
wnameless/oracle-xe-11g-r2:latest
ということがわかった。
https://github.com/testcontainers/testcontainers-python/blob/master/oracle/testcontainers/oracle/init.py
これを適当にローカルで直接動かしてみる。
❯ docker run -d -p 49161:1521 wnameless/oracle-xe-11g-r2
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
7b6b64688534360b3c8118466e4b0a4957ba810ba3fa07a660f0558fccc30581
なるほど、おれのマシンが arm で、イメージが対応していないからか。
platform 指定して実行できるか調べてみる。
(ドキュメントを軽く検索した感じ、現在は手段なさそう???