Skip to content

Conversation

@premun
Copy link
Member

@premun premun commented Jul 1, 2021

  • Adds support for <CustomCommands> in Android flows
  • Changes Android windows payload script from .bat to .ps1
  • Allows to re-use 1 app for multiple work items but different inputs (and specify work item name)
  • Adds tests for custom commands
  • De-duplicates common code unit test projects
  • Makes unit tests work in non-ci runs

Resolves dotnet/xharness#590

@premun
Copy link
Member Author

premun commented Jul 1, 2021

@fanyang-mono this PR introduces the proper way how we will need to create XHarness Helix jobs in Android/Apple (Apple is ready for some time).

The reason for that is that it will enable us to react to infrastructural issues, do retries and log build telemetry correctly.

I can assist with introducing this for the runtime tests.

The README describes how it's intended to be used:
https://github.com/dotnet/arcade/blob/f2e84e9577e49e3046c215d74e7e4bb499a1a74f/src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/Readme.md

@premun
Copy link
Member Author

premun commented Jul 1, 2021

@imhameed @fanyang-mono @SamMonoRT this PR also adds a new capability - we can now re-use 1 application for multiple work items and have each work item for example call the app with different commands (but in parallel on multiple machines) so just an FYI in case this would help you in some scenarios where for example some tests take a long time and you want to split them.

@fanyang-mono
Copy link
Member

Nice improvement! However, I am not sure how the current runtime tests infrastructure would be able to leverage this. For runtime tests, the xunit tests themselves are running on host. The tests then calls to bash or powershell scripts. Inside the bash or powershell script, the xharness test command gets invoked. If I understand this feature correctly, the runtime test infrastructure would need to be rewrite like how the library tests are, in order to adopt this feature.

@premun
Copy link
Member Author

premun commented Jul 1, 2021

@fanyang-mono it's sort of also not a choice to use it. We will require it so that the Helix mobile device infrastructure is actually maintainable for us. We already spoke about this with Imran and Sam.
Another reason for this is we will start adding monitoring around XHarness jobs and alerting around failing devices and such so we will require everyone using the devices to go through the XHarness SDK.
We will also add telemetry so that we can measure infrastructural failures.
We also add retries in case we recognize a failing device so there's bonuses for you too.

And all these are inside of the XHarness SDK wrapper which changes quite often as we find new way to improve stability.

Also please consider that we have to maintain a good state of all devices so that a bad runtime test won't affect other customers of mobile devices.

However, it can be as simple as not creating the <HelixWorkItem> with the dotnet xUnit.dll ... Helix command but creating <XHarnessApkToTest> instead with the <CustomCommand> being set to dotnet xUnit.dll ... so the change technically doesn't have to be large.

@fanyang-mono
Copy link
Member

fanyang-mono commented Jul 1, 2021

@premun Yes, I understand that we need to make it better and easier to monitor and maintain the devices. If the change is simple as you said, we could give it a try to see what happens. When are you targeting for us to adopt this feature?

@premun
Copy link
Member Author

premun commented Jul 7, 2021

@MattGal could you have a look at this PR please? Thanks!

@SamMonoRT
Copy link
Member

@imhameed @fanyang-mono @SamMonoRT this PR also adds a new capability - we can now re-use 1 application for multiple work items and have each work item for example call the app with different commands (but in parallel on multiple machines) so just an FYI in case this would help you in some scenarios where for example some tests take a long time and you want to split them.

Do you plan to update the existing runtime and runtime staging lanes for devices too ?

Copy link
Member

@MattGal MattGal left a comment

Choose a reason for hiding this comment

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

Seems reasonable, I'd like to chat about the work item payload construction (mostly the recreation of zips over and over) before this merges.

<AndroidInstrumentationName>net.dot.MonoRunner</AndroidInstrumentationName>
</XHarnessApkToTest>

<XHarnessApkToTest Include="System.Text.Json-with-custom-commands">
Copy link
Member

Choose a reason for hiding this comment

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

Now that I've read this far, I think it's likely this will delete and re-zip the same APK payload over and over.

Copy link
Member Author

Choose a reason for hiding this comment

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

It will create new archive for each work item and each archive will contain the APK plus the custom payload scripts created for the work item.

For example in this example, the command.sh file will differ in the archives.

I don't think this is such a big problem, considering we're doing this in parallel. It would be a bit more difficult to synchronize this between processes and create one base archive and then clone it and inject the command.sh so I am not sure it is worth the effort?

Copy link
Member

Choose a reason for hiding this comment

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

I still think it is worth the effort to upload once and reuse work item payloads with this feature. The biggest costs we're seeing lately are from storage (@ulisesh was just showing me this) and the XHarness on-prem testing seems correlated to the biggest increases in spending.

Since you're using these as work item payloads, the bandwidth costs should be roughly the same making N payloads for 1 app, but the storage will rise because users are fully within their rights to use 1 APK for 400 tests now. Additionally, the time sink of uploading the same thing potentially hundreds of times will also be noticeable when prepping the payloads in these scenarios. I'm not blocking the PR, just noting this for future consideration.

@premun
Copy link
Member Author

premun commented Jul 8, 2021

@SamMonoRT

Do you plan to update the existing runtime and runtime staging lanes for devices too ?

I am not sure what you mean?

@SamMonoRT
Copy link
Member

@SamMonoRT

Do you plan to update the existing runtime and runtime staging lanes for devices too ?

I am not sure what you mean?

Is there any followup work needed for individual device CI lanes or will this change in SDK just flow down without required changes in yaml scripts ?

@premun
Copy link
Member Author

premun commented Jul 8, 2021

@SamMonoRT
Is there any followup work needed for individual device CI lanes or will this change in SDK just flow down without required changes in yaml scripts ?

We need to check this in, let Maestro bump Arcade in runtime and then this is the state we're in I believe:

  • iOS is still in PR (CoreCLR runtime tests + Mono on the x64 iOS simulator runtime#43954)
  • Android is already checked in
  • Both need to start using the <CustomCommands> feature
    • Android is less important at the moment because there is not that much going on in the wrapper scripts
    • iOS should not be checked in without this (we spoke about this)
  • iOS still has perf issues if I understand it correctly as the tests just take too long and one of the work items still needs 4 hours to run so there's more work on the iOS side too
  • This change actually allows to split the long running work item into several smaller work items
  • I understand that the approach taken by @fanyang-mono and @imhameed was now unified (I see @imhameed using MobileAppHandler) so technically the change can happen for Android and @imhameed can then merge it into his PR and start using it too?
  • I spoke with @fanyang-mono about the change to <CustomCommands> briefly, however, I am off next week and partially the one after. There are docs around the feature (the Readme in this PR) and conceptually it is totally doable however I am not sure how complex the MSBuild wrapper runtime tests around the Helix SDK have are

@SamMonoRT
Copy link
Member

@SamMonoRT
Is there any followup work needed for individual device CI lanes or will this change in SDK just flow down without required changes in yaml scripts ?

We need to check this in, let Maestro bump Arcade in runtime and then this is the state we're in I believe:

  • iOS is still in PR (CoreCLR runtime tests + Mono on the x64 iOS simulator runtime#43954)

  • Android is already checked in

  • Both need to start using the <CustomCommands> feature

    • Android is less important at the moment because there is not that much going on in the wrapper scripts
    • iOS should not be checked in without this (we spoke about this)
  • iOS still has perf issues if I understand it correctly as the tests just take too long and one of the work items still needs 4 hours to run so there's more work on the iOS side too

  • This change actually allows to split the long running work item into several smaller work items

  • I understand that the approach taken by @fanyang-mono and @imhameed was now unified (I see @imhameed using MobileAppHandler) so technically the change can happen for Android and @imhameed can then merge it into his PR and start using it too?

  • I spoke with @fanyang-mono about the change to <CustomCommands> briefly, however, I am off next week and partially the one after. There are docs around the feature (the Readme in this PR) and conceptually it is totally doable however I am not sure how complex the MSBuild wrapper runtime tests around the Helix SDK have are

Thanks for detailing the changes required. For iOS we are targetting getting this in by next Tuesday (Preview 7 cutoff). Will this land prior to that so iOS can leverage this goodness of smaller workitems.

@premun
Copy link
Member Author

premun commented Jul 9, 2021

@SamMonoRT I only need this reviewed but seems like @MattGal is off. If you need this in, I could check it in and work through his potential feedback in retrospective

@SamMonoRT
Copy link
Member

@SamMonoRT I only need this reviewed but seems like @MattGal is off. If you need this in, I could check it in and work through his potential feedback in retrospective

Let's wait for the right approvals. Hopefully we have it in early next week.

@premun
Copy link
Member Author

premun commented Jul 20, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@MattGal MattGal left a comment

Choose a reason for hiding this comment

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

Changes look good to me. I have some misgivings about making distinct work item payloads for the same app package but it's really hard to grasp the final cost until it's in use and working correctly.

ITaskItem appBundleItem)
{
string appFolderPath = appBundleItem.ItemSpec.TrimEnd(Path.DirectorySeparatorChar);
// The user can re-use the same .apk for 2 work items so the name of the work item will come from ItemSpec and path from metadata
Copy link
Member

Choose a reason for hiding this comment

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

Can't tell, does this make use of the payload reuse behavior (so upload once, download multiple times)?

"--xcode \"$xcode_path\" " +
"-v " +
(includesTestRunner
? $"--launch-timeout \"$launch_timeout\" "
Copy link
Member

Choose a reason for hiding this comment

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

Another place where an interpolated string can prevent errors in future changes.

<AndroidInstrumentationName>net.dot.MonoRunner</AndroidInstrumentationName>
</XHarnessApkToTest>

<XHarnessApkToTest Include="System.Text.Json-with-custom-commands">
Copy link
Member

Choose a reason for hiding this comment

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

I still think it is worth the effort to upload once and reuse work item payloads with this feature. The biggest costs we're seeing lately are from storage (@ulisesh was just showing me this) and the XHarness on-prem testing seems correlated to the biggest increases in spending.

Since you're using these as work item payloads, the bandwidth costs should be roughly the same making N payloads for 1 app, but the storage will rise because users are fully within their rights to use 1 APK for 400 tests now. Additionally, the time sink of uploading the same thing potentially hundreds of times will also be noticeable when prepping the payloads in these scenarios. I'm not blocking the PR, just noting this for future consideration.

@premun premun merged commit dc5deb1 into dotnet:main Jul 21, 2021
@premun premun deleted the prvysoky/custom-commands-android branch July 21, 2021 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrap custom user Helix payloads into the Helix SDK job scripts

6 participants