Postponed on #3193189: Get only translations for localized vocabularies d6/TermLocalizedTranslation.php
Problem/Motivation
When running a migration with the UI, failures are logged to watchdog but that table is deleted as part of tearing down the test setup. That leaves the developer with no information to find the migration causing the failure, as seen in this screenshot at #2746541-153: Migrate D6 and D7 node revision translations to D8:
We need a way to save and report those errors.
Proposed resolution
Access all pages of /admin/reports/dblog in the test site so the results are saved in the BROWSERTEST_OUTPUT_DIRECTORY directory.
Remaining tasks
Find out why test fail on sqlite
Update patch
Review
Commit
Comment | File | Size | Author |
---|
Issue fork drupal-3082211
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3082211-migrate-ui-tests changes, plain diff MR !5272
Comments
Comment #3
Wim LeersComment #6
quietone CreditAttribution: quietone commentedComment #7
quietone CreditAttribution: quietone as a volunteer commentedThis will save the entire watchdog log to a csv file in the BROWSERTEST_OUTPUT_DIRECTORY. I couldn't think of a better place to put such a file. This could be smarter and only get warnings and errors.
Comment #8
benjifisherSaving a CSV file seems like a work-around, not a real solution.
Can we do
drupalGet()
intearDown()
and save the browser output of/admin/reports/dblog
along with the rest of the UI pages?Comment #9
Pooja Ganjage CreditAttribution: Pooja Ganjage at Asentech LLC commentedHi,
Creating a patch as suggested in #8 comment.
Please review the patch.
Thanks.
Comment #10
Pooja Ganjage CreditAttribution: Pooja Ganjage at Asentech LLC commentedComment #12
Vishalghyv CreditAttribution: Vishalghyv at Google Summer of Code commentedHave not seen the issue in detail but drupalGet is undefined in migrate_drupal_ui/tests/src/Functional/ - Reason for failing of test,
Without its fix patch will not work
Comment #13
Pooja Ganjage CreditAttribution: Pooja Ganjage at Asentech LLC commentedComment #14
quietone CreditAttribution: quietone as a volunteer commented@Pooja Ganjage, Thanks for working on this. When making a patch always add an interdiff, or a diff, whichever is appropriate. There are instructions for creating an interdiff in the handbook. If you think a diff is not needed, just add a comment stating why. It also helps to keep costs down if you run the relevant tests locally before uploading a patch. Thanks!
@benjifisher, yes, it is a workaround. And yes, we can save /admin/reports/dblog to the browser output directory. However, the links will not work, making it hard to read the message and if the local site has log messages it will be rather confusing if you follow one. Also, how does one get all the pages?
Comment #15
quietone CreditAttribution: quietone as a volunteer commentedAnd now a patch for the suggestion in #8, that will get all the log entries. I have tested this locally and found it usable to review the entire log. It isn't ideal but it is much, much better than nothing or having to remember to set breakpoints and then search the watchdog table before the test db is deleted.
No interdiff because this is a new approach.
Comment #16
benjifisherI like this approach a lot better!
Can we be a little more specific? We might follow the wrong link if we just search for the text "Next page". (Does
clickLink('Next page')
look for a link whose text contains "Next page" or does it only match if that is the complete link text?)Slight refinement: do not search for "Next page" twice.
Or does this work?
What we are doing here is a little unusual, so maybe we should add a code comment.
MigrateUpgradeTestBase
extendsBrowserTestBase
, which alreadyuse
sUiHelperTrait
. Why do we need this?I know that #12 claims that
drupalGet()
is not available. I see: the patch in #9 trieddrupalGet()
as a global function. I meant$this->drupalGet()
as in #15.Comment #17
quietone CreditAttribution: quietone as a volunteer commentedAs I started to make changes for #16 I realized that this will output the pages for tests where it really isn't needed. This is really for Upgrade6 and Upgrade7 tests and the upcoming Rollback tests. So, I have changed this to only have those tests save the logs. And after the logs are saved there is a test of the number of errors in the watchdog log. That way, the test will fail if new errors are introduced and then one has the browser output for the logs to look at to help figure out what went wrong. Unfortunately, this adds another abstract method, getLogCountsError().
Another problem that this happens at the end of the test and by then the logged in user is not user 1. Since accessing the log requires user 1, an login request as user 1 is made. Unfortunately, that always fails. It fails with manual testing as well. I am fairly sure that worked in the past so that needs to be looked at.
There is no interdiff because this is a new approach. It probably needs more comments but I want to figure out why user 1 can't log in after the migration.
Comment #19
quietone CreditAttribution: quietone as a volunteer commentedThis fixes the user 1 login problem that I messed up.
Comment #21
quietone CreditAttribution: quietone as a volunteer commentedNot sure how to figure this one out. The failing test passes locally with both with run-tests.sh and phpunit.
Comment #22
benjifisherThe test failed with
If you update
outputLogs()
fromto
and run the test locally, then you can see the 37 expected errors on one page (no pagination needed). Also one error from the
node
module.Staring at the list, can we guess which of the errors are not logged when the testbot runs the test? I see exactly 4 copies of
(Get the full text of the message from the
title
attribute.)Comment #23
SpokjeI've whacked in couple of assertions on the expected watchdog errors (interdiff attached), these pass my local test, but the way it looks the 4 errors about
A translation already exists for the specified language
are not in the CI -environment.See test-result here
Comment #24
benjifisher@Spokje: Thanks! Certainly it is better to use
RfcLogLevel::ERROR
instead of'3'
as in #22.Looking at the results of my local test, these are
/admin/reports/deblog/972
through...975
. The full text (from thetitle
attributes):Comment #25
SpokjeBy hacking
Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase
to extendWebDriverTestBase
I was able to get a screenshot from the Watchdog log on Drupal CI.(Very Evil Patch that made the screenshot here)
Indeed the 4
A translation already exists for the specified language
errors mentioned by @benjifisher in #24 are not present on the Drupal CI environment.On my local install they _are_ present (and it seems on @benjifisher's install as well).
Hope Bigger Brains than mine are able to figure out why those errors are not present on CI, but present when running local.
Comment #26
quietone CreditAttribution: quietone as a volunteer commentedNeeded a reroll, probably because of #2565931: Handle long comment bundle names.
Comment #27
quietone CreditAttribution: quietone as a volunteer commentedOptionally, the errors are coming from d6_taxonomy_term_translation and d6_term_node_translation. Maybe those migrations can be changed and the errors avoided?
Comment #29
quietone CreditAttribution: quietone as a volunteer commentedAn idea for avoiding the errors.
Comment #31
quietone CreditAttribution: quietone as a volunteer commentedAnother attempt, this changes d6_taxonomy_term_localized to skip rows that are not using localization. This patch is based on #26.
Edit; fix grammar
Comment #32
quietone CreditAttribution: quietone as a volunteer commentedCreated an issue for fixing the d6_taxonomy_term_localized_translation migration. #3193189: Get only translations for localized vocabularies d6/TermLocalizedTranslation.php.
I am not yet marking this a blocked, because work can continue on a) why drupalci reports different results and b) improving the test. For b) is a count a message sufficient here or should we count the types of messages. In one sense this is about saving the log for review after the test so the number of message is sufficient. However, we could take advantage of this and add more assertions on the message type or message text.
Comment #33
quietone CreditAttribution: quietone as a volunteer commentedUpdating the patch in #26 with the latest version of #3193189: Get only translations for localized vocabularies d6/TermLocalizedTranslation.php to make sure that Upgrade6Test passes with that change.
Comment #34
quietone CreditAttribution: quietone as a volunteer commentedpostponing on #3193189: Get only translations for localized vocabularies d6/TermLocalizedTranslation.php
Comment #36
quietone CreditAttribution: quietone as a volunteer commentedRemoving tag, I don't know that tag or how I did that.
Comment #37
quietone CreditAttribution: quietone as a volunteer commentedJust a reroll.
Comment #38
quietone CreditAttribution: quietone as a volunteer commentedComment #39
mikelutzNeed the return typehint that is in the docblock to be added to the method declaration
Which brings up the issue that you've declared the return value to be an int, but you are returning void here. Should these `return 0;`?
Comment #40
quietone CreditAttribution: quietone as a volunteer commentedThis should fix #39 1 and 2. I added the return type hints and added 'return 0' as needed.
Comment #42
quietone CreditAttribution: quietone as a volunteer commentedRemove duplicate doc block and fix the test to test for integers.
Comment #44
quietone CreditAttribution: quietone as a volunteer commentedYep, forgot to check Upgrade7Test like I did for Upgrade6Test.
Comment #45
danflanagan8I patched and ran
Drupal\Tests\migrate_drupal_ui\Functional\d7\Upgrade7Test
locally, and I get all the logs pages as html.While you can't click into the links (since we don't scrape those pages), you can read the un-truncated message by hovering over the link since the link title holds the un-truncated message.
I'm confused about something, though: if the test fails, I don't see browser output for all the log pages.
I tested this by setting
$context['results']['failures'] = 1;
inMigrateUpgradeImportBatch::run()
. The result is that I get a test failure like this:And that's where my browser output stops. I can't get to the log pages because they apparently aren't scraped. So the logs aren't there when I actually need them!
Is this something wrong or different with my local test setup? Or is there something I'm misunderstanding? Or is this a real problem with the approach in the issue?
Setting to NW to get response. Thanks!
Comment #46
quietone CreditAttribution: quietone at PreviousNext commented@danflanagan8, thanks for testing this.
You are not wrong. The logs are only accessed, and thus part of the browser_output, at the end of the test. Any assertion that fails before that will mean that the logs are not output.
To fix that let's go back to the original idea made by benjifisher in #8 and move this into the tearDown method. By doing that it is possible to always access the logs.
Comment #47
quietone CreditAttribution: quietone at PreviousNext commentedSomehow uploaded that patch twice. I'll cancel the tests for the first one.
Comment #48
danflanagan8Thanks, @quietone. That makes sense and I like the fixes.
Now I get the logs even if the test fails.
I only have one suggestion for the patch, and I'm open to a rebuttal on it. Regarding the new abstract function:
What would you think about changing that to a protected property just like the new ones you added in the last patch. It could be
protected $logCountsError = 0;
or even leave it nullprotected $logCountsError;
.And then that default value could be overridden as needed. That way we wouldn't have to duplicate this all over:
Setting to NW to get a response. Once again, open to rebuttal!
Comment #49
quietone CreditAttribution: quietone at PreviousNext commented@danflanagan8, I wasn't fond of that abstract method either. I did want to return to look at that after the tests completed in #46 but, as we can see, that did not happen. I do agree with you that the three variables should be properties should on the TestBase class.
#48. This patch implements the suggestion.
Comment #51
quietone CreditAttribution: quietone at PreviousNext commentedThe test failure was fixed in #3255836: Test fails due to Composer 2.2 so returning this to Needs Review. Not rerunning to the tests until there is a review.
Comment #52
danflanagan8I somehow lost track of this one! The latest patch looks really nice. I'm going trigger tests and then RTBC when they pass.
Comment #53
danflanagan8Darn, apparently this needs a reroll. Tagging and setting to NW.
Comment #54
quietone CreditAttribution: quietone at PreviousNext commentedHere is the reroll. I also noticed that we all missed that the logs were not tested in Upgrade6Test so I added that as well.
Comment #55
danflanagan8Oops. Well this time I applied the patch and tested with
Upgrade6Test
, but otherwise just like I did in #45. The logs were available when the test passed as well as when the test failed. I'm happy.Comment #57
quietone CreditAttribution: quietone at PreviousNext commentedThe failing test is Drupal\Tests\file\FunctionalJavascript\FileManagedFileElementTest which I don't see on the #2829040: [meta] Known intermittent, random, and environment-specific test failures but it unrelated, so restarting the tests.
Comment #59
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedBack to RTBC as per comment #57.
Comment #60
danflanagan8For the record, #57 was not the latest failure. The failure in #58 is in
Drupal\Tests\views\Functional\Plugin\DisplayTest
which is a different random failure.Comment #62
danflanagan8Most recent random failure was in Drupal\Tests\layout_builder\FunctionalJavascript\AjaxBlockTest
Back to RTBC.
Comment #63
quietone CreditAttribution: quietone at PreviousNext commentedAdding 10.0.x version
Comment #65
quietone CreditAttribution: quietone at PreviousNext commentedNeed to increase the count of errors logged maybe because aggregator was removed from the test. Or maybe not since Upgrade7Test is not affected. But for the purpose of this issue the number of errors in not a problem, we just want to make sure they are logged. This will become a test that needs to change when a module is removed, sort of like the entity_counts, so at least it is the same two files.
Comment #66
quietone CreditAttribution: quietone at PreviousNext commentedReroll after #3267513: Handle migration tests for removing RDF
Comment #67
danflanagan8Reroll looks correct. RTBC. Thanks, @quietone!
Comment #69
quietone CreditAttribution: quietone at PreviousNext commentedUnrelated failure in Drupal\Tests\quickedit\FunctionalJavascript\QuickEditFileTest::testRemove
Restoring RTBC
Comment #71
quietone CreditAttribution: quietone at PreviousNext commentedrandom fail, Drupal\Tests\quickedit\FunctionalJavascript\QuickEditFileTest::testRemove
Comment #73
quietone CreditAttribution: quietone at PreviousNext commentedAnd again, 1) Drupal\Tests\quickedit\FunctionalJavascript\QuickEditFileTest::testRemove
Comment #75
quietone CreditAttribution: quietone at PreviousNext commentedThere is a new failure and I tracked it down to #3277057: Make Claro the default admin theme in Standard profile.
We can either change the count of errors logged or install Seven in the destination site. I did the later in order to preserve what is on the source site, that is the theme settings for Seven. doing that changes the number of blocks, so an entity count is updated.
Comment #76
danflanagan8This makes sense to me. RTBC.
This got me wondering if all the tests we've been moving to contrib are going to start failing, but it looks like they'll be fine. Those tests don't assert the number of log errors so they shouldn't mind a few extra errors.
Comment #77
benjifisherThe patch for this issue needs a reroll after #3219959: Update standard profile so Olivero is the default theme. I am adding the Novice tag for the reroll.
Comment #78
quietone CreditAttribution: quietone at PreviousNext commentedAnd another reroll.
Comment #79
quietone CreditAttribution: quietone at PreviousNext commentedUpdating the tags.
And setting to NR so someone checks the reroll.
Comment #80
benjifisherThanks for the reroll!
I compared the patches in #75 and #78. Other than metadata, the only differences were an entity count and an expected error count in Upgrade7Test. If the testbot is happy, then I am happy. Back to RTBC.
Comment #82
catchI was a bit confused why we're visiting the log pages reading the patch, but it seems like a decent way to preserve the messages and couldn't think of another idea.
Committed/pushed to 10.1.x and cherry-picked back to 9.4.x, thanks!
Comment #83
xjmThis issue may have broken D9 head; a revert patch is running at #2994000: Notice in logs when setting invalid translation config for a content type.
Comment #84
mikelutzMust have been this one. We changed the block count several times as the new themes became default, all of which should be in 9.4 and 10, but we should have ran the test again against D9, there are enough differences. I would be fine with leaving this in 10.1+ and reverting 9.4,9.5, and 10.0 if that's an option.
Comment #87
catchReverted from 9.4.x and 9.5.x for now.
Comment #88
quietone CreditAttribution: quietone at PreviousNext commentedWorking on a patch for D9.
Comment #89
quietone CreditAttribution: quietone at PreviousNext commentedI don't know why this is failing on sqlite. And locally, I don't seem to be able to run tests with sqlite anymore. Looks like some investigation is in order.
Comment #90
quietone CreditAttribution: quietone at PreviousNext commentedWhat I didn't realize is that the test was running with sqlite, it was just taking a very long time. It takes 50 minutes (!) to run Upgrade6Test.php but it fails when asserting that the upgrade succeeded which happens before the point where the test fails on the testbot.
Not sure what to try next.
Comment #92
catchThis is failing on sqlite on 10.0.x and 10.1.x too, reverted from those branches as well.
Comment #94
quietone CreditAttribution: quietone at PreviousNext commentedUpdate remaining tasks
Adding a test with sqlite to #78, to show the error.
Comment #95
quietone CreditAttribution: quietone at PreviousNext commentedLet's see if I can get testbot to output something useful.
Comment #97
quietone CreditAttribution: quietone at PreviousNext commentedThat doe show the differences in the output for mysql and sqlite.
1) The order of error messages for the d6_term_node_translation migration vary. For mysql it is source id 2001, 2001, 3, 2001. For sqlite it is source id 2001, 3, 2001, 2001.
2) For sqlite there is an extra entry at the end,
This message is listed earlier in the watchdog log with both mysql and sqlite. The message is from the d6 Field source plugin which is used in migration d6_field.yml, so it makes sense for it appear early in the log. But for some reason, with sqlite that source plugin is running again later in the upgrade. The d6_field source plugin is used in the d6_field migration and the d6_field_option_translation migration.
Now, I just need to figure how to use that to make a fix. Hmm....
Edit: s/node complete/d6_node_term_node_translation/
Comment #98
quietone CreditAttribution: quietone at PreviousNext commentedThe process plugin, NodeCompleteNodeTranslationLookup, will return the nid and langcode when the language is NULL. The patch changes the to return NULL when the langcode is NULL.
Comment #100
quietone CreditAttribution: quietone at PreviousNext commentedI didn't remove the test code.
This patch added the possible fix to NodeCompleteNodeTranslationLookup. The interdiff is against the patch that got committed.
Comment #102
quietone CreditAttribution: quietone at PreviousNext commentedJust updating the patch.
Comment #103
quietone CreditAttribution: quietone at PreviousNext commentedA bit of a typo.
Comment #105
quietone CreditAttribution: quietone at PreviousNext commented@sonam_sharma, credit has been removed per How is credit granted for Drupal core issues
Comment #106
quietone CreditAttribution: quietone at PreviousNext commentedThis patch removes the changes to drupalci and to core/modules/migrate_drupal/src/Plugin/migrate/process/NodeCompleteNodeTranslationLookup.php. The latter should be in a separate issue.
Comment #109
quietone CreditAttribution: quietone at PreviousNext commentedBack to needs review.
Comment #111
smustgrave CreditAttribution: smustgrave commentedWant to request an uncheck all button. Since the fix has moved to MR5272 hiding the patches for clarity.
Rebased MR5272 to run test-only feature
The change itself seems simple enough.
Comment #112
longwaveAdded some questions to the MR.
Comment #113
quietone CreditAttribution: quietone at PreviousNext commentedI've answered the queries and adjusted the error message count.
Comment #114
smustgrave CreditAttribution: smustgrave commentedLeft some small nitpicky stuff, leaving in review for additional eyes.
Comment #115
smustgrave CreditAttribution: smustgrave commentedSeems nitpicky stuff was addressed. Since this was close before believe it's fine to mark now.
Comment #116
longwaveNeeds rebasing against 11.x, there are lots of unrelated changes in the MR.
Comment #117
quietone CreditAttribution: quietone at PreviousNext commented@longwave, sorry about that. I don't know how that happened, but it is fixed now. I am restoring RTBC because there were no conflicts when rebasing.
Comment #118
longwaveConfirmed via GitLab CI that the tests pass on SQLite now. However, decided not to backport as this is a minimal improvement and seems slightly fragile given the hardcoded log counts.
Committed a904645 and pushed to 11.x. Thanks!