Documentation does not list ALTER ROLE netbox CREATEDB requirement to execute unittests #7986

Closed
opened 2025-12-29 20:30:51 +01:00 by adam · 3 comments
Owner

Originally created by @dhenschen on GitHub (May 3, 2023).

Change Type

Addition

Area

Development

Proposed Changes

I followed through the Development documentation and did not find much information on how to run the tests. I executed the following commands under sudo -u postgres psql based on the PostgreSQL Database Installation documentation and the configuration_testing.py file. I'm running Ubuntu 22.04.

CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'netbox';
ALTER DATABASE netbox OWNER TO netbox;

After creating the database, I tried to run the tests and encountered the following error:

(venv) dohenschen@desktop:~/Documents/netbox/netbox/netbox$ export NETBOX_CONFIGURATION=netbox.configuration_testing
(venv) dohenschen@desktop:~/Documents/netbox/netbox/netbox$ cd ..
(venv) dohenschen@desktop:~/Documents/netbox/netbox$ python manage.py test
Found 5774 test(s).
Creating test database for alias 'default'...
Got an error creating the test database: permission denied to create database

The following StackOverflow post led me to the missing command: https://stackoverflow.com/questions/43734650/createdb-database-creation-failed-error-permission-denied-to-create-database

(venv) dohenschen@desktop:~/Documents/netbox/netbox$ sudo -u postgres psql
[sudo] password for dhenschen:
could not change directory to "/home/dohenschen/Documents/netbox/netbox": Permission denied
psql (14.7 (Ubuntu 14.7-0ubuntu0.22.04.1))
Type "help" for help.

postgres=# ALTER ROLE netbox CREATEDB;
ALTER ROLE
postgres=# \q

Once I added the CREATEDB Attribute to the netbox user I was able to run the tests without the permission denied error.

I think it would be helpful to list this step in the documentation to help newcomers get the tests up and running without permission errors.

Note: I would be willing to open a pull request for this documentation if others think that it would be beneficial.

Originally created by @dhenschen on GitHub (May 3, 2023). ### Change Type Addition ### Area Development ### Proposed Changes I followed through the Development documentation and did not find much information on how to run the tests. I executed the following commands under `sudo -u postgres psql` based on the [PostgreSQL Database Installation](https://docs.netbox.dev/en/stable/installation/1-postgresql/) documentation and the configuration_testing.py file. I'm running Ubuntu 22.04. ``` CREATE DATABASE netbox; CREATE USER netbox WITH PASSWORD 'netbox'; ALTER DATABASE netbox OWNER TO netbox; ``` After creating the database, I tried to run the tests and encountered the following error: ``` (venv) dohenschen@desktop:~/Documents/netbox/netbox/netbox$ export NETBOX_CONFIGURATION=netbox.configuration_testing (venv) dohenschen@desktop:~/Documents/netbox/netbox/netbox$ cd .. (venv) dohenschen@desktop:~/Documents/netbox/netbox$ python manage.py test Found 5774 test(s). Creating test database for alias 'default'... Got an error creating the test database: permission denied to create database ``` The following StackOverflow post led me to the missing command: https://stackoverflow.com/questions/43734650/createdb-database-creation-failed-error-permission-denied-to-create-database ``` (venv) dohenschen@desktop:~/Documents/netbox/netbox$ sudo -u postgres psql [sudo] password for dhenschen: could not change directory to "/home/dohenschen/Documents/netbox/netbox": Permission denied psql (14.7 (Ubuntu 14.7-0ubuntu0.22.04.1)) Type "help" for help. postgres=# ALTER ROLE netbox CREATEDB; ALTER ROLE postgres=# \q ``` Once I added the CREATEDB Attribute to the `netbox` user I was able to run the tests without the permission denied error. I think it would be helpful to list this step in the documentation to help newcomers get the tests up and running without permission errors. Note: I would be willing to open a pull request for this documentation if others think that it would be beneficial.
adam added the type: documentationstatus: needs ownerpending closure labels 2025-12-29 20:30:51 +01:00
adam closed this issue 2025-12-29 20:30:51 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 5, 2023):

To be clear, the production database user should not have permission to create other databases; this is needed only for development purposes (to create the test database). We can add this as a note in the development documentation, but it should not be added to the general installation instructions.

@dhenschen assigning this to you. Thanks!

@jeremystretch commented on GitHub (May 5, 2023): To be clear, the production database user should **not** have permission to create other databases; this is needed only for development purposes (to create the test database). We can add this as a note in the development documentation, but it should not be added to the general installation instructions. @dhenschen assigning this to you. Thanks!
Author
Owner

@github-actions[bot] commented on GitHub (Aug 25, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Aug 25, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Sep 24, 2024):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Sep 24, 2024): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7986