core/v1: add unit tests that allow internalTrafficPolicy field when type is ExternalName

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
Andrew Sy Kim 2021-09-08 14:01:05 -04:00
parent 60b38ee180
commit 99cb5d2f21

View File

@ -12291,6 +12291,21 @@ func TestValidateServiceCreate(t *testing.T) {
featureGates: []featuregate.Feature{features.ServiceInternalTrafficPolicy},
numErrs: 0,
},
{
// Typically this should fail validation, but in v1.22 we have existing clusters
// that may have allowed internalTrafficPolicy when Type=ExternalName.
// This test case ensures we don't break compatibility for internalTrafficPolicy
// when Type=ExternalName
name: "internalTrafficPolicy field is set when type is ExternalName",
tweakSvc: func(s *core.Service) {
cluster := core.ServiceInternalTrafficPolicyCluster
s.Spec.InternalTrafficPolicy = &cluster
s.Spec.Type = core.ServiceTypeExternalName
s.Spec.ExternalName = "foo.bar.com"
},
featureGates: []featuregate.Feature{features.ServiceInternalTrafficPolicy},
numErrs: 0,
},
{
name: "invalid internalTraffic field",
tweakSvc: func(s *core.Service) {