Skip to content

Commit

Permalink
Add retry for Trigger tests (#836)
Browse files Browse the repository at this point in the history
* add retry logic

* fix the csx compilation error

* use xRetry

* replace with RetryTheory

* add diagnostic messages to logs
  • Loading branch information
MaddyDev authored May 1, 2023
1 parent a0bedd2 commit b58a316
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageVersion Include="Moq" Version="4.18.2" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xRetry" Version="1.9.0" />
<PackageVersion Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="4.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
Expand Down
10 changes: 10 additions & 0 deletions performance/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,7 @@
"Microsoft.NET.Test.Sdk": "[17.4.0, )",
"Moq": "[4.18.2, )",
"Newtonsoft.Json": "[13.0.2, )",
"xRetry": "[1.9.0, )",
"xunit": "[2.4.2, )",
"xunit.runner.visualstudio": "[2.4.5, )"
}
Expand Down Expand Up @@ -2086,6 +2087,15 @@
"System.Configuration.ConfigurationManager": "5.0.0"
}
},
"xRetry": {
"type": "CentralTransitive",
"requested": "[1.9.0, )",
"resolved": "1.9.0",
"contentHash": "NeIbJrwpc5EUPagx/mdd/7KzpR36BO8IWrsbgtvOVjxD2xtmNfUHieZ24PeZ4oCYiLBcTviCy+og/bE/OvPchw==",
"dependencies": {
"xunit.core": "[2.4.0, 3.0.0)"
}
},
"xunit": {
"type": "CentralTransitive",
"requested": "[2.4.2, )",
Expand Down
6 changes: 3 additions & 3 deletions samples/samples-outofproc/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,9 @@
"microsoft.azure.functions.worker.extensions.sql": {
"type": "Project",
"dependencies": {
"Microsoft.Azure.Functions.Worker.Extensions.Abstractions": "1.1.0",
"Microsoft.Data.SqlClient": "5.0.1",
"System.Drawing.Common": "5.0.3"
"Microsoft.Azure.Functions.Worker.Extensions.Abstractions": "[1.1.0, )",
"Microsoft.Data.SqlClient": "[5.0.1, )",
"System.Drawing.Common": "[5.0.3, )"
}
},
"Microsoft.Azure.Functions.Worker.Extensions.Abstractions": {
Expand Down
27 changes: 14 additions & 13 deletions test/Integration/SqlTriggerBindingIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Moq;
using Xunit;
using Xunit.Abstractions;
using xRetry;

namespace Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration
{
Expand All @@ -28,7 +29,7 @@ public SqlTriggerBindingIntegrationTests(ITestOutputHelper output = null) : base
/// <summary>
/// Ensures that the user function gets invoked for each of the insert, update and delete operation.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task SingleOperationTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -76,7 +77,7 @@ await this.WaitForProductChanges(
/// Verifies that manually setting the batch size using the original config var correctly changes the
/// number of changes processed at once.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task BatchSizeOverrideTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -119,7 +120,7 @@ await this.WaitForProductChanges(
/// <summary>
/// Verifies that manually setting the max batch size correctly changes the number of changes processed at once
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task MaxBatchSizeOverrideTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -162,7 +163,7 @@ await this.WaitForProductChanges(
/// <summary>
/// Verifies that manually setting the polling interval correctly changes the delay between processing each batch of changes
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task PollingIntervalOverrideTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -204,7 +205,7 @@ await this.WaitForProductChanges(
/// Verifies that if several changes have happened to the table row since last invocation, then a single net
/// change for that row is passed to the user function.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task MultiOperationTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -285,7 +286,7 @@ await this.WaitForProductChanges(
/// <summary>
/// Ensures correct functionality with multiple user functions tracking the same table.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task MultiFunctionTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -411,7 +412,7 @@ public async Task MultiFunctionTriggerTest(SupportedLanguages lang)
/// <summary>
/// Ensures correct functionality with user functions running across multiple functions host processes.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public async Task MultiHostTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -462,7 +463,7 @@ await this.WaitForProductChanges(
/// <summary>
/// Tests the error message when the user table is not present in the database.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public void TableNotPresentTriggerTest(SupportedLanguages lang)
{
Expand All @@ -476,7 +477,7 @@ public void TableNotPresentTriggerTest(SupportedLanguages lang)
/// <summary>
/// Tests the error message when the user table does not contain primary key.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public void PrimaryKeyNotCreatedTriggerTest(SupportedLanguages lang)
{
Expand All @@ -491,7 +492,7 @@ public void PrimaryKeyNotCreatedTriggerTest(SupportedLanguages lang)
/// Tests the error message when the user table contains one or more primary keys with names conflicting with
/// column names in the leases table.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public void ReservedPrimaryKeyColumnNamesTriggerTest(SupportedLanguages lang)
{
Expand All @@ -506,7 +507,7 @@ public void ReservedPrimaryKeyColumnNamesTriggerTest(SupportedLanguages lang)
/// <summary>
/// Tests the error message when the user table contains columns of unsupported SQL types.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public void UnsupportedColumnTypesTriggerTest(SupportedLanguages lang)
{
Expand All @@ -521,7 +522,7 @@ public void UnsupportedColumnTypesTriggerTest(SupportedLanguages lang)
/// <summary>
/// Tests the error message when change tracking is not enabled on the user table.
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public void ChangeTrackingNotEnabledTriggerTest(SupportedLanguages lang)
{
Expand Down Expand Up @@ -557,7 +558,7 @@ public async void GetMetricsTest()
/// <summary>
/// Tests that when using an unsupported database the expected error is thrown
/// </summary>
[Theory]
[RetryTheory]
[SqlInlineData()]
public void UnsupportedDatabaseThrows(SupportedLanguages lang)
{
Expand Down
8 changes: 6 additions & 2 deletions test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xRetry" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Microsoft.AspNetCore.Http" />
Expand All @@ -18,8 +19,11 @@

<ItemGroup>
<None Update="Database\**\*.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="CopySamples" AfterTargets="Build">
Expand Down
9 changes: 9 additions & 0 deletions test/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@
"resolved": "13.0.2",
"contentHash": "R2pZ3B0UjeyHShm9vG+Tu0EBb2lC8b0dFzV9gVn50ofHXh9Smjk6kTn7A/FdAsC8B5cKib1OnGYOXxRBz5XQDg=="
},
"xRetry": {
"type": "Direct",
"requested": "[1.9.0, )",
"resolved": "1.9.0",
"contentHash": "NeIbJrwpc5EUPagx/mdd/7KzpR36BO8IWrsbgtvOVjxD2xtmNfUHieZ24PeZ4oCYiLBcTviCy+og/bE/OvPchw==",
"dependencies": {
"xunit.core": "[2.4.0, 3.0.0)"
}
},
"xunit": {
"type": "Direct",
"requested": "[2.4.2, )",
Expand Down
4 changes: 4 additions & 0 deletions test/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"diagnosticMessages": true
}

0 comments on commit b58a316

Please sign in to comment.