From 5e49fb067fb5f49052806776d6971c43eb678cfa Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Fri, 25 Mar 2022 09:42:58 -0400 Subject: [PATCH] Fix flexvolume online resizing tests --- .../persistentvolumeclaim/strategy_test.go | 56 ++++++++----------- test/e2e/storage/flexvolume_online_resize.go | 2 +- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/pkg/registry/core/persistentvolumeclaim/strategy_test.go b/pkg/registry/core/persistentvolumeclaim/strategy_test.go index c41e6a27cb7..1f6a332a9b9 100644 --- a/pkg/registry/core/persistentvolumeclaim/strategy_test.go +++ b/pkg/registry/core/persistentvolumeclaim/strategy_test.go @@ -76,45 +76,35 @@ func TestDropConditions(t *testing.T) { }, } - for _, enabled := range []bool{true} { - for _, oldPvcInfo := range pvcInfo { - for _, newPvcInfo := range pvcInfo { - oldPvcHasConditins, oldPvc := oldPvcInfo.hasConditions, oldPvcInfo.pvc() - newPvcHasConditions, newPvc := newPvcInfo.hasConditions, newPvcInfo.pvc() + for _, oldPvcInfo := range pvcInfo { + for _, newPvcInfo := range pvcInfo { + oldPvcHasConditins, oldPvc := oldPvcInfo.hasConditions, oldPvcInfo.pvc() + newPvcHasConditions, newPvc := newPvcInfo.hasConditions, newPvcInfo.pvc() - t.Run(fmt.Sprintf("feature enabled=%v, old pvc %v, new pvc %v", enabled, oldPvcInfo.description, newPvcInfo.description), func(t *testing.T) { - StatusStrategy.PrepareForUpdate(ctx, newPvc, oldPvc) + t.Run(fmt.Sprintf("old pvc %s, new pvc %s", oldPvcInfo.description, newPvcInfo.description), func(t *testing.T) { + StatusStrategy.PrepareForUpdate(ctx, newPvc, oldPvc) - // old pvc should never be changed - if !reflect.DeepEqual(oldPvc, oldPvcInfo.pvc()) { - t.Errorf("old pvc changed: %v", diff.ObjectReflectDiff(oldPvc, oldPvcInfo.pvc())) + // old pvc should never be changed + if !reflect.DeepEqual(oldPvc, oldPvcInfo.pvc()) { + t.Errorf("old pvc changed: %v", diff.ObjectReflectDiff(oldPvc, oldPvcInfo.pvc())) + } + + switch { + case oldPvcHasConditins || newPvcHasConditions: + // new pvc should not be changed if the feature is enabled, or if the old pvc had Conditions + if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { + t.Errorf("new pvc changed: %v", diff.ObjectReflectDiff(newPvc, newPvcInfo.pvc())) } - - switch { - case enabled || oldPvcHasConditins: - // new pvc should not be changed if the feature is enabled, or if the old pvc had Conditions - if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { - t.Errorf("new pvc changed: %v", diff.ObjectReflectDiff(newPvc, newPvcInfo.pvc())) - } - case newPvcHasConditions: - // new pvc should be changed - if reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { - t.Errorf("new pvc was not changed") - } - // new pvc should not have Conditions - if !reflect.DeepEqual(newPvc, pvcWithoutConditions()) { - t.Errorf("new pvc had Conditions: %v", diff.ObjectReflectDiff(newPvc, pvcWithoutConditions())) - } - default: - // new pvc should not need to be changed - if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { - t.Errorf("new pvc changed: %v", diff.ObjectReflectDiff(newPvc, newPvcInfo.pvc())) - } + default: + // new pvc should not need to be changed + if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { + t.Errorf("new pvc changed: %v", diff.ObjectReflectDiff(newPvc, newPvcInfo.pvc())) } - }) - } + } + }) } } + } func TestPrepareForCreate(t *testing.T) { diff --git a/test/e2e/storage/flexvolume_online_resize.go b/test/e2e/storage/flexvolume_online_resize.go index 83add3af0d5..4b2721e0b8e 100644 --- a/test/e2e/storage/flexvolume_online_resize.go +++ b/test/e2e/storage/flexvolume_online_resize.go @@ -39,7 +39,7 @@ import ( imageutils "k8s.io/kubernetes/test/utils/image" ) -var _ = utils.SIGDescribe("Mounted flexvolume volume expand [Slow]", func() { +var _ = utils.SIGDescribe("[Feature:Flexvolumes] Mounted flexvolume volume expand [Slow]", func() { var ( c clientset.Interface ns string