Read PV object from apiserver to prevent flake

This commit is contained in:
Hemant Kumar
2020-08-20 15:25:58 -04:00
parent 1c548c328a
commit bad8a51b9a
3 changed files with 13 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ import (
"regexp"
"testing"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
@@ -147,6 +147,11 @@ func TestSyncHandler(t *testing.T) {
return nil, nil
})
if test.pv != nil {
fakeKubeClient.AddReactor("get", "persistentvolumes", func(action coretesting.Action) (bool, runtime.Object, error) {
return true, test.pv, nil
})
}
fakeKubeClient.AddReactor("patch", "persistentvolumeclaims", func(action coretesting.Action) (bool, runtime.Object, error) {
if action.GetSubresource() == "status" {
patchActionaction, _ := action.(coretesting.PatchAction)