From b58a31632642cc6fb20784a711cc9a08032cc2be Mon Sep 17 00:00:00 2001
From: Maddy <12754347+MaddyDev@users.noreply.github.com>
Date: Mon, 1 May 2023 16:01:22 -0700
Subject: [PATCH] Add retry for Trigger tests (#836)
* add retry logic
* fix the csx compilation error
* use xRetry
* replace with RetryTheory
* add diagnostic messages to logs
---
Directory.Packages.props | 1 +
performance/packages.lock.json | 10 +++++++
samples/samples-outofproc/packages.lock.json | 6 ++---
.../SqlTriggerBindingIntegrationTests.cs | 27 ++++++++++---------
....Azure.WebJobs.Extensions.Sql.Tests.csproj | 8 ++++--
test/packages.lock.json | 9 +++++++
test/xunit.runner.json | 4 +++
7 files changed, 47 insertions(+), 18 deletions(-)
create mode 100644 test/xunit.runner.json
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 9064c766e..e0dd5cf0d 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -15,6 +15,7 @@
+
diff --git a/performance/packages.lock.json b/performance/packages.lock.json
index b2526262a..168be8c16 100644
--- a/performance/packages.lock.json
+++ b/performance/packages.lock.json
@@ -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, )"
}
@@ -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, )",
diff --git a/samples/samples-outofproc/packages.lock.json b/samples/samples-outofproc/packages.lock.json
index 15d9eb98f..7698d5885 100644
--- a/samples/samples-outofproc/packages.lock.json
+++ b/samples/samples-outofproc/packages.lock.json
@@ -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": {
diff --git a/test/Integration/SqlTriggerBindingIntegrationTests.cs b/test/Integration/SqlTriggerBindingIntegrationTests.cs
index f0a3e1143..92646f3fd 100644
--- a/test/Integration/SqlTriggerBindingIntegrationTests.cs
+++ b/test/Integration/SqlTriggerBindingIntegrationTests.cs
@@ -15,6 +15,7 @@
using Moq;
using Xunit;
using Xunit.Abstractions;
+using xRetry;
namespace Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration
{
@@ -28,7 +29,7 @@ public SqlTriggerBindingIntegrationTests(ITestOutputHelper output = null) : base
///
/// Ensures that the user function gets invoked for each of the insert, update and delete operation.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task SingleOperationTriggerTest(SupportedLanguages lang)
{
@@ -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.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task BatchSizeOverrideTriggerTest(SupportedLanguages lang)
{
@@ -119,7 +120,7 @@ await this.WaitForProductChanges(
///
/// Verifies that manually setting the max batch size correctly changes the number of changes processed at once
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task MaxBatchSizeOverrideTriggerTest(SupportedLanguages lang)
{
@@ -162,7 +163,7 @@ await this.WaitForProductChanges(
///
/// Verifies that manually setting the polling interval correctly changes the delay between processing each batch of changes
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task PollingIntervalOverrideTriggerTest(SupportedLanguages lang)
{
@@ -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.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task MultiOperationTriggerTest(SupportedLanguages lang)
{
@@ -285,7 +286,7 @@ await this.WaitForProductChanges(
///
/// Ensures correct functionality with multiple user functions tracking the same table.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task MultiFunctionTriggerTest(SupportedLanguages lang)
{
@@ -411,7 +412,7 @@ public async Task MultiFunctionTriggerTest(SupportedLanguages lang)
///
/// Ensures correct functionality with user functions running across multiple functions host processes.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public async Task MultiHostTriggerTest(SupportedLanguages lang)
{
@@ -462,7 +463,7 @@ await this.WaitForProductChanges(
///
/// Tests the error message when the user table is not present in the database.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public void TableNotPresentTriggerTest(SupportedLanguages lang)
{
@@ -476,7 +477,7 @@ public void TableNotPresentTriggerTest(SupportedLanguages lang)
///
/// Tests the error message when the user table does not contain primary key.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public void PrimaryKeyNotCreatedTriggerTest(SupportedLanguages lang)
{
@@ -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.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public void ReservedPrimaryKeyColumnNamesTriggerTest(SupportedLanguages lang)
{
@@ -506,7 +507,7 @@ public void ReservedPrimaryKeyColumnNamesTriggerTest(SupportedLanguages lang)
///
/// Tests the error message when the user table contains columns of unsupported SQL types.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public void UnsupportedColumnTypesTriggerTest(SupportedLanguages lang)
{
@@ -521,7 +522,7 @@ public void UnsupportedColumnTypesTriggerTest(SupportedLanguages lang)
///
/// Tests the error message when change tracking is not enabled on the user table.
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public void ChangeTrackingNotEnabledTriggerTest(SupportedLanguages lang)
{
@@ -557,7 +558,7 @@ public async void GetMetricsTest()
///
/// Tests that when using an unsupported database the expected error is thrown
///
- [Theory]
+ [RetryTheory]
[SqlInlineData()]
public void UnsupportedDatabaseThrows(SupportedLanguages lang)
{
diff --git a/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj b/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj
index ef533f160..7dddc6de3 100644
--- a/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj
+++ b/test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj
@@ -5,6 +5,7 @@
+
@@ -18,8 +19,11 @@
- Always
-
+ Always
+
+
+ PreserveNewest
+
diff --git a/test/packages.lock.json b/test/packages.lock.json
index 492b16351..5eda640be 100644
--- a/test/packages.lock.json
+++ b/test/packages.lock.json
@@ -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, )",
diff --git a/test/xunit.runner.json b/test/xunit.runner.json
new file mode 100644
index 000000000..af6c85ea4
--- /dev/null
+++ b/test/xunit.runner.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
+ "diagnosticMessages": true
+}
\ No newline at end of file