Skip to content

Commit 4c2d8a9

Browse files
author
Maddie Clayton
authored
Merge pull request #6405 from matthchr/matthchr/fix-tests
Re-record Batch tests
2 parents 8f20059 + 6451e93 commit 4c2d8a9

File tree

47 files changed

+4276
-6598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4276
-6598
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchAccountTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ public BatchAccountTests(Xunit.Abstractions.ITestOutputHelper output)
2424
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
2525
}
2626

27-
[Fact(Skip = "Need service team to re-record test after changes to the ClientRuntime.")]
27+
[Fact]
2828
[Trait(Category.AcceptanceType, Category.CheckIn)]
29-
[Trait("Re-record", "ClientRuntime changes")]
3029
public void TestBatchAccountEndToEnd()
3130
{
3231
BatchController.NewInstance.RunPsTest("Test-BatchAccountEndToEnd");
3332
}
3433

3534
[Fact]
36-
[Trait(Category.AcceptanceType, Category.Flaky)]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3736
public void TestListNodeAgentSkus()
3837
{
3938
BatchController.NewInstance.RunPsTest("Test-GetBatchNodeAgentSkus");

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchApplicationPackageTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class BatchApplicationPackageTests : WindowsAzure.Commands.Test.Utilities
2525
private const string version = "foo";
2626

2727
[Fact]
28-
[Trait(Category.AcceptanceType, Category.Flaky)]
28+
[Trait(Category.AcceptanceType, Category.CheckIn)]
2929
public void TestUploadApplicationPackage()
3030
{
3131
string id = "newApplicationPackage";
@@ -55,7 +55,7 @@ public void TestUploadApplicationPackage()
5555
}
5656

5757
[Fact]
58-
[Trait(Category.AcceptanceType, Category.Flaky)]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
5959
public void TestUpdateApplicationPackage()
6060
{
6161
string id = "updateApplicationPackage";
@@ -84,8 +84,8 @@ public void TestUpdateApplicationPackage()
8484
MethodBase.GetCurrentMethod().Name);
8585
}
8686

87-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
88-
[Trait(Category.AcceptanceType, Category.Flaky)]
87+
[Fact]
88+
[Trait(Category.AcceptanceType, Category.CheckIn)]
8989
public void TestCreatePoolWithApplicationPackage()
9090
{
9191
string id = "createPoolWithApplicationPackage";
@@ -113,8 +113,8 @@ public void TestCreatePoolWithApplicationPackage()
113113
MethodBase.GetCurrentMethod().Name);
114114
}
115115

116-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
117-
[Trait(Category.AcceptanceType, Category.Flaky)]
116+
[Fact]
117+
[Trait(Category.AcceptanceType, Category.CheckIn)]
118118
public void TestUpdatePoolWithApplicationPackage()
119119
{
120120
string id = "updatePoolWithApplicationPackage";

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/CertificateTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public CertificateTests(Xunit.Abstractions.ITestOutputHelper output)
2727
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
2828
}
2929

30-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
31-
[Trait(Category.AcceptanceType, Category.Flaky)]
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3232
public void TestCertificateCrudOperations()
3333
{
3434
BatchController.NewInstance.RunPsTest("Test-CertificateCrudOperations");
3535
}
3636

37-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
38-
[Trait(Category.AcceptanceType, Category.Flaky)]
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3939
public void TestCancelCertificateDelete()
4040
{
4141
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/CertificateTests.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ function Test-CertificateCrudOperations
2222
$thumbprintAlgorithm = "sha1"
2323

2424
$localDir = ($pwd).Path # Use $pwd to get the local directory. If $pwd is not used, paths are relative to [Environment]::CurrentDirectory, which can be different
25-
$certPath = $localDir + "\Resources\BatchTestCert01.cer"
26-
$x509cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $certPath
25+
26+
$certPathVs = $localDir + "/Resources/BatchTestCert01.cer"
27+
# $certPathConsole = [System.IO.Path]::GetDirectoryName($PSScriptRoot) + "/Resources/BatchTestCert01.cer"
28+
# $certPath = if (Test-Path $certPathVs -PathType Leaf) { $certPathVs } Else { $certPathConsole }
29+
$x509cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $certPathVs
2730

2831
# Add the cert
2932
$x509cert | New-AzureBatchCertificate -BatchContext $context

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/Common.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ function Start-TestSleep($milliseconds)
2424
}
2525
}
2626

27+
function Compute-TestTimeout($seconds)
28+
{
29+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -eq [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
30+
{
31+
# Timeout of 3 hours, to deal with long delays in recording framework
32+
return 60 * 24 * 3
33+
}
34+
else
35+
{
36+
return $seconds
37+
}
38+
}
39+
2740
<#
2841
.SYNOPSIS
2942
Gets a Batch account name for testing.

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/ComputeNodeTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public ComputeNodeTests(Xunit.Abstractions.ITestOutputHelper output)
2828
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
2929
}
3030

31-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
32-
[Trait(Category.AcceptanceType, Category.Flaky)]
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3333
public void TestRemoveComputeNodes()
3434
{
3535
BatchController controller = BatchController.NewInstance;
@@ -51,8 +51,8 @@ public void TestRemoveComputeNodes()
5151
MethodBase.GetCurrentMethod().Name);
5252
}
5353

54-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
55-
[Trait(Category.AcceptanceType, Category.Flaky)]
54+
[Fact]
55+
[Trait(Category.AcceptanceType, Category.CheckIn)]
5656
public void TestRebootAndReimageComputeNode()
5757
{
5858
BatchController controller = BatchController.NewInstance;
@@ -74,8 +74,8 @@ public void TestRebootAndReimageComputeNode()
7474
MethodBase.GetCurrentMethod().Name);
7575
}
7676

77-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
78-
[Trait(Category.AcceptanceType, Category.Flaky)]
77+
[Fact]
78+
[Trait(Category.AcceptanceType, Category.CheckIn)]
7979
public void TestDisableAndEnableComputeNodeScheduling()
8080
{
8181
BatchController controller = BatchController.NewInstance;
@@ -94,8 +94,8 @@ public void TestDisableAndEnableComputeNodeScheduling()
9494
MethodBase.GetCurrentMethod().Name);
9595
}
9696

97-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
98-
[Trait(Category.AcceptanceType, Category.Flaky)]
97+
[Fact]
98+
[Trait(Category.AcceptanceType, Category.CheckIn)]
9999
public void TestGetComputeNodeRemoteLoginSettings()
100100
{
101101
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/ComputeNodeTests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ function Test-RemoveComputeNodes
3535
$select = "id,state"
3636
$computeNodes = Get-AzureBatchComputeNode -PoolId $poolId -Select $select -BatchContext $context
3737
$start = [DateTime]::Now
38-
$end = $start.AddSeconds(30)
38+
$timeout = Compute-TestTimeout 30
39+
$end = $start.AddSeconds($timeout)
3940
while ($computeNodes[0].State -ne 'LeavingPool' -and $computeNodes[1].State -ne 'LeavingPool')
4041
{
4142
if ([DateTime]::Now -gt $end)

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/ComputeNodeUserTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public ComputeNodeUserTests(Xunit.Abstractions.ITestOutputHelper output)
2727
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
2828
}
2929

30-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
31-
[Trait(Category.AcceptanceType, Category.Flaky)]
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3232
public void TestComputeNodeUserEndToEnd()
3333
{
3434
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/FileTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public FileTests(Xunit.Abstractions.ITestOutputHelper output)
2929
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
3030
}
3131

32-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
33-
[Trait(Category.AcceptanceType, Category.Flaky)]
32+
[Fact]
33+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3434
public void TestGetNodeFileContentByTask()
3535
{
3636
BatchController controller = BatchController.NewInstance;
@@ -57,8 +57,8 @@ public void TestGetNodeFileContentByTask()
5757
MethodBase.GetCurrentMethod().Name);
5858
}
5959

60-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
61-
[Trait(Category.AcceptanceType, Category.Flaky)]
60+
[Fact]
61+
[Trait(Category.AcceptanceType, Category.CheckIn)]
6262
public void TestGetNodeFileContentByComputeNode()
6363
{
6464
BatchController controller = BatchController.NewInstance;
@@ -76,8 +76,8 @@ public void TestGetNodeFileContentByComputeNode()
7676
MethodBase.GetCurrentMethod().Name);
7777
}
7878

79-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
80-
[Trait(Category.AcceptanceType, Category.Flaky)]
79+
[Fact]
80+
[Trait(Category.AcceptanceType, Category.CheckIn)]
8181
public void TestGetRemoteDesktopProtocolFile()
8282
{
8383
BatchController controller = BatchController.NewInstance;
@@ -95,8 +95,8 @@ public void TestGetRemoteDesktopProtocolFile()
9595
MethodBase.GetCurrentMethod().Name);
9696
}
9797

98-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
99-
[Trait(Category.AcceptanceType, Category.Flaky)]
98+
[Fact]
99+
[Trait(Category.AcceptanceType, Category.CheckIn)]
100100
public void TestDeleteNodeFileByTask()
101101
{
102102
BatchController controller = BatchController.NewInstance;
@@ -122,8 +122,8 @@ public void TestDeleteNodeFileByTask()
122122
MethodBase.GetCurrentMethod().Name);
123123
}
124124

125-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
126-
[Trait(Category.AcceptanceType, Category.Flaky)]
125+
[Fact]
126+
[Trait(Category.AcceptanceType, Category.CheckIn)]
127127
public void TestDeleteNodeFileByComputeNode()
128128
{
129129
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobScheduleTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ public JobScheduleTests(Xunit.Abstractions.ITestOutputHelper output)
2525
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
2626
}
2727

28-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
29-
[Trait(Category.AcceptanceType, Category.Flaky)]
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3030
public void TestJobScheduleCRUD()
3131
{
3232
BatchController.NewInstance.RunPsTest("Test-JobScheduleCRUD");
3333
}
3434

3535

36-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
37-
[Trait(Category.AcceptanceType, Category.Flaky)]
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3838
public void TestDisableEnableTerminateJobSchedule()
3939
{
4040
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public JobTests(Xunit.Abstractions.ITestOutputHelper output)
2626
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
2727
}
2828

29-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
30-
[Trait(Category.AcceptanceType, Category.Flaky)]
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3131
public void TestJobCRUD()
3232
{
3333
BatchController.NewInstance.RunPsTest("Test-JobCRUD");
3434
}
3535

3636

37-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
38-
[Trait(Category.AcceptanceType, Category.Flaky)]
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3939
public void TestDisableEnableTerminateJob()
4040
{
4141
BatchController controller = BatchController.NewInstance;
@@ -57,8 +57,8 @@ public void TestDisableEnableTerminateJob()
5757
MethodBase.GetCurrentMethod().Name);
5858
}
5959

60-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
61-
[Trait(Category.AcceptanceType, Category.Flaky)]
60+
[Fact]
61+
[Trait(Category.AcceptanceType, Category.CheckIn)]
6262
public void IfJobSetsAutoFailure_ItCompletesWhenAnyTaskFails()
6363
{
6464
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/PoolTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public PoolTests(Xunit.Abstractions.ITestOutputHelper output)
3030
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
3131
}
3232

33-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
34-
[Trait(Category.AcceptanceType, Category.Flaky)]
33+
[Fact]
34+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3535
public void TestPoolCRUD()
3636
{
3737
BatchController.NewInstance.RunPsTest("Test-PoolCRUD");
3838
}
3939

40-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
41-
[Trait(Category.AcceptanceType, Category.Flaky)]
40+
[Fact]
41+
[Trait(Category.AcceptanceType, Category.CheckIn)]
4242
public void TestResizeAndStopResizePool()
4343
{
4444
BatchController controller = BatchController.NewInstance;
@@ -59,8 +59,8 @@ public void TestResizeAndStopResizePool()
5959
MethodBase.GetCurrentMethod().Name);
6060
}
6161

62-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
63-
[Trait(Category.AcceptanceType, Category.Flaky)]
62+
[Fact]
63+
[Trait(Category.AcceptanceType, Category.CheckIn)]
6464
public void TestAutoScaleActions()
6565
{
6666
BatchController controller = BatchController.NewInstance;
@@ -81,8 +81,8 @@ public void TestAutoScaleActions()
8181
MethodBase.GetCurrentMethod().Name);
8282
}
8383

84-
[Fact(Skip = "Need Batch team to re-record failing test. See the following issue: https://github.com/Azure/azure-powershell/issues/5006")]
85-
[Trait(Category.AcceptanceType, Category.Flaky)]
84+
[Fact]
85+
[Trait(Category.AcceptanceType, Category.CheckIn)]
8686
public void TestChangeOSVersion()
8787
{
8888
BatchController controller = BatchController.NewInstance;

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/ScenarioTestHelpers.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public static string AddTestCertificate(BatchController controller, BatchAccount
9797
{
9898
PSCertificate existingCert = client.ListCertificates(getParameters).FirstOrDefault();
9999
DateTime start = DateTime.Now;
100-
DateTime end = start.AddMinutes(5);
100+
TimeSpan timeout = GetTimeout(TimeSpan.FromMinutes(5));
101+
DateTime end = start.Add(timeout);
101102

102103
// Cert might still be deleting from other tests, so we wait for the delete to finish.
103104
while (existingCert != null && existingCert.State == CertificateState.Deleting)
@@ -154,7 +155,7 @@ public static void WaitForCertificateToFailDeletion(BatchController controller,
154155

155156
PSCertificate cert = client.ListCertificates(parameters).First();
156157

157-
DateTime timeout = DateTime.Now.AddMinutes(2);
158+
DateTime timeout = DateTime.Now.Add(GetTimeout(TimeSpan.FromMinutes(2)));
158159
while (cert.State != CertificateState.DeleteFailed)
159160
{
160161
if (DateTime.Now > timeout)
@@ -262,7 +263,7 @@ public static void WaitForSteadyPoolAllocation(BatchController controller, Batch
262263
PoolId = poolId
263264
};
264265

265-
DateTime timeout = DateTime.Now.AddMinutes(5);
266+
DateTime timeout = DateTime.Now.Add(GetTimeout(TimeSpan.FromMinutes(5)));
266267
PSCloudPool pool = client.ListPools(options).First();
267268
while (pool.AllocationState != AllocationState.Steady)
268269
{
@@ -347,7 +348,7 @@ public static void CreateTestJob(BatchController controller, BatchAccountContext
347348
/// </summary>
348349
public static string WaitForRecentJob(BatchController controller, BatchAccountContext context, string jobScheduleId, string previousJob = null)
349350
{
350-
DateTime timeout = DateTime.Now.AddMinutes(2);
351+
DateTime timeout = DateTime.Now.Add(GetTimeout(TimeSpan.FromMinutes(2)));
351352
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
352353

353354
ListJobScheduleOptions options = new ListJobScheduleOptions(context)
@@ -508,7 +509,7 @@ public static void WaitForIdleComputeNode(BatchController controller, BatchAccou
508509
Select = "id,state"
509510
};
510511

511-
DateTime timeout = DateTime.Now.AddMinutes(5);
512+
DateTime timeout = DateTime.Now.Add(GetTimeout(TimeSpan.FromMinutes(10)));
512513
PSComputeNode computeNode = client.ListComputeNodes(options).First();
513514
while (computeNode.State != ComputeNodeState.Idle)
514515
{
@@ -606,5 +607,15 @@ private static void Sleep(int milliseconds)
606607
Thread.Sleep(milliseconds);
607608
}
608609
}
610+
611+
private static TimeSpan GetTimeout(TimeSpan timeout)
612+
{
613+
if (HttpMockServer.Mode == HttpRecorderMode.Playback)
614+
{
615+
return TimeSpan.FromHours(3);
616+
}
617+
618+
return timeout;
619+
}
609620
}
610621
}

0 commit comments

Comments
 (0)