4 ms·
Interesting idea to implement a proxy that does something on each new connection. I’ll have to think about that but very cool concept that lets this work for te
by peter_l_downs 3y ago
Interesting idea to implement a proxy that does something on each new connection. I’ll have to think about that but very cool concept that lets this work for tests written in any language.
Will each testcase need to run migrations after connecting for the first time? Also, I’m used to using clients which lazily pool connections, do they still work with this model?
Op, I’d be curious what you think of my project pgtestdb, which takes a different approach: use a single server, but create new databases each time. Maybe there is some middle ground where a proxy creates a new cloned db after each connection?
https://github.com/peterldowns/pgtestdb https://github.com/peterldowns/pgtestdb
- thom 3y agoI assume the idea here is similar to other embedded Postgres libraries - you create a template database that is very fast to copy on startup (or you manually copy the correct files which is even faster) so you don’t need to run migrations. In our tests on one of the JVM equivalents the overhead is about 20ms per test which is entirely tolerable. Making this language agnostic is really interesting though.
- peter_l_downs 3y agoYeah, the parent project mentions that you can use pg_dump and pg_restore, but the examples don't seem to show that (or I'm misreading them.) My project uses template databases to do exactly what you said. Definitely fast and definitely nice.