Skip to content

Conversation

@jmagman
Copy link
Member

@jmagman jmagman commented Jan 21, 2021

Upload test logs for LUCI tests.

HostAgent.dumpDirectory defaults to env FLUTTER_LOGS_DIR which is a path set up in the LUCI recipe which will be uploaded to GCS and viewable in the test run UI (https://flutter-review.googlesource.com/c/recipes/+/9944):
Screen Shot 2021-01-25 at 9 50 46 AM
Fallback to a tmp directory when FLUTTER_LOGS_DIR env does not exist (like when run locally).

As a proof-of-concept, use the new HostAgent.dumpDirectory in a test. Persist module_test_ios XCUITest results (This would have helped with test failures like #70630).

Future work

Add dump method to the Device class to collect additional logs, to be called on test failures for connected devices. For example, AndroidDevice.dump() could upload abd dumpsys meminfo, abd dumpsys procstats, etc to the uploaded directory.

#74344

@jmagman
Copy link
Member Author

jmagman commented Jan 22, 2021

@jmagman
Copy link
Member Author

jmagman commented Jan 22, 2021

Logs show it writing files to the recipe_cleanup directory
-resultBundlePath /opt/s/w/ir/k/recipe_cleanup/flutter_logs_dir/module_test_ios-objc-2021-01-22T11:12:20.902358
but I don't see any files in run module_test_ios https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20module_test_ios/2701/steps?succeeded=true&debug=false

@godofredoc Is there more needed to get this working than the recipe change?

[Edit: I know the recipe change was reverted, we can look once it re-lands]

@jmagman
Copy link
Member Author

jmagman commented Jan 22, 2021

I think this is working (it found the recipe_cleanup/flutter_logs_dir log directory from FLUTTER_LOGS_DIR env and wrote test results there). We can merge this whenever and investigate why the logs weren't actually uploaded later.

@godofredoc
Copy link
Contributor

I think this is working (it found the recipe_cleanup/flutter_logs_dir log directory from FLUTTER_LOGS_DIR env and wrote test results there). We can merge this whenever and investigate why the logs weren't actually uploaded later.

Here is a task execution using this PR and my updates to the recipes: https://chromium-swarm.appspot.com/task?id=5145de6679dca410 please take a look.

@jmagman
Copy link
Member Author

jmagman commented Jan 25, 2021

It sure looks like it's working @godofredoc!
Screen Shot 2021-01-25 at 9 50 46 AM

I'm going to get rid of the simulator system log collection, seems like it'll be a lot of noise, though it was a good test.

@jmagman jmagman changed the title Dump state on failing devicelab test to recipe artifact location Dump logs on failing devicelab test to recipe artifact location Jan 25, 2021
@jmagman
Copy link
Member Author

jmagman commented Jan 25, 2021

@godofredoc I can't figure out that UI, how can I see this PR, your updates to the recipe, and the module_test_ios test?

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have the context to review this, but happy to see more logs being made available :)

@jonahwilliams
Copy link
Contributor

(that said, if you wanted to GVC real quick and walk me through it, that might help)

@jmagman
Copy link
Member Author

jmagman commented Jan 25, 2021

I don't really have the context to review this, but happy to see more logs being made available :)

I expanded on the description a bit for context. Essentially, it's finding the FLUTTER_LOGS_DIR environment variable and saving any interesting logs to that path (with fallback to a tmp directory if not found). The contents of that directory will be uploaded and be available on the test run summary page for download (the upload is handled in the recipe, so not this PR). As a proof-of-concept I added uploading the module_test_ios Xcode test results bundle to this location so we can see if it works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a risk of us dumping old logs on a particular test with this sort of host based structure?

i.e. an agent runs a simulator task, then crashes running a physical ios test. The dumped logs include both combined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or I guess this could happen from the same agent - do these logs get cleaned up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked this same question. 😄

Me:

Does this directory need to be removed after upload so the logs don't bleed between tests?

@godofredoc:

The good news is that directory is the in the api.path['cleanup'] which luci cleans up automatically after the task execution.

As for these particular simulator logs, they actually aren't cleaned up between tests, so we'd need to correlate timestamps. For example, the example task execution at started at Jan 22 18:26 but shows simulator logs from Jan 17 18:08:47 (I've since removed the system.log files from upload, but it does upload app crashes from the simulator on task failure). I can file a recipe issue to remove this directory before the Xcode select step, but I don't think this test runner code should worry about that.

However if we say uploaded a adb logcat with a timestamp of the beginning of the test and saved it to the directory, it would be cleaned up after task execution and wouldn't be present in any other tasks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something, something great minds.

I'd be concerned about leaving all of the responsibility of deleting old logs (outside of the upload dir) to the recipes. If someone less familiar with our CI system (most of us) wants to add new logs, then they would also need to know the change the recipe in the right way.

Checking timestamps here seems like a reasonable approach. And yeah, if logs come through adb with a timestamp start they should be fairly up to date.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone less familiar with our CI system (most of us) wants to add new logs, then they would also need to know the change the recipe in the right way.

I hope that would be rare and these artifacts would be more transient, like screenshots, or device log dumps, or IDE test logs, or size analysis files. We could push more of that stuff into this upload directory instead of dumping it all into the task stdout as we do now. I just happened to think of simulator app crashes first, and I had hoped they would be cleaned up between Xcode installs, but I guess not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I would like is for this to fail in a way that doesn't upload logs/files instead of uploading old logs/files, because the former is much easier to notice immediately

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those logs generated in deriveddata? if yes, deriveddata is cleaned up before running every task.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those logs generated in deriveddata? if yes, deriveddata is cleaned up before running every task.

Unfortunately not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed.

@godofredoc
Copy link
Contributor

see this PR, your updates to the recipe, and the module_test_ios test?

I relanded the change a few hours ago, let me re-trigger the all the build in this PR to see the output.

@jmagman
Copy link
Member Author

jmagman commented Jan 27, 2021

I narrowed the scope of this change. I removed the platform implementations of HostAgent and just exposed the dumpDirectory. All this does now is upload the XCUITest results for module_test_ios.

I can add more things we find useful in future PRs.

@jmagman
Copy link
Member Author

jmagman commented Jan 29, 2021

Ready for re-review, @jonahwilliams

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jmagman jmagman merged commit f4f33fd into flutter:master Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants