test

package
v1.10.14 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 20 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 GetPrometheusMetric added in v1.10.12

func GetPrometheusMetric(name string) (*dto.MetricFamily, error)

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.

Jump to

Keyboard shortcuts

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