mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 01:23:48 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user