Skip to content

Commit

Permalink
test: Added UTs for ReadyPodsCount and WaitForAllToBeReady methods
Browse files Browse the repository at this point in the history
  • Loading branch information
samihan-dell committed Nov 18, 2024
1 parent 936fcc3 commit 5117acb
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkg/k8sclient/resources/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,53 @@ func (suite *PodTestSuite) TestDeleteAll() {
})
}

func (suite *PodTestSuite) TestReadyPodsCount() {
podconf := &pod.Config{
NamePrefix: "pod-prov-test-",
PvcNames: []string{"pvc1", "pvc2", "pvc3"},
VolumeName: "vol",
MountPath: "/data",
ContainerName: "prov-test",
ContainerImage: "quay.io/centos/centos:latest",
Command: []string{"/app/run.sh"},
}

client, err := suite.kubeClient.CreatePodClient("test-namespace")
suite.NoError(err)

podTmpl := client.MakePod(podconf)
suite.Equal("test-namespace", podTmpl.Namespace)

suite.Run("Ready Pods Count test", func() {
readyCount, err := client.ReadyPodsCount(context.Background())
suite.Equal(readyCount, 0)
suite.NoError(err)
})
}

func (suite *PodTestSuite) TestWaitForAllToBeReady() {
podconf := &pod.Config{
NamePrefix: "pod-prov-test-",
PvcNames: []string{"pvc1", "pvc2", "pvc3"},
VolumeName: "vol",
MountPath: "/data",
ContainerName: "prov-test",
ContainerImage: "quay.io/centos/centos:latest",
Command: []string{"/app/run.sh"},
}

client, err := suite.kubeClient.CreatePodClient("test-namespace")
suite.NoError(err)

podTmpl := client.MakePod(podconf)
suite.Equal("test-namespace", podTmpl.Namespace)

suite.Run("waits for all Pods to be in Ready state test", func() {
err := client.WaitForAllToBeReady(context.Background())
suite.NoError(err)
})
}

func TestPodTestSuite(t *testing.T) {
suite.Run(t, new(PodTestSuite))
}

0 comments on commit 5117acb

Please sign in to comment.