Skip to content

Commit ef2f6cd

Browse files
committed
[CI] Run TimeZoneInfo tests in parallel.
1 parent 47e00d7 commit ef2f6cd

File tree

2 files changed

+116
-9
lines changed

2 files changed

+116
-9
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ stages:
819819
parameters:
820820
testRunTitle: MSBuildDeviceIntegration On Device - macOS
821821
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll
822-
nunitConsoleExtraArgs: --where "test != Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrect"
822+
nunitConsoleExtraArgs: --where "cat != TimeZoneInfo"
823823
testResultsFile: TestResult-MSBuildDeviceIntegration-$(XA.Build.Configuration).xml
824824

825825
- task: MSBuild@1
@@ -837,8 +837,8 @@ stages:
837837
artifactName: Test Results - MSBuild With Emulator - macOS
838838

839839
# Check - "Xamarin.Android (Test TimeZoneInfo With Emulator - macOS)"
840-
- job: mac_timezonedevice_tests
841-
displayName: TimeZoneInfo With Emulator - macOS
840+
- job: mac_timezonedevice_tests_node1
841+
displayName: TimeZoneInfo - macOS - 1
842842
pool: $(HostedMac)
843843
timeoutInMinutes: 240
844844
cancelTimeoutInMinutes: 5
@@ -864,8 +864,8 @@ stages:
864864
parameters:
865865
testRunTitle: TimeZoneInfoTests On Device - macOS
866866
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
867+
nunitConsoleExtraArgs: --where "test == Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrectNode1"
868+
testResultsFile: TestResult-TimeZoneInfoTests-Node1-$(XA.Build.Configuration).xml
869869

870870
- task: MSBuild@1
871871
displayName: shut down emulator
@@ -879,7 +879,97 @@ stages:
879879

880880
- template: yaml-templates/upload-results.yaml
881881
parameters:
882-
artifactName: Test Results - TimeZoneInfo With Emulator - macOS
882+
artifactName: Test Results - TimeZoneInfo With Emulator - macOS - 1
883+
884+
# Check - "Xamarin.Android (Test TimeZoneInfo With Emulator - macOS)"
885+
- job: mac_timezonedevice_tests_node2
886+
displayName: TimeZoneInfo - macOS - 2
887+
pool: $(HostedMac)
888+
timeoutInMinutes: 240
889+
cancelTimeoutInMinutes: 5
890+
workspace:
891+
clean: all
892+
steps:
893+
- template: yaml-templates/setup-test-environment.yaml
894+
895+
- task: DownloadPipelineArtifact@1
896+
inputs:
897+
artifactName: $(TestAssembliesArtifactName)
898+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
899+
900+
- task: MSBuild@1
901+
displayName: start emulator
902+
inputs:
903+
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
904+
configuration: $(XA.Build.Configuration)
905+
msbuildArguments: >
906+
/t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog
907+
908+
- template: yaml-templates/run-nunit-tests.yaml
909+
parameters:
910+
testRunTitle: TimeZoneInfoTests On Device - macOS
911+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll
912+
nunitConsoleExtraArgs: --where "test == Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrectNode2"
913+
testResultsFile: TestResult-TimeZoneInfoTests-Node2-$(XA.Build.Configuration).xml
914+
915+
- task: MSBuild@1
916+
displayName: shut down emulator
917+
inputs:
918+
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
919+
configuration: $(XA.Build.Configuration)
920+
msbuildArguments: >
921+
/t:AcquireAndroidTarget,ReleaseAndroidTarget
922+
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
923+
condition: always()
924+
925+
- template: yaml-templates/upload-results.yaml
926+
parameters:
927+
artifactName: Test Results - TimeZoneInfo With Emulator - macOS - 2
928+
929+
# Check - "Xamarin.Android (Test TimeZoneInfo With Emulator - macOS)"
930+
- job: mac_timezonedevice_tests_node3
931+
displayName: TimeZoneInfo - macOS - 3
932+
pool: $(HostedMac)
933+
timeoutInMinutes: 240
934+
cancelTimeoutInMinutes: 5
935+
workspace:
936+
clean: all
937+
steps:
938+
- template: yaml-templates/setup-test-environment.yaml
939+
940+
- task: DownloadPipelineArtifact@1
941+
inputs:
942+
artifactName: $(TestAssembliesArtifactName)
943+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
944+
945+
- task: MSBuild@1
946+
displayName: start emulator
947+
inputs:
948+
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
949+
configuration: $(XA.Build.Configuration)
950+
msbuildArguments: >
951+
/t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog
952+
953+
- template: yaml-templates/run-nunit-tests.yaml
954+
parameters:
955+
testRunTitle: TimeZoneInfoTests On Device - macOS
956+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll
957+
nunitConsoleExtraArgs: --where "test == Xamarin.Android.Build.Tests.DeploymentTest.CheckTimeZoneInfoIsCorrectNode3"
958+
testResultsFile: TestResult-TimeZoneInfoTests-Node3-$(XA.Build.Configuration).xml
959+
960+
- task: MSBuild@1
961+
displayName: shut down emulator
962+
inputs:
963+
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
964+
configuration: $(XA.Build.Configuration)
965+
msbuildArguments: >
966+
/t:AcquireAndroidTarget,ReleaseAndroidTarget
967+
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
968+
condition: always()
969+
970+
- template: yaml-templates/upload-results.yaml
971+
parameters:
972+
artifactName: Test Results - TimeZoneInfo With Emulator - macOS - 3
883973

884974
# Check - "Xamarin.Android (Test Designer - macOS)"
885975
- job: designer_integration_mac

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)