We will never publish a beta if we don't start testing the upgrade path correctly.

What we need here is the ability to load some test Drupal 6 database, launch the upgrade process on them, and finally assert that everything went correctly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Damien Tournoud’s picture

Status: Active » Needs review
FileSize
151.33 KB

Here is a first attempt at this, courtesy of chx and myself. This is currently MySQL only, and rely on the mysql command line tool.

Damien Tournoud’s picture

FileSize
152.18 KB

So, we hit a bug in the upgrade process. So surprising :)

Here is the same patch with a temporary fix by forcing the user upgrade to run first in the process.

chx’s picture

FileSize
722 bytes

I am installing Drupal 6 with http://www.os-cms.net/content/article/view/1 this script and then cp sites/default/default.settings.php sites/default/settings.php ; chmod a+w sites/default/settings.php ;mysql -e 'drop database drupal6'; php install_drupal.php (i dont need to create the db, it's on tmpfs hence the drop cant delete the db ony the tables. handy.) and then see attached script for dumping.

Damien Tournoud’s picture

FileSize
280.62 KB

Same patch as #2 with a portable PHP dump.

We had to add NO_AUTO_VALUE_ON_ZERO mode for MySQL, because otherwise MySQL renumbers the 0 key.

Damien Tournoud’s picture

FileSize
279.9 KB

Same patch as #4 but with some hackery to work-around the insertion of 0 values. chx feels it's cleaner this way.

chx’s picture

Priority: Normal » Critical
FileSize
889 bytes

Critical because we are fixing a bug too. Added the latest dumper here with the users table fix.

Damien Tournoud’s picture

An improved dumper, with more comments and a new export format, more compact and compliant with Drupal's coding standards.

Damien Tournoud’s picture

FileSize
203.93 KB

The proof that this new format is actually more compact :)

chx’s picture

Well, of course, if you remove the array keys :) so who wants to RTBC this itsy-bitsy patchy?

dhthwy’s picture

+1 to RTBC.

dhthwy’s picture

Status: Needs review » Reviewed & tested by the community

Can't find anything wrong with it myself. Looks pretty awesome.

Webappz’s picture

#8: 838438.patch queued for re-testing.

Damien Tournoud’s picture

Issue tags: +D7 upgrade path
webchick’s picture

Status: Reviewed & tested by the community » Needs work

Wow!! This is GREAT! :D

The one major thing missing for me is a README.txt or... something. That explains how to create this for each version, and also how to keep this updated through the ages, not only for minor schema adjustments in the version previous, but also for when we start shipping a Drupal 7 schema for Drupal 8.

For example, I have no idea how you made that drupal6_bare.sql.php file. I assume it's from the result of those dumper scripts, but then we probably ought to store the dumper script in along with the test rather than having to find issue #838438 to re-do this in Drupal 8.

Is it a full schema dump of a stock installation of Drupal 6? Looks like not, since I see "nk"'s user record in there (not sure how you got uid 2 ;P). So if not, why are some things different than others, and can we document when that's the case..?

Also, which version of Drupal 6 was this against? We don't have that documented anywhere in the test or at the top of the sql.php file. Incidentally, can we rename that drupal_6.schema.php? There's no SQL in there from what I can see.

Then, each release of Drupal 7, do I need to re-run this dump file on whatever the current version of Drupal 6 is, or how does this get updated as Drupal 6's schema changes..?

Finally, could we get some docblock on +class BasicUpgradePath extends UpgradePathTestCase { to explain what "Basic" upgrade path means..?

Sorry to mark it needs work for essentially documentation, but I want to strike while you both are in the same place. :P Once you go home, the chances of this documentation materializing are slim to none, and we absolutely need it in order for this test to be updated through the life of Drupal 7, 8, 9...

chx’s picture

quick note: I got uid 2 because the dumper increases uid by 1 and then issues an UPDATE users SET uid = uid - 1 to avoid writing a 0 into a serial. MySQL messes that up.

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
259.01 KB

New patch up for review:

  • Added more comments to upgrade.test and the dump file (including how to rebuild it), and renamed the dump file to drupal-6.bare.database.php
  • Added the dumper script to the patch, as scripts/dump-database-d6.sh, and moved the drupal_var_export() utility function in includes/variable.inc
  • Found out that filter_update_7005 had a hard dependency on taxonomy_update_7002, which is dumb because taxonomy is not a required module, so refactored part of filter_update_7005 that was specific to user and taxonomy out of filter.install
  • Added a bunch of extra tests in BasicUpgradePath::testBasicUpgrade
  • Slightly changed the dump format so that it is slightly more readable (via chx)

The upgrade process is totally a mess right now. We really need to get this first step committed so that start refactoring it, and build more tests over this framework.

chx’s picture

Status: Needs review » Reviewed & tested by the community

The dumper script is there, there is a description of how the D6 dump was created, it's a stock install now. I think we are good to go.

chx’s picture

FileSize
256.88 KB

I added moooore comments to the dumper script to make webchick feel better :)

Edit: the dumper script is at the end of the patch.

boombatower’s picture

Marked #377856: Provide D6 to D7 update test as duplicate. Appears to be doing the same thing.

carlos8f’s picture

This is amazing stuff. Thank you, DamZ and chx!

chx’s picture

FileSize
258.87 KB
chx’s picture

FileSize
258.85 KB
webchick’s picture

I spent about an hour reviewing this patch but lost my review thanks to a Dreditor/Drupal.org JS conflict. Sigh.

We went through most of it on IRC. The latest patch here reflects the following changes:

1. The includes/variable.inc file was missing. Now added.

2. Also renamed it to 'utility.inc' since it's not actually for variable-related functions. This file allows us to add seldomly-used, yet handy functions that we don't want loaded on every page request, vs. bootstrap.inc or common.inc which are.

3. The comment above the database.php file said it was generated from a stock Drupal install, but that wasn't the case; only dblog and update were enabled. This was fixed. This will help future maintenance of this test.

Waiting for testbot to come back green and then this looks good to go.

webchick’s picture

Also, some follow-up that would be nice:

+  // Don't output values for those tables.
+  if (substr($table, 0, 5) == 'cache' || $table == 'sessions' || $table == 'watchdog') {

It'd be convenient if the 'exempt' tables were moved closer to the top of the script in a variable that could be easily changed. This changes between major (and sometimes minor) versions of Drupal.

+  // It was previously possible for a value of "0" to be stored in database
+  // tables to indicate that a particular piece of text should be filtered
+  // using the default text format.
+  $default_format = variable_get('filter_default_format', 1);
+  db_update('block_custom')
+    ->fields(array('format' => $default_format))
+    ->condition('format', 0)
+    ->execute();

This code is copy/pasted multiple times in the patch, and presumably also exists in node.install somewhere. We should probably pull it into a helper function, since that would reduce code duplication in core, and also offer the ability for contrib to use it as well.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok, testbot shows we're good. Committed to HEAD, with minor comment massaging. Great job!

Damien Tournoud’s picture

Status: Fixed » Needs review
FileSize
885 bytes

Some followups:

  • The dump script (dump-database-d6.sh) still tries to load variable.inc, which was renamed to utility.inc
  • UpgradePathTestCase fails to properly delete the test tables

Sorry about those.

aspilicious’s picture

Status: Needs review » Needs work

Wrong patch damien :)

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
2.6 KB

Indeed. Here is the correct one.

Damien Tournoud’s picture

FileSize
7.04 KB

Updated setUp() and tearDown() to the new way of building test connections introduced by #195416: Table prefixes should be per database connection. We can probably remove some of the code duplication between UpgradePathTestCase and DrupalWebTestCase in a subsequent clean-up.

This unbreaks HEAD.

chx’s picture

Status: Needs review » Reviewed & tested by the community

yay for unbroken HEAD.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

Gábor Hojtsy’s picture

Where did this change from 0 as default format to a specified number happened? I've submitted a head2head issue for this so we make sure to investigate. This is not at all mentioned/discussed in this issue unfortunately. See http://drupal.org/node/845434

Damien Tournoud’s picture

@Gábor, this was part of filter_update_7005() already. It was not introduced in this patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

amitaibu’s picture

Component: update system » ajax system
FileSize
2.88 KB

For anyone that might need it, here's a script to dump files from drupal 7. I need it in order to write a test for a hook_update_N(). The change in the script is minor:
- Change include to include_once dirname(__FILE__) . '/includes/utility.inc';
- Remove db_result_array()

remove .txt from file name.

amitaibu’s picture

Nope, it's actually not working. This one is a bit better, but I still get DatabaseSchemaObjectExistsException: Cannot add field <em class="placeholder">sessions</em>.<em class="placeholder">ssid</em>: field already exists error when I try to import it via simpletest.

amitaibu’s picture

So:
1) Here's the adapted dump script that works.
2) Also attached the simpletest class that I use for OG, which extends UpgradePathTestCase. UpgradePathTestCase has some D6 related hacks, so we can simply remove them.