Skip to content

Commit b78307c

Browse files
.Net: Revert RetryFacts for AzureOpenAI Integration Tests (#12576)
### Motivation and Context - Added timeout to up to 100 seconds for potential failing long running tests - Removed recently added RetryFact due to a potential disruption in the current integration infrastructure when multiple integration tests are running in parallel from merge queue. --------- Co-authored-by: Mark Wallace <[email protected]>
1 parent 43e0dc4 commit b78307c

7 files changed

+78
-25
lines changed

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatClient_AutoFunctionChoiceBehaviorTests.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.ComponentModel;
77
using System.Globalization;
88
using System.Linq;
9+
using System.Net.Http;
910
using System.Text;
1011
using System.Threading.Tasks;
1112
using Azure.Identity;
@@ -14,13 +15,13 @@
1415
using Microsoft.SemanticKernel;
1516
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
1617
using SemanticKernel.IntegrationTests.TestSettings;
17-
using xRetry;
1818
using Xunit;
1919

2020
namespace SemanticKernel.IntegrationTests.Connectors.AzureOpenAI;
2121

22-
public sealed class AzureOpenAIChatClientAutoFunctionChoiceBehaviorTests : BaseIntegrationTest
22+
public sealed class AzureOpenAIChatClientAutoFunctionChoiceBehaviorTests : BaseIntegrationTest, IDisposable
2323
{
24+
private HttpClient? _httpClient;
2425
private readonly Kernel _kernel;
2526
private readonly FakeFunctionFilter _autoFunctionInvocationFilter;
2627
private readonly IChatClient _chatClient;
@@ -34,7 +35,7 @@ public AzureOpenAIChatClientAutoFunctionChoiceBehaviorTests()
3435
this._chatClient = this._kernel.GetRequiredService<IChatClient>();
3536
}
3637

37-
[RetryFact]
38+
[Fact]
3839
public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
3940
{
4041
// Arrange
@@ -65,7 +66,7 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomat
6566
Assert.Contains("GetCurrentDate", invokedFunctions);
6667
}
6768

68-
[RetryFact]
69+
[Fact]
6970
public async Task SpecifiedInPromptInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
7071
{
7172
// Arrange
@@ -443,6 +444,7 @@ public async Task SpecifiedInCodeInstructsAIModelToCallFunctionInParallelOrSeque
443444

444445
private Kernel InitializeKernel()
445446
{
447+
this._httpClient ??= new() { Timeout = TimeSpan.FromSeconds(100) };
446448
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get<AzureOpenAIConfiguration>();
447449
Assert.NotNull(azureOpenAIConfiguration);
448450
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
@@ -454,11 +456,18 @@ private Kernel InitializeKernel()
454456
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
455457
modelId: azureOpenAIConfiguration.ChatModelId,
456458
endpoint: azureOpenAIConfiguration.Endpoint,
457-
credentials: new AzureCliCredential());
459+
credentials: new AzureCliCredential(),
460+
httpClient: this._httpClient);
458461

459462
return kernelBuilder.Build();
460463
}
461464

465+
public void Dispose()
466+
{
467+
this._httpClient?.Dispose();
468+
this._chatClient?.Dispose();
469+
}
470+
462471
private readonly IConfigurationRoot _configuration = new ConfigurationBuilder()
463472
.AddJsonFile(path: "testsettings.json", optional: false, reloadOnChange: true)
464473
.AddJsonFile(path: "testsettings.development.json", optional: true, reloadOnChange: true)

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatClient_NoneFunctionChoiceBehaviorTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.ComponentModel;
66
using System.Globalization;
7+
using System.Net.Http;
78
using System.Text;
89
using System.Threading.Tasks;
910
using Azure.Identity;
@@ -16,8 +17,9 @@
1617

1718
namespace SemanticKernel.IntegrationTests.Connectors.AzureOpenAI;
1819

19-
public sealed class AzureOpenAIChatClientNoneFunctionChoiceBehaviorTests : BaseIntegrationTest
20+
public sealed class AzureOpenAIChatClientNoneFunctionChoiceBehaviorTests : BaseIntegrationTest, IDisposable
2021
{
22+
private HttpClient? _httpClient;
2123
private readonly Kernel _kernel;
2224
private readonly FakeFunctionFilter _autoFunctionInvocationFilter;
2325
private readonly IChatClient _chatClient;
@@ -181,8 +183,15 @@ public async Task SpecifiedInPromptInstructsConnectorNotToInvokeKernelFunctionFo
181183
Assert.Empty(invokedFunctions);
182184
}
183185

186+
public void Dispose()
187+
{
188+
this._httpClient?.Dispose();
189+
this._chatClient?.Dispose();
190+
}
191+
184192
private Kernel InitializeKernel()
185193
{
194+
this._httpClient ??= new() { Timeout = TimeSpan.FromSeconds(100) };
186195
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get<AzureOpenAIConfiguration>();
187196
Assert.NotNull(azureOpenAIConfiguration);
188197
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
@@ -194,7 +203,8 @@ private Kernel InitializeKernel()
194203
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
195204
modelId: azureOpenAIConfiguration.ChatModelId,
196205
endpoint: azureOpenAIConfiguration.Endpoint,
197-
credentials: new AzureCliCredential());
206+
credentials: new AzureCliCredential(),
207+
httpClient: this._httpClient);
198208

199209
return kernelBuilder.Build();
200210
}

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatClient_RequiredFunctionChoiceBehaviorTests.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
using System.ComponentModel;
66
using System.Globalization;
77
using System.Linq;
8+
using System.Net.Http;
89
using System.Threading.Tasks;
910
using Azure.Identity;
1011
using Microsoft.Extensions.AI;
1112
using Microsoft.Extensions.Configuration;
1213
using Microsoft.SemanticKernel;
1314
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
1415
using SemanticKernel.IntegrationTests.TestSettings;
15-
using xRetry;
1616
using Xunit;
1717

1818
namespace SemanticKernel.IntegrationTests.Connectors.AzureOpenAI;
1919

20-
public sealed class AzureOpenAIChatClientRequiredFunctionChoiceBehaviorTests : BaseIntegrationTest
20+
public sealed class AzureOpenAIChatClientRequiredFunctionChoiceBehaviorTests : BaseIntegrationTest, IDisposable
2121
{
22+
private HttpClient? _httpClient;
2223
private readonly Kernel _kernel;
2324
private readonly FakeFunctionFilter _autoFunctionInvocationFilter;
2425
private readonly IChatClient _chatClient;
@@ -32,7 +33,7 @@ public AzureOpenAIChatClientRequiredFunctionChoiceBehaviorTests()
3233
this._chatClient = this._kernel.GetRequiredService<IChatClient>();
3334
}
3435

35-
[RetryFact]
36+
[Fact]
3637
public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
3738
{
3839
// Arrange
@@ -63,7 +64,7 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomat
6364
Assert.Contains("GetCurrentDate", invokedFunctions);
6465
}
6566

66-
[RetryFact(Skip = "For manual verification only")]
67+
[Fact]
6768
public async Task SpecifiedInPromptInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
6869
{
6970
// Arrange
@@ -352,8 +353,15 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeNonKernelFunctionManu
352353
Assert.Empty(invokedFunctions);
353354
}
354355

356+
public void Dispose()
357+
{
358+
this._httpClient?.Dispose();
359+
this._chatClient?.Dispose();
360+
}
361+
355362
private Kernel InitializeKernel()
356363
{
364+
this._httpClient ??= new() { Timeout = TimeSpan.FromSeconds(100) };
357365
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get<AzureOpenAIConfiguration>();
358366
Assert.NotNull(azureOpenAIConfiguration);
359367
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
@@ -365,7 +373,8 @@ private Kernel InitializeKernel()
365373
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
366374
modelId: azureOpenAIConfiguration.ChatModelId,
367375
endpoint: azureOpenAIConfiguration.Endpoint,
368-
credentials: new AzureCliCredential());
376+
credentials: new AzureCliCredential(),
377+
httpClient: this._httpClient);
369378

370379
return kernelBuilder.Build();
371380
}

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_AutoFunctionChoiceBehaviorTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.ComponentModel;
77
using System.Globalization;
88
using System.Linq;
9+
using System.Net.Http;
910
using System.Text;
1011
using System.Threading.Tasks;
1112
using Azure.Identity;
@@ -15,13 +16,13 @@
1516
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
1617
using Microsoft.SemanticKernel.Connectors.OpenAI;
1718
using SemanticKernel.IntegrationTests.TestSettings;
18-
using xRetry;
1919
using Xunit;
2020

2121
namespace SemanticKernel.IntegrationTests.Connectors.AzureOpenAI;
2222

23-
public sealed class AzureOpenAIAutoFunctionChoiceBehaviorTests : BaseIntegrationTest
23+
public sealed class AzureOpenAIAutoFunctionChoiceBehaviorTests : BaseIntegrationTest, IDisposable
2424
{
25+
private HttpClient? _httpClient;
2526
private readonly Kernel _kernel;
2627
private readonly FakeFunctionFilter _autoFunctionInvocationFilter;
2728
private readonly IChatCompletionService _chatCompletionService;
@@ -35,7 +36,7 @@ public AzureOpenAIAutoFunctionChoiceBehaviorTests()
3536
this._chatCompletionService = this._kernel.GetRequiredService<IChatCompletionService>();
3637
}
3738

38-
[RetryFact]
39+
[Fact]
3940
public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
4041
{
4142
// Arrange
@@ -63,7 +64,7 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomat
6364
Assert.Contains("GetCurrentDate", invokedFunctions);
6465
}
6566

66-
[RetryFact]
67+
[Fact]
6768
public async Task SpecifiedInPromptInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
6869
{
6970
// Arrange
@@ -396,8 +397,14 @@ public async Task SpecifiedInCodeInstructsAIModelToCallFunctionInParallelOrSeque
396397
}
397398
}
398399

400+
public void Dispose()
401+
{
402+
this._httpClient?.Dispose();
403+
}
404+
399405
private Kernel InitializeKernel()
400406
{
407+
this._httpClient ??= new() { Timeout = TimeSpan.FromSeconds(100) };
401408
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get<AzureOpenAIConfiguration>();
402409
Assert.NotNull(azureOpenAIConfiguration);
403410
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
@@ -409,7 +416,8 @@ private Kernel InitializeKernel()
409416
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
410417
modelId: azureOpenAIConfiguration.ChatModelId,
411418
endpoint: azureOpenAIConfiguration.Endpoint,
412-
credentials: new AzureCliCredential());
419+
credentials: new AzureCliCredential(),
420+
httpClient: this._httpClient);
413421

414422
return kernelBuilder.Build();
415423
}

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_NoneFunctionChoiceBehaviorTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.ComponentModel;
66
using System.Globalization;
7+
using System.Net.Http;
78
using System.Text;
89
using System.Threading.Tasks;
910
using Azure.Identity;
@@ -15,8 +16,9 @@
1516

1617
namespace SemanticKernel.IntegrationTests.Connectors.AzureOpenAI;
1718

18-
public sealed class AzureOpenAINoneFunctionChoiceBehaviorTests : BaseIntegrationTest
19+
public sealed class AzureOpenAINoneFunctionChoiceBehaviorTests : BaseIntegrationTest, IDisposable
1920
{
21+
private HttpClient? _httpClient;
2022
private readonly Kernel _kernel;
2123
private readonly FakeFunctionFilter _autoFunctionInvocationFilter;
2224

@@ -160,8 +162,14 @@ public async Task SpecifiedInPromptInstructsConnectorNotToInvokeKernelFunctionFo
160162
Assert.Empty(invokedFunctions);
161163
}
162164

165+
public void Dispose()
166+
{
167+
this._httpClient?.Dispose();
168+
}
169+
163170
private Kernel InitializeKernel()
164171
{
172+
this._httpClient ??= new() { Timeout = TimeSpan.FromSeconds(100) };
165173
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get<AzureOpenAIConfiguration>();
166174
Assert.NotNull(azureOpenAIConfiguration);
167175
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
@@ -173,7 +181,8 @@ private Kernel InitializeKernel()
173181
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
174182
modelId: azureOpenAIConfiguration.ChatModelId,
175183
endpoint: azureOpenAIConfiguration.Endpoint,
176-
credentials: new AzureCliCredential());
184+
credentials: new AzureCliCredential(),
185+
httpClient: this._httpClient);
177186

178187
return kernelBuilder.Build();
179188
}

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_RequiredFunctionChoiceBehaviorTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.ComponentModel;
66
using System.Globalization;
77
using System.Linq;
8+
using System.Net.Http;
89
using System.Threading.Tasks;
910
using Azure.Identity;
1011
using Microsoft.Extensions.Configuration;
@@ -13,13 +14,13 @@
1314
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
1415
using Microsoft.SemanticKernel.Connectors.OpenAI;
1516
using SemanticKernel.IntegrationTests.TestSettings;
16-
using xRetry;
1717
using Xunit;
1818

1919
namespace SemanticKernel.IntegrationTests.Connectors.AzureOpenAI;
2020

21-
public sealed class AzureOpenAIRequiredFunctionChoiceBehaviorTests : BaseIntegrationTest
21+
public sealed class AzureOpenAIRequiredFunctionChoiceBehaviorTests : BaseIntegrationTest, IDisposable
2222
{
23+
private HttpClient? _httpClient;
2324
private readonly Kernel _kernel;
2425
private readonly FakeFunctionFilter _autoFunctionInvocationFilter;
2526
private readonly IChatCompletionService _chatCompletionService;
@@ -74,7 +75,7 @@ public AzureOpenAIRequiredFunctionChoiceBehaviorTests()
7475
// Assert.Contains("GetCurrentDate", invokedFunctions);
7576
//}
7677

77-
[RetryFact]
78+
[Fact]
7879
public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
7980
{
8081
// Arrange
@@ -102,7 +103,7 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionAutomat
102103
Assert.Contains("GetCurrentDate", invokedFunctions);
103104
}
104105

105-
[RetryFact]
106+
[Fact]
106107
public async Task SpecifiedInPromptInstructsConnectorToInvokeKernelFunctionAutomaticallyAsync()
107108
{
108109
// Arrange
@@ -400,8 +401,14 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeNonKernelFunctionManu
400401
Assert.Empty(invokedFunctions);
401402
}
402403

404+
public void Dispose()
405+
{
406+
this._httpClient?.Dispose();
407+
}
408+
403409
private Kernel InitializeKernel()
404410
{
411+
this._httpClient ??= new() { Timeout = TimeSpan.FromSeconds(100) };
405412
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get<AzureOpenAIConfiguration>();
406413
Assert.NotNull(azureOpenAIConfiguration);
407414
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
@@ -413,7 +420,8 @@ private Kernel InitializeKernel()
413420
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
414421
modelId: azureOpenAIConfiguration.ChatModelId,
415422
endpoint: azureOpenAIConfiguration.Endpoint,
416-
credentials: new AzureCliCredential());
423+
credentials: new AzureCliCredential(),
424+
httpClient: this._httpClient);
417425

418426
return kernelBuilder.Build();
419427
}

dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAIChatCompletion_NonStreamingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public async Task ChatCompletionWithWebSearchAsync()
163163
Assert.NotEmpty(chatCompletion.Annotations);
164164
}
165165

166-
[Fact]
166+
[Fact(Skip = "For manual verification only")]
167167
public async Task ChatCompletionWithAudioInputAndOutputAsync()
168168
{
169169
// Arrange

0 commit comments

Comments
 (0)