Skip to content

Commit 926a41b

Browse files
committed
Trying to fix CI test runs
1 parent 1232906 commit 926a41b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/WebJobs.Script/Host/ScriptHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ internal static void ApplyConfiguration(JObject config, ScriptHostConfiguration
13591359
hostConfig.HostConfigMetadata = config;
13601360

13611361
JArray functions = (JArray)config["functions"];
1362-
if (functions != null && functions.Count > 0)
1362+
if (scriptConfig.Functions == null && functions != null && functions.Count > 0)
13631363
{
13641364
scriptConfig.Functions = new Collection<string>();
13651365
foreach (var function in functions)

test/WebJobs.Script.Tests.Integration/Host/WebScriptHostManagerTimeoutTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task OnTimeoutException_IgnoreToken_StopsManager()
2828

2929
await RunTimeoutExceptionTest(trace, handleCancellation: false);
3030

31-
await TestHelpers.Await(() => !(_manager.State == ScriptHostState.Running));
31+
await TestHelpers.Await(() => !(_manager.State == ScriptHostState.Running), userMessage: "Expected host to not be running");
3232
Assert.DoesNotContain(trace.Traces, t => t.Message.StartsWith("Done"));
3333
Assert.Contains(trace.Traces, t => t.Message.StartsWith("Timeout value of 00:00:03 exceeded by function 'Functions.TimeoutToken' (Id: "));
3434
Assert.Contains(trace.Traces, t => t.Message == "A function timeout has occurred. Host is shutting down.");
@@ -43,15 +43,14 @@ public async Task OnTimeoutException_UsesToken_ManagerKeepsRunning()
4343

4444
// wait a few seconds to make sure the manager doesn't die
4545
await Assert.ThrowsAsync<ApplicationException>(() => TestHelpers.Await(() => !(_manager.State == ScriptHostState.Running),
46-
timeout: 3000, throwWhenDebugging: true));
46+
timeout: 3000, throwWhenDebugging: true, userMessage: "Expected host manager not to die"));
4747
Assert.Contains(trace.Traces, t => t.Message.StartsWith("Done"));
4848
Assert.Contains(trace.Traces, t => t.Message.StartsWith("Timeout value of 00:00:03 exceeded by function 'Functions.TimeoutToken' (Id: "));
4949
Assert.DoesNotContain(trace.Traces, t => t.Message == "A function timeout has occurred. Host is shutting down.");
5050
}
5151

5252
private async Task RunTimeoutExceptionTest(TraceWriter trace, bool handleCancellation)
5353
{
54-
TimeSpan gracePeriod = TimeSpan.FromMilliseconds(5000);
5554
_manager = await CreateAndStartWebScriptHostManager(trace);
5655

5756
string scenarioName = handleCancellation ? "useToken" : "ignoreToken";
@@ -80,7 +79,7 @@ private async Task<WebScriptHostManager> CreateAndStartWebScriptHostManager(Trac
8079
var mockEventManager = new Mock<IScriptEventManager>();
8180
var manager = new WebScriptHostManager(config, new TestSecretManagerFactory(), mockEventManager.Object, ScriptSettingsManager.Instance, new WebHostSettings { SecretsPath = _secretsDirectory.Path });
8281
Task task = Task.Run(() => { manager.RunAndBlock(); });
83-
await TestHelpers.Await(() => manager.State == ScriptHostState.Running);
82+
await TestHelpers.Await(() => manager.State == ScriptHostState.Running, userMessage: "Expected host to be running");
8483

8584
return manager;
8685
}

test/WebJobs.Script.Tests.Shared/TestHelpers.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static string FunctionsTestDirectory
3333
}
3434
}
3535

36-
public static async Task Await(Func<bool> condition, int timeout = 60 * 1000, int pollingInterval = 2 * 1000, bool throwWhenDebugging = false)
36+
public static async Task Await(Func<bool> condition, int timeout = 60 * 1000, int pollingInterval = 2 * 1000, bool throwWhenDebugging = false, string userMessage = null)
3737
{
3838
DateTime start = DateTime.Now;
3939
while (!condition())
@@ -43,7 +43,12 @@ public static async Task Await(Func<bool> condition, int timeout = 60 * 1000, in
4343
bool shouldThrow = !Debugger.IsAttached || (Debugger.IsAttached && throwWhenDebugging);
4444
if (shouldThrow && (DateTime.Now - start).TotalMilliseconds > timeout)
4545
{
46-
throw new ApplicationException("Condition not reached within timeout.");
46+
string error = "Condition not reached within timeout.";
47+
if (userMessage != null)
48+
{
49+
error += " " + userMessage;
50+
}
51+
throw new ApplicationException(error);
4752
}
4853
}
4954
}

0 commit comments

Comments
 (0)