Documentation ¶
Index ¶
- Constants
- Variables
- func Backend(name string, port networkingv1.ServiceBackendPort) *networkingv1.IngressBackend
- func CheckEvent(recorder *record.FakeRecorder, expected string, shouldMatch bool) error
- func CreateAndInsertNodes(gce *gce.Cloud, nodeNames []string, zoneName string) ([]*api_v1.Node, error)
- func DecodeIngress(data []byte) (*networkingv1.Ingress, error)
- func Float64ToPtr(val float64) *float64
- func GCEInstanceExists(name string, g *gce.Cloud) (bool, error)
- func Int64ToPtr(val int64) *int64
- func NewBackendConfig(name types.NamespacedName, spec backendconfig.BackendConfigSpec) *backendconfig.BackendConfig
- func NewIngress(name types.NamespacedName, spec networkingv1.IngressSpec) *networkingv1.Ingress
- func NewL4ILBService(onlyLocal bool, port int) *api_v1.Service
- func NewService(name types.NamespacedName, spec api_v1.ServiceSpec) *api_v1.Service
- type FakeRecorderSource
- type FlagSaver
- type L4ILBErrorMetricInfo
- type L4ILBLatencyMetricInfo
Constants ¶
const ( FinalizerAddFlag = flag("enable-finalizer-add") FinalizerRemoveFlag = flag("enable-finalizer-remove") EnableV2FrontendNamerFlag = flag("enable-v2-frontend-namer") )
Variables ¶
var ( FrontendConfig = &frontendconfigv1beta1.FrontendConfig{ ObjectMeta: meta_v1.ObjectMeta{ Name: "config-test", Namespace: "test", }, } IngressWithoutFrontendConfig = &v1.Ingress{ ObjectMeta: meta_v1.ObjectMeta{ Name: "ing-no-config", Namespace: "test", }, } IngressWithFrontendConfig = &v1.Ingress{ ObjectMeta: meta_v1.ObjectMeta{ Name: "ing-with-config", Namespace: "test", Annotations: map[string]string{ annotations.FrontendConfigKey: "config-test", }, }, } IngressWithFrontendConfigOtherNamespace = &v1.Ingress{ ObjectMeta: meta_v1.ObjectMeta{ Name: "ing-with-config", Namespace: "other-namespace", Annotations: map[string]string{ annotations.FrontendConfigKey: "config-test", }, }, } IngressWithOtherFrontendConfig = &v1.Ingress{ ObjectMeta: meta_v1.ObjectMeta{ Name: "ing-with-config", Namespace: "test", Annotations: map[string]string{ annotations.FrontendConfigKey: "other-config", }, }, } )
The below vars are used for sharing unit testing types with multiple packages.
var ( BackendPort = networkingv1.ServiceBackendPort{Number: 80} DefaultBeSvcPort = utils.ServicePort{ ID: utils.ServicePortID{Service: types.NamespacedName{Namespace: "system", Name: "default"}, Port: BackendPort}, NodePort: 30000, Protocol: annotations.ProtocolHTTP, } )
Functions ¶
func Backend ¶
func Backend(name string, port networkingv1.ServiceBackendPort) *networkingv1.IngressBackend
Backend returns an IngressBackend with the given service name/port.
func CheckEvent ¶ added in v1.9.0
func CheckEvent(recorder *record.FakeRecorder, expected string, shouldMatch bool) error
CheckEvent watches for events in the given FakeRecorder and checks if it matches the given string. It will be used in the l4 firewall XPN tests once TestEnsureLoadBalancerDeletedSucceedsOnXPN and others are uncommented.
func CreateAndInsertNodes ¶ added in v1.9.0
func CreateAndInsertNodes(gce *gce.Cloud, nodeNames []string, zoneName string) ([]*api_v1.Node, error)
CreateAndInsertNodes adds the given nodeNames in the given zone as GCE instances, so they can be looked up in tests.
func DecodeIngress ¶
func DecodeIngress(data []byte) (*networkingv1.Ingress, error)
DecodeIngress deserializes an Ingress object.
func Float64ToPtr ¶ added in v1.9.1
Float64ToPtr returns float ptr for given float.
func GCEInstanceExists ¶ added in v1.9.0
GCEInstanceExists returns if a given instance name exists.
func Int64ToPtr ¶ added in v1.10.0
Int64ToPtr returns int ptr for given int.
func NewBackendConfig ¶
func NewBackendConfig(name types.NamespacedName, spec backendconfig.BackendConfigSpec) *backendconfig.BackendConfig
NewBackendConfig returns a BackendConfig with the given spec.
func NewIngress ¶
func NewIngress(name types.NamespacedName, spec networkingv1.IngressSpec) *networkingv1.Ingress
NewIngress returns an Ingress with the given spec.
func NewL4ILBService ¶ added in v1.9.0
NewL4ILBService creates a Service of type LoadBalancer with the Internal annotation.
func NewService ¶
func NewService(name types.NamespacedName, spec api_v1.ServiceSpec) *api_v1.Service
NewService returns a Service with the given spec.
Types ¶
type FakeRecorderSource ¶ added in v1.10.0
type FakeRecorderSource struct{}
func (*FakeRecorderSource) Recorder ¶ added in v1.10.0
func (_ *FakeRecorderSource) Recorder(ns string) record.EventRecorder
type FlagSaver ¶ added in v1.8.0
type FlagSaver struct {
// contains filtered or unexported fields
}
FlagSaver is an utility type to capture the value of a flag and reset back to the saved value.
func NewFlagSaver ¶ added in v1.8.0
func NewFlagSaver() FlagSaver
NewFlagSaver returns a flag saver by initializing the map.
type L4ILBErrorMetricInfo ¶ added in v1.11.2
L4ILBErrorMetricInfo holds the state of the l4_ilb_sync_error_count metric.
func GetL4ILBErrorMetric ¶ added in v1.11.2
func GetL4ILBErrorMetric(t *testing.T) *L4ILBErrorMetricInfo
GetL4ILBErrorMetric gets the current state of the l4_ilb_sync_error_count metric.
func (*L4ILBErrorMetricInfo) ValidateDiff ¶ added in v1.11.2
func (old *L4ILBErrorMetricInfo) ValidateDiff(new, expect *L4ILBErrorMetricInfo, t *testing.T)
ValidateDiff ensures that the diff between the old and the new metric is as expected. The test uses diff rather than absolute values since the metrics are cumulative of all test cases.
type L4ILBLatencyMetricInfo ¶ added in v1.11.2
type L4ILBLatencyMetricInfo struct { CreateCount uint64 DeleteCount uint64 UpdateCount uint64 UpperBoundSeconds float64 // contains filtered or unexported fields }
L4LatencyMetricInfo holds the state of the l4_ilb_sync_duration_seconds metric.
func GetL4LatencyMetric ¶ added in v1.11.2
func GetL4LatencyMetric(t *testing.T) *L4ILBLatencyMetricInfo
GetL4LatencyMetric gets the current state of the l4_ilb_sync_duration_seconds metric.
func (*L4ILBLatencyMetricInfo) ValidateDiff ¶ added in v1.11.2
func (old *L4ILBLatencyMetricInfo) ValidateDiff(new, expect *L4ILBLatencyMetricInfo, t *testing.T)
ValidateDiff ensures that the diff between the old and the new metric is as expected. The test uses diff rather than absolute values since the metrics are cumulative of all test cases.