Documentation
¶
Index ¶
- Constants
- func K8sSecretResource(namespace, name, secretType string, kv ...any) unstructured.Unstructured
- func NewPreviewEnvPreSetup(testName string, workspaceScope string, kubernetesNamespace string) (preSetup func(ctx context.Context, t *testing.T, test RPTest), envID string)
- type RPTest
- type RPTestOptions
- type RequiredFeature
- type RequiredFeatureValidatorType
- type TestOptions
- type TestStep
Constants ¶
const ( ContainerLogPathEnvVar = "RADIUS_CONTAINER_LOG_PATH" APIVersion = "2023-10-01-preview" TestNamespace = "kind-radius" AWSDeletionRetryLimit = 5 )
Variables ¶
This section is empty.
Functions ¶
func K8sSecretResource ¶
func K8sSecretResource(namespace, name, secretType string, kv ...any) unstructured.Unstructured
K8sSecretResource creates the secret resource from the given namespace, name, secretType and key-value pairs, for Initial Resource in NewRPTest().
func NewPreviewEnvPreSetup ¶ added in v0.59.0
func NewPreviewEnvPreSetup(testName string, workspaceScope string, kubernetesNamespace string) (preSetup func(ctx context.Context, t *testing.T, test RPTest), envID string)
NewPreviewEnvPreSetup creates a PreSetup function that provisions a preview environment and configures its Kubernetes namespace for recipe-driven resource deployment. It returns the PreSetup function and the environment resource ID.
The preview environment is created via `rad env create <name> --preview --kubernetes-namespace <ns>`, which automatically registers a default recipe pack (including container recipes) and sets the Kubernetes namespace where recipes will deploy resources.
The environment name is derived from the test name with "-env" suffix to avoid collisions. The kubernetesNamespace parameter specifies where recipes should deploy K8s resources — this typically matches the test's expected pod namespace (often the test name).
t.Cleanup is registered immediately after env creation to prevent resource leaks.
Types ¶
type RPTest ¶
type RPTest struct {
Options RPTestOptions
Name string
Description string
InitialResources []unstructured.Unstructured
Steps []TestStep
PostDeleteVerify func(ctx context.Context, t *testing.T, ct RPTest)
// PreSetup is called after CreateInitialResources but before test steps.
// Use this for setup that requires the CLI, such as creating preview environments
// with recipe packs for tests using Radius.Core/Radius.Compute resource types.
PreSetup func(ctx context.Context, t *testing.T, test RPTest)
// RequiredFeatures specifies the optional features that are required
// for this test to run.
RequiredFeatures []RequiredFeature
// FastCleanup when true, initiates resource deletion but doesn't wait for completion.
// Useful when unique resource names are used and cluster cleanup handles orphaned resources.
// This dramatically reduces test execution time by avoiding deletion timeouts.
FastCleanup bool
}
func NewRPTest ¶
func NewRPTest(t *testing.T, name string, steps []TestStep, initialResources ...unstructured.Unstructured) RPTest
NewRPTest creates a new RPTest instance with the given name, steps and initial resources.
func (RPTest) CheckRequiredFeatures ¶
CheckRequiredFeatures checks the test environment for the features that the test requires and skips the test if not, otherwise returns an error if there is an issue.
func (RPTest) CleanUpExtensionResources ¶
func (ct RPTest) CleanUpExtensionResources(resources []unstructured.Unstructured)
Method CleanUpExtensionResources deletes all resources in the given slice of unstructured objects.
func (RPTest) CreateInitialResources ¶
CreateInitialResources creates a namespace and creates initial resources from the InitialResources field of the RPTest struct. It returns an error if either of these operations fail.
type RPTestOptions ¶
type RPTestOptions struct {
test.TestOptions
CustomAction *clientv2.CustomActionClient
ManagementClient clients.ApplicationsManagementClient
AWSClient aws.AWSCloudControlClient
// Connection gets access to the Radius connection which can be used to create API clients.
Connection sdk.Connection
// Workspace gets access to the Radius workspace which can be used to create API clients.
Workspace *workspaces.Workspace
}
func NewRPTestOptions ¶
func NewRPTestOptions(t *testing.T) RPTestOptions
NewRPTestOptions sets up the test environment by loading configs, creating a test context, creating an ApplicationsManagementClient, creating an AWSCloudControlClient, and returning an RPTestOptions struct.
type RequiredFeature ¶
type RequiredFeature string
RequiredFeature is used to specify an optional feature that is required for the test to run.
const ( // FeatureDapr should used with required features to indicate a test dependency // on Dapr. FeatureDapr RequiredFeature = "Dapr" // FeatureCSIDriver should be used with required features to indicate a test dependency // on the CSI driver. FeatureCSIDriver RequiredFeature = "CSIDriver" // FeatureAWS should be used with required features to indicate a test dependency on AWS cloud provider. FeatureAWS RequiredFeature = "AWS" // FeatureAzure should be used with required features to indicate a test dependency on Azure cloud provider. FeatureAzure RequiredFeature = "Azure" )
type RequiredFeatureValidatorType ¶
type RequiredFeatureValidatorType string
RequiredFeatureValidatorType is used to specify the type of validator to use
const ( // Use CRD to check for required features RequiredFeatureValidatorTypeCRD RequiredFeatureValidatorType = "ValidatorCRD" // Use cloud provider API to check for required features RequiredFeatureValidatorTypeCloud RequiredFeatureValidatorType = "ValidatorCloud" )
type TestOptions ¶
type TestOptions struct {
test.TestOptions
DiscoveryClient discovery.DiscoveryInterface
}
func NewTestOptions ¶
func NewTestOptions(t *testing.T) TestOptions
NewTestOptions creates a new TestOptions object with the given testing.T object.
type TestStep ¶
type TestStep struct {
Executor step.Executor
RPResources *validation.RPResourceSet
K8sOutputResources []unstructured.Unstructured
K8sObjects *validation.K8sObjectSet
AWSResources *validation.AWSResourceSet
PostStepVerify func(ctx context.Context, t *testing.T, ct RPTest)
SkipKubernetesOutputResourceValidation bool
SkipObjectValidation bool
SkipResourceDeletion bool
}