testutil

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RadiusSystemNamespace = "radius-system"
)

Variables

This section is empty.

Functions

func ExposeIngress added in v0.32.0

func ExposeIngress(t *testing.T, ctx context.Context, client *k8s.Clientset, config *rest.Config, remotePort int, stopChan chan struct{}, portChan chan int, errorChan chan error)

ExposeIngress creates a port-forward session and sends the (assigned) local port to portChan. It exposes a pod in the RadiusSystemNamespace with the selector "app.kubernetes.io/component=envoy" on the given remotePort and returns the port number and an error if any.

func ExposePod added in v0.32.0

func ExposePod(t *testing.T, ctx context.Context, client *k8s.Clientset, config *rest.Config, namespace string, selector string, remotePort int, stopChan chan struct{}, portChan chan int, errorChan chan error)

ExposePod creates a port-forward session. It finds a pod matching the given selector, creates an API Server URL, sets up a port-forwarder, and sends the assigned port to the portChan channel.

func GenerateS3BucketName added in v0.32.0

func GenerateS3BucketName() string

GenerateS3BucketName generates a unique S3 bucket name.

func GetAWSAccountId added in v0.32.0

func GetAWSAccountId() string

GetAWSAccountId retrieves the AWS Account ID from the environment and returns it as a string.

func GetAWSRegion added in v0.32.0

func GetAWSRegion() string

GetAWSRegion returns the AWS region from the environment variable "AWS_REGION".

func GetBicepRecipeRegistry added in v0.32.0

func GetBicepRecipeRegistry() string

GetBicepRecipeRegistry returns the default recipe registry if one is not set in the environment.

func GetBicepRecipeVersion added in v0.32.0

func GetBicepRecipeVersion() string

GetBicepRecipeVersion returns the version of the Bicep recipe to be used, either from the environment variable or the default value "latest".

func GetCreationTimestamp added in v0.32.0

func GetCreationTimestamp() string

GetCreationTimestamp returns the elapsed time since the Unix epoch in seconds.

func GetDockerRegistry added in v0.37.0

func GetDockerRegistry() string

GetDockerRegistry returns the Docker registry from the environment variable DOCKER_REGISTRY or the default value "ghcr.io/radius-project".

func GetGitPAT added in v0.33.0

func GetGitPAT() string

GetGitPAT gets the personal access token for the git account private modules are stored.

func GetHTTPProxyList added in v0.32.0

func GetHTTPProxyList(ctx context.Context, client runtime_client.Client, namespace, application string) (*contourv1.HTTPProxyList, error)

GetHTTPProxyList returns a list of HTTPProxies for the specified application. It returns an error if the list cannot be retrieved.

func GetMagpieImage added in v0.32.0

func GetMagpieImage() string

GetMagpieImage creates a string with the default Docker registry and image tag for MagpieGo.

func GetMagpieTag added in v0.32.0

func GetMagpieTag() string

GetMagpieTag sets a default image tag and returns a string with the format "magpietag=<imageTag>"

func GetOIDCIssuer added in v0.32.0

func GetOIDCIssuer() string

GetOIDCIssuer gets the OIDC Issuer URI from the environment variable FUNCTEST_OIDC_ISSUER or a default value if the environment variable is empty.

func GetTerraformPrivateModuleSource added in v0.33.0

func GetTerraformPrivateModuleSource() string

GetTerraformPrivateModuleSource gets the terraform private git module source to use in tests from the environment variable TF_RECIPE_PRIVATE_GIT_SOURCE.

func GetTerraformRecipeModuleServerURL added in v0.32.0

func GetTerraformRecipeModuleServerURL() string

GetTerraformRecipeModuleServerURL gets the terraform module server to use in tests from the environment variable TF_RECIPE_MODULE_SERVER_URL. If the environment variable is not set, it uses the default value for local testing (http://localhost:8999).

The data is returned in bicep parameter format using the parameter name 'moduleServer'. The return value of this function can be used as a parameter to 'rad deploy'.

Example:

moduleServer=http://localhost:8999.

func IsMapNonIntersecting added in v0.32.0

func IsMapNonIntersecting(notExpectedMap map[string]string, actualMap map[string]string) bool

IsMapNonIntersecting returns true if the notExpectedMap and actualMap do not have any keys in common

func IsMapSubSet added in v0.32.0

func IsMapSubSet(expectedMap map[string]string, actualMap map[string]string) bool

IsMapSubSet returns true if the expectedMap is a subset of the actualMap

func MustGetTestData

func MustGetTestData[T any](file string) *T

MustGetTestData reads testdata and unmarshals it to the given type, panicking if an error occurs.

func MustUnmarshalFromFile added in v0.30.0

func MustUnmarshalFromFile(file string, out any)

MustUnmarshalFromFile reads testdata and unmarshals it to the given type, panicking if an error occurs.

func ReadFixture

func ReadFixture(filename string) []byte

ReadFixture reads testdata fixtures, panicking if an error occurs.

The prefix `./testdata/` is automatically added to the filename. Tests can 'escape' the testdata directory by prefixing the filename with `../`.

Example:

ReadFixture("foo.json") -> ./testdata/foo.json

func SetDefault added in v0.32.0

func SetDefault() (string, string)

SetDefault sets the default Docker registry and image tag if they are not already set in the environment.

func WriteBicepParameterFile added in v0.32.0

func WriteBicepParameterFile(t *testing.T, data map[string]any) string

WriteBicepParameterFile writes a Bicep parameter file to a temporary file and returns the path to the file. The temporary file will be removed when the test finishes.

Types

type ProxyMetadata added in v0.32.0

type ProxyMetadata struct {
	Hostname string
	Status   string
}

func GetHTTPProxyMetadata added in v0.32.0

func GetHTTPProxyMetadata(ctx context.Context, client runtime_client.Client, namespace, application string) (*ProxyMetadata, error)

GetHTTPProxyMetadata finds the fqdn set on the root HTTPProxy of the specified application and the current status (e.g. "Valid", "Invalid"). It returns an error if the root proxy is not found.

type TestWriter added in v0.32.0

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

func (TestWriter) Write added in v0.32.0

func (tw TestWriter) Write(p []byte) (n int, err error)

TestWriter.Write writes the given byte slice to the test log.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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