Skip to content

Commit 3e0b4da

Browse files
authored
[CI] Run TimeZoneInfo tests in parallel. (#4161)
Create RunAllTests variable Creates a new RunAllTests variable that defaults to false. This variable is used as a condition to trigger running our extended regression test suite. This variable is set to true in the following ways: The master pipeline sets the value to true so all commits to master run the full suite. The value is set to true for a PR build if: The branch name contains mono- The branch is not a fork This allows our Mono bump branches PRs (which take the form of mono-2019-12) to run the full suite, as there is a much higher chance of breakage for these commits. If you are queuing a new run from the UI, clicking the Variables option will allow you to set it to true for that run. (The variable shows up with the default value so you don't have to remember its name.) Put extended suites behind RunAllTests variable The following test suites are behind this new variable: Integrated Regression - MacOS Integrated Regression - Windows TimeZoneInfo - MacOS The effective changes are: Previously the integrated regression suite also ran for non-fork PR builds. Previously the TZI suite ran on all PR builds. We have determined that these suites are unlikely to break for normal day-to-day changes, so by default they will now only run on master commits and Mono bump PRs. As stated above, if you feel your change may be risky you can manually kick off a full test in the Pipelines UI. Updates the regression test stage introduced in commit 47e00d7 to only run when the mac_build stage completes successfully, as it depends on artifacts produced by that stage. Parallelize TimeZoneInfo tests The TimeZoneInfo test suite has been split across 3 build nodes to reduce each run below the target of 1 hour. (Previously this step took over 2 hours.)
1 parent 656085a commit 3e0b4da

File tree

3 files changed

+96
-56
lines changed

3 files changed

+96
-56
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ variables:
5353
HostedMac: Hosted Mac Internal
5454
HostedWinVS2019: Hosted Windows 2019 with VS2019
5555
VSEngWinVS2019: VSEng-Xamarin-Android
56+
# Run all tests if:
57+
# - User who queued the job requested it (They set XA.RunAllTests to true)
58+
# - This is the master integration branch (Pipeline defaults XA.RunAllTests to true)
59+
# - This is a non-fork branch with name containing "mono-" (for Mono bumps)
60+
IsMonoBranch: $[and(eq(variables['XA.Commercial.Build'], 'true'), ne(variables['System.PullRequest.IsFork'], 'True'), contains(variables['Build.SourceBranchName'], 'mono-'))]
61+
RunAllTests: $[or(eq(variables['XA.RunAllTests'], true), eq(variables['IsMonoBranch'], true))]
5662

5763
# Stage and Job "display names" are shortened because they are combined to form the name of the corresponding GitHub check.
5864
stages:
@@ -819,7 +825,7 @@ stages:
819825
parameters:
820826
testRunTitle: MSBuildDeviceIntegration On Device - macOS
821827
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll
822-
nunitConsoleExtraArgs: --where "test != Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrect"
828+
nunitConsoleExtraArgs: --where "cat != TimeZoneInfo"
823829
testResultsFile: TestResult-MSBuildDeviceIntegration-$(XA.Build.Configuration).xml
824830

825831
- task: MSBuild@1
@@ -836,51 +842,6 @@ stages:
836842
parameters:
837843
artifactName: Test Results - MSBuild With Emulator - macOS
838844

839-
# Check - "Xamarin.Android (Test TimeZoneInfo With Emulator - macOS)"
840-
- job: mac_timezonedevice_tests
841-
displayName: TimeZoneInfo With Emulator - macOS
842-
pool: $(HostedMac)
843-
timeoutInMinutes: 240
844-
cancelTimeoutInMinutes: 5
845-
workspace:
846-
clean: all
847-
steps:
848-
- template: yaml-templates/setup-test-environment.yaml
849-
850-
- task: DownloadPipelineArtifact@1
851-
inputs:
852-
artifactName: $(TestAssembliesArtifactName)
853-
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
854-
855-
- task: MSBuild@1
856-
displayName: start emulator
857-
inputs:
858-
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
859-
configuration: $(XA.Build.Configuration)
860-
msbuildArguments: >
861-
/t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog
862-
863-
- template: yaml-templates/run-nunit-tests.yaml
864-
parameters:
865-
testRunTitle: TimeZoneInfoTests On Device - macOS
866-
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll
867-
nunitConsoleExtraArgs: --where "test == Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrect"
868-
testResultsFile: TestResult-TimeZoneInfoTests-$(XA.Build.Configuration).xml
869-
870-
- task: MSBuild@1
871-
displayName: shut down emulator
872-
inputs:
873-
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
874-
configuration: $(XA.Build.Configuration)
875-
msbuildArguments: >
876-
/t:AcquireAndroidTarget,ReleaseAndroidTarget
877-
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
878-
condition: always()
879-
880-
- template: yaml-templates/upload-results.yaml
881-
parameters:
882-
artifactName: Test Results - TimeZoneInfo With Emulator - macOS
883-
884845
# Check - "Xamarin.Android (Test Designer - macOS)"
885846
- job: designer_integration_mac
886847
displayName: Designer - macOS
@@ -984,12 +945,12 @@ stages:
984945
- stage: integrated_regression_test
985946
displayName: Regression Tests
986947
dependsOn: mac_build
987-
condition: and(eq(variables['XA.Commercial.Build'], 'true'), ne(variables['System.PullRequest.IsFork'], 'True'))
948+
condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(variables['RunAllTests'], true))
988949
jobs:
989950

990951
# Check - "Xamarin.Android (Test Integrated Regression - macOS)"
991952
- job: integrated_regression_mac_1
992-
displayName: macOS - Node 1
953+
displayName: Mac-1
993954
pool:
994955
name: VSEng-Xamarin-Mac-Devices
995956
demands:
@@ -1005,7 +966,7 @@ stages:
1005966

1006967
# Check - "Xamarin.Android (Test Integrated Regression - macOS)"
1007968
- job: integrated_regression_mac_2
1008-
displayName: macOS - Node 2
969+
displayName: Mac-2
1009970
pool:
1010971
name: VSEng-Xamarin-Mac-Devices
1011972
demands:
@@ -1021,7 +982,7 @@ stages:
1021982

1022983
# Check - "Xamarin.Android (Test Integrated Regression - macOS)"
1023984
- job: integrated_regression_mac_3
1024-
displayName: macOS - Node 3
985+
displayName: Mac-3
1025986
pool:
1026987
name: VSEng-Xamarin-Mac-Devices
1027988
demands:
@@ -1037,7 +998,7 @@ stages:
1037998

1038999
# Check - "Xamarin.Android (Test Integrated Regression - Windows)"
10391000
- job: integrated_regression_Win_1
1040-
displayName: Windows - Node 1
1001+
displayName: Windows-1
10411002
pool:
10421003
name: VSEng-Xamarin-Win-XMA
10431004
demands:
@@ -1059,7 +1020,7 @@ stages:
10591020

10601021
# Check - "Xamarin.Android (Test Integrated Regression - Windows)"
10611022
- job: integrated_regression_Win_2
1062-
displayName: Windows - Node 2
1023+
displayName: Windows-2
10631024
pool:
10641025
name: VSEng-Xamarin-Win-XMA
10651026
demands:
@@ -1081,7 +1042,7 @@ stages:
10811042

10821043
# Check - "Xamarin.Android (Test Integrated Regression - Windows)"
10831044
- job: integrated_regression_Win_3
1084-
displayName: Windows - Node 3
1045+
displayName: Windows-3
10851046
pool:
10861047
name: VSEng-Xamarin-Win-XMA
10871048
demands:
@@ -1100,3 +1061,16 @@ stages:
11001061
node_id: 3
11011062

11021063
- template: remove-visualstudio.yml@yaml
1064+
1065+
# TimeZoneInfo tests
1066+
- template: yaml-templates\run-timezoneinfo-tests.yaml
1067+
parameters:
1068+
node_id: 1
1069+
1070+
- template: yaml-templates\run-timezoneinfo-tests.yaml
1071+
parameters:
1072+
node_id: 2
1073+
1074+
- template: yaml-templates\run-timezoneinfo-tests.yaml
1075+
parameters:
1076+
node_id: 3
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Runs TimeZoneInfo tests against an emulator running on macOS
2+
3+
parameters:
4+
node_id: 0
5+
6+
jobs:
7+
- job: mac_timezoneinfo_tests_${{ parameters.node_id }}
8+
displayName: TimeZone - Mac-${{ parameters.node_id }}
9+
pool: $(HostedMac)
10+
timeoutInMinutes: 90
11+
cancelTimeoutInMinutes: 5
12+
workspace:
13+
clean: all
14+
steps:
15+
- template: setup-test-environment.yaml
16+
17+
- task: DownloadPipelineArtifact@1
18+
inputs:
19+
artifactName: $(TestAssembliesArtifactName)
20+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
21+
22+
- task: MSBuild@1
23+
displayName: start emulator
24+
inputs:
25+
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
26+
configuration: $(XA.Build.Configuration)
27+
msbuildArguments: >
28+
/t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog
29+
30+
- template: run-nunit-tests.yaml
31+
parameters:
32+
testRunTitle: TimeZoneInfoTests On Device - macOS
33+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll
34+
nunitConsoleExtraArgs: --where "test == Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrectNode${{ parameters.node_id }}"
35+
testResultsFile: TestResult-TimeZoneInfoTests-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml
36+
37+
- task: MSBuild@1
38+
displayName: shut down emulator
39+
inputs:
40+
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
41+
configuration: $(XA.Build.Configuration)
42+
msbuildArguments: >
43+
/t:AcquireAndroidTarget,ReleaseAndroidTarget
44+
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
45+
condition: always()
46+
47+
- template: upload-results.yaml
48+
parameters:
49+
artifactName: Test Results - TimeZoneInfo With Emulator - macOS - ${{ parameters.node_id }}

tests/MSBuildDeviceIntegration/Tests/DeploymentTest.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ public void CheckXamarinFormsAppDeploysAndAButtonWorks ()
182182
}, Path.Combine (Root, builder.ProjectDirectory, "button-logcat.log")), "Button Should have been Clicked.");
183183
}
184184

185-
static object [] GetTimeZoneTestCases ()
185+
private const int NODE_COUNT = 3;
186+
187+
static object [] GetTimeZoneTestCases (int node)
186188
{
187189
List<object> tests = new List<object> ();
188190
var ignore = new string [] {
@@ -197,12 +199,27 @@ static object [] GetTimeZoneTestCases ()
197199
tz,
198200
});
199201
}
200-
return tests.ToArray ();
202+
return tests.Where (p => tests.IndexOf (p) % NODE_COUNT == node).ToArray ();
201203
}
202204

203205
[Test]
204-
[TestCaseSource (nameof (GetTimeZoneTestCases))]
206+
[TestCaseSource (nameof (GetTimeZoneTestCases), new object [] { 0 })]
207+
[Retry (1)]
208+
[Category ("TimeZoneInfo")]
209+
public void CheckTimeZoneInfoIsCorrectNode1 (string timeZone) => CheckTimeZoneInfoIsCorrect (timeZone);
210+
211+
[Test]
212+
[TestCaseSource (nameof (GetTimeZoneTestCases), new object [] { 1 })]
205213
[Retry (1)]
214+
[Category ("TimeZoneInfo")]
215+
public void CheckTimeZoneInfoIsCorrectNode2 (string timeZone) => CheckTimeZoneInfoIsCorrect (timeZone);
216+
217+
[Test]
218+
[TestCaseSource (nameof (GetTimeZoneTestCases), new object [] { 2 })]
219+
[Retry (1)]
220+
[Category ("TimeZoneInfo")]
221+
public void CheckTimeZoneInfoIsCorrectNode3 (string timeZone) => CheckTimeZoneInfoIsCorrect (timeZone);
222+
206223
public void CheckTimeZoneInfoIsCorrect (string timeZone)
207224
{
208225
if (!HasDevices)

0 commit comments

Comments
 (0)