mirror of https://github.com/kubernetes/kops.git
Create a better image validation test
This commit is contained in:
parent
8ecd648135
commit
dd578430e8
|
|
@ -385,7 +385,7 @@ func TestIGUpdatePolicy(t *testing.T) {
|
||||||
func TestValidInstanceGroup(t *testing.T) {
|
func TestValidInstanceGroup(t *testing.T) {
|
||||||
grid := []struct {
|
grid := []struct {
|
||||||
IG *kops.InstanceGroup
|
IG *kops.InstanceGroup
|
||||||
ExpectedErrors int
|
ExpectedErrors []string
|
||||||
Description string
|
Description string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -401,7 +401,7 @@ func TestValidInstanceGroup(t *testing.T) {
|
||||||
Image: "my-image",
|
Image: "my-image",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExpectedErrors: 0,
|
ExpectedErrors: []string{},
|
||||||
Description: "Valid master instance group failed to validate",
|
Description: "Valid master instance group failed to validate",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -417,7 +417,7 @@ func TestValidInstanceGroup(t *testing.T) {
|
||||||
Image: "my-image",
|
Image: "my-image",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExpectedErrors: 0,
|
ExpectedErrors: []string{},
|
||||||
Description: "Valid API Server instance group failed to validate",
|
Description: "Valid API Server instance group failed to validate",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -433,7 +433,7 @@ func TestValidInstanceGroup(t *testing.T) {
|
||||||
Image: "my-image",
|
Image: "my-image",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExpectedErrors: 0,
|
ExpectedErrors: []string{},
|
||||||
Description: "Valid node instance group failed to validate",
|
Description: "Valid node instance group failed to validate",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -449,13 +449,28 @@ func TestValidInstanceGroup(t *testing.T) {
|
||||||
Image: "my-image",
|
Image: "my-image",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExpectedErrors: 0,
|
ExpectedErrors: []string{},
|
||||||
Description: "Valid bastion instance group failed to validate",
|
Description: "Valid bastion instance group failed to validate",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
IG: &kops.InstanceGroup{
|
||||||
|
ObjectMeta: v1.ObjectMeta{
|
||||||
|
Name: "eu-central-1a",
|
||||||
|
},
|
||||||
|
Spec: kops.InstanceGroupSpec{
|
||||||
|
Role: kops.InstanceGroupRoleBastion,
|
||||||
|
Subnets: []string{"eu-central-1a"},
|
||||||
|
MaxSize: fi.Int32(1),
|
||||||
|
MinSize: fi.Int32(1),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ExpectedErrors: []string{"Forbidden::spec.image"},
|
||||||
|
Description: "Valid instance group must have image set",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, g := range grid {
|
for _, g := range grid {
|
||||||
errList := ValidateInstanceGroup(g.IG, nil, true)
|
errList := ValidateInstanceGroup(g.IG, nil, true)
|
||||||
testErrors(t, g.Description, errList, []string{})
|
testErrors(t, g.Description, errList, g.ExpectedErrors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,16 +70,6 @@ func TestPopulateInstanceGroup_Role_Required(t *testing.T) {
|
||||||
expectErrorFromPopulateInstanceGroup(t, cluster, g, channel, "spec.role")
|
expectErrorFromPopulateInstanceGroup(t, cluster, g, channel, "spec.role")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPopulateInstanceGroup_Image_Required(t *testing.T) {
|
|
||||||
_, cluster := buildMinimalCluster()
|
|
||||||
g := buildMinimalNodeInstanceGroup()
|
|
||||||
g.Spec.Image = ""
|
|
||||||
|
|
||||||
channel := &kopsapi.Channel{}
|
|
||||||
|
|
||||||
expectErrorFromPopulateInstanceGroup(t, cluster, g, channel, "unable to determine default image for InstanceGroup nodes")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPopulateInstanceGroup_AddTaintsCollision(t *testing.T) {
|
func TestPopulateInstanceGroup_AddTaintsCollision(t *testing.T) {
|
||||||
_, cluster := buildMinimalCluster()
|
_, cluster := buildMinimalCluster()
|
||||||
input := buildMinimalNodeInstanceGroup()
|
input := buildMinimalNodeInstanceGroup()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue