From a9c43938fc9998563aaa827750a72f21e295ef69 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Mon, 10 Jun 2024 16:33:32 -0400 Subject: [PATCH] test: move NUMA platform scan out of testing global The `testing.go` test helpers file for the driver manager initializes the NUMA scan as a package-global variable. This causes it to be pulled in even in production builds, so even running commands like `nomad version` will cause the NUMA scan to happen. Move the scan into the test helper setup. --- client/pluginmanager/drivermanager/testing.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/pluginmanager/drivermanager/testing.go b/client/pluginmanager/drivermanager/testing.go index fb1687a703a..d20b508c8fe 100644 --- a/client/pluginmanager/drivermanager/testing.go +++ b/client/pluginmanager/drivermanager/testing.go @@ -21,20 +21,19 @@ import ( ) type testManager struct { - logger log.Logger - loader loader.PluginCatalog + logger log.Logger + loader loader.PluginCatalog + topology *numalib.Topology } -var ( - topology = numalib.Scan(numalib.PlatformScanners()) -) - func TestDriverManager(t *testing.T) Manager { + topology := numalib.Scan(numalib.PlatformScanners()) logger := testlog.HCLogger(t).Named("driver_mgr") pluginLoader := catalog.TestPluginLoader(t) return &testManager{ - logger: logger, - loader: singleton.NewSingletonLoader(logger, pluginLoader), + logger: logger, + loader: singleton.NewSingletonLoader(logger, pluginLoader), + topology: topology, } } @@ -45,7 +44,7 @@ func (m *testManager) PluginType() string { return base.PluginTypeDriver } func (m *testManager) Dispense(driver string) (drivers.DriverPlugin, error) { baseConfig := &base.AgentConfig{ Driver: &base.ClientDriverConfig{ - Topology: topology, + Topology: m.topology, }, } instance, err := m.loader.Dispense(driver, base.PluginTypeDriver, baseConfig, m.logger)