Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Oracle Database version to the latest 23c version #1528

Closed
gvenzl opened this issue Jun 10, 2023 · 7 comments
Closed

Upgrade Oracle Database version to the latest 23c version #1528

gvenzl opened this issue Jun 10, 2023 · 7 comments
Assignees
Labels
type: task A general task

Comments

@gvenzl
Copy link

gvenzl commented Jun 10, 2023

Hi all,

I wanted to let you know that Oracle released a new version of its database, Oracle Database 23c Free which will also be the next LTS version.
I have already made Docker images for that version available too and if you like, you can upgrade from:

OracleContainer container = new OracleContainer("gvenzl/oracle-xe:21.3.0-slim").withReuse(true);

to gvenzl/oracle-free:23-slim.

If you always want to be on the latest version, you could also just opt for gvenzl/oracle-free:slim and whenever a new free Oracle DB version releases, I will move that slim pointer to that new Docker image version.

If I can help with a PR or similar, I'm also happy to do so.

Thanks,

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 10, 2023
@schauder schauder added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 14, 2023
@schauder schauder self-assigned this Jun 14, 2023
@schauder
Copy link
Contributor

Hi Gerald, thanks for letting us know.

Just replacing the image name wasn't sufficient.

I got

Failed to verify that image 'gvenzl/oracle-free:23-slim' is a compatible substitute for 'gvenzl/oracle-xe'. This generally means that you are trying to use an image that Testcontainers has not been designed to use. If this is deliberate, and if you are confident that the image is compatible, you should declare compatibility in code using the `asCompatibleSubstituteFor` method. For example:
   DockerImageName myImage = DockerImageName.parse("gvenzl/oracle-free:23-slim").asCompatibleSubstituteFor("gvenzl/oracle-xe");
and then use `myImage` instead.

So I use this as instructed:

DockerImageName dockerImageName = DockerImageName.parse("gvenzl/oracle-free:23-slim")
					.asCompatibleSubstituteFor("gvenzl/oracle-xe");
OracleContainer container = new OracleContainer(dockerImageName).withReuse(true);

But that now leads to

[2023-06-13T16:45:54.068Z] Caused by: java.sql.SQLRecoverableException: Listener refused the connection with the following error:
[2023-06-13T16:45:54.068Z] ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
[2023-06-13T16:45:54.068Z]  
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:902)
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:813)
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:80)
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:816)
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:620)
[2023-06-13T16:45:54.068Z] 	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
[2023-06-13T16:45:54.068Z] 	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:155)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:146)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:169)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118)
[2023-06-13T16:45:54.068Z] 	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
[2023-06-13T16:45:54.068Z] 	... 142 more
[2023-06-13T16:45:54.068Z] Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
[2023-06-13T16:45:54.068Z] ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
[2023-06-13T16:45:54.068Z]  
[2023-06-13T16:45:54.068Z] 	at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:308)
[2023-06-13T16:45:54.068Z] 	at oracle.net.ns.NSProtocol.connect(NSProtocol.java:353)
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1701)
[2023-06-13T16:45:54.068Z] 	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:626)
[2023-06-13T16:45:54.068Z] 	... 155 more

My interpretation is that TestContainers things the database is ready, when it really isn't.

I updated to the latest TestContainers version (1.18.3) but that didn't help.

I'm currently not sure how to proceed. @gvenzl do you have any suggestion?

@loiclefevre
Copy link
Contributor

@schauder, there is a minor change to do regarding the connection string since the exposed database service is no more xepdb1 but instead freepdb1.

@schauder
Copy link
Contributor

Thanks for the hint.

Setting the name in Testcontainers to freepdb1 does NOT work, since it then tries to create that database and fails because it already exists.
But explicitly setting a name different from both freepdb1 and xepdb1 works.

And all our tests pass without further changes.

Are you going to create a ticket with TestContainers so we get better direct support? Or will you consider changing the image to better work with the current TestContainers integration?
I'd appreciate a link to any ticket so I can remove the workaround I have to put into place.

schauder added a commit that referenced this issue Jun 14, 2023
The new image is configured as compatible with the old image, which it actually isn't.
The default database names are different, so we also set a database name that is different both from the one used by TestContainers as default and the one used by the Docker image.
If the TestContainers default is used the database is not found, because the image just creates the default one and the name doesn't mach.
If the Docker image default is used, the image creates its default database and then tries to create it again, which fails.

These workarounds may be removed once TestContainers properly supports the new image.

Closing #1528
@schauder
Copy link
Contributor

Resolved by 3cac9d1

@loiclefevre
Copy link
Contributor

Indeed, you have to change the connection string only, as the FREEPDB1 database is created by default but XEPDB1 is hardcoded in TestContainers. Creating a second pluggable database works obviously as well.

For tickets, I'd ask to @gvenzl...

@gvenzl
Copy link
Author

gvenzl commented Jun 14, 2023

Hi @schauder,

First of all, thanks a lot for updating the tests to the new version of Oracle DB!

I apologize for not mentioning the database name change and that I was unaware that Testcontainers verifies the image and hence requires . asCompatibleSubstituteFor().

I can confirm that I am talking with Testcontainers to enhance their support for the new Oracle Database Free Docker image.
I am still fairly new to Testcontainers internals, but current discussions suggest we should have different modules/classes for different images, hence probably having new OracleXEContainer and OracleFreeContainer.

If you have any opinions or insights on that approach, I'm sure both the Testcontainers team and certainly I would be grateful!

@gvenzl
Copy link
Author

gvenzl commented Nov 4, 2023

Hey @schauder,

Just a quick update, today Testcontainers merged a new Oracle Free module, see testcontainers/testcontainers-java@fa23ae4

It should be available for use soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants