Skip to content

Commit 6b9c144

Browse files
committed
improve timeout if TestFunctionHost does not start
1 parent 1a23614 commit 6b9c144

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

test/WebJobs.Script.Tests.Integration/TestFunctionHost.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ public async Task RestartAsync(CancellationToken cancellationToken)
167167

168168
private Task StartAsync()
169169
{
170+
bool exit = false;
170171
var startTask = Task.Run(async () =>
171172
{
172173
bool running = false;
173-
while (!running)
174+
while (!running && !exit)
174175
{
175176
running = await IsHostStarted();
176177

@@ -187,6 +188,7 @@ private Task StartAsync()
187188
}
188189
else
189190
{
191+
exit = true;
190192
throw new Exception("Functions Host timed out trying to start.");
191193
}
192194

@@ -282,7 +284,7 @@ public void Dispose()
282284
_testServer.Dispose();
283285
}
284286

285-
internal virtual async Task<bool> IsHostStarted()
287+
private async Task<bool> IsHostStarted()
286288
{
287289
HostStatus status = await GetHostStatusAsync();
288290
return status.State == $"{ScriptHostState.Running}" || status.State == $"{ScriptHostState.Error}";

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/HostConfigurationExceptionTests.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ public TemporaryTestFunctionHost(string scriptPath, string logPath,
9292
: base(scriptPath, logPath, configureWebHostServices, configureScriptHostWebJobsBuilder, configureScriptHostAppConfiguration, configureScriptHostLogging, configureScriptHostServices)
9393
{
9494
}
95-
96-
// Overriding this function as currently there's that causes HostState to be "Initialized" in case host.json has errors
97-
// TODO: Once the issue is fixed, this class needs to be removed.
98-
// https://github.com/Azure/azure-functions-host/issues/5959
99-
internal override async Task<bool> IsHostStarted()
100-
{
101-
HostStatus status = await GetHostStatusAsync();
102-
return status.State == $"{ScriptHostState.Running}" || status.State == $"{ScriptHostState.Error}" || status.State == $"{ScriptHostState.Initialized}";
103-
}
10495
}
10596
}
10697
}

0 commit comments

Comments
 (0)