Skip to content

Commit

Permalink
Increase Hosting tests timeout (#43695)
Browse files Browse the repository at this point in the history
* Increase Hosting tests timeout

There are some environments (checked CoreCLR, no tiered compilation) where the current timeout is insufficient. Increasing the timeout so the tests don't fail in these environments.

Fix #43389
  • Loading branch information
eerhardt authored Oct 23, 2020
1 parent 10d31ee commit ae908fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ string SaveRandomConfig()
{
configReloadedCancelTokenSource.Cancel();
}, null);
// Wait for up to 10 seconds, if config reloads at any time, cancel the wait.
await Task.WhenAny(Task.Delay(10000, configReloadedCancelToken)); // Task.WhenAny ignores the task throwing on cancellation.
// Wait for up to 1 minute, if config reloads at any time, cancel the wait.
await Task.WhenAny(Task.Delay(TimeSpan.FromMinutes(1), configReloadedCancelToken)); // Task.WhenAny ignores the task throwing on cancellation.
Assert.NotEqual(dynamicConfigMessage1, dynamicConfigMessage2); // Messages are different.
Assert.Equal(dynamicConfigMessage2, config["Hello"]); // Config DID reload from disk
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -1223,7 +1224,7 @@ public void ThrowExceptionForCustomImplementationOfIHostApplicationLifetime()
/// (after an await), the exception gets logged correctly.
/// </summary>
[Fact]
public void BackgroundServiceAsyncExceptionGetsLogged()
public async Task BackgroundServiceAsyncExceptionGetsLogged()
{
using TestEventListener listener = new TestEventListener();

Expand All @@ -1238,8 +1239,9 @@ public void BackgroundServiceAsyncExceptionGetsLogged()
})
.Start();

// give the background service 5 seconds to log the failure
Task timeout = Task.Delay(new TimeSpan(0, 0, 5));
// give the background service 1 minute to log the failure
TimeSpan timeout = TimeSpan.FromMinutes(1);
Stopwatch sw = Stopwatch.StartNew();

while (true)
{
Expand All @@ -1251,10 +1253,8 @@ public void BackgroundServiceAsyncExceptionGetsLogged()
break;
}

if (timeout.IsCompleted)
{
Assert.True(false, "'BackgroundService failed' did not get logged");
}
Assert.InRange(sw.Elapsed, TimeSpan.Zero, timeout);
await Task.Delay(TimeSpan.FromMilliseconds(30));
}
}

Expand Down

0 comments on commit ae908fe

Please sign in to comment.