Skip to content

Commit

Permalink
fix: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sbhat14 authored and sbhat14 committed Nov 6, 2024
1 parent 599436d commit 5ea2e85
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Below you will find the step syntax next to the name of the method it utilizes.
- `<GK> [the] deployment <any-characters-except-(")> is running in namespace <any-characters-except-(")>` kdt.KubeClientSet.DeploymentIsRunning
- `<GK> [the] data in [the] ConfigMap "<any-characters-except-(")>" in namespace "<any-characters-except-(")>" has key "<any-characters-except-(")>" with value "<any-characters-except-(")>"` kdt.KubeClientSet.ConfigMapDataHasKeyAndValue
- `<GK> [the] persistentvolume <any-characters-except-(")> exists with status (Available|Bound|Released|Failed|Pending)` kdt.KubeClientSet.PersistentVolExists
- `<GK> [the] persistentvolumeclaim <any-characters-except-(")> exists with status (Available|Bound|Released|Failed|Pending) in namespace <any-characters-except-(")>` kdt.KubeClientSet.PersistentVolClaimExists
- `<GK> [the] (clusterrole|clusterrolebinding) with name <any-characters-except-(")> should be found` kdt.KubeClientSet.ClusterRbacIsFound
- `<GK> [the] ingress <non-whitespace-characters> in [the] namespace <non-whitespace-characters> [is] [available] on port <digits> and path <any-characters-except-(")>` kdt.KubeClientSet.IngressAvailable
- `<GK> [I] send <digits> tps to ingress <non-whitespace-characters> in [the] namespace <non-whitespace-characters> [available] on port <digits> and path <any-characters-except-(")> for <digits> (minutes|seconds) expecting up to <digits> error[s]` kdt.KubeClientSet.SendTrafficToIngress
Expand Down
6 changes: 4 additions & 2 deletions pkg/kube/structured/structured.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ func PersistentVolExists(kubeClientset kubernetes.Interface, name, expectedPhase
}

func PersistentVolClaimExists(kubeClientset kubernetes.Interface, name, expectedPhase string, namespace string) error {
vol, err := GetPersistentVolumeClaim(kubeClientset, name, namespace)
vol, err := util.RetryOnError(&util.DefaultRetry, util.IsRetriable, func() (interface{}, error) {
return GetPersistentVolumeClaim(kubeClientset, name, namespace)
})
if err != nil {
return err
}
phase := string(vol.Status.Phase)
phase := string(vol.(*corev1.PersistentVolumeClaim).Status.Phase)
if phase != expectedPhase {
return fmt.Errorf("persistentvolumeclaim had unexpected phase %v, expected phase %v", phase, expectedPhase)
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/kube/structured/structured_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func TestPersistentVolClaimExists(t *testing.T) {
kubeClientset: fake.NewSimpleClientset(getResource(t, persistentVolumeClaimType, persistentvolumeClaimName)),
name: persistentvolumeClaimName,
namespace: "",
expectedPhase: "",
expectedPhase: "Bound",
},
wantErr: false,
},
Expand All @@ -518,7 +518,7 @@ func TestPersistentVolClaimExists(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := PersistentVolClaimExists(tt.args.kubeClientset, tt.args.name, tt.args.namespace, tt.args.expectedPhase); (err != nil) != tt.wantErr {
if err := PersistentVolClaimExists(tt.args.kubeClientset, tt.args.name, tt.args.expectedPhase, tt.args.namespace); (err != nil) != tt.wantErr {
t.Errorf("PersistentVolClaimExists() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down Expand Up @@ -885,6 +885,9 @@ func getResourceWithAll(t *testing.T, resourceType, name, namespace, label strin
Namespace: namespace,
Labels: labels,
},
Status: corev1.PersistentVolumeClaimStatus{
Phase: corev1.ClaimBound,
},
}
case statefulSetType:
return &appsv1.StatefulSet{
Expand Down

0 comments on commit 5ea2e85

Please sign in to comment.