Roundup Tracker - Issues

Issue 2550705

classification
test requires "CREATE" privilege on Pg - print creation command required for postgresql admin
Type: rfe Severity: minor
Components: Database Versions: 1.4
process
Status: new
:
: : ber, rouilj, schlatterbeck, tonimueller
Priority: :

Created on 2011-05-30 10:16 by tonimueller, last changed 2024-05-01 16:45 by rouilj.

Messages
msg4312 Author: [hidden] (tonimueller) Date: 2011-05-30 10:16
roundup's tests for PostgreSQL seem to require that the
'rounduptest' user has the 'CREATE' privilege:

$ ./run_tests.py
Running unit tests at level 1
Running unit tests from /home/toni/mnt/deb/roundup/roundup-1.4.17/.
/usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning:
Module test was already imported from
+/home/toni/mnt/deb/roundup/roundup-1.4.17/./test/__init__.pyc, but
/usr/lib/pymodules/python2.6 is being added to sys.path
  from pkg_resources import resource_stream
Including anydbm tests
Traceback (most recent call last):
  File "./run_tests.py", line 886, in <module>
    process_args()
  File "./run_tests.py", line 876, in process_args
    bad = main(module_filter, test_filter, libdir)
  File "./run_tests.py", line 668, in main
    runner(files, test_filter, debug)
  File "./run_tests.py", line 586, in runner
    s = get_suite(file)
  File "./run_tests.py", line 511, in get_suite
    return suite_func()
  File
"/home/toni/mnt/deb/roundup/roundup-1.4.17/./test/test_indexer.py", line
195, in test_suite
    postgresqlOpener.module.db_nuke(config, 1)
  File
"/home/toni/mnt/deb/roundup/roundup-1.4.17/./roundup/backends/back_postgresql.py",
line 48, in db_nuke
    db_command(config, command)
  File
"/home/toni/mnt/deb/roundup/roundup-1.4.17/./roundup/backends/back_postgresql.py",
line 73, in db_command
    raise RuntimeError('10 attempts to create database failed')
RuntimeError: 10 attempts to create database failed


It would be better if the test suite could make use of a pre-existing
database.
msg4324 Author: [hidden] (ber) Date: 2011-07-01 15:32
How can we completely, securely empty the database, in case we want
to reuse an existing one?
msg4342 Author: [hidden] (schlatterbeck) Date: 2011-07-15 13:06
This doesn't just happen in the test. The database is dropped and
recreated when you call roundup-admin initialise. So for roundup you
always needed create permission on the database. Maybe someone proposes
a fix (this would be nice for hosting setups where the op doesn't have
create permission).
msg4344 Author: [hidden] (ber) Date: 2011-07-15 14:04
We could print out the commands necessary when doing an initialisation,
so they could be send to the admin. For the tests, I guess it would be 
okay to empty and reuse a database I guess.
msg8005 Author: [hidden] (rouilj) Date: 2024-04-22 15:58
One additional note, in version 2.4.0 roundup can use a schema in a postgresql
database. issue2550852 has the discussion and links.

This allows the admin to create the database and have the roundup
user work with create schema privs not create database.

My test workflow has:

          sudo -u postgres psql -c "CREATE ROLE rounduptest_schema LOGIN PASSWORD 
'knownpasswordhere';" -U postgres
          sudo -u postgres psql -c "CREATE DATABASE rounduptest_schema;" -U postgres
          sudo -u postgres psql -c "GRANT CREATE ON DATABASE rounduptest_schema TO 
rounduptest_schema;" -U postgres

to allow creation/deletion of schemas on the database.

Granted this just pushes the grant create down a level but it fulfills the requirement
for postgres testing to use a pre-created database (if you squint hard enough).

I think running:

 python -m pytest -k "postgresql and schema" test/test_postgresql.py
 python -m pytest -k "not postgresql" test

should provide good test coverage. Patches to add markers 
(https://docs.pytest.org/en/7.1.x/example/markers.html) to make this easier
are welcome.
msg8006 Author: [hidden] (tonimueller) Date: 2024-04-22 16:00
Hi John,

On Mon, Apr 22, 2024 at 03:58:07PM +0000, John Rouillard wrote:
> One additional note, in version 2.4.0 roundup can use a schema in a postgresql

on PyPI, I can not find any version 2.4.0.

> database. issue2550852 has the discussion and links.

But thank you for this information, anyway!

Kind regards,
Toni
msg8025 Author: [hidden] (rouilj) Date: 2024-05-01 16:45
Toni, 2.4.0 is the current development release. It will be on pypi in mid july, 2024.

You can work with the pre-release code getting it from the github mirror or the
main mercurial repo as documented at:

   https://www.roundup-tracker.org/code.html

Sorry for the confusion.
History
Date User Action Args
2024-05-01 16:45:25rouiljsetmessages: + msg8025
2024-04-22 16:00:54tonimuellersetmessages: + msg8006
2024-04-22 15:58:07rouiljsetnosy: + rouilj
messages: + msg8005
2019-09-14 14:08:46rouiljsettitle: test requires "CREATE" privilege on Pg -> test requires "CREATE" privilege on Pg - print creation command required for postgresql admin
2011-07-15 14:04:54bersetmessages: + msg4344
2011-07-15 13:06:31schlatterbecksetnosy: + schlatterbeck
messages: + msg4342
2011-07-01 15:32:28bersetnosy: + ber
messages: + msg4324
2011-05-30 10:16:10tonimuellercreate