diff --git a/test-outofproc/TriggerWithException.cs b/test-outofproc/TriggerWithException.cs index e2d529d8a..6f4560ad2 100644 --- a/test-outofproc/TriggerWithException.cs +++ b/test-outofproc/TriggerWithException.cs @@ -32,6 +32,7 @@ public static void Run( throw new InvalidOperationException(ExceptionMessage); } logger.LogInformation("SQL Changes: " + Utils.JsonSerializeObject(changes)); + } } } diff --git a/test/Integration/SqlTriggerBindingIntegrationTests.cs b/test/Integration/SqlTriggerBindingIntegrationTests.cs index 92646f3fd..4d735b409 100644 --- a/test/Integration/SqlTriggerBindingIntegrationTests.cs +++ b/test/Integration/SqlTriggerBindingIntegrationTests.cs @@ -578,11 +578,13 @@ public void UnsupportedDatabaseThrows(SupportedLanguages lang) /// /// Tests that when a user function throws an exception we'll retry executing that function once the lease timeout expires /// - [Fact] - public async Task FunctionExceptionsCauseRetry() + [RetryTheory] + [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.JavaScript, SupportedLanguages.Python, SupportedLanguages.PowerShell, SupportedLanguages.Csx, SupportedLanguages.Java)] // Keeping static state for threwException across calls is only valid for C# and Java. + public async Task FunctionExceptionsCauseRetry(SupportedLanguages lang) { this.SetChangeTrackingForTable("Products"); - this.StartFunctionHost(nameof(TriggerWithException), SupportedLanguages.CSharp, true); + this.StartFunctionHost(nameof(TriggerWithException), lang, useTestFolder: true); TaskCompletionSource taskCompletionSource = new(); void TestExceptionMessageSeen(object sender, DataReceivedEventArgs e) { @@ -605,7 +607,7 @@ void TestExceptionMessageSeen(object sender, DataReceivedEventArgs e) (SqlTableChangeMonitor.LeaseIntervalInSeconds * 1000) + batchProcessingTimeout); // First wait for the exception message to show up - await taskCompletionSource.Task.TimeoutAfter(TimeSpan.FromMilliseconds(this.GetBatchProcessingTimeout(1, 30)), "Timed out waiting for exception message"); + await taskCompletionSource.Task.TimeoutAfter(TimeSpan.FromMilliseconds(batchProcessingTimeout), "Timed out waiting for exception message"); // Now wait for the retry to occur and successfully pass await changesTask; diff --git a/test/Integration/test-java/src/main/java/com/function/TriggerWithException.java b/test/Integration/test-java/src/main/java/com/function/TriggerWithException.java new file mode 100644 index 000000000..6fc784270 --- /dev/null +++ b/test/Integration/test-java/src/main/java/com/function/TriggerWithException.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.function; + +import com.microsoft.azure.functions.ExecutionContext; +import com.microsoft.azure.functions.annotation.FunctionName; +import com.microsoft.azure.functions.sql.annotation.SQLTrigger; +import com.function.Common.SqlChangeProduct; +import com.google.gson.Gson; +import java.util.logging.Level; + +public class TriggerWithException { + public final String ExceptionMessage = "TriggerWithException test exception"; + private static Boolean threwException = false; + + @FunctionName("TriggerWithException") + public void run( + @SQLTrigger(name = "changes", tableName = "[dbo].[Products]", connectionStringSetting = "SqlConnectionString") SqlChangeProduct[] changes, + ExecutionContext context) throws Exception { + + if (!threwException) { + threwException = true; + throw new Exception(ExceptionMessage); + } + context.getLogger().log(Level.INFO, "SQL Changes: " + new Gson().toJson(changes)); + } +}