Documentation
¶
Index ¶
- func CreateHTTPClient(tlsSecret *corev1.Secret, host string) (*http.Client, error)
- func GenerateGateway(gatewayNSN types.NamespacedName, gatewayClass *gatewayv1.GatewayClass, ...) *gwtypes.Gateway
- func GenerateGatewayConfiguration(namespace string, opts ...gatewayConfigurationOption) *operatorv1beta1.GatewayConfiguration
- func GenerateHTTPRoute(namespace string, gatewayName, serviceName string, ...) *gatewayv1.HTTPRoute
- func GetAdmissionWebhookListenHost() string
- func GetDefaultDataPlaneBaseImage() string
- func GetDefaultDataPlaneImage() string
- func GetDefaultDataPlaneImagePreviousMinor() string
- func MustBuildRequest(t *testing.T, ctx context.Context, method, url, host string) *http.Request
- func MustCreateHTTPClient(t *testing.T, tlsSecret *corev1.Secret, host string) *http.Client
- func MustGenerateGatewayClass(t *testing.T, parametersRefs ...gatewayv1.ParametersReference) *gatewayv1.GatewayClass
- func ParseGoTestFlags(testRunner func(t *testing.T), testSuiteToRun []func(t *testing.T)) []func(t *testing.T)
- func RunTestSuite(t *testing.T, testSuite []func(*testing.T))
- func SetDefaultDataPlaneBaseImage(image string)
- func SetDefaultDataPlaneImage(image string)
- func SetupTestEnv(t *testing.T, ctx context.Context, env environments.Environment) (*corev1.Namespace, *clusters.Cleaner)
- func TLSSecretData(t *testing.T, ca Cert, c Cert) map[string][]byte
- func WithControlPlaneWebhookDisabled() func(*operatorv1beta1.GatewayConfiguration)
- type Cert
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateHTTPClient ¶ added in v1.2.2
CreateHTTPClient creates an HTTP client with the given TLS secret and host and returns an error if it fails
func GenerateGateway ¶ added in v1.2.2
func GenerateGateway(gatewayNSN types.NamespacedName, gatewayClass *gatewayv1.GatewayClass, opts ...func(gateway *gatewayv1.Gateway)) *gwtypes.Gateway
GenerateGateway generates a Gateway to be used in tests
func GenerateGatewayConfiguration ¶ added in v1.2.2
func GenerateGatewayConfiguration(namespace string, opts ...gatewayConfigurationOption) *operatorv1beta1.GatewayConfiguration
GenerateGatewayConfiguration generates a GatewayConfiguration to be used in tests
func GenerateHTTPRoute ¶ added in v1.2.2
func GenerateHTTPRoute(namespace string, gatewayName, serviceName string, opts ...func(*gatewayv1.HTTPRoute)) *gatewayv1.HTTPRoute
GenerateHTTPRoute generates an HTTPRoute to be used in tests
func GetAdmissionWebhookListenHost ¶
func GetAdmissionWebhookListenHost() string
GetAdmissionWebhookListenHost returns the host IP address depends on environment where the test is running.
func GetDefaultDataPlaneBaseImage ¶
func GetDefaultDataPlaneBaseImage() string
GetDefaultDataPlaneBaseImage returns the default data plane base image.
func GetDefaultDataPlaneImage ¶
func GetDefaultDataPlaneImage() string
GetDefaultDataPlaneImage returns the default data plane image.
func GetDefaultDataPlaneImagePreviousMinor ¶ added in v1.4.0
func GetDefaultDataPlaneImagePreviousMinor() string
GetDefaultDataPlaneImagePreviousMinor returns the default data plane image with the previous version.
func MustBuildRequest ¶ added in v1.2.2
MustBuildRequest creates an HTTP request with the given method, URL, and host
func MustCreateHTTPClient ¶ added in v1.2.2
MustCreateHTTPClient creates an HTTP client with the given TLS secret and host
func MustGenerateGatewayClass ¶ added in v1.2.2
func MustGenerateGatewayClass(t *testing.T, parametersRefs ...gatewayv1.ParametersReference) *gatewayv1.GatewayClass
MustGenerateGatewayClass generates the default GatewayClass to be used in tests
func ParseGoTestFlags ¶
func ParseGoTestFlags(testRunner func(t *testing.T), testSuiteToRun []func(t *testing.T)) []func(t *testing.T)
ParseGoTestFlags is a helper function that allows usage of -run and -skip flags in go test. It performs filtering on its own (in the best-effort manner). Actual implementation from the standard library is quite complex, e.g. see: https://github.com/golang/go/blob/f719d5cffdb8298eff7a5ef533fe95290e8c869c/src/testing/match.go#L55, thus we only use regex - that should be good enough in most cases. Function returns a test suite that should be run in testRunner function (defined test with RunTestSuite(...) called inside).
func RunTestSuite ¶
RunTestSuite runs all tests from the test suite. Import and call in a test function. Value for testSuite should be obtained from ParseGoTestFlags(...) (assign value to global variable and pass it as argument). Environment needs to be bootstrapped in TestMain or a test case itself. It is recommended for tests that need to be imported in other repositories.
func SetDefaultDataPlaneBaseImage ¶
func SetDefaultDataPlaneBaseImage(image string)
SetDefaultDataPlaneBaseImage sets the default data plane base image.
func SetDefaultDataPlaneImage ¶
func SetDefaultDataPlaneImage(image string)
SetDefaultDataPlaneImage sets the default data plane image.
func SetupTestEnv ¶
func SetupTestEnv(t *testing.T, ctx context.Context, env environments.Environment) (*corev1.Namespace, *clusters.Cleaner)
SetupTestEnv is a helper function for tests which conveniently creates a cluster cleaner (to clean up test resources automatically after the test finishes) and creates a new namespace for the test to use. The namespace is being automatically deleted during the test teardown using t.Cleanup().
func TLSSecretData ¶
TLSSecretData creates TLS secret data that can be then used as Secret.Data field when using certificates secrets in tests.
func WithControlPlaneWebhookDisabled ¶ added in v1.4.0
func WithControlPlaneWebhookDisabled() func(*operatorv1beta1.GatewayConfiguration)
WithControlPlaneWebhookDisabled disables the admission webhook for the control plane
Types ¶
type Cert ¶
type Cert struct { Cert *x509.Certificate CertPEM *bytes.Buffer Key *ecdsa.PrivateKey KeyPEM *bytes.Buffer }
Cert represents a TLS certificate that can be used for testing purposes.
func CreateCert ¶
func CreateCert(t *testing.T, name string, caCert *x509.Certificate, caPrivKey *ecdsa.PrivateKey) Cert
CreateCert creates a certificates using the provided CA and its private key.