Merge pull request #50435 from NickrenREN/localstorage-downwardapi
Automatic merge from submit-queue (batch tested with PRs 51471, 50561, 50435, 51473, 51436) Add local storage to downwards API **Release note**: ```release-note Add local ephemeral storage to downward API ``` /assign @NickrenREN
This commit is contained in:
@@ -2863,6 +2863,52 @@ func TestValidatePorts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalStorageEnvWithFeatureGate(t *testing.T) {
|
||||
testCases := []api.EnvVar{
|
||||
{
|
||||
Name: "ephemeral-storage-limits",
|
||||
ValueFrom: &api.EnvVarSource{
|
||||
ResourceFieldRef: &api.ResourceFieldSelector{
|
||||
ContainerName: "test-container",
|
||||
Resource: "limits.ephemeral-storage",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ephemeral-storage-requests",
|
||||
ValueFrom: &api.EnvVarSource{
|
||||
ResourceFieldRef: &api.ResourceFieldSelector{
|
||||
ContainerName: "test-container",
|
||||
Resource: "requests.ephemeral-storage",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
// Enable alpha feature LocalStorageCapacityIsolation
|
||||
err := utilfeature.DefaultFeatureGate.Set("LocalStorageCapacityIsolation=true")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to enable feature gate for LocalStorageCapacityIsolation: %v", err)
|
||||
return
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
if errs := validateEnvVarValueFrom(testCase, field.NewPath("field")); len(errs) != 0 {
|
||||
t.Errorf("expected success, got: %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
// Disable alpha feature LocalStorageCapacityIsolation
|
||||
err = utilfeature.DefaultFeatureGate.Set("LocalStorageCapacityIsolation=false")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to disable feature gate for LocalStorageCapacityIsolation: %v", err)
|
||||
return
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
if errs := validateEnvVarValueFrom(testCase, field.NewPath("field")); len(errs) == 0 {
|
||||
t.Errorf("expected failure for %v", testCase.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateEnv(t *testing.T) {
|
||||
successCase := []api.EnvVar{
|
||||
{Name: "abc", Value: "value"},
|
||||
|
Reference in New Issue
Block a user