-
Notifications
You must be signed in to change notification settings - Fork 65
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
521 test robustness pgbouncer #522
Conversation
And using sh can make some things fail. E.g: ``` [[: not found ```
This sends a PAUSE and RESUME to pgbouncer (in case there's one) before and after executing tests, to make sure new connections are established in the tests. This may be especially important when role or session settings are modified in the DB (same happens in prod, BTW).
This is needed to make the setup a little bit more robust: when trying to delete the test database, it won't be able if there are "idle sessions" in the db (that is, connections from pgbouncer to the test database). Otherwise it fails when trying to create the database, because there's already one with the same name.
I understand that for this to be really more automated and useful, I'd need to tweak the travis build and docker image to make use of No big deal and no strong opinion, it is simply that it helped me to run existing tests, taking into account subtle differences between direct vs pgbounced connections. |
test/support/db_utils.js
Outdated
port: dbConfig.db_port | ||
}); | ||
|
||
// We just chain a PAUSE followed by a RESUME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ei, what is the objective of pause - resume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pgbouncer.github.io/usage.html#admin-console
PAUSE [db];
PgBouncer tries to disconnect from all servers, first waiting for all queries to complete. The command will not return before all queries are finished. To be used at the time of database restart.
RESUME [db];
Resume work from previous PAUSE or SUSPEND command.
Wait for all the running queries to finish and let the new ones reconnect. This way you pick the changed session parameters such as set statement_timeout
. Sames happens in production, BTW, but there the connections are refreshed usually more often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just leave a couple of picky comments for the sake of clarity :)
Is this also happening in your environment for Windshaft-cartodb
??
test/support/db_utils.js
Outdated
|
||
// We just chain a PAUSE followed by a RESUME | ||
client.connect(); | ||
client.query('PAUSE', (err, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, follow Node.js conventions:
client.query('PAUSE', (err, res) => {
if (err) {
return callback(err);
}
client.query('RESUME', (err, res) => ...);
}
If you inmediatly return after calling the callback, there is no need to wrap following sentences into a else
statement.
test/support/db_utils.js
Outdated
port: dbConfig.db_port | ||
}); | ||
|
||
// We just chain a PAUSE followed by a RESUME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about // We just chain a PAUSE followed by a RESUME to reset internal pool connections of PgBouncer
?
Yet you can see some tests are indeed affected by this:
(if I use the standard 5432 port, all of them pass). Arguably, I'd be less concerned about |
As suggested in review comment.
As suggested in review comment.
As suggested by jshint: - Remove the unused `res` return value - Add a semicolon at the end of the file
I covered your comments (that I always appreciate) and pleased jshint. Now time to merge. Thanks! |
👍 |
This PR makes it possible to execute tests with and without pgbouncer.
This fixes the issue #521