Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser][MT] Log ManagedThreadId and NativeThreadId for known test failures #98291

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,22 @@ await Assert.ThrowsAsync<TaskCanceledException>(async () =>
{
CancellationTokenSource cts = new CancellationTokenSource();
var promise = response.Content.ReadAsStringAsync(cts.Token);
cts.Cancel();
await promise;
try
mkhamoyan marked this conversation as resolved.
Show resolved Hide resolved
{
Console.WriteLine("HttpClient_CancelInDifferentThread: ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
cts.Cancel();
await promise;
}
catch (TaskCanceledException ex)
{
Console.WriteLine("HttpClient_CancelInDifferentThread: TaskCanceledException is thrown with message: " + ex.ToString());
throw;
}
catch (OperationCanceledException ex)
{
Console.WriteLine("HttpClient_CancelInDifferentThread: OperationCanceledException is thrown with message: " + ex.ToString());
throw;
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,20 @@ public async Task ThreadingTimer(Executor executor)
await executor.Execute(async () =>
{
TaskCompletionSource tcs = new TaskCompletionSource();
Console.WriteLine("ThreadingTimer: Start Time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);

using var timer = new Timer(_ =>
{
Assert.NotEqual(1, Environment.CurrentManagedThreadId);
Assert.True(Thread.CurrentThread.IsThreadPoolThread);
tcs.SetResult();
hit = true;
tcs.SetResult();
}, null, 100, Timeout.Infinite);

await tcs.Task;
}, cts.Token);

Console.WriteLine("ThreadingTimer: End Time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
Assert.True(hit);
}

Expand Down Expand Up @@ -451,7 +453,7 @@ await executor.Execute(Task () =>
{
exception = ex;
}

Console.WriteLine("WaitAssertsOnJSInteropThreads: ExecuterType: " + executor.Type + " ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
executor.AssertBlockingWait(exception);

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,20 @@ public class NamedCall
using var cts = new CancellationTokenSource(8);
try {
mr.Wait(cts.Token);
} catch (OperationCanceledException) { /* ignore */ }
} catch (OperationCanceledException) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be swallowed I think. Because it's not really the expected outcome.
If it was expected outcome, the outer assert should process that case, rather than misleading null, which for this test means that something is broken for Main and WebWorker executors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to not swallow OperationCanceledException.

Console.WriteLine("ManualResetEventSlim.Wait: OperationCanceledException is ignored " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
/* ignore */
}
}},
new NamedCall { Name = "SemaphoreSlim.Wait", Call = delegate (CancellationToken ct) {
using var sem = new SemaphoreSlim(2);
var cts = new CancellationTokenSource(8);
try {
sem.Wait(cts.Token);
} catch (OperationCanceledException) { /* ignore */ }
} catch (OperationCanceledException) {
Console.WriteLine("SemaphoreSlim.Wait: OperationCanceledException is ignored " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
/* ignore */
}
}},
};

Expand Down
Loading