metabase / metabase

The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
https://metabase.com
Other
38.82k stars 5.16k forks source link

Ability to quickly reset the App DB through an API call for E2E testing #48471

Open Tony-metabase opened 1 month ago

Tony-metabase commented 1 month ago

Is your feature request related to a problem? Please describe. The need is for a way to quickly reset the Metabase Application database to a known state before each test.

Describe the solution you'd like The ability to reset the database through an API. Right now we have a "Revision History" for Dashboards in which you can simply click and the Dashboard will revert to a previous state.

Image

The idea would be to have a similar endpoint but to a previous instance state. So that the whole instance gets reverted to a known state before the test.

Describe alternatives you've considered

You can do things manually or use the container/DB commands themself, example:

  1. You could do some bespoke scripting with pg_dump and pg_restore ... So theoretically you can also do CREATE DATABASE [dbname] TEMPLATE [template db name]; so you could set your "snapshot" database up, then before each test do CREATE DATABASE my_temp_db TEMPLATE my_snapshot; and set up the app db to use the new db.

  2. Another suggestion is you can save a Postgres container in a certain state, so you can configure Metabase and then save the container in that exact moment, and then use that container every single time so you start over, but on the initial state.

david-ape commented 1 month ago

This would be extremely useful for us. In order to embed Metabase dashboards in our Ruby on Rails app with appropriate user access control, we have tightly coupled integration, including managing collections, dashboards, questions, groups, and permissions. We have many automated tests and the setup/teardown process is painful (either time consuming or a lot of work or both), particularly when we have to update the tests because of a Metabase upgrade.