Initialize Postgres Test Role Outside of Vagrant

RESOLVED WONTFIX

Status

RESOLVED WONTFIX
5 years ago
2 years ago

People

(Reporter: bramwelt, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
Vagrant makes things very simple, yet relying on it for something things makes others complex.

Changes just landed to initialize the test role in Postgres for Vagrant, so that spinning up a VM and running `make test` should work fine. These changes should really be part of the `make test` (or later python.py test). That way they work apart from using Vagrant.
(Reporter)

Comment 1

5 years ago
To clarify,

Having a superuser Postgres role be created through Vagrant is fine, but running tests using the superuser account is not. `make test` if not passed a superuser postgres account, should either prompt for credentials, or respond with the commands users need to run in Postgres, so that test accounts created have access to the databases they need.
(In reply to Trevor Bramwell :bramwelt from comment #1)
> To clarify,
> 
> Having a superuser Postgres role be created through Vagrant is fine, but
> running tests using the superuser account is not. `make test` if not passed
> a superuser postgres account, should either prompt for credentials, or
> respond with the commands users need to run in Postgres, so that test
> accounts created have access to the databases they need.

+1 ^ either of these sound pretty good to me
So I *think* the way it works now is if there is a role for your POSIX username which is a superuser, then things will work fine.. however sometimes people will be running in situations where this is not true (managed postgres for example AWS RDS, heroku, some kind of IT company-provided access etc. etc.)

If you need to override it, from looking at the Makefile I *think* "make test database_superusername=blah" will work... we could then give Makefile (or some script it calls) the ability to create the roles and DBs and such that it needs.

If you're going to be digging this far into it, I'd suggest that this might be a good time to deprecate "make test" and get "python setup.py test" working... otherwise it's going to be adding more to the Makefile and associated scripts, when I suspect you'd rather be removing things :)
(In reply to Robert Helmer [:rhelmer] from comment #3)
> So I *think* the way it works now is if there is a role for your POSIX
> username which is a superuser, then things will work fine.. however
> sometimes people will be running in situations where this is not true
> (managed postgres for example AWS RDS, heroku, some kind of IT
> company-provided access etc. etc.)
> 
> If you need to override it, from looking at the Makefile I *think* "make
> test database_superusername=blah" will work... we could then give Makefile
> (or some script it calls) the ability to create the roles and DBs and such
> that it needs.
> 
> If you're going to be digging this far into it, I'd suggest that this might
> be a good time to deprecate "make test" and get "python setup.py test"
> working... otherwise it's going to be adding more to the Makefile and
> associated scripts, when I suspect you'd rather be removing things :)

Or as we just discussed in IRC - keep "make test" but make it a thin wrapper for "python setup.py test"
I looked through the code involved and the following are true:

1. "make test" runs "scripts/test.sh" and that's it--so it's a thin wrapper now for all the things that are done in "scripts/test.sh".

2. scripts/test.sh looks at the environment for the pg role/credentials used so doing:

   make test database_username=foo

will use "foo" for the database username. Ditto for other things. If you don't specify anything, then the defaults are used.


My reading of comment #1 suggests that if "make test" is run, it should first check to see if database_ vars specify a database role that exists and if not, tell the user how to create it. That seems like the only outstanding task here.

Does that sound right?
We're switching over to docker for local development things and ditching Vagrant. Given that, I'm going through and closing all the Vagrant-related bugs.

The docker environment has a fully functional "make dockertest" rule that does all the setup required to build the environment to run all the tests in a docker container.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.