diff --git a/.github/workflows/pre-main.yml b/.github/workflows/pre-main.yml index f5887f1eb..effe39d7b 100644 --- a/.github/workflows/pre-main.yml +++ b/.github/workflows/pre-main.yml @@ -3,9 +3,9 @@ name: Test Incoming Changes 'on': push: - branches: [main] + branches: [main, ginkgo_removal] pull_request: - branches: [main] + branches: [main, ginkgo_removal] jobs: lint: diff --git a/tests/globalhelper/daemonset.go b/tests/globalhelper/daemonset.go index 9c18f0325..5dca91a39 100644 --- a/tests/globalhelper/daemonset.go +++ b/tests/globalhelper/daemonset.go @@ -11,16 +11,18 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" appsv1Typed "k8s.io/client-go/kubernetes/typed/apps/v1" + corev1Typed "k8s.io/client-go/kubernetes/typed/core/v1" . "github.com/onsi/gomega" ) func CreateAndWaitUntilDaemonSetIsReady(daemonSet *appsv1.DaemonSet, timeout time.Duration) error { - return createAndWaitUntilDaemonSetIsReady(GetAPIClient().K8sClient.AppsV1(), daemonSet, timeout) + return createAndWaitUntilDaemonSetIsReady(GetAPIClient().K8sClient.AppsV1(), GetAPIClient().K8sClient.CoreV1(), daemonSet, timeout) } // CreateAndWaitUntilDaemonSetIsReady creates daemonSet and waits until all pods are up and running. func createAndWaitUntilDaemonSetIsReady(appsClient appsv1Typed.AppsV1Interface, + coreClient corev1Typed.CoreV1Interface, daemonSet *appsv1.DaemonSet, timeout time.Duration) error { runningDaemonSet, err := appsClient.DaemonSets(daemonSet.Namespace).Create( context.TODO(), daemonSet, metav1.CreateOptions{}) @@ -33,7 +35,7 @@ func createAndWaitUntilDaemonSetIsReady(appsClient appsv1Typed.AppsV1Interface, } Eventually(func() bool { - status, err := isDaemonSetReady(appsClient, runningDaemonSet.Namespace, runningDaemonSet.Name) + status, err := isDaemonSetReady(appsClient, coreClient, runningDaemonSet.Namespace, runningDaemonSet.Name) if err != nil { glog.Errorf( "daemonset %s is not ready, retry in 5 seconds", runningDaemonSet.Name) @@ -47,7 +49,7 @@ func createAndWaitUntilDaemonSetIsReady(appsClient appsv1Typed.AppsV1Interface, return nil } -func isDaemonSetReady(client appsv1Typed.AppsV1Interface, namespace string, name string) (bool, error) { +func isDaemonSetReady(client appsv1Typed.AppsV1Interface, coreClient corev1Typed.CoreV1Interface, namespace string, name string) (bool, error) { daemonSet, err := client.DaemonSets(namespace).Get( context.TODO(), name, @@ -58,7 +60,7 @@ func isDaemonSetReady(client appsv1Typed.AppsV1Interface, namespace string, name } // Get number of nodes and compare with the number of scheduled pods - numNodes := GetNumberOfNodes() + numNodes := GetNumberOfNodes(coreClient) if daemonSet.Status.DesiredNumberScheduled == int32(numNodes) && daemonSet.Status.NumberReady == daemonSet.Status.DesiredNumberScheduled { return true, nil diff --git a/tests/globalhelper/daemonset_test.go b/tests/globalhelper/daemonset_test.go index 07c4854eb..2800a3fbe 100644 --- a/tests/globalhelper/daemonset_test.go +++ b/tests/globalhelper/daemonset_test.go @@ -123,10 +123,19 @@ func TestIsDaemonsetReady(t *testing.T) { var runtimeObjects []runtime.Object runtimeObjects = append(runtimeObjects, generateDaemonset(testCase.numAvailable, testCase.numScheduled, testCase.numUnavailable, testCase.numReady)) + runtimeObjects = append(runtimeObjects, &corev1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-node", + Labels: map[string]string{ + "node-role.kubernetes.io/worker-cnf": "", + }, + }, + }) + client := k8sfake.NewSimpleClientset(runtimeObjects...) t.Run(testCase.name, func(t *testing.T) { - got, err := isDaemonSetReady(client.AppsV1(), "default", "test-daemonset") + got, err := isDaemonSetReady(client.AppsV1(), client.CoreV1(), "default", "test-daemonset") if (err != nil) != testCase.wantErr { t.Errorf("isDaemonsetReady() error = %v, wantErr %v", err, testCase.wantErr) diff --git a/tests/globalhelper/nodes.go b/tests/globalhelper/nodes.go index 58a8d6397..c5347efdb 100644 --- a/tests/globalhelper/nodes.go +++ b/tests/globalhelper/nodes.go @@ -92,8 +92,8 @@ func NodeHasHugePagesEnabled(node *corev1.Node, resourceName string) bool { return hugepagesEnabled } -func GetNumberOfNodes() int { - return getNumberOfNodes(GetAPIClient().K8sClient.CoreV1()) +func GetNumberOfNodes(client corev1Typed.CoreV1Interface) int { + return getNumberOfNodes(client) } func getNumberOfNodes(client corev1Typed.CoreV1Interface) int {