Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#77 | 2348875-77.patch | 1.03 MB | benjy |
#75 | interdiff.txt | 411 bytes | benjy |
#75 | 2348875-75.patch | 1.03 MB | benjy |
#72 | reviewable-do-not-test.patch | 8.78 KB | benjy |
#72 | 2348875-72.patch | 1.03 MB | benjy |
Comments
Comment #1
ultimikeComment #2
ultimikechx feels that dumps should probably be reorganized per table instead of per test.
Comment #3
benjy CreditAttribution: benjy commentedYes 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.
Comment #4
bdone CreditAttribution: bdone commentedi'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.
Comment #5
bdone CreditAttribution: bdone commented@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.
Comment #6
bdone CreditAttribution: bdone commentedjust 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.
Comment #7
bdone CreditAttribution: bdone commentedhere's start to this sandbox D6 install profile that i'm suggesting: https://www.drupal.org/sandbox/bdone/2358293.
Comment #8
benjy CreditAttribution: benjy commentedI 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.
Comment #9
bdone CreditAttribution: bdone commentedi'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?
Comment #10
benjy CreditAttribution: benjy commentedHow is this issue coming along? Have we done anymore work on the install profile?
Comment #11
chx CreditAttribution: chx commentedHere's what we should do:
The workflow after that:
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.
Comment #12
benjy CreditAttribution: benjy commentedOK, 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.
Comment #15
benjy CreditAttribution: benjy commentedOK, 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.
Comment #16
benjy CreditAttribution: benjy commentedOK, 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.
Comment #17
chx CreditAttribution: chx commentedLet's see what the bot says.
Comment #19
benjy CreditAttribution: benjy commentedOK, 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.
Comment #21
benjy CreditAttribution: benjy commentedSee how this goes, still got MigrateDrupal6Test to convert and some mess in the user tests to unravel.
Comment #23
benjy CreditAttribution: benjy commentedFixed a bunch of tests, fixed up tests depending on the dumps and added the primary key support to the export script.
Comment #24
benjy CreditAttribution: benjy commentedAnd a first attempt at fixing up MigrateDrupal6Test.
Comment #27
benjy CreditAttribution: benjy commentedFixed 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.
Comment #29
benjy CreditAttribution: benjy commentedFixed 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.
Comment #30
benjy CreditAttribution: benjy commentedRemoved watchdog, menu_router tables bloating the dumps.
Comment #31
benjy CreditAttribution: benjy commentedGit fail, this should be right now.
Comment #35
benjy CreditAttribution: benjy commentedThis 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.
Comment #37
benjy CreditAttribution: benjy commentedMore fixes plus updates the export script to exclude users 0 and 1.
Comment #39
benjy CreditAttribution: benjy commentedMore 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
Comment #41
benjy CreditAttribution: benjy commentedOK, field and revision stuff broken as expected, couple fixes here, will carry on with the test tomorrow.
Comment #43
benjy CreditAttribution: benjy commentedMore 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.
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.
Comment #45
benjy CreditAttribution: benjy commentedMore fixes and more exports. This should hopefully be much closer. Probably won't fix Drupal6MigrateTest though.
Comment #47
benjy CreditAttribution: benjy commentedFound 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.
Comment #48
benjy CreditAttribution: benjy commentedOK, 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.
Comment #49
benjy CreditAttribution: benjy commentedComment #50
benjy CreditAttribution: benjy commentedComment #51
benjy CreditAttribution: benjy commentedPatch 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
Comment #53
benjy CreditAttribution: benjy commentedFew things still referencing the deleted dumps.
Comment #54
benjy CreditAttribution: benjy commentedMissed a few references.
Comment #56
benjy CreditAttribution: benjy commentedComment #57
benjy CreditAttribution: benjy commentedUpdated the export script to format the dumps to Drupal's coding standards, also fixed a few comments.
Comment #58
chx CreditAttribution: chx commentedNote 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?Comment #59
chx CreditAttribution: chx commentedRerolled and included a review only patch not containing the test and dump changes.
Comment #61
chx CreditAttribution: chx commentedSigh. The drop is always moving. The review patch didn't change.
Comment #63
benjy CreditAttribution: benjy commentedHad 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?
Comment #65
benjy CreditAttribution: benjy commentedI 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.
Comment #66
chx CreditAttribution: chx commentedI 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).
Comment #67
chx CreditAttribution: chx commentedI fixed a single letter typo in LoadEntity and so I am reuploading the whole package: patch, interdiff, review patch.
Comment #68
benjy CreditAttribution: benjy commentedFinal patch, adds the dumping of the database to the table export script as an improvement discussed in IRC. Still RTBC.
Comment #69
alexpottThe blank line here contains spaces - can the generator be fixed - or is this a feature?
Comment #70
alexpottBack to needs review for #69
Comment #71
benjy CreditAttribution: benjy commentedalexpott, 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.
Comment #72
benjy CreditAttribution: benjy commentedAs discussed in IRC, changes made:
Comment #73
chx CreditAttribution: chx commentedLet's try this one more time.
Comment #74
alexpottSorry I should have spotted this first time around... one (very) minor thing - the template should have a new line at the end.
Comment #75
benjy CreditAttribution: benjy commentedFixed.
Comment #77
benjy CreditAttribution: benjy commentedRe-roll, patch conflicted with something else.
Comment #78
benjy CreditAttribution: benjy commentedBack to RTBC. Only added a newline.
Comment #79
alexpottMigrate is not frozen during beta. Committed ec9a3ec and pushed to 8.0.x. Thanks!
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.
Comment #81
benjy CreditAttribution: benjy commentedDone: #2406377: Remove unnecessary $field_storage->status assertions from MigrateFieldTest