test(plugins): speed up integration tests (~45% improvement) (#5137)
* test(plugins): speed up integration tests with shared wazero cache Reduce plugin test suite runtime from ~22s to ~12s by: - Creating a shared wazero compilation cache directory in TestPlugins() and setting conf.Server.CacheFolder globally so all test Manager instances reuse compiled WASM binaries from disk cache - Moving 6 createTestManager* calls from inside It blocks to BeforeAll blocks in scrobbler_adapter_test.go and manager_call_test.go - Replacing time.Sleep(2s) in KVStore TTL test with Eventually polling - Reducing WebSocket callback sleeps from 100ms to 10ms Signed-off-by: Deluan <deluan@navidrome.org> * test(plugins): enhance websocket tests by storing server messages for verification Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -36,6 +36,20 @@ var (
|
||||
func TestPlugins(t *testing.T) {
|
||||
tests.Init(t, false)
|
||||
buildTestPlugins(t, testDataDir)
|
||||
|
||||
// Create a shared wazero compilation cache directory.
|
||||
// All test managers will point CacheFolder here so that WASM compilation
|
||||
// is done once per binary and then reused from disk cache.
|
||||
sharedCacheDir, err := os.MkdirTemp("", "plugins-shared-cache-*")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create shared cache dir: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { os.RemoveAll(sharedCacheDir) })
|
||||
|
||||
// Set CacheFolder globally so all tests (including those using
|
||||
// configtest.SetupConfig) inherit it without needing to set it manually.
|
||||
conf.Server.CacheFolder = sharedCacheDir
|
||||
|
||||
log.SetLevel(log.LevelFatal)
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Plugins Suite")
|
||||
@@ -114,7 +128,6 @@ func createTestManagerWithPluginsAndMetrics(pluginConfig map[string]map[string]s
|
||||
conf.Server.Plugins.Enabled = true
|
||||
conf.Server.Plugins.Folder = tmpDir
|
||||
conf.Server.Plugins.AutoReload = false
|
||||
conf.Server.CacheFolder = filepath.Join(tmpDir, "cache")
|
||||
|
||||
// Setup mock DataStore with pre-enabled plugins
|
||||
mockPluginRepo := tests.CreateMockPluginRepo()
|
||||
|
||||
Reference in New Issue
Block a user