Skip to content

Commit b58a316

Browse files
authored
Add retry for Trigger tests (#836)
* add retry logic * fix the csx compilation error * use xRetry * replace with RetryTheory * add diagnostic messages to logs
1 parent a0bedd2 commit b58a316

File tree

7 files changed

+47
-18
lines changed

7 files changed

+47
-18
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PackageVersion Include="Moq" Version="4.18.2" />
1616
<PackageVersion Include="xunit" Version="2.4.2" />
1717
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
18+
<PackageVersion Include="xRetry" Version="1.9.0" />
1819
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="4.0.1" />
1920
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
2021
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />

performance/packages.lock.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,7 @@
18901890
"Microsoft.NET.Test.Sdk": "[17.4.0, )",
18911891
"Moq": "[4.18.2, )",
18921892
"Newtonsoft.Json": "[13.0.2, )",
1893+
"xRetry": "[1.9.0, )",
18931894
"xunit": "[2.4.2, )",
18941895
"xunit.runner.visualstudio": "[2.4.5, )"
18951896
}
@@ -2086,6 +2087,15 @@
20862087
"System.Configuration.ConfigurationManager": "5.0.0"
20872088
}
20882089
},
2090+
"xRetry": {
2091+
"type": "CentralTransitive",
2092+
"requested": "[1.9.0, )",
2093+
"resolved": "1.9.0",
2094+
"contentHash": "NeIbJrwpc5EUPagx/mdd/7KzpR36BO8IWrsbgtvOVjxD2xtmNfUHieZ24PeZ4oCYiLBcTviCy+og/bE/OvPchw==",
2095+
"dependencies": {
2096+
"xunit.core": "[2.4.0, 3.0.0)"
2097+
}
2098+
},
20892099
"xunit": {
20902100
"type": "CentralTransitive",
20912101
"requested": "[2.4.2, )",

samples/samples-outofproc/packages.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,9 @@
846846
"microsoft.azure.functions.worker.extensions.sql": {
847847
"type": "Project",
848848
"dependencies": {
849-
"Microsoft.Azure.Functions.Worker.Extensions.Abstractions": "1.1.0",
850-
"Microsoft.Data.SqlClient": "5.0.1",
851-
"System.Drawing.Common": "5.0.3"
849+
"Microsoft.Azure.Functions.Worker.Extensions.Abstractions": "[1.1.0, )",
850+
"Microsoft.Data.SqlClient": "[5.0.1, )",
851+
"System.Drawing.Common": "[5.0.3, )"
852852
}
853853
},
854854
"Microsoft.Azure.Functions.Worker.Extensions.Abstractions": {

test/Integration/SqlTriggerBindingIntegrationTests.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Moq;
1616
using Xunit;
1717
using Xunit.Abstractions;
18+
using xRetry;
1819

1920
namespace Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration
2021
{
@@ -28,7 +29,7 @@ public SqlTriggerBindingIntegrationTests(ITestOutputHelper output = null) : base
2829
/// <summary>
2930
/// Ensures that the user function gets invoked for each of the insert, update and delete operation.
3031
/// </summary>
31-
[Theory]
32+
[RetryTheory]
3233
[SqlInlineData()]
3334
public async Task SingleOperationTriggerTest(SupportedLanguages lang)
3435
{
@@ -76,7 +77,7 @@ await this.WaitForProductChanges(
7677
/// Verifies that manually setting the batch size using the original config var correctly changes the
7778
/// number of changes processed at once.
7879
/// </summary>
79-
[Theory]
80+
[RetryTheory]
8081
[SqlInlineData()]
8182
public async Task BatchSizeOverrideTriggerTest(SupportedLanguages lang)
8283
{
@@ -119,7 +120,7 @@ await this.WaitForProductChanges(
119120
/// <summary>
120121
/// Verifies that manually setting the max batch size correctly changes the number of changes processed at once
121122
/// </summary>
122-
[Theory]
123+
[RetryTheory]
123124
[SqlInlineData()]
124125
public async Task MaxBatchSizeOverrideTriggerTest(SupportedLanguages lang)
125126
{
@@ -162,7 +163,7 @@ await this.WaitForProductChanges(
162163
/// <summary>
163164
/// Verifies that manually setting the polling interval correctly changes the delay between processing each batch of changes
164165
/// </summary>
165-
[Theory]
166+
[RetryTheory]
166167
[SqlInlineData()]
167168
public async Task PollingIntervalOverrideTriggerTest(SupportedLanguages lang)
168169
{
@@ -204,7 +205,7 @@ await this.WaitForProductChanges(
204205
/// Verifies that if several changes have happened to the table row since last invocation, then a single net
205206
/// change for that row is passed to the user function.
206207
/// </summary>
207-
[Theory]
208+
[RetryTheory]
208209
[SqlInlineData()]
209210
public async Task MultiOperationTriggerTest(SupportedLanguages lang)
210211
{
@@ -285,7 +286,7 @@ await this.WaitForProductChanges(
285286
/// <summary>
286287
/// Ensures correct functionality with multiple user functions tracking the same table.
287288
/// </summary>
288-
[Theory]
289+
[RetryTheory]
289290
[SqlInlineData()]
290291
public async Task MultiFunctionTriggerTest(SupportedLanguages lang)
291292
{
@@ -411,7 +412,7 @@ public async Task MultiFunctionTriggerTest(SupportedLanguages lang)
411412
/// <summary>
412413
/// Ensures correct functionality with user functions running across multiple functions host processes.
413414
/// </summary>
414-
[Theory]
415+
[RetryTheory]
415416
[SqlInlineData()]
416417
public async Task MultiHostTriggerTest(SupportedLanguages lang)
417418
{
@@ -462,7 +463,7 @@ await this.WaitForProductChanges(
462463
/// <summary>
463464
/// Tests the error message when the user table is not present in the database.
464465
/// </summary>
465-
[Theory]
466+
[RetryTheory]
466467
[SqlInlineData()]
467468
public void TableNotPresentTriggerTest(SupportedLanguages lang)
468469
{
@@ -476,7 +477,7 @@ public void TableNotPresentTriggerTest(SupportedLanguages lang)
476477
/// <summary>
477478
/// Tests the error message when the user table does not contain primary key.
478479
/// </summary>
479-
[Theory]
480+
[RetryTheory]
480481
[SqlInlineData()]
481482
public void PrimaryKeyNotCreatedTriggerTest(SupportedLanguages lang)
482483
{
@@ -491,7 +492,7 @@ public void PrimaryKeyNotCreatedTriggerTest(SupportedLanguages lang)
491492
/// Tests the error message when the user table contains one or more primary keys with names conflicting with
492493
/// column names in the leases table.
493494
/// </summary>
494-
[Theory]
495+
[RetryTheory]
495496
[SqlInlineData()]
496497
public void ReservedPrimaryKeyColumnNamesTriggerTest(SupportedLanguages lang)
497498
{
@@ -506,7 +507,7 @@ public void ReservedPrimaryKeyColumnNamesTriggerTest(SupportedLanguages lang)
506507
/// <summary>
507508
/// Tests the error message when the user table contains columns of unsupported SQL types.
508509
/// </summary>
509-
[Theory]
510+
[RetryTheory]
510511
[SqlInlineData()]
511512
public void UnsupportedColumnTypesTriggerTest(SupportedLanguages lang)
512513
{
@@ -521,7 +522,7 @@ public void UnsupportedColumnTypesTriggerTest(SupportedLanguages lang)
521522
/// <summary>
522523
/// Tests the error message when change tracking is not enabled on the user table.
523524
/// </summary>
524-
[Theory]
525+
[RetryTheory]
525526
[SqlInlineData()]
526527
public void ChangeTrackingNotEnabledTriggerTest(SupportedLanguages lang)
527528
{
@@ -557,7 +558,7 @@ public async void GetMetricsTest()
557558
/// <summary>
558559
/// Tests that when using an unsupported database the expected error is thrown
559560
/// </summary>
560-
[Theory]
561+
[RetryTheory]
561562
[SqlInlineData()]
562563
public void UnsupportedDatabaseThrows(SupportedLanguages lang)
563564
{

test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<PackageReference Include="Moq" />
66
<PackageReference Include="xunit" />
77
<PackageReference Include="xunit.runner.visualstudio" />
8+
<PackageReference Include="xRetry" />
89
<PackageReference Include="Microsoft.NET.Sdk.Functions" />
910
<PackageReference Include="Newtonsoft.Json" />
1011
<PackageReference Include="Microsoft.AspNetCore.Http" />
@@ -18,8 +19,11 @@
1819

1920
<ItemGroup>
2021
<None Update="Database\**\*.sql">
21-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
22-
</None>
22+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
23+
</None>
24+
<None Update="xunit.runner.json">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</None>
2327
</ItemGroup>
2428

2529
<Target Name="CopySamples" AfterTargets="Build">

test/packages.lock.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@
7474
"resolved": "13.0.2",
7575
"contentHash": "R2pZ3B0UjeyHShm9vG+Tu0EBb2lC8b0dFzV9gVn50ofHXh9Smjk6kTn7A/FdAsC8B5cKib1OnGYOXxRBz5XQDg=="
7676
},
77+
"xRetry": {
78+
"type": "Direct",
79+
"requested": "[1.9.0, )",
80+
"resolved": "1.9.0",
81+
"contentHash": "NeIbJrwpc5EUPagx/mdd/7KzpR36BO8IWrsbgtvOVjxD2xtmNfUHieZ24PeZ4oCYiLBcTviCy+og/bE/OvPchw==",
82+
"dependencies": {
83+
"xunit.core": "[2.4.0, 3.0.0)"
84+
}
85+
},
7786
"xunit": {
7887
"type": "Direct",
7988
"requested": "[2.4.2, )",

test/xunit.runner.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"diagnosticMessages": true
4+
}

0 commit comments

Comments
 (0)