test

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 134 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unit        = "unit"
	Integration = "integration"
	Controller  = "controller"
	E2E         = "e2e"
	Slow        = "slow"
	Temporal    = "temporal"
)

Variables

View Source
var ExternalResources sync.WaitGroup
View Source
var Log = logger.New(logger.WithLogLevel(logger.DefaultLogLevel.Level())).Named("test")
View Source
var TestDataFS embed.FS

Functions

func ContextWithAuthorizedID added in v0.5.4

func ContextWithAuthorizedID(ctx context.Context, clusterID string) context.Context

func DownloadCertManagerCRDs added in v0.4.1

func DownloadCertManagerCRDs(scheme *runtime.Scheme) []*apiextensionsv1.CustomResourceDefinition

func EnableIfCI added in v0.4.1

func EnableIfCI[T any](decorator T) any

func ExpectRuleGroupToExist added in v0.6.0

func ExpectRuleGroupToExist(
	client cortexadmin.CortexAdminClient,
	ctx context.Context,
	tenant string,
	groupName string,
	pollInterval time.Duration,
	maxTimeout time.Duration,
)

func LoadPlugins added in v0.4.1

func LoadPlugins(loader *plugins.PluginLoader, mode meta.PluginMode) int

func LoadUnaryPlugins added in v0.5.4

func LoadUnaryPlugins(loader *plugins.PluginLoader) int

func NewApiExtensionTestPlugin added in v0.4.1

func NewApiExtensionTestPlugin(
	srv apiextensions.ManagementAPIExtensionServer,
	svcDesc *grpc.ServiceDesc,
	impl interface{},
) *plugin.ClientConfig

func NewApiExtensionUnaryTestPlugin added in v0.5.4

func NewApiExtensionUnaryTestPlugin(
	srv apiextensions.UnaryAPIExtensionServer,
	svcDesc *grpc.ServiceDesc,
	impl interface{},
) *plugin.ClientConfig

func NewOverridePrometheusConfig added in v0.5.4

func NewOverridePrometheusConfig(configPath string, jobs []PrometheusJob) *overridePrometheusConfig

func NewTestCapabilityBackend added in v0.4.1

func NewTestCapabilityBackend(
	ctrl *gomock.Controller,
	capBackend *CapabilityInfo,
) capabilityv1.BackendClient

func NewTestClusterStore added in v0.4.1

func NewTestClusterStore(ctrl *gomock.Controller) storage.ClusterStore

func NewTestFinder added in v0.5.4

func NewTestFinder(ctrl *gomock.Controller, groups func() []rules.RuleGroup) notifier.Finder[rules.RuleGroup]

func NewTestIdentProvider added in v0.4.1

func NewTestIdentProvider(ctrl *gomock.Controller, id string) ident.Provider

func NewTestKeyValueStore added in v0.4.1

func NewTestKeyValueStore[T any](ctrl *gomock.Controller, clone func(T) T) storage.KeyValueStoreT[T]

func NewTestKeyValueStoreBroker added in v0.4.1

func NewTestKeyValueStoreBroker(ctrl *gomock.Controller) storage.KeyValueStoreBroker

func NewTestKeyringStore added in v0.4.1

func NewTestKeyringStore(ctrl *gomock.Controller, prefix string, ref *corev1.Reference) storage.KeyringStore

func NewTestKeyringStoreBroker added in v0.4.1

func NewTestKeyringStoreBroker(ctrl *gomock.Controller, handler ...KeyringStoreHandler) storage.KeyringStoreBroker

func NewTestRBACStore added in v0.4.1

func NewTestRBACStore(ctrl *gomock.Controller) storage.RBACStore

func NewTestStorageBackend added in v0.4.1

func NewTestStorageBackend(ctx context.Context, ctrl *gomock.Controller) storage.Backend

func NewTestTokenStore added in v0.4.1

func NewTestTokenStore(ctx context.Context, ctrl *gomock.Controller) storage.TokenStore

func RandomName added in v0.6.0

func RandomName(seed int64) string

func RunTestEnvironment

func RunTestEnvironment(
	testEnv *envtest.Environment,
	runControllerManager bool,
	externalEnv bool,
	reconcilers ...Reconciler,
) (stop context.CancelFunc, k8sManager ctrl.Manager, k8sClient client.Client)

func StandaloneHttpRequest added in v0.6.0

func StandaloneHttpRequest(
	method string,
	url string,
	requestBody []byte,
	values url.Values,
	tls *tls.Config,
) (code int, body []byte, err error)

StandaloneHttpRequest is a helper function to make a http request to a given url. returns status code, body and any errors

func StartControllerManager added in v0.2.0

func StartControllerManager(ctx context.Context, testEnv *envtest.Environment)

func StartStandaloneTestEnvironment added in v0.4.1

func StartStandaloneTestEnvironment(opts ...EnvironmentOption)

func TestData added in v0.4.1

func TestData(filename string) []byte

Types

type BenchRunner added in v0.5.4

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

func (*BenchRunner) StartWorker added in v0.5.4

func (b *BenchRunner) StartWorker(ctx context.Context)

type CapabilityInfo added in v0.4.1

type CapabilityInfo struct {
	Name              string
	CanInstall        bool
	InstallerTemplate string
	Storage           storage.ClusterStore
}

type Environment added in v0.4.1

type Environment struct {
	EnvironmentOptions

	TestBin           string
	Logger            *zap.SugaredLogger
	CRDDirectoryPaths []string

	Processes struct {
		Etcd      future.Future[*os.Process]
		APIServer future.Future[*os.Process]
	}
	// contains filtered or unexported fields
}

func (*Environment) Context added in v0.6.0

func (e *Environment) Context() context.Context

func (*Environment) CortexTLSConfig added in v0.6.0

func (e *Environment) CortexTLSConfig() *tls.Config

func (*Environment) EtcdClient added in v0.4.1

func (e *Environment) EtcdClient() (*clientv3.Client, error)

func (*Environment) EtcdConfig added in v0.4.1

func (e *Environment) EtcdConfig() *v1beta1.EtcdStorageSpec

func (*Environment) GatewayConfig added in v0.4.1

func (e *Environment) GatewayConfig() *v1beta1.GatewayConfig

func (*Environment) GatewayTLSConfig added in v0.4.1

func (e *Environment) GatewayTLSConfig() *tls.Config

func (*Environment) GetAgent added in v0.4.1

func (e *Environment) GetAgent(id string) RunningAgent

func (*Environment) GetAlertingManagementWebhookEndpoint added in v0.6.0

func (e *Environment) GetAlertingManagementWebhookEndpoint() string

func (*Environment) ManagementClientConn added in v0.5.4

func (e *Environment) ManagementClientConn() grpc.ClientConnInterface

func (*Environment) NewBenchRunner added in v0.5.4

func (e *Environment) NewBenchRunner(agent string, desc bench.WorkloadDesc) (*BenchRunner, error)

func (*Environment) NewCortexAdminClient added in v0.5.4

func (e *Environment) NewCortexAdminClient() cortexadmin.CortexAdminClient

func (*Environment) NewCortexOpsClient added in v0.6.0

func (e *Environment) NewCortexOpsClient() cortexops.CortexOpsClient

func (*Environment) NewManagementClient added in v0.4.1

func (e *Environment) NewManagementClient() managementv1.ManagementClient

func (*Environment) PrometheusAPIEndpoint added in v0.4.1

func (e *Environment) PrometheusAPIEndpoint() string

func (*Environment) Start added in v0.4.1

func (e *Environment) Start(opts ...EnvironmentOption) error

func (*Environment) StartAgent added in v0.4.1

func (e *Environment) StartAgent(id string, token *corev1.BootstrapToken, pins []string, opts ...StartAgentOption) (int, <-chan error)

func (*Environment) StartAgentDisconnectServer added in v0.6.1

func (e *Environment) StartAgentDisconnectServer()

func (*Environment) StartCortex added in v0.6.0

func (e *Environment) StartCortex(ctx context.Context)

func (*Environment) StartInstrumentationServer added in v0.5.4

func (e *Environment) StartInstrumentationServer(ctx context.Context) (int, chan struct{})

Starts a server that exposes Prometheus metrics

Returns port number of the server & a channel that shutdowns the server

func (*Environment) StartK8s added in v0.4.1

func (e *Environment) StartK8s() (*rest.Config, *runtime.Scheme, error)

func (*Environment) StartManager added in v0.4.1

func (e *Environment) StartManager(restConfig *rest.Config, reconcilers ...Reconciler) ctrl.Manager

func (*Environment) StartMockKubernetesMetricServer added in v0.6.0

func (e *Environment) StartMockKubernetesMetricServer(ctx context.Context) (port int)

func (*Environment) StartNodeExporter added in v0.6.1

func (e *Environment) StartNodeExporter()

func (*Environment) StartPrometheus added in v0.4.1

func (e *Environment) StartPrometheus(opniAgentPort int, override ...*overridePrometheusConfig) int

`prometheus/config.yaml` is the default monitoring config. `slo/prometheus/config.yaml` is the default SLO config.

func (*Environment) Stop added in v0.4.1

func (e *Environment) Stop() error

type EnvironmentOption added in v0.4.1

type EnvironmentOption func(*EnvironmentOptions)

func WithAgentIdSeed added in v0.6.0

func WithAgentIdSeed(seed int64) EnvironmentOption

func WithDefaultAgentOpts added in v0.5.4

func WithDefaultAgentOpts(opts ...StartAgentOption) EnvironmentOption

func WithDelayStartCortex added in v0.6.0

func WithDelayStartCortex(delay chan struct{}) EnvironmentOption

func WithDelayStartEtcd added in v0.6.0

func WithDelayStartEtcd(delay chan struct{}) EnvironmentOption

func WithEnableCortex added in v0.4.1

func WithEnableCortex(enable bool) EnvironmentOption

func WithEnableCortexClusterDriver added in v0.6.0

func WithEnableCortexClusterDriver(enable bool) EnvironmentOption

func WithEnableDisconnectServer added in v0.6.1

func WithEnableDisconnectServer(enable bool) EnvironmentOption

func WithEnableEtcd added in v0.4.1

func WithEnableEtcd(enable bool) EnvironmentOption

func WithEnableGateway added in v0.4.1

func WithEnableGateway(enable bool) EnvironmentOption

func WithEnableJetstream added in v0.6.0

func WithEnableJetstream(enable bool) EnvironmentOption

func WithEnableNodeExporter added in v0.6.1

func WithEnableNodeExporter(enable bool) EnvironmentOption

func WithEnableRealtimeServer added in v0.5.4

func WithEnableRealtimeServer(enable bool) EnvironmentOption

type EnvironmentOptions added in v0.4.1

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

type HealthStore added in v0.5.4

type HealthStore struct {
	GetHealthShouldFail bool
	// contains filtered or unexported fields
}

func (*HealthStore) GetHealth added in v0.5.4

func (*HealthStore) SetHealth added in v0.5.4

func (hb *HealthStore) SetHealth(health *corev1.Health)

type KeyringStoreHandler added in v0.4.1

type KeyringStoreHandler = func(prefix string, ref *corev1.Reference) storage.KeyringStore

type Lease added in v0.4.1

type Lease struct {
	ID         int64
	Expiration time.Time
	TokenID    string
}

type LeaseStore added in v0.4.1

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

func NewLeaseStore added in v0.4.1

func NewLeaseStore(ctx context.Context) *LeaseStore

func (*LeaseStore) LeaseExpired added in v0.4.1

func (ls *LeaseStore) LeaseExpired() <-chan string

func (*LeaseStore) New added in v0.4.1

func (ls *LeaseStore) New(tokenID string, ttl time.Duration) *Lease

type PrometheusJob added in v0.5.4

type PrometheusJob struct {
	JobName    string
	ScrapePort int
}

type Reconciler

type Reconciler interface {
	SetupWithManager(ctrl.Manager) error
}

type RunningAgent added in v0.4.1

type RunningAgent struct {
	Agent agent.AgentInterface
	*sync.Mutex
}

type StartAgentOption added in v0.4.1

type StartAgentOption func(*StartAgentOptions)

func WithAgentVersion added in v0.6.0

func WithAgentVersion(version string) StartAgentOption

func WithContext added in v0.4.1

func WithContext(ctx context.Context) StartAgentOption

func WithRemoteGatewayAddress added in v0.5.4

func WithRemoteGatewayAddress(addr string) StartAgentOption

func WithRemoteKubeconfig added in v0.5.4

func WithRemoteKubeconfig(kubeconfig string) StartAgentOption

type StartAgentOptions added in v0.4.1

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

type TestEnvClusterDriver added in v0.6.0

type TestEnvClusterDriver struct {
	cortexops.UnsafeCortexOpsServer

	Env           *Environment
	Configuration *cortexops.ClusterConfiguration
	// contains filtered or unexported fields
}

func NewTestEnvClusterDriver added in v0.6.0

func NewTestEnvClusterDriver(env *Environment) *TestEnvClusterDriver

func (*TestEnvClusterDriver) ConfigureCluster added in v0.6.0

func (*TestEnvClusterDriver) GetClusterConfiguration added in v0.6.0

func (*TestEnvClusterDriver) GetClusterStatus added in v0.6.0

func (*TestEnvClusterDriver) Name added in v0.6.0

func (d *TestEnvClusterDriver) Name() string

func (*TestEnvClusterDriver) ShouldDisableNode added in v0.6.0

func (d *TestEnvClusterDriver) ShouldDisableNode(*corev1.Reference) error

func (*TestEnvClusterDriver) UninstallCluster added in v0.6.0

func (d *TestEnvClusterDriver) UninstallCluster(context.Context, *emptypb.Empty) (*emptypb.Empty, error)

Directories

Path Synopsis
mock
apiextensions
Package mock_apiextensions is a generated GoMock package.
Package mock_apiextensions is a generated GoMock package.
capability
Package mock_v1 is a generated GoMock package.
Package mock_v1 is a generated GoMock package.
ext
Package mock_ext is a generated GoMock package.
Package mock_ext is a generated GoMock package.
ident
Package mock_ident is a generated GoMock package.
Package mock_ident is a generated GoMock package.
notifier
Package mock_notifier is a generated GoMock package.
Package mock_notifier is a generated GoMock package.
rbac
Package mock_rbac is a generated GoMock package.
Package mock_rbac is a generated GoMock package.
rules
Package mock_rules is a generated GoMock package.
Package mock_rules is a generated GoMock package.
storage
Package mock_storage is a generated GoMock package.
Package mock_storage is a generated GoMock package.

Jump to

Keyboard shortcuts

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