-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[OracleContainer] Unable to execute statements which need system privileges #4615
Comments
This approach should work, see also the "Initialization script" paragraph in the image docs: Can you please share a simple reproducer example, as per https://github.com/testcontainers/testcontainers-java-repro? |
Thank you for your reply. So, my initialization wasn't right. In the script I execute I explicitly need to add Before I'll try to complete the sample asap. |
This code looks fine. But do I understand it correctly that it works now? What aspect exactly was easier to use with the old Oracle XE image? Asking so I can understand if this is something that Testcontainers should provide as an API or something that should be changed in the image (cc @gvenzl). |
Yes, all is working now. I'd like to provide feedback on the changes made in TestContainers and the Oracle-XE image: From a testcontainers users view, I'm not allowed to use the SYSTEM user anymore, which makes it more difficult to create database objects, which need sys admin privileges. From a oracle-xe image users view, now the default user and schema is now "TEST". Before I'm also using Flyway, before So, it is more a combination of things, why I need to do some extra labour to connect all the dots and make it work. |
Unfortunately, I can't really comment on the implementation details and best practices of the Oracle XE image we use (since this is provided by the community, @gvenzl in this case). So in this regard, we tend to rely on technology experts from the community that maintain Docker images. Testcontainers always needs to implicitly integrate against the used image and its constraints. Also, note that compared to the previously used default image by an anonymous maintainer, we are now using an image that has been adopted by wider parts of the community and considerably improves our abilities to continuously support it. However, we can always improve the UX, either by providing higher-level APIs or implementing it upstream in the image. In this case, I personally can't assess what is the best way to use the image for your use case and what are the Oracle idiomatic ways of using tablespaces and initialization scripts (or if it could be solved by other means or by using a pluggable database?). |
Hi all, I think this issue here is related to the one that @tomdevroomen also opened over at gvenzl/oci-oracle-xe#41.
@tomdevroomen, I'm afraid I don't have much knowledge about how things were before |
@tomdevroomen Can you please provide a code example of how you did it with the older version? Note that you can also construct the JDBC URL yourself and e.g. use |
Hi, thank you for this conversation and let's see if we can improve things, either on my side or the testcontainers/oci-oracle-xe side :-) Before my script to have a basic setup for my db was:
I was able to run this script through the TestContainers API:
Now with the changes made in 1.16.2 and the introduction of the default test user on the image the script and code to have the same result are:
So, for me the TestContainer If this is the way it is intended, that's fine, and I found my way now. Thank you for your cooperation! |
Thanks for sharing this. We might think about running |
That would help in my situation. I'm not an Oracle DB expert, maybe @gvenzl can answer this? |
Hi both! First of all, thanks for the additional explanation, @tomdevroomen, this helps a lot!
Yes, I think this is the right thing to do. The initialization scripts are intended to further align/tune the database setup according to the needs of the user. Perhaps some database parameters need to be changed, new pluggable database or tablespaces created, all of which require super-user privileges to do so.
The On a side note, @tomdevroomen, there should be no need for this one:
Given that you already created the table under the |
@gvenzl thank you for your feedback! Really nice to see developing this thread to useful outcome for us all! |
After checking some of the images of the other database modules, I think we should discuss aligning their behavior. E.g. for PostgreSQL and MySQL, we are implicitly returning a JDBC connection for a superuser and would also run the init scripts with those privileges. It might therefore more appropriate to implement it in a similar fashion for However we proceed, I feel we need a general alignment across all JDBC containers. Do you have some thoughts on this @rnorth? |
I agree, up until
😄 I think that this would be at odds with ease-of-use and would probably be a breaking change, so for this aspect in particular I'd be wary. I think that running init scripts with superuser privileges would be appropriate. However, I'd still want to think about whether this could introduce a breaking change somehow (either just implicit expectations about which user runs the init script, or breaking peoples workarounds). Hopefully we'll conclude that it's safe to do, especially with precedent for it existing in other DB modules. I would love to have a wider think about init scripts in general some time, and whether our approach of pushing data through JDBC (with all its statement-splitting nightmares) is something we should be avoiding via copying scripts to the container - for DBs that support it. This was suggested by a user previously and weighs on my mind as a potentially pragmatic step. |
Just to add my 2 cents here without having the history or knowledge of the inner works:
I think you would have to run init scripts with superuser privileges as the very setup to get to such an application user for testing would require these privileges to begin with, meaning that without superuser privileges one cannot create a new application user on the database. It is true that the image I produce has a mechanism built-in for that but that's orthogonal to a Testcontainers user who uses Testcontainers so that he/she doesn't have to care about underlying images and their implementation details. In general, there are two broad categories of pre-testing conditions that a user has to think about before running tests:
1. Get the data model into the right shape: 2. General DB setup: Generally, 1. concerns itself only within a given schema (unless an application uses more than one schema) and hence the user owning that schema can perform everything necessary (create new tables, indexes, etc.). 2., however, is where one definitely needs superuser privileges, and don't forget that this step may also involve the plumbing to get to step 1., i.e. the creation of such a schema user that can then be used. I'm not sure whether this is helping or not, but in a nutshell, there is no easy way around for Testcontainers not to provide a way to run scripts without superuser privileges without also making it potentially harder for users to get their database setup into the right shape. |
After creating the container, how can we access the container and perform ddl operations on the db created in container?can you please share any reference to perform dynamic operations using java springboot |
I just updated to testcontainers 1.16.2 with new OracleContainer setup.
Before I could use a initScript to create tablespaces, but now I'm not able to use system user anymore.
The system user has been disabled, but I need to create tablespaces, for which the test user doesn't have privileges.
I've tried to copy the initScript to the container with
.withCopyFileToContainer(MountableFile.forClasspathResource("init.sql"), "container-entrypoint-startdb.d/");
but the script wasn't picked up when the container was started.How should I proceed?
Thank you!
The text was updated successfully, but these errors were encountered: