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

[testing] Cleaning up TemplateTests iOS simulator issues #20817

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

ivanpovazan
Copy link
Member

@ivanpovazan ivanpovazan commented Feb 23, 2024

Description

This PR tries to fix failures reported in: #21077

The issues seem to be caused by the following:

  • we are querying xharness to find the device's UDID based on ios-simulator-64 in:
    public string XHarnessID { get; set; } = "ios-simulator-64";
  • since we are only passing the device name: ios-simulator-64, xharness returns the first device that matches the pattern. However, there can be more device with the same name but different version which can lead to unwanted behaviour

Problem scenario

There are two devices:
- ios-simulator-64_17.0 (e.g., UDID: 491595A5-EBC3-4605-9069-7D2E57E826B0, State: Shutdown)
- ios-simulator-64_17.2 (eg., UDID: A3DB0329-7EE0-4C6C-A69A-2B6CF76F870E, State: Booted)

When querying for device's UDID based on ios-simulator-64 only, xharness will return: 491595A5-EBC3-4605-9069-7D2E57E826B0 which is a device already in 'Shutdown' state.

This can be a problem, as the sequence in the test SetUp code in TemplateTests:

TestSimulator.Shutdown();
Assert.IsTrue(TestSimulator.Launch(), $"Failed to boot simulator with UDID '{TestSimulator.GetUDID()}'.");
TestSimulator.ShowWindow();

can further cause the simulator to be in a corrupted state:

   [ToolRunner] Running: xcrun simctl shutdown 491595A5-EBC3-4605-9069-7D2E57E826B0
   [ToolRunner] Process 'xcrun' exited with code: 149
   [ToolRunner] Running: xcrun simctl boot 491595A5-EBC3-4605-9069-7D2E57E826B0
   [ToolRunner] Process 'xcrun' exited with code: 0

Which finally makes the test execution fail:

error VSTEST1: Microsoft.Maui.IntegrationTests.AppleTemplateTests.AppleTemplateSetup()   Failed to boot simulator with UDID '491595A5-EBC3-4605-9069-7D2E57E826B0'

Solution

This PR tries to fix the problem by:

  • utilizing the same logic for preparing and reseting iOS simulators prior to test run (like we do for device and UI tests) and
  • explicitly querying the exact device name and version
    which should bring us always to a clean state, before executing TemplateTests

Contributes to:

@ivanpovazan ivanpovazan added the do-not-merge Don't merge this PR label Feb 23, 2024
@ivanpovazan ivanpovazan self-assigned this Feb 23, 2024
@ivanpovazan ivanpovazan force-pushed the use-xharness-everywhere branch from 49c0135 to 77ed473 Compare March 8, 2024 14:12
@ivanpovazan ivanpovazan changed the title [WIP] Cleaning up CI iOS simulator issues [testing] Cleaning up TemplateTests iOS simulator issues Mar 8, 2024
@ivanpovazan ivanpovazan marked this pull request as ready for review March 8, 2024 15:13
@ivanpovazan ivanpovazan requested a review from a team as a code owner March 8, 2024 15:13
@ivanpovazan ivanpovazan added area-testing Unit tests, device tests and removed do-not-merge Don't merge this PR labels Mar 8, 2024
@rmarinho rmarinho merged commit 23069ff into dotnet:main Mar 15, 2024
43 of 47 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants