mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
fix: add feature-gate is disabled unit tests
This commit is contained in:
parent
0393497468
commit
a548688ffe
@ -73,11 +73,12 @@ func TestAdmit(t *testing.T) {
|
|||||||
vacWithFinalizer.Finalizers = []string{volumeutil.VACProtectionFinalizer}
|
vacWithFinalizer.Finalizers = []string{volumeutil.VACProtectionFinalizer}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
resource schema.GroupVersionResource
|
resource schema.GroupVersionResource
|
||||||
object runtime.Object
|
object runtime.Object
|
||||||
expectedObject runtime.Object
|
expectedObject runtime.Object
|
||||||
namespace string
|
namespace string
|
||||||
|
enableVacFeatureGate bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"persistentvolumeclaims: create -> add finalizer",
|
"persistentvolumeclaims: create -> add finalizer",
|
||||||
@ -85,6 +86,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
claim,
|
claim,
|
||||||
claimWithFinalizer,
|
claimWithFinalizer,
|
||||||
claim.Namespace,
|
claim.Namespace,
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"persistentvolumeclaims: finalizer already exists -> no new finalizer",
|
"persistentvolumeclaims: finalizer already exists -> no new finalizer",
|
||||||
@ -92,6 +94,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
claimWithFinalizer,
|
claimWithFinalizer,
|
||||||
claimWithFinalizer,
|
claimWithFinalizer,
|
||||||
claimWithFinalizer.Namespace,
|
claimWithFinalizer.Namespace,
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"persistentvolumes: create -> add finalizer",
|
"persistentvolumes: create -> add finalizer",
|
||||||
@ -99,6 +102,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
pv,
|
pv,
|
||||||
pvWithFinalizer,
|
pvWithFinalizer,
|
||||||
pv.Namespace,
|
pv.Namespace,
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"persistentvolumes: finalizer already exists -> no new finalizer",
|
"persistentvolumes: finalizer already exists -> no new finalizer",
|
||||||
@ -106,20 +110,39 @@ func TestAdmit(t *testing.T) {
|
|||||||
pvWithFinalizer,
|
pvWithFinalizer,
|
||||||
pvWithFinalizer,
|
pvWithFinalizer,
|
||||||
pvWithFinalizer.Namespace,
|
pvWithFinalizer.Namespace,
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"volumeattributesclasses: create -> add finalizer",
|
"volumeattributesclasses VacFeatureGate disabled: create -> no finalizer added",
|
||||||
|
storageapi.SchemeGroupVersion.WithResource("volumeattributesclasses"),
|
||||||
|
vac,
|
||||||
|
vac,
|
||||||
|
vac.Namespace,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"volumeattributesclasses VacFeatureGate disabled: finalizer already exists -> no new finalizer",
|
||||||
|
storageapi.SchemeGroupVersion.WithResource("volumeattributesclasses"),
|
||||||
|
vacWithFinalizer,
|
||||||
|
vacWithFinalizer,
|
||||||
|
vac.Namespace,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"volumeattributesclasses VacFeatureGate enabled: create -> add finalizer",
|
||||||
storageapi.SchemeGroupVersion.WithResource("volumeattributesclasses"),
|
storageapi.SchemeGroupVersion.WithResource("volumeattributesclasses"),
|
||||||
vac,
|
vac,
|
||||||
vacWithFinalizer,
|
vacWithFinalizer,
|
||||||
vac.Namespace,
|
vac.Namespace,
|
||||||
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"volumeattributesclasses: finalizer already exists -> no new finalizer",
|
"volumeattributesclasses VacFeatureGate enabled: finalizer already exists -> no new finalizer",
|
||||||
storageapi.SchemeGroupVersion.WithResource("volumeattributesclasses"),
|
storageapi.SchemeGroupVersion.WithResource("volumeattributesclasses"),
|
||||||
vacWithFinalizer,
|
vacWithFinalizer,
|
||||||
vacWithFinalizer,
|
vacWithFinalizer,
|
||||||
vac.Namespace,
|
vac.Namespace,
|
||||||
|
true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,10 +150,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
ctrl := newPlugin()
|
ctrl := newPlugin()
|
||||||
|
|
||||||
// Enable feature gate for tests with VolumeAttributesClass
|
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.VolumeAttributesClass, test.enableVacFeatureGate)
|
||||||
if test.object.GetObjectKind().GroupVersionKind().Kind == "VolumeAttributesClass" {
|
|
||||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.VolumeAttributesClass, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
obj := test.object.DeepCopyObject()
|
obj := test.object.DeepCopyObject()
|
||||||
attrs := admission.NewAttributesRecord(
|
attrs := admission.NewAttributesRecord(
|
||||||
|
Loading…
Reference in New Issue
Block a user