testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

[fix/oracle]: service name is XE, not xe.

Open pmpetit opened this issue 2 years ago • 2 comments

testing always return "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor" it is because the service is names "XE".

see this command:

root@a09a1d6ea6c3:/# su - oracle
oracle@a09a1d6ea6c3:~$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 11-MAY-2022 11:41:15

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                11-MAY-2022 11:40:49
Uptime                    0 days 0 hr. 0 min. 26 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/a09a1d6ea6c3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a09a1d6ea6c3)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a09a1d6ea6c3)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XE" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully
oracle@a09a1d6ea6c3:~$

the service name is "XE", not "xe". so if you want to connect using (in testcontainers/core/generic.py) line 48

        if db_name:
            url += '/' + db_name

it means that you want to connect using a service name, so get_connection_url must return "XE" as service_name

if it were :

        if db_name:
            url += ': + db_name

then you could use "xe" (the db_name). but it is not the case

pmpetit avatar May 11 '22 11:05 pmpetit

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.56%. Comparing base (99a3252) to head (c0f95ab). Report is 333 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #214   +/-   ##
=======================================
  Coverage   86.56%   86.56%           
=======================================
  Files          27       27           
  Lines         722      722           
  Branches       65       65           
=======================================
  Hits          625      625           
  Misses         76       76           
  Partials       21       21           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar May 11 '22 21:05 codecov-commenter

Thanks for the fix. Would you mind adding a test demonstrating what behavior this change fixes (the existing tests seem to pass fine without the change in db_name)?

tillahoffmann avatar Jun 22 '22 14:06 tillahoffmann

@pmpetit i believe this change is no longer necessary in oracle-free which we have moved our implementation to since the merge of #363 - if its still an issue, please reopen :+1:

alexanderankin avatar Apr 01 '24 11:04 alexanderankin