Commit message: Migrate variables to config by bdone, chx, cosmicdreams, jacintocapote, jessehs, jibran, marvil07, mpgeek #2154955
This is the conversion of every upgrade_variable_to_config() call to migrations. They are tested. Yes, it's a big but it should be fairly easy to review as there is no architecture change here.
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | 2154955_38.patch | 114.23 KB | chx |
| #38 | interdiff.txt | 8.26 KB | chx |
| #30 | interdiff.txt | 7.78 KB | chx |
| #11 | interdiff.txt | 5.48 KB | jibran |
| #10 | 2154955_10.patch | 112.47 KB | chx |
Comments
Comment #2
chx commentedBot fluke.
Comment #3
chx commentedComment #4
chx commentedI ran
for i in core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6* ; do git log --follow --pretty=format:"%an" $i ; done|sort |uniqand created the commit message based on that.Comment #5
jibranIMO this should be serialize($var); This way it is more maintainable.
and here is a code review
Comment #6
jibranSome doc fixes.
Comment #9
jibranSome more doc fixes.
Comment #10
chx commentedThat assert is right to fail; it was commented out in my patch; I have added a @TODO to explain what's up. I rolled #2130315: Variable to config: menu.settings into the issue as well.
Comment #11
jibranThanks for adding the @todo. Here is an interdiff :). It is a long patch needs interdiff to help reviewer.
Comment #12
jibranFor future reference.
EOL error.
Wrong namespace.
Comment #13
jibranand fixes.
Comment #15
jibranone more miner fix
Comment #16
chx commentedDefaults need to be loaded. Stay tuned.
Comment #17
chx commentedLet's keep that in a followup instead. Looks like this
but then we get scope creep of architecture changes, unit tests for the new code etc. Let's stay on target.
Comment #19
chx commentedThe last stragglers slowly arrive (as the last subsystems get ported to CMI). Here's search.
Comment #20
chx commentedComment #21
chx commenteddawehner questioned why the tests are not d6. they are now. I also applied the same changes to the sandbox. Here's how:
I copied these commands just in case there's trouble.
Edit: I checked the test results and I see
Drupal\migrate_drupal\Tests\d6\MigrateUserConfigsTestand all that. The move worked.Comment #22
dawehnerThank you!
Comment #23
xjm21: 2154955_21.patch queued for re-testing.
Comment #25
chx commentedComment #26
jibran@file doc is wrong in all files I'll fix it.
Comment #27
jibranIt is a simple reroll so back to RTBC.
Comment #30
chx commentedmmm config is not type casting now. Except when it does.
Comment #32
benjy commentedReroll as requested.
Comment #33
benjy commentedFixed other assertions.
Comment #35
chx commentedFinally back to green. No changes since RTBC just config threw us by being strongly typed now.
Comment #36
webchickSpent some time reviewing this today with xjm, moshe, and eff.
Over-arching concern is:
- How do we a) know that, and b) continue to know that ;) the dump PHP files are accurate as compared to the source schemas? In the past, we used actual database dumps to test the upgrade path; this moves it to code-generated database dumps, which is better for modularity, but presumes that we've caught everything accurate and transcribed it into PHP. So, is this coming from a script? If so, where is this script? I didn't find it on looking in /scripts.
- The second unknown (without lengthy manual verification) is whether or not all of the values in the dumps are reflected in the assertions in the tests, along with the correct default values. Can we automate this somewhow so that if these two ever were to fall out of sync, we would know?
A few comments about the specific elements of the patch:
This hunk ends up getting copy/pasted like 600 times in this patch. It'd be far preferable, I think, it to be in the code only once and then called into the various tests that need it. While the risk of that schema changing in D6 is pretty low, that's not necessarily the case for D7 which still has another N years go to until 9.x LTS comes out.
Just a silly typo.
Can we add some comments to explain why this was done? No other tests had to do this.
This whole section changes from serialized string values to serialize('Foo'). The rest of them don't. What's up with that? We should be consistent.
Comment #37
chx commented> In the past, we used actual database dumps to test the upgrade path
And these are copypasted from the those dumps because we are way too lazy to write our own :D perhaps the values have been changed but the very reason the dumps have not been removed because we intend to use them for the d7-d8 migration.
> Can we automate this somehow
The assertions are only same-looking for this particular batch of migrations. They are very different for, say, entity migrations. So while we could automate -- we could run the migration, and write an assert for every piece of config data migrated -- it's pointless as it'd only do these tests which are written.
> Can we add some comments to explain why this was done? No other tests had to do this.
That's because simpletest overrides the file path config and that was the value we got instead of ours. Other tests need it theoretically to test correctly but they work without because simpletest doesn't override them.
> This whole section changes from serialized string values to serialize('Foo'). The rest of them don't. What's up with that? We should be consistent.
Busted! The serialized parts are typically the copypaste from the D6 dumpfiles and the serialize(foo) is what we manually added.
Comment #38
chx commentedThe interdiff is partial to make it easier to review -- pointless to bloat the interdiff with the variable table creation moved into Drupal6DumpCommon for every dump. Note that a number of variables are not found in the D6 dumps (heh, actually a few are not found in D6 either, I removed those). A note on testing: our tests are by necessity much more through than the D6-D7 path -- the D6-D7 upgrade path tests could focus on changes but migrate copies over everything so we truly test whether everything migrates as we describe. This doesn't mean the descriptions are correct. if there would an API returning the site slogan we could test with that , short of that we hope that everything wanting the slogan runs
\Drupal::config('system.site')->get('slogan').Comment #39
webchickCool, class Drupal6DumpCommon addresses point 1. The other points are addressed, too.
The test coverage is extremely thorough, so I'm not criticising it, but I'm a bit concerned about ongoing maintenance/upkeep.
Right now, each Dump file adds 1-N lines like this:
Then, later, there's a test that pulls in that database dump and makes 1-N test assertions like so:
So my questions are:
a) Where did 'i:35' come from in the first place, and how can we verify that it's correct against a valid D6 schema?
b) How do we know, other than rigorous manual cross-referencing of Dumps to Tests, whether or not we indeed have assertions for all values inserted?
c) Is there a way we can automate the generation of these dumps/assertions to catch changes that may have happened in the upstream schema (both schema and default values)? While this is unlikely to happen in Drupal 6, it could definitely still happen in Drupal 7 sometime in the next 4+ years until it's EOLed.
Does that make sense?
These questions aren't commit-blockers btw, but I would love to have them answered before we go too far down the road of mass-copying this pattern to other migrations.
Comment #40
webchickAlso, this is totally unrelated but just a question I had when reviewing the patch:
For "source," I can grep for drupal6_variable, and that gets me to core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Plugin/migrate/source/d6/Variable.php.
For "destination," I can grep for d8_config (side-note: could we please make a minor follow-up to make those plugin IDs consistently spell out the word "drupal"? :D) and that gets me to core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Config.php
However, I'm not sure how to see what "process" class is being used to convert the values. It took us a few minutes to realize that it was doing "new name : old name." Maybe something for a follow-up issue to discuss DX-wise, not sure.
Comment #41
chx commented> a) Where did 'i:35' come from in the first place, and how can we verify that it's correct against a valid D6 schema?
> How do we know, other than rigorous manual cross-referencing of Dumps to Tests, whether or not we indeed have assertions for all values inserted?
You trust the migration team it did the cross referencing.
> Is there a way we can automate the generation of these dumps/assertions
I recommend developing a strong AI :) Even for variables to config you need to find the default value in the code -- and if it's meaningless (say, empty string) create a testable version yourself. For generic case, it's truly hopeless.
> mass-copying this pattern to other migrations.
We aren't. We do create dumps for other migrations and we assert them but those are different dumps and different asserts.
> However, I'm not sure how to see what "process" class is being used to convert the values
You read the process handbook page to realize it's
get. https://drupal.org/node/2129651The get plugin is used to copy a value from a source property.
Comment #42
webchickOk, so in a nutshell (summarizing from IRC): those default values are manually entered through inspecting the D6 code, and then they're manually copy/pasted to assertion messages. There's no real way of automating this... default variables don't get into the database unless you somehow loop through and save the config form for every module, and even then it doesn't cover variables like actions_max_stack which only appears in variable_get().
So this is a bit unfortunate, because the tests basically only test the D6 schema at some point in time, and assume that whoever wrote that part of the tests did so correctly and was meticulous about finding all of the variables and transcribing their values properly in two different places. It also means that we will only catch holes and bugs in these default values/tests as people report bugs with the migration path.
However, what's here now is definitely far more complete than the current upgrade path tests, so I think in the end we come out ahead here.
Comment #43
dawehnerThese changes looks pretty good. I am not sure whether it is a good idea to move the custom homepage and site name to pretty much the default one.
This removes the certainty that the patch really works, but I don't block based upon that.
In general I wonder whether migrate in core would migrate the views settings as well
Comment #44
webchickOk, awesome!
Committed and pushed to 8.x. Thanks!