数据库还原到特定状态以进行测试 [英] database restore to particular state for testing

查看:138
本文介绍了数据库还原到特定状态以进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Oracle(或postgres)数据库和应用服务器执行集成测试。为了将每个测试与另一个测试隔离开,在每个测试之前删除数据库架构并重新创建。

We use an Oracle(or postgres) database and an application server to execute integration tests. To isolate each test from another one , the database schema is dropped and re-created before each test.

如您所见,这是一个耗时的过程。该应用程序使用100多个表。我们正在考虑编写自定义sql,以从每个表中删除不需要的数据。有没有更好的方法来保存和恢复数据库状态?

As you see this is a time taking process. The application uses 100+ tables. We are thinking of writing custom sql to delete unwanted data from each tables. Is there a better way to save and restore database state?

(看来 DBUnit 可以做到这一点,我

( It appears DBUnit could do this, I have not tried it yet. )

单个测试包括:


  • 创建数据库模式。

  • 启动应用服务器。

  • 启动多个客户端应用程序。

  • 执行并验证。

  • create database schema.
  • Start app server.
  • Start multiple client applications.
  • Execute and verify.

我们有5000个奇数测试,耗时700个小时左右。 (我们在网格环境中完成此操作,在一夜之间完成)

We have 5000 odd tests, taking 700 hours or so. (we do it on a grid environment, finishes overnight)

大多数测试使用的数据量较小,例如最多10 MB。

Most of the tests uses small data sizes, say up to 10 MB.

推荐答案

Oracle闪回允许您使用简单的SQL查询在指定的时间点还原表。
该文档位于此处

Oracle Flashback allows you to restore a table at a specified time point using a simple SQL query. The documentation is available here.

我不知道Postgre是否具有类似功能。

I don't know if Postgre has a similar feature.

这篇关于数据库还原到特定状态以进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆