cybertec-postgresql / db_migrator

Other
21 stars 8 forks source link

Introduce testing system with pgTAP #27

Closed fljdin closed 1 year ago

fljdin commented 1 year ago

This PR adds a dedicated testing system to db_migrator, based on PGXS build infrastructure and pgTAP testing framework. A CONTRIBUTING.md is provided to explain how to run testing suite locally.

Add a no-operation (noop) plugin that rely on file_fdw and /dev/null. From my point of view, it will deliver more immediate feedback and quality than using other plugin as we did before. User tables and partitions tables must be attached to local datafiles (.dat) to test data insertion when with_data is enabled on materialize_foreign_table() calls.

Setup script executes db_migrate_prepare() function and populates staging tables with convenient datasets needed by pgTAP suite. Test ordering is managed by schedule files for pg_regress as setup must be executed before any others step, or even tables must exists before indexes creation.

laurenz commented 1 year ago

An interesting initiative.

So far, I have used the regression test for ora_migrator to test db_migrator. But of course that requires that you have Oracle installed, and it can only test the features that Oracle supports (as we saw with the partial index patch, where the regression tests didn't catch that I messed up your code).

Let me know when you feel confident enough about the code that I should review it.

fljdin commented 1 year ago

This PR is ready for review.

laurenz commented 1 year ago

I expect to get to it this week.

laurenz commented 1 year ago

Would it be ok for you to develop in the testing-with-pgtap branch of this repository? Then we have fewer problems merging patches back and forth.

fljdin commented 1 year ago

This PR is ready to be pushed into cybertec-postgresql:testing-with-pgtap branch. I'll stop working on my fork, as you already suggested before. Good catch.

laurenz commented 1 year ago

I notice that some features are untested:

I think it would be great if you added some tests for these as well.