Skip to content

Commit a1e76af

Browse files
committed
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell into dev
2 parents 04137b7 + fabbc88 commit a1e76af

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ExtensionTests/AzureVMSqlServerExtensionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void TestCleanUp()
5858
}
5959

6060

61-
[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set,Remove)-AzureVMSqlServerExtension)")]
61+
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set,Remove)-AzureVMSqlServerExtension)")]
6262
public void GetAzureVMSqlServerExtensionTest()
6363
{
6464
try
@@ -97,7 +97,7 @@ public void GetAzureVMSqlServerExtensionTest()
9797
}
9898
}
9999

100-
[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
100+
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
101101
public void UpdateVMWithSqlServerExtensionTest()
102102
{
103103
try
@@ -130,7 +130,7 @@ public void UpdateVMWithSqlServerExtensionTest()
130130
}
131131
}
132132

133-
[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
133+
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
134134
public void AddRoleWithSqlServerExtensionTest()
135135
{
136136
try
@@ -161,7 +161,7 @@ public void AddRoleWithSqlServerExtensionTest()
161161
}
162162

163163

164-
[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
164+
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
165165
public void UpdateRoleWithSqlServerExtensionTest()
166166
{
167167
try

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,31 @@ namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
5555

5656
public class ServiceManagementCmdletTestHelper
5757
{
58+
private T RunPSCmdletAndReturnFirst<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false, bool retryOnConflict = true)
59+
{
60+
var result = default(T);
61+
if (retryOnConflict)
62+
{
63+
Utilities.RetryActionUntilSuccess(
64+
() => result = RunPSCmdletAndReturnFirstHelper<T>(cmdlet),
65+
"ConflictError", 3, 60);
66+
}
67+
else
68+
{
69+
result = RunPSCmdletAndReturnFirstHelper<T>(cmdlet);
70+
}
71+
return result;
72+
73+
}
74+
5875
/// <summary>
5976
/// Run a powershell cmdlet that returns the first PSObject as a return value.
6077
/// </summary>
6178
/// <typeparam name="T"></typeparam>
6279
/// <param name="cmdlet"></param>
6380
/// <param name="debug"></param>
6481
/// <returns></returns>
65-
private T RunPSCmdletAndReturnFirst<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
82+
private T RunPSCmdletAndReturnFirstHelper<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
6683
{
6784
var azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdlet);
6885
Collection<PSObject> result = azurePowershellCmdlet.Run(debug);
@@ -91,14 +108,31 @@ private T RunPSCmdletAndReturnFirst<T>(PowershellCore.CmdletsInfo cmdlet, bool d
91108
return default(T);
92109
}
93110

111+
private Collection<T> RunPSCmdletAndReturnAll<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false, bool retryOnConflict = true)
112+
{
113+
var result = new Collection<T>();
114+
if (retryOnConflict)
115+
{
116+
Utilities.RetryActionUntilSuccess(
117+
() => result = RunPSCmdletAndReturnAllHelper<T>(cmdlet),
118+
"ConflictError", 3, 60);
119+
}
120+
else
121+
{
122+
result = RunPSCmdletAndReturnAllHelper<T>(cmdlet);
123+
}
124+
return result;
125+
}
126+
127+
94128
/// <summary>
95129
/// Run a powershell cmdlet that returns a collection of PSObjects as a return value.
96130
/// </summary>
97131
/// <typeparam name="T"></typeparam>
98132
/// <param name="cmdlet"></param>
99133
/// <param name="debug"></param>
100134
/// <returns></returns>
101-
private Collection<T> RunPSCmdletAndReturnAll<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
135+
private Collection<T> RunPSCmdletAndReturnAllHelper<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
102136
{
103137
var azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdlet);
104138
Collection<PSObject> result = azurePowershellCmdlet.Run(debug);
@@ -1314,9 +1348,7 @@ public SM.PersistentVMRoleContext ExportAzureVM(string vmName, string serviceNam
13141348
public ManagementOperationContext UpdateAzureVM(string vmName, string serviceName, SM.PersistentVM persistentVM)
13151349
{
13161350
ManagementOperationContext result = new ManagementOperationContext();
1317-
Utilities.RetryActionUntilSuccess(
1318-
() => result = RunPSCmdletAndReturnFirst<ManagementOperationContext>(new UpdateAzureVMCmdletInfo(vmName, serviceName, persistentVM)),
1319-
"409", 3, 60);
1351+
result = RunPSCmdletAndReturnFirst<ManagementOperationContext>(new UpdateAzureVMCmdletInfo(vmName, serviceName, persistentVM));
13201352
return result;
13211353
}
13221354

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/Utilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public static void RetryActionUntilSuccess(Action act, string errorMessage, int
586586
}
587587
catch (Exception e)
588588
{
589-
if (e.ToString().Contains(errorMessage))
589+
if (e.ToString().Contains(errorMessage) || (e.InnerException != null && e.InnerException.ToString().Contains(errorMessage)))
590590
{
591591
Console.WriteLine("{0} error occurs! retrying ...", errorMessage);
592592
if (e.InnerException != null)

0 commit comments

Comments
 (0)