This is an automated email from the ASF dual-hosted git repository.

wilfreds pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new 76aaf7e3 [YUNIKORN-2973] Adding GinkgoLinter (#941)
76aaf7e3 is described below

commit 76aaf7e30156ebb434ed5ed1a4de034341a9e399
Author: rrajesh <[email protected]>
AuthorDate: Fri Dec 13 16:12:09 2024 +1100

    [YUNIKORN-2973] Adding GinkgoLinter (#941)
    
    Fix issues raised by the linter in the tests.
    
    Closes: #941
    
    Signed-off-by: Wilfred Spiegelenburg <[email protected]>
---
 .golangci.yml                                                    | 4 ++++
 test/e2e/admission_controller/admission_controller_suite_test.go | 4 ++--
 test/e2e/admission_controller/admission_controller_test.go       | 4 ++--
 test/e2e/basic_scheduling/basic_scheduling_test.go               | 5 ++---
 test/e2e/framework/helpers/k8s/events.go                         | 4 ++--
 test/e2e/recovery_and_restart/recovery_and_restart_test.go       | 4 ++--
 6 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/.golangci.yml b/.golangci.yml
index 9819f608..4ee0cc3c 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 1db0e3cf..36f80ae4 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 82097f6a..620a9f19 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 e1f7211e..55439385 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 fd6287d9..f3fe820b 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 a94df26c..8c4a56ba 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))
        })


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to