validation

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Copyright 2023 The Radius Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 The Radius Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 The Radius Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	AWSS3BucketResourceType         = "AWS.S3/Bucket"
	AWSMemoryDBClusterResourceType  = "AWS.MemoryDB/Cluster"
	AWSRDSDBInstanceResourceType    = "AWS.RDS/DBInstance"
	AWSLogsMetricFilterResourceType = "AWS.Logs/MetricFilter"
	AWSLogsLogGroupResourceType     = "AWS.Logs/LogGroup"
)
View Source
const (
	IntervalForDeploymentCreation = 3 * time.Second
	IntervalForPodShutdown        = 3 * time.Second
	IntervalForResourceCreation   = 3 * time.Second

	// We want to make sure to produce some output any time we're in a watch
	// otherwise it's hard to know if it got stuck.
	IntervalForWatchHeartbeat = 10 * time.Second
)
View Source
const (
	EnvironmentsResource = "applications.core/environments"
	ApplicationsResource = "applications.core/applications"
	HttpRoutesResource   = "applications.core/httpRoutes"
	GatewaysResource     = "applications.core/gateways"
	ContainersResource   = "applications.core/containers"
	VolumesResource      = "applications.core/volumes"
	SecretStoresResource = "applications.core/secretStores"

	RabbitMQQueuesResource    = "applications.messaging/rabbitMQQueues"
	DaprPubSubBrokersResource = "applications.dapr/pubSubBrokers"
	DaprSecretStoresResource  = "applications.dapr/secretStores"
	DaprStateStoresResource   = "applications.dapr/stateStores"
	MongoDatabasesResource    = "applications.datastores/mongoDatabases"
	RedisCachesResource       = "applications.datastores/redisCaches"
	SQLDatabasesResource      = "applications.datastores/sqlDatabases"
	ExtendersResource         = "applications.core/extenders"
)

Variables

This section is empty.

Functions

func DeleteAWSResource

func DeleteAWSResource(ctx context.Context, resource *AWSResource, client awsclient.AWSCloudControlClient) error

DeleteAWSResource checks if the given AWS resource exists, deletes it if it does and waits until the delete is complete,

returning an error if any of these steps fail.

func DeleteRPResource

func DeleteRPResource(ctx context.Context, t *testing.T, cli *radcli.CLI, client clients.ApplicationsManagementClient, resource RPResource) error

DeleteRPResource deletes an environment or application resource depending on the type of the resource passed in, and returns an error if one occurs.

func GetResourceIdentifier

func GetResourceIdentifier(ctx context.Context, resourceType string, name string) (string, error)

GetResourceIdentifier retrieves the identifier of a resource from the environment variables and the context.

func GetResourceTypeName

func GetResourceTypeName(ctx context.Context, resource *AWSResource) (string, error)

GetResourceTypeName retrieves the AWS resource type name from the resource identifier and context. It returns an error if the resource identifier or context is invalid.

func IsAWSResourceNotFound

func IsAWSResourceNotFound(ctx context.Context, resource *AWSResource, client awsclient.AWSCloudControlClient) (bool, error)

IsAWSResourceNotFound checks if the given AWS resource is not found.

func SaveContainerLogs

func SaveContainerLogs(ctx context.Context, k8s *kubernetes.Clientset, namespace string, logPrefix string) (watchk8s.Interface, error)

SaveContainerLogs watches for all pods in the given namespace and saves their container logs to disk.

func SaveLogsForApplication

func SaveLogsForApplication(ctx context.Context, k8s *kubernetes.Clientset, namespace string, logPrefix string, appName string) (watchk8s.Interface, error)

SaveLogsForApplication watches for all radius pods that are part of the given application in a given namespace and saves their container logs to disk.

func ValidateAWSResources

func ValidateAWSResources(ctx context.Context, t *testing.T, expected *AWSResourceSet, client awsclient.AWSCloudControlClient)

ValidateAWSResources checks that the expected AWS resources exist and have the expected properties.

func ValidateDeploymentsRunning

func ValidateDeploymentsRunning(ctx context.Context, t *testing.T, k8s *kubernetes.Clientset, expected K8sObjectSet)

ValidateDeploymentsRunning checks if the expected deployments have been created in the given namespace and logs any unrecognized deployments. If all expected deployments have been created, it returns, otherwise it retries until the context is done.

func ValidateNoPodsInApplication

func ValidateNoPodsInApplication(ctx context.Context, t *testing.T, k8s *kubernetes.Clientset, namespace string, application string)

ValidateNoPodsInApplication checks if there are any pods in the given namespace for the given application and waits for them to be deleted if found.

func ValidateObjectsRunning

func ValidateObjectsRunning(ctx context.Context, t *testing.T, k8s *kubernetes.Clientset, dynamic dynamic.Interface, expected K8sObjectSet)

ValidateObjectsRunning checks if the expected Kubernetes objects are running in the given namespace.

func ValidateRPResources

func ValidateRPResources(ctx context.Context, t *testing.T, expected *RPResourceSet, client clients.ApplicationsManagementClient)

ValidateRPResources checks if the expected resources exist in the response and validates the output resources if present.

Types

type AWSResource

type AWSResource struct {
	// Type of the resource (e.g. AWS.S3/Bucket)
	Type string
	// Name of the resource (e.g. my-bucket)
	Name string
	// Primary identifier of the resource (e.g. my-bucket)
	Identifier string
	// Properties of the resource
	Properties map[string]any
	// Determines whether or not the resource should be deleted after the test
	SkipDeletion bool
}

type AWSResourceSet

type AWSResourceSet struct {
	Resources []AWSResource
}

type K8sObject

type K8sObject struct {
	GroupVersionResource schema.GroupVersionResource
	Labels               map[string]string
	Kind                 string
	SkipLabelValidation  bool
	ResourceName         string
}

func NewDaprComponent

func NewDaprComponent(application string, name string) K8sObject

NewDaprComponent creates a K8sObject for a Dapr component with the Labels set to the application and name.

func NewK8sHTTPProxyForResource

func NewK8sHTTPProxyForResource(application string, name string) K8sObject

NewK8sHTTPProxyForResource creates a K8sObject for a HttpProxy with the Labels set to the application and name provided.

func NewK8sPodForResource

func NewK8sPodForResource(application string, name string) K8sObject

NewK8sPodForResource creates a new K8sObject with Kind set to "Pod" and the selector labels for the pod set to the given application and name.

func NewK8sSecretForResource

func NewK8sSecretForResource(application string, name string) K8sObject

NewK8sSecretForResource creates a K8sObject for a secret with the Labels set to the application and name.

func NewK8sSecretForResourceWithResourceName

func NewK8sSecretForResourceWithResourceName(resourceName string) K8sObject

NewK8sSecretForResourceWithResourceName creates a K8sObject for a secret with the Labels set to the application and name.

func NewK8sServiceForResource

func NewK8sServiceForResource(application string, name string) K8sObject

NewK8sServiceForResource creates a new K8sObject for a service with the Labels set to the application and name.

func (K8sObject) ValidateLabels

func (k K8sObject) ValidateLabels(validate bool) K8sObject

ValidateLabels creates a copy of the K8sObject and sets the SkipLabelValidation field based on the validate parameter.

type K8sObjectSet

type K8sObjectSet struct {
	Namespaces map[string][]K8sObject
}

type OutputResourceResponse

type OutputResourceResponse struct {
	// ID is the resource ID of the output resource.
	ID string
}

Output resource fields returned as a part of get/list response payload for Radius resources.

type PodMonitor

type PodMonitor struct {
	K8s *kubernetes.Clientset
	Pod corev1.Pod
}

func (PodMonitor) ValidateRunning

func (pm PodMonitor) ValidateRunning(ctx context.Context, t *testing.T)

PodMonitor ValidateRunning watches a pod for its status to become running and checks its readiness, retrying a few times if the readiness check fails. If the pod enters a failing state, an error is returned.

type RPResource

type RPResource struct {
	Type            string
	Name            string
	App             string
	OutputResources []OutputResourceResponse
}

type RPResourceSet

type RPResourceSet struct {
	Resources []RPResource
}

Jump to

Keyboard shortcuts

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