diff --git a/.golangci.yml b/.golangci.yml index 9819f608c..4ee0cc3c7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,6 +40,9 @@ linters-settings: funlen: lines: 120 statements: 80 + ginkgolinter: + enabled: true + path : ./test depguard: rules: main: @@ -74,6 +77,7 @@ linters: - gosec - dogsled - whitespace + - ginkgolinter issues: exclude-use-default: true diff --git a/test/e2e/admission_controller/admission_controller_suite_test.go b/test/e2e/admission_controller/admission_controller_suite_test.go index 1db0e3cf1..36f80ae40 100644 --- a/test/e2e/admission_controller/admission_controller_suite_test.go +++ b/test/e2e/admission_controller/admission_controller_suite_test.go @@ -194,7 +194,7 @@ var _ = BeforeSuite(func() { restClient = yunikorn.RClient{} kubeClient = k8s.KubeCtl{} - Expect(kubeClient.SetClient()).To(BeNil()) + Expect(kubeClient.SetClient()).To(Succeed()) yunikorn.EnsureYuniKornConfigsPresent() yunikorn.UpdateConfigMapWrapper(oldConfigMap, "") @@ -218,7 +218,7 @@ var _ = BeforeSuite(func() { var _ = AfterSuite(func() { kubeClient = k8s.KubeCtl{} - Expect(kubeClient.SetClient()).To(BeNil()) + Expect(kubeClient.SetClient()).To(Succeed()) By(fmt.Sprintf("Removing priority class %s", testNonYkPriorityClass.Name)) err := kubeClient.DeletePriorityClass(testNonYkPriorityClass.Name) diff --git a/test/e2e/admission_controller/admission_controller_test.go b/test/e2e/admission_controller/admission_controller_test.go index 82097f6ac..620a9f19d 100644 --- a/test/e2e/admission_controller/admission_controller_test.go +++ b/test/e2e/admission_controller/admission_controller_test.go @@ -45,7 +45,7 @@ const cronJobPodTimeout = 65 * time.Second var _ = ginkgo.Describe("AdmissionController", func() { ginkgo.BeforeEach(func() { kubeClient = k8s.KubeCtl{} - gomega.Expect(kubeClient.SetClient()).To(gomega.BeNil()) + gomega.Expect(kubeClient.SetClient()).To(gomega.Succeed()) ns = "ns-" + common.RandSeq(10) ginkgo.By(fmt.Sprintf("Creating namespace: %s for admission controller tests", ns)) var ns1, err1 = kubeClient.CreateNamespace(ns, nil) @@ -445,7 +445,7 @@ var _ = ginkgo.Describe("AdmissionController", func() { rs.Status.ReadyReplicas, rs.Status.AvailableReplicas) } - gomega.Ω(len(replicaSetList.Items)).To(gomega.Equal(2)) + gomega.Ω(replicaSetList.Items).To(gomega.HaveLen(2)) }) ginkgo.AfterEach(func() { diff --git a/test/e2e/basic_scheduling/basic_scheduling_test.go b/test/e2e/basic_scheduling/basic_scheduling_test.go index e1f7211e8..554393853 100644 --- a/test/e2e/basic_scheduling/basic_scheduling_test.go +++ b/test/e2e/basic_scheduling/basic_scheduling_test.go @@ -48,7 +48,7 @@ var _ = ginkgo.BeforeSuite(func() { suiteName = common.GetSuiteName(filename) // Initializing kubectl client kClient = k8s.KubeCtl{} - gomega.Ω(kClient.SetClient()).To(gomega.BeNil()) + gomega.Ω(kClient.SetClient()).To(gomega.Succeed()) // Initializing rest client restClient = yunikorn.RClient{} yunikorn.EnsureYuniKornConfigsPresent() @@ -101,8 +101,7 @@ var _ = ginkgo.Describe("", func() { ginkgo.It("Verify_Pod_Alloc_Props", func() { ginkgo.By("Verify the pod allocation properties") - gomega.Ω(appsInfo.Allocations).NotTo(gomega.BeNil()) - gomega.Ω(len(appsInfo.Allocations)).NotTo(gomega.BeZero()) + gomega.Ω(appsInfo.Allocations).NotTo(gomega.BeEmpty()) allocation := appsInfo.Allocations[0] gomega.Ω(allocation).NotTo(gomega.BeNil()) gomega.Ω(allocation.AllocationKey).NotTo(gomega.BeNil()) diff --git a/test/e2e/framework/helpers/k8s/events.go b/test/e2e/framework/helpers/k8s/events.go index fd6287d9a..f3fe820b5 100644 --- a/test/e2e/framework/helpers/k8s/events.go +++ b/test/e2e/framework/helpers/k8s/events.go @@ -142,7 +142,7 @@ func (e *EventHandler) WaitForUpdate(timeout time.Duration) bool { func ObserveConfigMapInformerUpdateAfterAction(action func()) { kubeClient := KubeCtl{} - gomega.Expect(kubeClient.SetClient()).To(gomega.BeNil()) + gomega.Expect(kubeClient.SetClient()).To(gomega.Succeed()) // Setup ConfigMap informer stopChan := make(chan struct{}) @@ -156,5 +156,5 @@ func ObserveConfigMapInformerUpdateAfterAction(action func()) { // Wait for ConfigMap informer recevie update event. updateOk := eventHandler.WaitForUpdate(30 * time.Second) - gomega.Ω(updateOk).To(gomega.Equal(true)) + gomega.Ω(updateOk).To(gomega.BeTrue()) } diff --git a/test/e2e/recovery_and_restart/recovery_and_restart_test.go b/test/e2e/recovery_and_restart/recovery_and_restart_test.go index a94df26c4..8c4a56bad 100644 --- a/test/e2e/recovery_and_restart/recovery_and_restart_test.go +++ b/test/e2e/recovery_and_restart/recovery_and_restart_test.go @@ -140,7 +140,7 @@ var _ = ginkgo.Describe("", func() { gomega.Ω(appsInfo).NotTo(gomega.BeNil()) ginkgo.By("Verify the pod allocation properties") gomega.Ω(appsInfo).NotTo(gomega.BeNil()) - gomega.Ω(len(appsInfo.Allocations)).NotTo(gomega.BeZero()) + gomega.Ω(appsInfo.Allocations).NotTo(gomega.BeNil()) allocations := appsInfo.Allocations[0] gomega.Ω(allocations).NotTo(gomega.BeNil()) gomega.Ω(allocations.AllocationKey).NotTo(gomega.BeNil()) @@ -149,7 +149,7 @@ var _ = ginkgo.Describe("", func() { core := sleepRespPod.Spec.Containers[0].Resources.Requests.Cpu().MilliValue() mem := sleepRespPod.Spec.Containers[0].Resources.Requests.Memory().Value() resMap := allocations.ResourcePerAlloc - gomega.Ω(len(resMap)).NotTo(gomega.BeZero()) + gomega.Ω(resMap).NotTo(gomega.BeEmpty()) gomega.Ω(resMap["memory"]).To(gomega.Equal(mem)) gomega.Ω(resMap["vcore"]).To(gomega.Equal(core)) })