Svc REST: Add new model of feature tests

This scaffolding allows us to assert more on each test case, and more
consistently.

Set input fields from output fields IFF they are expected AND not set on
input.  This allows us to verify the "after" state (expected) whether
the test case specified the value or not, and still pass the generic
cmp.Equal.

Use this in a few tests to prove its worth, more to do.

Some of the existing tests that are focused on create and delete can
probably be replaced by these.

This could be used in other test cases that are open-coding a lot of the
same stuff.  Later commits.
This commit is contained in:
Tim Hockin
2021-07-11 22:41:17 -07:00
parent 446a2c730d
commit 5363f1646f
3 changed files with 989 additions and 36 deletions

View File

@@ -205,3 +205,28 @@ func SetHealthCheckNodePort(value int32) Tweak {
svc.Spec.HealthCheckNodePort = value
}
}
// SetSessionAffinity sets the SessionAffinity field.
func SetSessionAffinity(affinity api.ServiceAffinity) Tweak {
return func(svc *api.Service) {
svc.Spec.SessionAffinity = affinity
switch affinity {
case api.ServiceAffinityNone:
svc.Spec.SessionAffinityConfig = nil
case api.ServiceAffinityClientIP:
timeout := int32(10)
svc.Spec.SessionAffinityConfig = &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
TimeoutSeconds: &timeout,
},
}
}
}
}
// SetExternalName sets the ExternalName field.
func SetExternalName(val string) Tweak {
return func(svc *api.Service) {
svc.Spec.ExternalName = val
}
}