mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 19:28:16 +00:00
Active deadline seconds validation improvements
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package validation
|
||||
|
||||
import (
|
||||
"math"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -3350,6 +3351,7 @@ func TestValidateDNSPolicy(t *testing.T) {
|
||||
|
||||
func TestValidatePodSpec(t *testing.T) {
|
||||
activeDeadlineSeconds := int64(30)
|
||||
activeDeadlineSecondsMax := int64(math.MaxUint32)
|
||||
|
||||
minUserID := types.UnixUserID(0)
|
||||
maxUserID := types.UnixUserID(2147483647)
|
||||
@@ -3378,6 +3380,21 @@ func TestValidatePodSpec(t *testing.T) {
|
||||
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
||||
ServiceAccountName: "acct",
|
||||
},
|
||||
{ // Populate all fields with larger active deadline.
|
||||
Volumes: []api.Volume{
|
||||
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
||||
},
|
||||
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
|
||||
InitContainers: []api.Container{{Name: "ictr", Image: "iimage", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
|
||||
RestartPolicy: api.RestartPolicyAlways,
|
||||
NodeSelector: map[string]string{
|
||||
"key": "value",
|
||||
},
|
||||
NodeName: "foobar",
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
ActiveDeadlineSeconds: &activeDeadlineSecondsMax,
|
||||
ServiceAccountName: "acct",
|
||||
},
|
||||
{ // Populate HostNetwork.
|
||||
Containers: []api.Container{
|
||||
{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File",
|
||||
@@ -3450,6 +3467,7 @@ func TestValidatePodSpec(t *testing.T) {
|
||||
}
|
||||
|
||||
activeDeadlineSeconds = int64(0)
|
||||
activeDeadlineSecondsTooLarge := int64(math.MaxUint32 + 1)
|
||||
|
||||
minUserID = types.UnixUserID(-1)
|
||||
maxUserID = types.UnixUserID(2147483648)
|
||||
@@ -3591,6 +3609,19 @@ func TestValidatePodSpec(t *testing.T) {
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
||||
},
|
||||
"active-deadline-seconds-too-large": {
|
||||
Volumes: []api.Volume{
|
||||
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
||||
},
|
||||
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
|
||||
RestartPolicy: api.RestartPolicyAlways,
|
||||
NodeSelector: map[string]string{
|
||||
"key": "value",
|
||||
},
|
||||
NodeName: "foobar",
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
ActiveDeadlineSeconds: &activeDeadlineSecondsTooLarge,
|
||||
},
|
||||
"bad nodeName": {
|
||||
NodeName: "node name",
|
||||
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
|
||||
|
||||
Reference in New Issue
Block a user