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

Inconsistent test failure in GlobalSettingsTests #8107

Open
MiYanni opened this issue Jun 12, 2024 · 1 comment
Open

Inconsistent test failure in GlobalSettingsTests #8107

MiYanni opened this issue Jun 12, 2024 · 1 comment
Labels

Comments

@MiYanni
Copy link
Member

MiYanni commented Jun 12, 2024

Summary

It seems that the GlobalSettings is designed in a way where it doesn't clean up properly. The tests for it fail intermittently:

Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GlobalSettings'.
   at Microsoft.TemplateEngine.Edge.BuiltInManagedProvider.GlobalSettings.GetInstalledTemplatePackagesAsync(CancellationToken cancellationToken) in /_/src/Microsoft.TemplateEngine.Edge/BuiltInManagedProvider/GlobalSettings.cs:line 70
   at Microsoft.TemplateEngine.Edge.UnitTests.GlobalSettingsTests.<>c__DisplayClass3_0.<<TestFileWatcher>b__0>d.MoveNext() in /_/test/Microsoft.TemplateEngine.Edge.UnitTests/GlobalSettingsTests.cs:line 54
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

If you look at the TestFileWatcher test, to explain what it does in English:

  • Creates 2 instances of GlobalSettings that point to the same settings file.
  • Sets a SettingsChanged event for the second instance using a TaskCompletionSource that retrieves an installed template package
  • The first instance creates template package data and sets it
  • The test waits until the TaskCompletionSource finishes, asserts that it didn't time out, and checks to see that the template package data from the task is correct

Now, somehow, the error above seems to indicate that the second instance of GlobalSettings no longer exists when the SettingsChanged event is fired. This instance is scoped to the lifetime of the test method. Maybe the event is fired a second time? Maybe there is something else going on with Dispose that I'm unaware of?

This happened on 2 different PRs that I've observed so far. It happened (in both) on the Linux Debug job for the PR.

Logs

@MiYanni MiYanni added the test label Jun 12, 2024
@MiYanni
Copy link
Member Author

MiYanni commented Jun 13, 2024

Another failure but in the OSX Release job:

Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GlobalSettings'.
   at Microsoft.TemplateEngine.Edge.BuiltInManagedProvider.GlobalSettings.GetInstalledTemplatePackagesAsync(CancellationToken cancellationToken) in /_/src/Microsoft.TemplateEngine.Edge/BuiltInManagedProvider/GlobalSettings.cs:line 70
   at Microsoft.TemplateEngine.Edge.UnitTests.GlobalSettingsTests.<>c__DisplayClass3_0.<<TestFileWatcher>b__0>d.MoveNext() in /_/test/Microsoft.TemplateEngine.Edge.UnitTests/GlobalSettingsTests.cs:line 54
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

Log: Microsoft.TemplateEngine.Edge.UnitTests_net9.0_x64 (2).log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant