diff --git a/test/e2e/bmc.go b/test/e2e/bmc.go index 6bea16b5a4..6d67ad350c 100644 --- a/test/e2e/bmc.go +++ b/test/e2e/bmc.go @@ -3,7 +3,6 @@ package e2e import ( "os" - . "github.com/onsi/gomega" "gopkg.in/yaml.v2" ) @@ -28,10 +27,14 @@ type BMC struct { SSHPort string `yaml:"sshPort,omitempty"` } -func LoadBMCConfig(configPath string) *[]BMC { +func LoadBMCConfig(configPath string) (*[]BMC, error) { configData, err := os.ReadFile(configPath) //#nosec - Expect(err).ToNot(HaveOccurred(), "Failed to read the bmcs config file") var bmcs []BMC - Expect(yaml.Unmarshal(configData, &bmcs)).To(Succeed()) - return &bmcs + if err != nil { + return nil, err + } + if err := yaml.Unmarshal(configData, &bmcs); err != nil { + return nil, err + } + return &bmcs, nil } diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index eb9d31ce3d..a4edf7a73a 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -170,7 +170,8 @@ var _ = SynchronizedBeforeSuite(func() []byte { err := metal3api.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) e2eConfig = LoadE2EConfig(configPath) - bmcs = LoadBMCConfig(bmcConfigPath) + bmcs, err := LoadBMCConfig(bmcConfigPath) + Expect(err).ToNot(HaveOccurred(), "Failed to read the bmcs config file") bmc = (*bmcs)[GinkgoParallelProcess()-1] clusterProxy = framework.NewClusterProxy("bmo-e2e", kubeconfigPath, scheme) })