开发者

I'm working with Drupal and I want to diff between two databases, to see which tables have been updated in a given session. how do I do this?

开发者 https://www.devze.com 2023-03-25 07:46 出处:网络
I\'m working with Drupal on a project, trying to find a way to speed up tests (we\'re using Cucumber and Selenium), and I\'m trying to see which tables have been changed in a given series of steps, so

I'm working with Drupal on a project, trying to find a way to speed up tests (we're using Cucumber and Selenium), and I'm trying to see which tables have been changed in a given series of steps, so I can just revert dump and out reset those tables between each test case.

Right now, Simpletest, the Drupal testing framework works by installing and setting up the tables for every module needed for a test, which makes for slow tests, and I'm emulating a similar approach by loading a db dump for each test.

Given that a site, if you're doing integration testing has a 'known good' state to be starting from, I think it would be faster to be able to just revert back to that point each time, instead of waiting twenty seconds or so to drop the database then pipe the dumpfile back in between each test runs.

However, when I try diffing between two dumpfiles (ie before.I.create.a.node.sql, and after.I.create.a.node.sql) the output is an unreadable开发者_运维技巧 load of serialised php, that I can't make sense of.

Ae there any tools I can use to help work out which tables I need to drop and rebuild between test cases, so I don't incur the 20 second hit on each test, short of reading the schema and code of every module I'm working with?

I'm following the ideas outlined here with getting cucumber to work with PHP, and yes, I have seen [this question here on a similar subject

Thanks!


Drupal does store a lot of serialized PHP in the database. But the main part of it is kept in the cache tables; like cache, cache_field, cache_menu, etc and you can safely truncate these before dumping the database.

If you have any simpletest tables you could drop those. They are all temporary and is used only for running your Simpletest test suite.

That should reduce the dump size a lot. If it's not enough I can recommend reading up on the tables in the book Pro Drupal Development, or you could skim through the .install files to read the module's schema definitions. Though most will probably be real data you'd want to revert between tests.

Because of the relational nature of the database, be sure to either know exactly what you're doing or dump/revert all the remaining tables together.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号