diff --git a/controllers/sriovnetworkpoolconfig_controller_test.go b/controllers/sriovnetworkpoolconfig_controller_test.go index 5b76d1d19..b95f5edac 100644 --- a/controllers/sriovnetworkpoolconfig_controller_test.go +++ b/controllers/sriovnetworkpoolconfig_controller_test.go @@ -13,12 +13,18 @@ import ( mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" ) var _ = Describe("Operator", func() { Context("When is up", func() { It("should be able to create machine config for MachineConfigPool specified in sriov pool config", func() { + if vars.ClusterType != consts.ClusterTypeOpenshift { + Skip("test should only be executed with openshift cluster type") + } + config := &sriovnetworkv1.SriovNetworkPoolConfig{} config.SetNamespace(testNamespace) config.SetName("ovs-hw-offload-config") diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 0493ab7c6..6a9b1af5d 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -67,7 +67,7 @@ const ( interval = time.Millisecond * 250 ) -var _ = BeforeSuite(func(done Done) { +var _ = BeforeSuite(func() { logf.SetLogger(zap.New( zap.WriteTo(GinkgoWriter), zap.UseDevMode(true), @@ -213,15 +213,16 @@ var _ = BeforeSuite(func(done Done) { poolConfig.SetName(constants.DefaultConfigName) poolConfig.Spec = sriovnetworkv1.SriovNetworkPoolConfigSpec{} Expect(k8sClient.Create(context.TODO(), poolConfig)).Should(Succeed()) - close(done) }) var _ = AfterSuite(func() { By("tearing down the test environment") cancel() - Eventually(func() error { - return testEnv.Stop() - }, timeout, time.Second).ShouldNot(HaveOccurred()) + if testEnv != nil { + Eventually(func() error { + return testEnv.Stop() + }, timeout, time.Second).ShouldNot(HaveOccurred()) + } }) func TestAPIs(t *testing.T) {