Problem/Motivation

During our weekly Migrate in Core call on October 1, we discussed the fact that issues like #2346039: Add missing migrations to MigrateDrupal6Test and fix the result are due to bugs in our automated tests dump files. Currently, dump files are a bit unwieldy, as they are modified on an as-needed basis in a very unstructured manner.

Updating the dump files is infeasible, that was more than proven in this issue where we found:

  • Tests that were dependant on incomplete data sets. Eg, if the test needed one node type, it only created one node type but there were often side effects when the full table was populated.
  • There were outcomes in the tests that were impossible to achieve from a real D6 site.
  • Adding new CCK field previously was horrendously difficult, you had to add table columns, fields, field instances and the values across 4 or 5 files.

Proposed resolution

  • Load the test data from the dump files back into a D6 database. Done
  • Write a script to export the database back into our dump files, auto generated. Done
  • Fix up the dumps as appropriate using the D6 site and re-exporting. Done
  • Fix up tests based on incorrect assertions. Done
  • Export the D6 database into a compressed file and store that in the repository so other users can work on the dumps. See core/modules/migrate_drupal/src/Tests/d6.tar.gz
  • Put the D6 codebase required for the dump into a make file or a sandbox. See https://www.drupal.org/sandbox/benjy/2405029
  • Write some documentation on how to manipulate the dumps. See top of core/scripts/dump-database-d6.sh

Reviewing

  • There's a more reviewable patch in #51
  • Test changes were: Updating weights, timestamps and allowing for data that wasn't their with the partial subsets of data previously. Including new dump files.
  • One test was removed, see #48
  • Completely rewritten dump script in core/scripts/dump-database-d6.sh

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#77 2348875-77.patch1.03 MBbenjy
#75 interdiff.txt411 bytesbenjy
#75 2348875-75.patch1.03 MBbenjy
#72 reviewable-do-not-test.patch8.78 KBbenjy
#72 2348875-72.patch1.03 MBbenjy
#68 interdiff.txt576 bytesbenjy
#68 2348875-68.patch1.03 MBbenjy
#67 interdiff.txt886 byteschx
#67 2348875_67-do-not-test.patch10.86 KBchx
#67 2348875_67.patch1.04 MBchx
#65 interdiff.txt3.94 KBbenjy
#65 2348875-65.patch1.03 MBbenjy
#63 2348875-63.patch1.04 MBbenjy
#61 2348875_61.patch894.69 KBchx
#59 2348875_59-do-not-test.patch9.08 KBchx
#59 2348875_59.patch894.73 KBchx
#57 2348875-54.patch900.44 KBbenjy
#57 interdiff.txt1.53 KBbenjy
#54 interdiff.txt5.9 KBbenjy
#54 2348875-54.patch900.44 KBbenjy
#53 interdiff.txt1.81 KBbenjy
#53 2348875-53.patch897.8 KBbenjy
#51 2348875-51.patch897.33 KBbenjy
#51 2348875-51-review-do-not-test.patch111.88 KBbenjy
#48 2348875-48.patch573.95 KBbenjy
#45 2348875-45.patch575.82 KBbenjy
#43 2348875-43.patch574.12 KBbenjy
#41 2348875-41.patch543.38 KBbenjy
#39 2348875-39.patch541.92 KBbenjy
#37 2348875-37.patch513.85 KBbenjy
#35 2348875-35.patch335.55 KBbenjy
#31 2348875-30.patch416.93 KBbenjy
#30 2348875-29.patch80.99 KBbenjy
#29 2348875-28.patch1.04 MBbenjy
#27 2348875-27.patch1.31 MBbenjy
#24 2348875-24.patch244.05 KBbenjy
#23 2348875-23.patch239.04 KBbenjy
#21 2348875-21.patch232.2 KBbenjy
#19 2348875-17.patch176.23 KBbenjy
#15 interdiff.txt254.55 KBbenjy
#15 2348875-13.patch172.51 KBbenjy
#12 2348875-generated-tables.patch136.18 KBbenjy
#12 2348875-db-dump-script.patch5.16 KBbenjy
#12 createdb.txt273 bytesbenjy
#9 mt_d6_dumps_export201410228-31-drush.sql_.txt102.86 KBbdone
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ultimike’s picture

ultimike’s picture

chx feels that dumps should probably be reorganized per table instead of per test.

benjy’s picture

Yes I agree on that approach, I intend to take this on in the next couple of weeks, feel free to pick it up if you beat me to it.

bdone’s picture

i'm testing out an install profile today that we could maybe use for D6 and D7 migrate testing. we could try this as the D6 and D7 source databases so those sites can be committed and tested with. that'd also allow testers to easily check out a base install and also helps us to track the source we use for the eventual db dump. does this make sense? i'll post my progress so we can decide if it's of any value.

bdone’s picture

@benjy: i’d be happy to take on converting your D6 test database to an install profile, and/or building up a new D6 install profile, while double checking that it matches your local d6 db benchmark.

i think my sandbox install profile approach might give us a collaborative way to build up that source d6 dump, rather than a single db dump that we pass around. plus we get version control. and we could get a head start on the D7 dumps as a 7.x-1.x branch.

bdone’s picture

just to clarify after a conversation in irc w/ ultimike, i’m not suggesting we commit a new profile, especially a d6 one to d8! just that we use a profile to collaborate on the source for the dump itself.

only the full DB export (perhaps using dump-database-d6.sh) from the profile would committed to D8.

bdone’s picture

here's start to this sandbox D6 install profile that i'm suggesting: https://www.drupal.org/sandbox/bdone/2358293.

benjy’s picture

I was thinking it would be much quicker to just click a database together and then export the dump and commit that. Writing an install profile seems like a lot more effort.

But now you've mentioned it, committing the profile wouldn't be the worst idea, that would make it much easier to spool up a copy of the site if we needed to change the dumps. Eg, when you only have the DB, you need to know all the modules that need to exist in the codebase and that is more than just core for D6.

bdone’s picture

i've exported the complete simpletest D6 source tables from MigrateFullDrupalTestBase::testDrupal, so that we can discuss whether this data should be the benchmark we are striving to re-create in the mt profile i've been working with. if we were to get the entire source, regardless of using this profile or some other dump, is this the benchmark we were hoping to match whether in a profile or some other means?

benjy’s picture

How is this issue coming along? Have we done anymore work on the install profile?

chx’s picture

Here's what we should do:

  1. Write a script that runs over the dumps and builds a D6 database.
  2. Write a script that dumps the D6 database into per table Drupal 8 Dump classes.

The workflow after that:

  1. Run script 1.
  2. Tweak from Drupal 6 UI.
  3. Run script 2.

Only problem? After the first run we need to make all tests pass again... so this issue will be script 1, script 2, most dumps change, some tests change.

benjy’s picture

Status: Active » Needs review
FileSize
273 bytes
5.16 KB
136.18 KB

OK, I started on part 1, the script I used (createdb.txt) to generate the database from the dumps was simple, using the existing code from MigrateDrupal6Test. I attached it just in case we need it again, hopefully not.

I imported a working d6 database and then merged the generated database on top so we got cache, access and session tables etc. I had a few quirks to fix up such as the user table having a different structure based on some contrib modules, the file path been wrong disabling the system module etc etc. Eventually it worked and my D6 codebase was able to access the database.

I then updated the dump-database-d6.sh (2348875-db-dump-script.patch) to export the D6 database into the format required by the dumps files. Quite primitive, I rolled a basic template using str_replace. Also, i renamed it to .php, we should probably rename that back.

I've attached a patch (2348875-generated-tables.patch) with all the newly exported tables as well. That's the patch to start from when we begin converting the tests to work with the new tables.

The last submitted patch, 12: 2348875-db-dump-script.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: 2348875-generated-tables.patch, failed testing.

benjy’s picture

FileSize
172.51 KB
254.55 KB

OK, i added support for generating the table schema, fixed a few other issues with the generation and started work getting the MigrateActionConfigTest working. Still a few errors which mainly seem to be with the bugs in the dumps.

benjy’s picture

OK, wasn't a bug in the dump, just left over settings in my settings.php, MigrateActionConfigsTest should be easy to pass after the following:

* Improve the schema definition to fix unsupported types like longblob
* Schema definition needs to add primary and unique keys.
* Update the connection name used in the export script so as not to conflict with tests.

chx’s picture

Status: Needs work » Needs review

Let's see what the bot says.

Status: Needs review » Needs work

The last submitted patch, 15: 2348875-13.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
176.23 KB

OK, MigrateActionConfigTest is now passing. Updated a few more tests upto MigrateBookTest in the list, see how this goes.

Still need to add support for primary and unique keys in the definition generation.

Status: Needs review » Needs work

The last submitted patch, 19: 2348875-17.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
232.2 KB

See how this goes, still got MigrateDrupal6Test to convert and some mess in the user tests to unravel.

Status: Needs review » Needs work

The last submitted patch, 21: 2348875-21.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
239.04 KB

Fixed a bunch of tests, fixed up tests depending on the dumps and added the primary key support to the export script.

benjy’s picture

FileSize
244.05 KB

And a first attempt at fixing up MigrateDrupal6Test.

The last submitted patch, 23: 2348875-23.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 24: 2348875-24.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
1.31 MB

Fixed more tests, still some fails which are basically the result of corrupt dumps in that we were relying on the fact that some old dump files partially loaded tables.

I re-generated the dumps this time from a working D6 database after i'd been clicking around so a few extra tables. The cache tables have made the patch huge, i'll update the generation script to filter those out shortly.

Status: Needs review » Needs work

The last submitted patch, 27: 2348875-27.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
1.04 MB

Fixed another test that was causing me some issues, and updated the generation to exclude cache tables, regenerating the folder from scratch reduces the patch size a bit but we're still at 1mb.

Not sure what else the regeneration could have broke.

benjy’s picture

FileSize
80.99 KB

Removed watchdog, menu_router tables bloating the dumps.

benjy’s picture

FileSize
416.93 KB

Git fail, this should be right now.

The last submitted patch, 29: 2348875-28.patch, failed testing.

The last submitted patch, 30: 2348875-29.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 31: 2348875-30.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
335.55 KB

This should fix most the fails, I had to manually update the Table\Users.php file. The script needs updating to not export user 0 and 1 which are both needed if you actually want to be able to browse the D6 site.

For the careful eye, the patch gets a lot smaller because i truncated the menu_links table and replaced them with menu links from our tests data.

Status: Needs review » Needs work

The last submitted patch, 35: 2348875-35.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
513.85 KB

More fixes plus updates the export script to exclude users 0 and 1.

Status: Needs review » Needs work

The last submitted patch, 37: 2348875-37.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
541.92 KB

More fixes. The current dumps are corrupt, they don't accurately represent a state of a D6 website. For example in this instance, we had fields in the field and field instance tables that did not have a column in the content_type_* tables. I've been rebuilding the fields using the D6 admin UI to ensure they're correct.

Still have a few failures but uploading for the bot, see what else I broke by re-adding the fields.

Also, normalising the dumps allowed an existing test to pick up the bug that is already fixed here: #2394571: Filter formats on cck text fields are not looked up in the idMap

Status: Needs review » Needs work

The last submitted patch, 39: 2348875-39.patch, failed testing.

benjy’s picture

Assigned: Unassigned » benjy
Status: Needs work » Needs review
FileSize
543.38 KB

OK, field and revision stuff broken as expected, couple fixes here, will carry on with the test tomorrow.

Status: Needs review » Needs work

The last submitted patch, 41: 2348875-41.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
574.12 KB

More fixes, more dump regeneration and i've also included the bug fix from #2404955: Field Formatter settings have incorrect mappings for number formats

Also the dumps caught another bug which i've fixed with this, current tests cover it.

- path_plain: file_url_plan
+ path_plain: file_url_plain

I've updated a few tests but only weights since they're fiddly to get right to match the tests and in some cases impossible.

Status: Needs review » Needs work

The last submitted patch, 43: 2348875-43.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
575.82 KB

More fixes and more exports. This should hopefully be much closer. Probably won't fix Drupal6MigrateTest though.

Status: Needs review » Needs work

The last submitted patch, 45: 2348875-45.patch, failed testing.

benjy’s picture

Found another issue #2405017: Cannot migrate boolean fields of type text however I had the dumps wrong which trigged the error so it's not blocking this issue as i'm making the new dumps resemble the old ones as best I can.

benjy’s picture

Status: Needs work » Needs review
FileSize
573.95 KB

OK, more fixes and another bug: #2405023: Cannot create base_field_override entity, ID already exists

I removed this test, excluding a view mode doesn't makes sense. The only way this test worked before was because of a subset of data during the test. The "exclude" field is per field on the display, not the display itself.

-    // Make sure we don't have the excluded print entity display.
-    $display = entity_load('entity_view_display', 'node.story.print');
-    $this->assertNull($display, "Print entity display not found.");
benjy’s picture

Issue summary: View changes
benjy’s picture

Issue summary: View changes
benjy’s picture

Patch much bigger because i'm also removing the "Dump" folder. Also attaching a smaller patch of changed files to make it easier for review.

Think we're now postponed on #2404955: Field Formatter settings have incorrect mappings for number formats

Status: Needs review » Needs work

The last submitted patch, 51: 2348875-51.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
897.8 KB
1.81 KB

Few things still referencing the deleted dumps.

benjy’s picture

FileSize
900.44 KB
5.9 KB

Missed a few references.

The last submitted patch, 53: 2348875-53.patch, failed testing.

benjy’s picture

Issue summary: View changes
benjy’s picture

Issue summary: View changes
FileSize
1.53 KB
900.44 KB

Updated the export script to format the dumps to Drupal's coding standards, also fixed a few comments.

chx’s picture

Note that the patch doesn't contain any material changes (check git diff 8.0.x --name-only | grep -v 'Tests\|Dumps\|Table' | xargs git diff 8.0.x) after #2404955: Field Formatter settings have incorrect mappings for number formats is in so this is good to go once that's in. Yes, it changes the tests and dumps quite some but who cares except those who need to maintain those?

chx’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
894.73 KB
9.08 KB

Rerolled and included a review only patch not containing the test and dump changes.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 59: 2348875_59.patch, failed testing.

chx’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
894.69 KB

Sigh. The drop is always moving. The review patch didn't change.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 61: 2348875_61.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
1.04 MB

Had to move a few things to make the temp files work including a file_put_contents('/tmp/some-temp-file.jpg', ''); in MigrateDrupal6Test.

Dump got bigger because of a few temp tables on the D6 site such as cache_menu changing. I wonder if we should package a dump scrip that truncates those tables to try and reduce the amount of change in the DB?

Status: Needs review » Needs work

The last submitted patch, 63: 2348875-63.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
Issue tags: +Quick fix
FileSize
1.03 MB
3.94 KB

I found two bugs, one introduced by #2394571: Filter formats on cck text fields are not looked up in the idMap but not caught by the tests because of a bug in the dumps where db_storage was incorrectly set. The other bug introduced by #2394157: Update the EntityFile destination to handle temporary files again missed by the dumps because we didn't have a migration where the temporary directory was the same on the source and destination sites.

Interdiff shows the fix for the first bug, we could have a separate issue but we already have test coverage here?

I got around the second bug with an update to make it look exactly like the old dumps, created #2405337: EntityFile destination doesn't handle temporary files when the source and destination are the same to handle the short comings in the EntityFile destination.

Took a few hours to track these down, going to tag this issue quick fix because it will conflict with many other migrate issues and it would be better if the bugs were fixed in the individual issues.

chx’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Quick fix +Avoid commit conflicts

I doubt a 1MB patch can be called quickfix -- I think this is the right tag and also we can postpone any other migrate RTBC issue; I doubt there are many (thanks for all the commits).

chx’s picture

FileSize
1.04 MB
10.86 KB
886 bytes

I fixed a single letter typo in LoadEntity and so I am reuploading the whole package: patch, interdiff, review patch.

benjy’s picture

Assigned: benjy » Unassigned
FileSize
1.03 MB
576 bytes

Final patch, adds the dumping of the database to the table export script as an improvement discussed in IRC. Still RTBC.

alexpott’s picture

+    $this->database->insert("content_group_fields")->fields(array(
+      'type_name',
+      'group_name',
+      'field_name',
+    ))
+
+    ->execute();

The blank line here contains spaces - can the generator be fixed - or is this a feature?

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Back to needs review for #69

benjy’s picture

alexpott, It does that because i'm using 4 spaces as the prefix to the export function to make the indentation of the code work within the class. There is no easy way to fix that.

benjy’s picture

As discussed in IRC, changes made:

  • Removed the dependency on drush
  • Renamed the script to migrate-dump-d6.sh
  • Trim all white space from the generated class files.
  • Improved docs
chx’s picture

Status: Needs review » Reviewed & tested by the community

Let's try this one more time.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Sorry I should have spotted this first time around... one (very) minor thing - the template should have a new line at the end.

benjy’s picture

Status: Needs work » Needs review
FileSize
1.03 MB
411 bytes

Fixed.

Status: Needs review » Needs work

The last submitted patch, 75: 2348875-75.patch, failed testing.

benjy’s picture

Status: Needs work » Needs review
FileSize
1.03 MB

Re-roll, patch conflicted with something else.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC. Only added a newline.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Avoid commit conflicts

Migrate is not frozen during beta. Committed ec9a3ec and pushed to 8.0.x. Thanks!

-    $this->assertEqual($field_storage->status(), FALSE, "Status is FALSE");
+    $this->assertEqual($field_storage->status(), TRUE);

In core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php is going to result in a useless test assertion telling people that true = true - a test assertion message here is a nice thing to do. Can we get a followup to fix this.

  • alexpott committed ec9a3ec on 8.0.x
    Issue #2348875 by benjy, chx, bdone: Improving our dump files
    
benjy’s picture

Status: Fixed » Closed (fixed)

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