helpers

package
v1.14.0-beta8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 54 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ExactPath = iota
	PrefixPath
	RegexPath
)
View Source
const (
	// InvalidTestReqsEnvVar is used to define the behavior for running tests locally when the provided requirements
	// are not met. See ValidateRequirementsAndNotifyGinkgo for a detail of available behaviors
	InvalidTestReqsEnvVar = "INVALID_TEST_REQS"
)

Variables

This section is empty.

Functions

func BuilderFromVirtualService added in v1.12.21

func BuilderFromVirtualService(vs *v1.VirtualService) *virtualServiceBuilder

func Certificate added in v0.10.1

func Certificate() string

func DeferredGoroutineLeakDetector added in v1.13.0

func DeferredGoroutineLeakDetector(t *testing.T) func()

DeferredGoroutineLeakDetector returns a function that can be used in tests to identify goroutine leaks Example usage:

	leakDetector := DeferredGoroutineLeakDetector(t)
 defer leakDetector()
 ...

NOTE TO DEVS: We would like to extend the usage of this across more test suites: https://github.com/solo-io/gloo/issues/7147

func EventuallyObjectDeleted added in v1.8.3

func EventuallyObjectDeleted(getter ObjectGetter, intervals ...interface{})

func EventuallyObjectDeletedWithOffset added in v1.8.3

func EventuallyObjectDeletedWithOffset(offset int, getter ObjectGetter, intervals ...interface{})

func EventuallyResourceAccepted added in v1.8.3

func EventuallyResourceAccepted(getter InputResourceGetter, intervals ...interface{})

func EventuallyResourceDeleted added in v1.8.3

func EventuallyResourceDeleted(getter InputResourceGetter, intervals ...interface{})

func EventuallyResourceDeletedWithOffset added in v1.8.3

func EventuallyResourceDeletedWithOffset(offset int, getter InputResourceGetter, intervals ...interface{})

func EventuallyResourceRejected added in v1.9.0

func EventuallyResourceRejected(getter InputResourceGetter, intervals ...interface{})

func EventuallyResourceStatusMatchesState added in v1.8.3

func EventuallyResourceStatusMatchesState(offset int, getter InputResourceGetter, desiredStatusState core.Status_State, intervals ...interface{})

func EventuallyResourceWarning added in v1.8.3

func EventuallyResourceWarning(getter InputResourceGetter, intervals ...interface{})

func GetCallerDirectory added in v0.18.17

func GetCallerDirectory(skip ...int) (string, error)

returns absolute path to the currently executing directory

func GetCerts added in v0.10.1

func GetCerts(params Params) (string, string)

func GetKubeSecret added in v0.10.1

func GetKubeSecret(name, namespace string) *kubev1.Secret

func GlooDir added in v0.10.1

func GlooDir() string

func GlooHelmChartDir added in v0.10.1

func GlooHelmChartDir() string

func GlooInstallDir added in v0.10.1

func GlooInstallDir() string

func GlooTestContainersDir added in v0.10.1

func GlooTestContainersDir() string

func KubeDump added in v0.18.9

func KubeDump(namespaces ...string) (string, error)

dump all data from the kube cluster

func KubeDumpOnFail added in v0.18.9

func KubeDumpOnFail(out io.Writer, namespaces ...string) func()

func MakeGatewayRoute added in v0.18.32

func MakeGatewayRoute(pathType, length int) *gatwayv1.Route

func MakeMatcher added in v1.0.0

func MakeMatcher(pathType, length int) *matchers.Matcher

func MakeMultiMatcherRoute added in v1.0.0

func MakeMultiMatcherRoute(pathType1, length1, pathType2, length2 int) *v1.Route

func MakeRoute added in v0.10.1

func MakeRoute(pathType, length int) *v1.Route

func MtlsCertificate added in v1.14.0

func MtlsCertificate() string

func MtlsPrivateKey added in v1.14.0

func MtlsPrivateKey() string

func Must

func Must(err error)

func MustReadFile added in v0.18.17

func MustReadFile(name string) []byte

returns absolute path to the currently executing directory

func NewSnapshotWriter added in v1.12.21

func NewSnapshotWriter(clientSet ResourceClientSet, retryOptions []retry.Option) *snapshotWriterImpl

func NewVirtualServiceBuilder added in v1.9.25

func NewVirtualServiceBuilder() *virtualServiceBuilder

func PatchResource added in v1.12.32

func PatchResource(ctx context.Context, resourceRef *core.ResourceRef, mutator func(resource resources.Resource) resources.Resource, client clients.ResourceClient) error

PatchResource mutates an existing persisted resource, retrying if a resourceVersionError is encountered The mutator method must return the full object that will be persisted, any side effects from the mutator will be ignored

func PatchResourceWithOffset added in v1.12.32

func PatchResourceWithOffset(offset int, ctx context.Context, resourceRef *core.ResourceRef, mutator func(resource resources.Resource) resources.Resource, client clients.ResourceClient) error

PatchResourceWithOffset mutates an existing persisted resource, retrying if a resourceVersionError is encountered The mutator method must return the full object that will be persisted, any side effects from the mutator will be ignored

func PrintDockerState added in v1.4.0

func PrintDockerState()

func PrintGlooDebugLogs added in v1.0.0

func PrintGlooDebugLogs()

func PrintKubeState added in v1.4.0

func PrintKubeState()

func PrintProcessState added in v1.4.0

func PrintProcessState()

func PrivateKey added in v0.10.1

func PrivateKey() string

func ReadMetricByLabel added in v1.9.25

func ReadMetricByLabel(metricName string, labelKey string, labelValue string) (int, error)

ReadMetricByLabel looks up the specified metricName and returns the latest data recorded for the time series with the specified label key/value pair.

If the metric has not yet been registered, this function will fail. If the metric has been registered, but there is not yet any time series data recorded with the label key/value provided, then an error is returned. The error response allows tests to distinguish "the metric was never recorded" from "a value of 0 was recorded"

func RegisterGlooDebugLogPrintHandler added in v0.18.12

func RegisterGlooDebugLogPrintHandler()

func RegisterGlooDebugLogPrintHandlerAndClearLogs added in v0.18.12

func RegisterGlooDebugLogPrintHandlerAndClearLogs()

func ValidateRequirements

func ValidateRequirements(requirements []Requirement) error

ValidateRequirements returns an error if any of the Requirements are not met

func ValidateRequirementsAndNotifyGinkgo

func ValidateRequirementsAndNotifyGinkgo(requirements ...Requirement)

ValidateRequirementsAndNotifyGinkgo validates that the provided Requirements are met, and if they are not, uses the InvalidTestReqsEnvVar to determine how to proceed: Options are:

  • `run`: Ignore any invalid requirements and execute the tests
  • `skip`: Notify Ginkgo that the current spec was skipped
  • `fail`: Notify Ginkgo that the current spec has failed [DEFAULT]

func WriteDefaultGateways added in v1.2.13

func WriteDefaultGateways(writeNamespace string, gatewayClient v1.GatewayClient) error

Types

type InputResourceGetter added in v1.8.3

type InputResourceGetter func() (resources.InputResource, error)

type InputResourceListGetter added in v1.8.3

type InputResourceListGetter func() (resources.InputResourceList, error)

type ObjectGetter added in v1.8.3

type ObjectGetter func() (client.Object, error)

type Params added in v0.10.1

type Params struct {
	Hosts            string             // Comma-separated hostnames and IPs to generate a certificate for
	ValidFrom        *time.Time         // Creation date
	ValidFor         *time.Duration     // Duration that certificate is valid for
	IsCA             bool               // whether this cert should be its own Certificate Authority
	RsaBits          int                // Size of RSA key to generate. Ignored if EcdsaCurve is set
	EcdsaCurve       string             // ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521
	AdditionalUsages []x509.ExtKeyUsage // Usages to define in addition to default x509.ExtKeyUsageServerAuth
}

type RequiredConfiguration

type RequiredConfiguration struct {
	// contains filtered or unexported fields
}

func (RequiredConfiguration) Validate

func (r RequiredConfiguration) Validate() error

Validate returns an error is the RequiredConfiguration is not met

type Requirement

type Requirement func(configuration *RequiredConfiguration)

Requirement represents a required property for tests.

func AwsCredentials

func AwsCredentials() Requirement

AwsCredentials returns a Requirement that expects tests to require Aws credentials

func Consul

func Consul() Requirement

Consul returns a Requirement that expects tests to require a Consul instance

func DefinedEnv

func DefinedEnv(env string) Requirement

DefinedEnv returns a Requirement that expects tests to have the injected environment variable defined

func Kubernetes

func Kubernetes(reason string) Requirement

Kubernetes returns a Requirement that expects tests to require Kubernetes configuration

func LinuxOnly

func LinuxOnly(reason string) Requirement

LinuxOnly returns a Requirement that expects tests to only run on Linux

func TruthyEnv

func TruthyEnv(env string) Requirement

TruthyEnv returns a Requirement that expects tests to have the injected environment variable set to a truthy value

func Vault

func Vault() Requirement

Vault returns a Requirement that expects tests to require a Vault instance

type ResourceClientSet added in v1.12.21

type ResourceClientSet interface {
	GatewayClient() gatewayv1.GatewayClient
	HttpGatewayClient() gatewayv1.MatchableHttpGatewayClient
	VirtualServiceClient() gatewayv1.VirtualServiceClient
	RouteTableClient() gatewayv1.RouteTableClient
	VirtualHostOptionClient() gatewayv1.VirtualHostOptionClient
	RouteOptionClient() gatewayv1.RouteOptionClient
	SettingsClient() gloov1.SettingsClient
	UpstreamGroupClient() gloov1.UpstreamGroupClient
	UpstreamClient() gloov1.UpstreamClient
	ProxyClient() gloov1.ProxyClient
	AuthConfigClient() extauthv1.AuthConfigClient
	RateLimitConfigClient() externalrl.RateLimitConfigClient
	SecretClient() gloov1.SecretClient
	ArtifactClient() gloov1.ArtifactClient
}

type SnapshotWriter added in v1.12.21

type SnapshotWriter interface {
	WriteSnapshot(snapshot *gloosnapshot.ApiSnapshot, writeOptions clients.WriteOpts) error
	DeleteSnapshot(snapshot *gloosnapshot.ApiSnapshot, deleteOptions clients.DeleteOpts) error
}

Jump to

Keyboard shortcuts

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