question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[OracleContainer] Unable to execute statements which need system privileges

See original GitHub issue

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!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
tomdevroomencommented, Nov 4, 2021

@gvenzl thank you for your feedback!

Really nice to see developing this thread to useful outcome for us all!

2reactions
gvenzlcommented, Nov 5, 2021

Just to add my 2 cents here without having the history or knowledge of the inner works:

I think that running init scripts with superuser privileges would be appropriate.

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

1. Get the data model into the right shape: That’s usually the step where you make sure that your new tables/columns have been added and your starter set installed. It’s the basic framework that you need to test your application against the schema that your application provides and something that would probably be used and tested in conjunction with a Flyway or Liquibase.

2. General DB setup: That has much less to do with your application schema and functionality and much more about making sure that the database is in the right shape to allow for testing, i.e. the right database parameters, tablespaces, config, etc. setup. It’s the plumbing that in the good, old UAT world would have been done once by the admin who then passed on the connection details to the developers to do their testing against that one, central test database. In the brave, new containerized CI/CD world that setup now needs to be ensured/verified after every new container that has been created.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running init script on oracle test container with system privileges
In my case I'm using oracleContainer = new OracleContainer("gvenzl/oracle-xe:18.4.0-slim") .withUsername("test") .withPassword("test") .
Read more >
ALTER SESSION SET CONTAINER can only be executed as ...
Hi Orna,. Yes, you've found that you need to have the correct privilege in every container you wish to start a session in....
Read more >
Common Users & SYSDBA with #Oracle 12c Multitenancy
A 12c multitenant database introduces the new concept of local users and common users. This article shows simple use cases why DBAs may...
Read more >
Oracle Multitenant Application Containers – Part XI Common ...
As it does not have the CREATE SESSION privilege in any container ... Only a CDB common user can run an ALTER DATABASE...
Read more >
A Guide to Oracle PDB (Pluggable Database) and CDB ...
Showing the name of the container you are connected to is very handy, as it can help you decide what commands to run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found