Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Android tests on background thread #10841

Merged
merged 2 commits into from
Oct 26, 2022

Conversation

mattjohnsonpint
Copy link
Contributor

Hi. We have copied the Maui TestUtils source code into our project, and use it for running device tests on Android emulators, which we do in our GitHub Actions CI. This has been working well, except that at first we were getting a lot of intermittent keyDispatchingTimedOut errors such as the following:

info: Starting default instrumentation class on io.sentry.dotnet.maui.device.testapp (exit code 0 == success)
info: Running instrumentation class {default} took 43.3624407 seconds
warn: Skipping output line due to key-value-pair parse failure: 'INSTRUMENTATION_RESULT: longMsg=Input dispatching timed out (a751cb4 io.sentry.dotnet.maui.device.testapp/io.sentry.dotnet.maui.device.testapp.TestActivity (server) is not responding. Waited 5051ms for FocusEvent(hasFocus=true))'
info: Short message:
      keyDispatchingTimedOut
fail: No value for 'return-code' provided in instrumentation result. This may indicate a crashed test (see log)
info: Wrote current ADB log to /Users/runner/work/sentry-dotnet/sentry-dotnet/./test_output/adb-logcat-io.sentry.dotnet.maui.device.testapp-default.log
info: Attempting to remove apk 'io.sentry.dotnet.maui.device.testapp'..
info: Successfully uninstalled io.sentry.dotnet.maui.device.testapp
XHarness exit code: 82 (RETURN_CODE_NOT_SET)
Error: The process '/bin/sh' failed with exit code 82

(See getsentry/sentry-dotnet#1927)

After some investigation, we realized this was caused because the headless test runner is executing its tests on the main UI thread. We fixed it in our project with getsentry/sentry-dotnet#1929 some time ago - we no longer get keyDispatchingTimedOut errors.

Since it's been working well for us, I thought I should contribute it back here.

@ghost ghost added the community ✨ Community Contribution label Oct 22, 2022
@ghost
Copy link

ghost commented Oct 22, 2022

Hey there @mattjohnsonpint! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@mattjohnsonpint
Copy link
Contributor Author

Also, I presume the same thing is true for iOS tests, but we haven't set that up yet so I didn't want to change that blindly, but it would be here:

var runner = MauiTestApplicationDelegate.Current.Services.GetRequiredService<HeadlessTestRunner>();
await runner.RunTestsAsync();

@rmarinho
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@rmarinho rmarinho requested a review from hartez October 24, 2022 10:46
@Eilon Eilon added the area-infrastructure CI, Maestro / Coherency, upstream dependencies/versions label Oct 24, 2022
@mattleibow mattleibow merged commit e189169 into dotnet:main Oct 26, 2022
@mattleibow
Copy link
Member

Thanks for this. Once day we will have an actual device test package that shows all the work.

@mattjohnsonpint
Copy link
Contributor Author

Also, I presume the same thing is true for iOS tests ...

Just a follow-up. We added iOS tests a few weeks ago, and they have been working well. We didn't need to make any similar change.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-infrastructure CI, Maestro / Coherency, upstream dependencies/versions community ✨ Community Contribution platform/android 🤖
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants