test

package
v0.0.0-...-8f85093 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct {
	Ctx               context.Context
	ContextCancelFunc context.CancelFunc

	EventBroadcaster  *event.EventBroadcaster
	StatusDispatcher  dispatcher.Dispatcher
	Store             *MemoryStore
	GRPCSourceClient  *generic.CloudEventSourceClient[*api.Resource]
	DBFactory         db.SessionFactory
	AppConfig         *config.ApplicationConfig
	APIServer         server.Server
	MetricsServer     server.Server
	HealthCheckServer *server.HealthCheckServer
	EventServer       server.EventServer
	ControllerManager *server.ControllersServer
	WorkAgentHolder   *work.ClientHolder
	WorkAgentInformer workv1informers.ManifestWorkInformer
	TimeFunc          TimeFunc
	JWTPrivateKey     *rsa.PrivateKey
	JWTCA             *rsa.PublicKey
	T                 *testing.T
	// contains filtered or unexported fields
}

func NewHelper

func NewHelper(t *testing.T) *Helper

func RegisterIntegration

func RegisterIntegration(t *testing.T) (*Helper, *openapi.APIClient)

Register a test This should be run before every integration test

func (*Helper) CleanDB

func (helper *Helper) CleanDB() error

func (*Helper) ClearAllTables

func (helper *Helper) ClearAllTables()

func (*Helper) Count

func (helper *Helper) Count(table string) int64

func (*Helper) CreateConsumer

func (helper *Helper) CreateConsumer(name string) *api.Consumer

func (*Helper) CreateConsumerList

func (helper *Helper) CreateConsumerList(count int) (consumers []*api.Consumer)

func (*Helper) CreateConsumerWithLabels

func (helper *Helper) CreateConsumerWithLabels(name string, labels map[string]string) *api.Consumer

func (*Helper) CreateGRPCAuthRule

func (helper *Helper) CreateGRPCAuthRule(ctx context.Context, kubeClient kubernetes.Interface, ruleName, resourceType, resourceID string, actions []string) error

func (*Helper) CreateGRPCConn

func (helper *Helper) CreateGRPCConn(serverAddr, serverCAFile, tokenFile string) (*grpc.ClientConn, error)

func (*Helper) CreateJWTString

func (helper *Helper) CreateJWTString(account *amv1.Account) string

func (*Helper) CreateJWTToken

func (helper *Helper) CreateJWTToken(account *amv1.Account) *jwt.Token

func (*Helper) CreateResource

func (helper *Helper) CreateResource(consumerName, deployName string, replicas int) *api.Resource

CreateResource creates a resource with the given consumer name, deploy name, and replicas. It generates a deployment for nginx using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts.

func (*Helper) CreateResourceBundle

func (helper *Helper) CreateResourceBundle(consumerName, deployName string, replicas int) *api.Resource

CreateResourceBundle creates a resource bundle with the given consumer name, deploy name and replicas. It generates a deployment for nginx using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts.

func (*Helper) CreateResourceBundleList

func (helper *Helper) CreateResourceBundleList(consumerName string, count int) (resourceBundles []*api.Resource)

CreateResourceBundleList generates a list of resource bundles with the specified consumer name and count. Each resource gets a randomly generated deploy name for nginx deployments to avoid testing conflicts.

func (*Helper) CreateResourceList

func (helper *Helper) CreateResourceList(consumerName string, count int) (resources []*api.Resource)

CreateResourceList generates a list of resources with the specified consumer name and count. Each resource gets a randomly generated deploy name for nginx deployments to avoid testing conflicts.

func (*Helper) Delete

func (helper *Helper) Delete(obj interface{})

func (*Helper) DeleteAll

func (helper *Helper) DeleteAll(table interface{})

func (*Helper) EncodeManifestBundle

func (helper *Helper) EncodeManifestBundle(manifestJSON, deployName, deployNamespace string) (datatypes.JSONMap, error)

EncodeManifestBundle converts resource manifest JSON into a CloudEvent JSONMap representation.

func (*Helper) Env

func (helper *Helper) Env() *environments.Env

func (*Helper) HealthCheckURL

func (helper *Helper) HealthCheckURL(path string) string

func (*Helper) MetricsURL

func (helper *Helper) MetricsURL(path string) string

func (*Helper) MigrateDB

func (helper *Helper) MigrateDB() error

func (*Helper) MigrateDBTo

func (helper *Helper) MigrateDBTo(migrationID string)

func (*Helper) NewAPIResource

func (helper *Helper) NewAPIResource(consumerName, deployName string, replicas int) openapi.Resource

NewAPIResource creates an API resource with the given consumer name, deploy name, and replicas. It generates a deployment for nginx using the testManifestJSON template, giving it a random deploy name to avoid testing conflicts.

func (*Helper) NewAPIResourceWithSA

func (helper *Helper) NewAPIResourceWithSA(consumerName, deployName, sa string, replicas int) openapi.Resource

NewAPIResourceWithSA creates an API resource with the given consumer name, deploy name, service account, and replicas. It generates a nginx deployment using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts.

func (*Helper) NewAccount

func (helper *Helper) NewAccount(username, name, email string) *amv1.Account

func (*Helper) NewApiClient

func (helper *Helper) NewApiClient() *openapi.APIClient

func (*Helper) NewAuthenticatedContext

func (helper *Helper) NewAuthenticatedContext(account *amv1.Account) context.Context

func (*Helper) NewBundleEvent

func (helper *Helper) NewBundleEvent(source, action, consumerName, resourceID, deployName string, resourceVersion int64, replicas int) *cloudevents.Event

NewBundleEvent creates a CloudEvent with the given source, action, consumer name, resource ID, resource version, and replicas. It generates a bundle of nginx deployments using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts. If the action is "delete_request," the event includes a deletion timestamp.

func (*Helper) NewEvent

func (helper *Helper) NewEvent(source, action, consumerName, resourceID, deployName string, resourceVersion int64, replicas int) *cloudevents.Event

NewEvent creates a CloudEvent with the given source, action, consumer name, resource ID, deploy name, resource version, and replicas. It generates a nginx deployment using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts. If the action is "delete_request," the event includes a deletion timestamp.

func (*Helper) NewID

func (helper *Helper) NewID() string

NewID creates a new unique ID used internally to CS

func (*Helper) NewRandAccount

func (helper *Helper) NewRandAccount() *amv1.Account

func (*Helper) NewReadOnlyAPIResource

func (helper *Helper) NewReadOnlyAPIResource(consumerName, deployName string) openapi.Resource

NewReadOnlyAPIResource creates an API resource with the given consumer name and deploy name. It generates a read-only deployment manifests for nginx using the testReadOnlyManifestJSON template, giving it a random deploy name to avoid testing conflicts.

func (*Helper) NewResource

func (helper *Helper) NewResource(consumerName, deployName string, replicas int, resourceVersion int32) *api.Resource

NewReadOnlyResourceManifestJSON creates a resource with the given consumer name, deploy name, replicas, and resource version. It generates a deployment for nginx using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts.

func (*Helper) NewResourceBundle

func (helper *Helper) NewResourceBundle(consumerName, deployName string, replicas int, resourceVersion int32) *api.Resource

NewResourceBundle creates a resource bundle with the given consumer name, deploy name, replicas, and resource version.

func (*Helper) NewResourceManifestJSON

func (helper *Helper) NewResourceManifestJSON(deployName string, replicas int) string

NewResourceManifestJSON creates a resource manifest in JSON format with the given deploy name and replicas. It generates a deployment for nginx using the testManifestJSON template, assigning a random deploy name to avoid testing conflicts.

func (*Helper) NewUUID

func (helper *Helper) NewUUID() string

NewUUID creates a new unique UUID, which has different formatting than ksuid UUID is used by telemeter and we validate the format.

func (*Helper) OpenapiError

func (helper *Helper) OpenapiError(err error) openapi.Error

Convert an error response from the openapi client to an openapi error struct

func (*Helper) Reset

func (helper *Helper) Reset()

func (*Helper) ResetDB

func (helper *Helper) ResetDB() error

func (*Helper) RestURL

func (helper *Helper) RestURL(path string) string

func (*Helper) RestartMetricsServer

func (helper *Helper) RestartMetricsServer()

func (*Helper) RestartServer

func (helper *Helper) RestartServer()

func (*Helper) SkipIfShort

func (helper *Helper) SkipIfShort()

func (*Helper) StartControllerManager

func (helper *Helper) StartControllerManager(ctx context.Context)

func (*Helper) StartGRPCResourceSourceClient

func (helper *Helper) StartGRPCResourceSourceClient()

func (*Helper) StartJWKCertServerMock

func (helper *Helper) StartJWKCertServerMock() (teardown func() error)

func (*Helper) StartWorkAgent

func (helper *Helper) StartWorkAgent(ctx context.Context, clusterName string, bundle bool)

func (*Helper) Teardown

func (helper *Helper) Teardown()

type MemoryStore

type MemoryStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStore

func NewStore() *MemoryStore

func (*MemoryStore) Add

func (s *MemoryStore) Add(resource *api.Resource)

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(resourceID string)

func (*MemoryStore) Get

func (s *MemoryStore) Get(resourceID string) (*api.Resource, error)

func (*MemoryStore) List

func (s *MemoryStore) List(listOpts types.ListOptions) ([]*api.Resource, error)

func (*MemoryStore) ListByNamespace

func (s *MemoryStore) ListByNamespace(namespace string) []*api.Resource

func (*MemoryStore) UpSert

func (s *MemoryStore) UpSert(resource *api.Resource)

func (*MemoryStore) Update

func (s *MemoryStore) Update(resource *api.Resource) error

func (*MemoryStore) UpdateStatus

func (s *MemoryStore) UpdateStatus(resource *api.Resource) error

type ResourceBundleCodec

type ResourceBundleCodec struct{}

func (*ResourceBundleCodec) Decode

func (c *ResourceBundleCodec) Decode(evt *cloudevents.Event) (*api.Resource, error)

func (*ResourceBundleCodec) Encode

func (c *ResourceBundleCodec) Encode(source string, eventType types.CloudEventsType, resource *api.Resource) (*cloudevents.Event, error)

encode the kubernetes resource to a cloudevent format

func (*ResourceBundleCodec) EventDataType

func (c *ResourceBundleCodec) EventDataType() types.CloudEventsDataType

type ResourceCodec

type ResourceCodec struct{}

func (*ResourceCodec) Decode

func (c *ResourceCodec) Decode(evt *cloudevents.Event) (*api.Resource, error)

func (*ResourceCodec) Encode

func (c *ResourceCodec) Encode(source string, eventType types.CloudEventsType, resource *api.Resource) (*cloudevents.Event, error)

encode the kubernetes resource to a cloudevent format

func (*ResourceCodec) EventDataType

func (c *ResourceCodec) EventDataType() types.CloudEventsDataType

type TimeFunc

type TimeFunc func() time.Time

TimeFunc defines a way to get a new Time instance common to the entire test suite. Aria's environment has Virtual Time that may not be actual time. We compensate by synchronizing on a common time func attached to the test harness.

Directories

Path Synopsis
e2e
performance
cmd

Jump to

Keyboard shortcuts

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