test

package
v1.11.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FinalizerAddFlag          = flag("enable-finalizer-add")
	FinalizerRemoveFlag       = flag("enable-finalizer-remove")
	EnableV2FrontendNamerFlag = flag("enable-v2-frontend-namer")
)

Variables

View Source
var (
	FrontendConfig = &frontendconfigv1beta1.FrontendConfig{
		ObjectMeta: meta_v1.ObjectMeta{
			Name:      "config-test",
			Namespace: "test",
		},
	}

	IngressWithoutFrontendConfig = &v1beta1.Ingress{
		ObjectMeta: meta_v1.ObjectMeta{
			Name:      "ing-no-config",
			Namespace: "test",
		},
	}

	IngressWithFrontendConfig = &v1beta1.Ingress{
		ObjectMeta: meta_v1.ObjectMeta{
			Name:      "ing-with-config",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.FrontendConfigKey: "config-test",
			},
		},
	}

	IngressWithFrontendConfigOtherNamespace = &v1beta1.Ingress{
		ObjectMeta: meta_v1.ObjectMeta{
			Name:      "ing-with-config",
			Namespace: "other-namespace",
			Annotations: map[string]string{
				annotations.FrontendConfigKey: "config-test",
			},
		},
	}

	IngressWithOtherFrontendConfig = &v1beta1.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.

View Source
var (
	BackendPort      = intstr.IntOrString{Type: intstr.Int, IntVal: 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 intstr.IntOrString) *v1beta1.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) (*v1beta1.Ingress, error)

DecodeIngress deserializes an Ingress object.

func Float64ToPtr added in v1.9.1

func Float64ToPtr(val float64) *float64

Float64ToPtr returns float ptr for given float.

func GCEInstanceExists added in v1.9.0

func GCEInstanceExists(name string, g *gce.Cloud) (bool, error)

GCEInstanceExists returns if a given instance name exists.

func Int64ToPtr added in v1.10.0

func Int64ToPtr(val int64) *int64

Int64ToPtr returns int ptr for given int.

func NewBackendConfig

NewBackendConfig returns a BackendConfig with the given spec.

func NewIngress

func NewIngress(name types.NamespacedName, spec v1beta1.IngressSpec) *v1beta1.Ingress

NewIngress returns an Ingress with the given spec.

func NewL4ILBService added in v1.9.0

func NewL4ILBService(onlyLocal bool, port int) *api_v1.Service

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

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.

func (*FlagSaver) Reset added in v1.8.0

func (s *FlagSaver) Reset(key flag, flagPointer *bool)

Reset resets the value of given flag to a previously saved value. This does nothing if the flag value was not captured.

func (*FlagSaver) Save added in v1.8.0

func (s *FlagSaver) Save(key flag, flagPointer *bool)

Save captures the value of given flag.

type L4ILBErrorMetricInfo added in v1.11.2

type L4ILBErrorMetricInfo struct {
	ByGCEResource map[string]uint64
	ByErrorType   map[string]uint64
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL