Skip to content

Commit ee57d06

Browse files
authored
[ReceveryServices] Fix delay in long running operations (Azure#18568)
* fix delay * update changelog
1 parent d8ab059 commit ee57d06

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/TrackingHelpers.cs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ public static T GetOperationStatus<T>(RestAzureNS.AzureOperationResponse respons
4747
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
4848
while (opStatusResponse.Body.Status == ServiceClientModel.OperationStatusValues.InProgress)
4949
{
50-
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
51-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || !TestMockSupport.RunningMocked)
50+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
5251
{
53-
Thread.Sleep(5000);
52+
Thread.Sleep(10000);
53+
}
54+
else
55+
{
56+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
5457
}
5558
opStatusResponse = getOpStatus(operationId);
5659
}
@@ -79,10 +82,13 @@ public static T GetOperationStatus<T, S>(RestAzureNS.AzureOperationResponse<S> r
7982
while (opStatusResponse.Body.Status ==
8083
ServiceClientModel.OperationStatusValues.InProgress)
8184
{
82-
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
83-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || !TestMockSupport.RunningMocked)
85+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
86+
{
87+
Thread.Sleep(10000);
88+
}
89+
else
8490
{
85-
Thread.Sleep(5000);
91+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
8692
}
8793
opStatusResponse = getOpStatus(operationId);
8894
}
@@ -110,10 +116,13 @@ public static RestAzureNS.AzureOperationResponse GetOperationResult(
110116
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
111117
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
112118
{
113-
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
114-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || !TestMockSupport.RunningMocked)
119+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
120+
{
121+
Thread.Sleep(10000);
122+
}
123+
else
115124
{
116-
Thread.Sleep(5000);
125+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
117126
}
118127
opStatusResponse = getOpStatus(operationId);
119128
}
@@ -141,10 +150,13 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationStatusDataMove<T
141150
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
142151
while (opStatusResponse.Body.Status == "InProgress")
143152
{
144-
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
145-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || !TestMockSupport.RunningMocked)
153+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
146154
{
147-
Thread.Sleep(5000);
155+
Thread.Sleep(10000);
156+
}
157+
else
158+
{
159+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
148160
}
149161
opStatusResponse = getOpStatus(operationId);
150162
}
@@ -171,10 +183,13 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
171183
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
172184
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
173185
{
174-
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
175-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || !TestMockSupport.RunningMocked)
186+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
187+
{
188+
Thread.Sleep(10000);
189+
}
190+
else
176191
{
177-
Thread.Sleep(5000);
192+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
178193
}
179194
opStatusResponse = getOpStatus(operationId);
180195
}
@@ -216,10 +231,13 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
216231
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
217232
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
218233
{
219-
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
220-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || !TestMockSupport.RunningMocked)
234+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
235+
{
236+
Thread.Sleep(10000);
237+
}
238+
else
221239
{
222-
Thread.Sleep(5000);
240+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
223241
}
224242
opStatusResponse = getOpStatus(operationId);
225243
}

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed delay in long running operations [#18567]
2122

2223
## Version 5.4.0
2324
* Added support for Multi-user authorization using Resource Guard for recovery services vault.

0 commit comments

Comments
 (0)