mirror of
https://github.com/navidrome/navidrome.git
synced 2026-01-03 06:15:22 +00:00
fix(plugins): prevent race condition in plugin tests
Add EnsureCompiled calls in plugin test BeforeEach blocks to wait for WebAssembly compilation before loading plugins. This prevents race conditions where tests would attempt to load plugins before compilation completed, causing flaky test failures in CI environments. The race condition occurred because ScanPlugins() registers plugins synchronously but compiles them asynchronously in background goroutines with a concurrency limit of 2. Tests that immediately called LoadPlugin() or LoadMediaAgent() after ScanPlugins() could fail if compilation wasn't finished yet. Fixed in both adapter_media_agent_test.go and manager_test.go which had multiple tests vulnerable to this timing issue.
This commit is contained in:
parent
d5fa46e948
commit
9fcc996336
@ -26,6 +26,12 @@ var _ = Describe("Adapter Media Agent", func() {
|
||||
|
||||
mgr = createManager(nil, metrics.NewNoopInstance())
|
||||
mgr.ScanPlugins()
|
||||
|
||||
// Wait for all plugins to compile to avoid race conditions
|
||||
err := mgr.EnsureCompiled("multi_plugin")
|
||||
Expect(err).NotTo(HaveOccurred(), "multi_plugin should compile successfully")
|
||||
err = mgr.EnsureCompiled("fake_album_agent")
|
||||
Expect(err).NotTo(HaveOccurred(), "fake_album_agent should compile successfully")
|
||||
})
|
||||
|
||||
Describe("AgentName and PluginName", func() {
|
||||
|
||||
@ -31,6 +31,16 @@ var _ = Describe("Plugin Manager", func() {
|
||||
ctx = GinkgoT().Context()
|
||||
mgr = createManager(nil, metrics.NewNoopInstance())
|
||||
mgr.ScanPlugins()
|
||||
|
||||
// Wait for all plugins to compile to avoid race conditions
|
||||
err := mgr.EnsureCompiled("fake_artist_agent")
|
||||
Expect(err).NotTo(HaveOccurred(), "fake_artist_agent should compile successfully")
|
||||
err = mgr.EnsureCompiled("fake_album_agent")
|
||||
Expect(err).NotTo(HaveOccurred(), "fake_album_agent should compile successfully")
|
||||
err = mgr.EnsureCompiled("multi_plugin")
|
||||
Expect(err).NotTo(HaveOccurred(), "multi_plugin should compile successfully")
|
||||
err = mgr.EnsureCompiled("unauthorized_plugin")
|
||||
Expect(err).NotTo(HaveOccurred(), "unauthorized_plugin should compile successfully")
|
||||
})
|
||||
|
||||
It("should scan and discover plugins from the testdata folder", func() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user