Skip to content

Commit bfa7535

Browse files
authored
Update metadata manager tests (#10594)
1 parent 4c23ea9 commit bfa7535

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/WebJobs.Script/Host/FunctionMetadataManager.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,18 @@ public FunctionMetadataManager(IOptions<ScriptJobHostOptions> scriptOptions, IFu
6262
}
6363

6464
// Property is settable for testing purposes.
65-
internal int MetadataProviderTimeoutInSeconds { get; set; } = DefaultMetadataProviderTimeoutInSeconds;
65+
internal TimeSpan MetadataProviderTimeout
66+
{
67+
get
68+
{
69+
return _metadataProviderTimeout;
70+
}
71+
72+
set
73+
{
74+
_metadataProviderTimeout = value;
75+
}
76+
}
6677

6778
public ImmutableDictionary<string, ImmutableArray<string>> Errors { get; private set; }
6879

test/WebJobs.Script.Tests/FunctionMetadataManagerTests.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.ObjectModel;
88
using System.IO;
99
using System.Linq;
10+
using System.Threading;
1011
using System.Threading.Tasks;
1112
using Microsoft.Azure.WebJobs.Script.Description;
1213
using Microsoft.Azure.WebJobs.Script.Workers.Http;
@@ -223,6 +224,28 @@ public void FunctionMetadataManager_LoadFunctionMetadata_Throws_WhenFunctionProv
223224
Assert.DoesNotContain(traces, t => t.FormattedMessage.Contains("2 functions found (Custom)"));
224225
}
225226

227+
[Fact]
228+
public void FunctionMetadataManager_IsLogicApp_TimeoutIsInfinite()
229+
{
230+
using (new TestScopedEnvironmentVariable(EnvironmentSettingNames.AppKind, ScriptConstants.WorkFlowAppKind))
231+
{
232+
var functionMetadataCollection = new Collection<FunctionMetadata>();
233+
var mockFunctionErrors = new Dictionary<string, ImmutableArray<string>>();
234+
var mockFunctionMetadataProvider = new Mock<IFunctionMetadataProvider>();
235+
var mockFunctionProvider = new Mock<IFunctionProvider>();
236+
var workerConfigs = TestHelpers.GetTestWorkerConfigs();
237+
var testLoggerProvider = new TestLoggerProvider();
238+
var loggerFactory = new LoggerFactory();
239+
loggerFactory.AddProvider(testLoggerProvider);
240+
241+
FunctionMetadataManager testFunctionMetadataManager = TestFunctionMetadataManager.GetFunctionMetadataManager(new OptionsWrapper<ScriptJobHostOptions>(_scriptJobHostOptions),
242+
mockFunctionMetadataProvider.Object, new List<IFunctionProvider>() { mockFunctionProvider.Object }, new OptionsWrapper<HttpWorkerOptions>(_defaultHttpWorkerOptions), loggerFactory,
243+
new TestOptionsMonitor<LanguageWorkerOptions>(TestHelpers.GetTestLanguageWorkerOptions()));
244+
245+
Assert.Equal(Timeout.InfiniteTimeSpan, testFunctionMetadataManager.MetadataProviderTimeout);
246+
}
247+
}
248+
226249
[Fact]
227250
public void FunctionMetadataManager_LoadFunctionMetadata_Throws_WhenFunctionProvidersTimesOut()
228251
{
@@ -256,7 +279,7 @@ public void FunctionMetadataManager_LoadFunctionMetadata_Throws_WhenFunctionProv
256279
mockFunctionMetadataProvider.Object, new List<IFunctionProvider>() { goodFunctionMetadataProvider.Object, badFunctionMetadataProvider.Object }, new OptionsWrapper<HttpWorkerOptions>(_defaultHttpWorkerOptions), loggerFactory, new TestOptionsMonitor<LanguageWorkerOptions>(TestHelpers.GetTestLanguageWorkerOptions()));
257280

258281
// Set the timeout to 1 second for the test.
259-
testFunctionMetadataManager.MetadataProviderTimeoutInSeconds = 1;
282+
testFunctionMetadataManager.MetadataProviderTimeout = TimeSpan.FromSeconds(1);
260283

261284
var exception = Assert.Throws<TimeoutException>(() => testFunctionMetadataManager.LoadFunctionMetadata());
262285
Assert.Contains($"Timeout occurred while retrieving metadata from provider '{badFunctionMetadataProvider.Object.GetType().FullName}'. The operation exceeded the configured timeout of 1 seconds.", exception.Message);

0 commit comments

Comments
 (0)