Repository navigation
Convert all unit tests to use Postgres - #114
Merged
Merged
Conversation
jtniehof
force-pushed
the
postgres_unittest
branch
from
January 11, 2022 21:03
b14323c to
f1e7e3d
Compare
* Checked-in database remains, since used by unit tests. * Remove "full test" since functional and unit tests are now more split, running against installed and built versions, respectively.
* This is a step towards treating these tests more like the emptyDB tests.
…y data * Input data now human readable. - Remove old testDB.sqlite (functional output) * Converts these tests to use Postgresql. * Some test fixes for postgres (tests only, not actual functionality): - Postgres enforces length limit on character varying - Integers 0/1 were being used instead of booleans
* testDB not emptyDB, since used for more than empty tests.
* Three main changes in one commit:
- Cut down the size of the magEIS test database (this is why this is
all combined in one commit, so that there are not many commits
with different versions of the large sqlite file.)
- Change tests based on the new database contents
- Update tests to load data from a JSON file instead of holding
the database
* Also adds ability to pass an existing DButils to the DButils
constructor, useful in ProcessQueue tests.
* Includes several fixes for postgresql
- Return order not guaranteed in postgres, a few tests changed.
- getProductID when a name is passed in and there is no record.
dnadeau-lanl
approved these changes
Jan 21, 2022
dnadeau-lanl
left a comment
Contributor
There was a problem hiding this comment.
Impressive. That was a big "json" file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a follow on from #113 to do all database-touching unit tests in Postgres as well as sqlite.
Because this removes the sqlite testing database, it closes #34. It does not fill the entire wishlist of #34, in that it doesn't support having lots of different database structures. Long-term, I think the best approach is to implement #7 and then have all tests run against the latest database structure, except for unit tests of the migration tools (which will need other means of building the test databases.)
It also converts the unit tests (and thus CI) to use the version of dbprocessing in the
builddirectory...this lets you test updates without installing them.The biggest commit is the one that converts the RBSP_mageis database to a JSON file instead of sqlite database. This did a huge amount of work in one commit, because otherwise there would be multiple checked-in versions of the binary test database file, making the repository much larger (this is what we're trying to avoid with this PR). So this commit:
I found this approach makes the sqlite tests slightly slower (about a minute instead of 30s on my machine) and the Postgresql tests are quite a bit slower yet (about 5 minutes for the whole suite, on my machine). Reducing the size of the test database further didn't affect this much; it seems to be primarily in the table setup and teardown. But that can potentially be looked at later...it's not a ridiculous length of time for the test suite.
Fortunately there were only a couple of Postgresql-related bugs found and fixed by doing these tests.
The use of Postgresql databases is added to the documentation.
PR Checklist
Closes #if this PR closes the issue, or some other reference, such asSee #if it is related in some other way)