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

[Enhancement]: Allow Oracle container builder to set the database name

Open sebastienros opened this issue 1 year ago • 2 comments

Problem

The currently used Oracle image uses a database named XEPDB1. In the more recent versions of the image it is named FREEPDB1. The current API allows us to change the image to use with Oracle but doesn't permit to change the database name:

  • WithDatabase(string) exists but is private
  • Merge(configuration) exists but is protected and the class sealed

As a consequence there is no way to pick a newer version of this image, potentially with better security.

Solution

Make WithDatabase public

Benefit

Not having to request the image to be changed in TestContainers.

Alternatives

N/A

Would you like to help contributing this enhancement?

Yes

sebastienros avatar Aug 13 '24 15:08 sebastienros

I believe the method is private because previous versions did not support changing the database name, but it seems this is supported in version 18c and later (see ORACLE_DATABASE). We need to update the builder's logic accordingly. In the meantime, you can either use the generic builder or set the environment variable and use your own connection string as a workaround for this limitation (maybe we need to adjust the wait strategy too).

HofmeisterAn avatar Aug 13 '24 15:08 HofmeisterAn

I was working on this a few days ago. Pull request #1231 did not come out of the blue, it was a prerequisite to select the correct default database name (XE, XEPDB1 or FREEPDB1) based on the Docker image version. 😉

I have a branch that support all Oracle versions: https://github.com/0xced/testcontainers-dotnet/tree/feature/oracle-all-versions Currently it's stacked on #1165 because it was easier to write all the tests with the new Testcontainers.Xunit package.

0xced avatar Aug 14 '24 12:08 0xced