Skip to content

Commit

Permalink
Merge pull request #5452 from hulizhe/karmadactltoppod
Browse files Browse the repository at this point in the history
enhance top pod command
  • Loading branch information
karmada-bot authored Aug 29, 2024
2 parents c9e0ad7 + 1a34a70 commit ac20f41
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
6 changes: 6 additions & 0 deletions pkg/karmadactl/top/top_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ var (
# Show metrics for all pods in the default namespace
%[1]s top pod
# Show metrics for all pods in the default namespace in member1 cluster
%[1]s top pod --clusters=member1
# Show metrics for all pods in the default namespace in member1 and member2 cluster
%[1]s top pod --clusters=member1,member2
# Show metrics for all pods in the given namespace
%[1]s top pod --namespace=NAMESPACE
Expand Down
36 changes: 19 additions & 17 deletions test/e2e/karmadactl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,28 +589,30 @@ var _ = ginkgo.Describe("Karmadactl top testing", func() {
})

ginkgo.It("Karmadactl top existing pod", func() {
for _, clusterName := range framework.ClusterNames() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", pod.Name, "-n", pod.Namespace, "-C", clusterName)
ginkgo.By("Karmadactl top existing pod", func() {
for _, clusterName := range framework.ClusterNames() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", pod.Name, "-n", pod.Namespace, "-C", clusterName)
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}
})

ginkgo.By("Karmadactl top existing pod without setting cluster flag", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", pod.Name, "-n", pod.Namespace)
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}
})

ginkgo.It("Karmadactl top existing pod without setting cluster flag", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", pod.Name, "-n", pod.Namespace)
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
})

ginkgo.It("Karmadactl top pod without specific podName", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", "-A")
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
for _, clusterName := range framework.ClusterNames() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", "-A", "-C", clusterName)
ginkgo.By("Karmadactl top pod without specific podName", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", "-A")
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}
for _, clusterName := range framework.ClusterNames() {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, pod.Namespace, karmadactlTimeout, "top", "pod", "-A", "-C", clusterName)
_, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
}
})
})
})
})
Expand Down

0 comments on commit ac20f41

Please sign in to comment.