test

package
v0.11.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 89 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnablePlugin added in v0.9.2

func EnablePlugin(mode meta.PluginMode, schemeFunc func(context.Context) meta.Scheme)

Adds the calling plugin to the list of plugins that will be loaded in the test environment. The plugin metadata is inferred from the caller's package. This will apply to all test environments in a suite.

Must be called from init() in a package of the form github.com/rancher/opni/plugins/<name>/test

func FindTestBin added in v0.9.2

func FindTestBin() (string, error)

func NewApiExtensionTestPlugin added in v0.4.1

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

func RandomName added in v0.6.0

func RandomName(seed int64) string

Types

type AlertManagerPorts added in v0.11.0

type AlertManagerPorts struct {
	ApiPort      int
	ClusterPort  int
	EmbeddedPort int
}

type EnvClientOption added in v0.9.2

type EnvClientOption func(o *EnvClientOptions)

func WithClientCaching added in v0.9.2

func WithClientCaching(memoryLimitBytes int64, _ time.Duration) EnvClientOption

type EnvClientOptions added in v0.9.2

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

type Environment added in v0.4.1

type Environment struct {
	EnvironmentOptions

	TestBin           string
	Logger            *zap.SugaredLogger
	CRDDirectoryPaths []string
	// contains filtered or unexported fields
}

func EnvFromContext added in v0.9.2

func EnvFromContext(ctx context.Context) *Environment

func (*Environment) BootstrapNewAgent added in v0.11.0

func (e *Environment) BootstrapNewAgent(id string, opts ...StartAgentOption) error

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) DeleteAgent added in v0.11.0

func (e *Environment) DeleteAgent(id string) error

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) GatewayClientTLSConfig added in v0.11.0

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

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) GenerateNewTempDirectory added in v0.8.0

func (e *Environment) GenerateNewTempDirectory(prefix string) string

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) GetPorts added in v0.9.2

func (e *Environment) GetPorts() ServicePorts

func (*Environment) GetTempDirectory added in v0.9.1

func (e *Environment) GetTempDirectory() string

func (*Environment) JetStreamConfig added in v0.6.2

func (e *Environment) JetStreamConfig() *v1beta1.JetStreamStorageSpec

func (*Environment) ManagementClientConn added in v0.5.4

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

func (*Environment) NewAlertConditionsClient added in v0.8.2

func (e *Environment) NewAlertConditionsClient() alertingv1.AlertConditionsClient

func (*Environment) NewAlertEndpointsClient added in v0.8.2

func (e *Environment) NewAlertEndpointsClient() alertingv1.AlertEndpointsClient

func (*Environment) NewAlertNotificationsClient added in v0.8.3

func (e *Environment) NewAlertNotificationsClient() alertingv1.AlertNotificationsClient

func (*Environment) NewGatewayConfig added in v0.8.0

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

func (*Environment) NewManagementClient added in v0.4.1

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

func (*Environment) NewStreamConnection added in v0.11.0

func (e *Environment) NewStreamConnection(pins []string) (grpc.ClientConnInterface, <-chan error)

func (*Environment) PrometheusAPIEndpoint added in v0.4.1

func (e *Environment) PrometheusAPIEndpoint() string

func (*Environment) PutTestData added in v0.8.0

func (e *Environment) PutTestData(inputPath string, data []byte) string

func (*Environment) SetPrometheusNodeConfigOverride added in v0.9.2

func (e *Environment) SetPrometheusNodeConfigOverride(agentId string, override *OverridePrometheusConfig)

func (*Environment) SimulateKubeObject added in v0.9.2

func (e *Environment) SimulateKubeObject(kPort int)

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) StartEmbeddedAlertManager added in v0.8.2

func (e *Environment) StartEmbeddedAlertManager(
	ctx context.Context,
	configFilePath string,
	opniPort *int,
	peers ...string,
) (ports AlertManagerPorts)

func (*Environment) StartEmbeddedJetstream added in v0.8.2

func (e *Environment) StartEmbeddedJetstream() (*nats.Conn, error)

func (*Environment) StartGrafana added in v0.9.1

func (e *Environment) StartGrafana(extraDockerArgs ...string)

func (*Environment) StartInstrumentationServer added in v0.5.4

func (e *Environment) StartInstrumentationServer() (int, chan struct{})

Starts a server that exposes Prometheus metrics

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

func (*Environment) StartMockKubernetesMetricServer added in v0.6.0

func (e *Environment) StartMockKubernetesMetricServer() (port int)

func (*Environment) StartNodeExporter added in v0.6.1

func (e *Environment) StartNodeExporter()

func (*Environment) StartOTELCollectorContext added in v0.9.2

func (e *Environment) StartOTELCollectorContext(ctx waitctx.PermissiveContext, opniAgentId string, spec *otel.OTELSpec) error

func (*Environment) Stop added in v0.4.1

func (e *Environment) Stop() error

func (*Environment) UnsafeStartPrometheus added in v0.11.0

func (e *Environment) UnsafeStartPrometheus(ctx waitctx.PermissiveContext, opniAgentId string, override ...*OverridePrometheusConfig) (int, error)

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

func (*Environment) WriteGrafanaConfig added in v0.9.1

func (e *Environment) WriteGrafanaConfig()

type EnvironmentOption added in v0.4.1

type EnvironmentOption func(*EnvironmentOptions)

func WithDefaultAgentOpts added in v0.5.4

func WithDefaultAgentOpts(opts ...StartAgentOption) 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 WithStorageBackend added in v0.6.2

func WithStorageBackend(backend v1beta1.StorageType) EnvironmentOption

type EnvironmentOptions added in v0.4.1

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

type OverridePrometheusConfig added in v0.9.2

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

func NewOverridePrometheusConfig added in v0.5.4

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

type PrometheusJob added in v0.5.4

type PrometheusJob struct {
	JobName     string
	ScrapePort  int
	MetricsPath string
}

type RunningAgent added in v0.4.1

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

type ServicePorts added in v0.9.2

type ServicePorts struct {
	Etcd             int `env:"ETCD_PORT"`
	Jetstream        int `env:"JETSTREAM_PORT"`
	GatewayGRPC      int `env:"OPNI_GATEWAY_GRPC_PORT"`
	GatewayHTTP      int `env:"OPNI_GATEWAY_HTTP_PORT"`
	GatewayMetrics   int `env:"OPNI_GATEWAY_METRICS_PORT"`
	ManagementGRPC   int `env:"OPNI_MANAGEMENT_GRPC_PORT"`
	ManagementHTTP   int `env:"OPNI_MANAGEMENT_HTTP_PORT"`
	ManagementWeb    int `env:"OPNI_MANAGEMENT_WEB_PORT"`
	CortexGRPC       int `env:"CORTEX_GRPC_PORT"`
	CortexHTTP       int `env:"CORTEX_HTTP_PORT"`
	TestEnvironment  int `env:"TEST_ENV_API_PORT"`
	DisconnectPort   int `env:"AGENT_DISCONNECT_PORT"`
	NodeExporterPort int `env:"NODE_EXPORTER_PORT"`
}

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 WithListenPort added in v0.9.2

func WithListenPort(port int) StartAgentOption

func WithLocalAgent added in v0.9.0

func WithLocalAgent() StartAgentOption

func WithRemoteGatewayAddress added in v0.5.4

func WithRemoteGatewayAddress(addr string) StartAgentOption

type StartAgentOptions added in v0.4.1

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

type TestAggregatorConfig added in v0.9.2

type TestAggregatorConfig struct {
	AggregatorAddress  string
	HealthCheckAddress string
	AgentEndpoint      string
	LogsEnabled        bool
	Metrics            otel.MetricsConfig
	Containerized      bool
}

func (TestAggregatorConfig) MetricReceivers added in v0.9.2

func (t TestAggregatorConfig) MetricReceivers() []string

type TestNodeConfig added in v0.9.2

type TestNodeConfig struct {
	AggregatorAddress string
	ReceiverFile      string
	Instance          string
	Logs              otel.LoggingConfig
	Metrics           otel.MetricsConfig
	Containerized     bool
}

func (TestNodeConfig) MetricReceivers added in v0.9.2

func (t TestNodeConfig) MetricReceivers() []string

type TestPluginSet added in v0.11.0

type TestPluginSet map[meta.PluginMode][]testPlugin

func (TestPluginSet) EnablePlugin added in v0.11.0

func (tp TestPluginSet) EnablePlugin(pkgName, pluginName string, mode meta.PluginMode, schemeFunc func(context.Context) meta.Scheme)

func (TestPluginSet) LoadPlugins added in v0.11.0

func (tp TestPluginSet) LoadPlugins(ctx context.Context, loader *plugins.PluginLoader, mode meta.PluginMode) int

Directories

Path Synopsis
conformance
mock
apiextensions
Package mock_apiextensions is a generated GoMock package.
Package mock_apiextensions is a generated GoMock package.
apiextensions/stream
Package mock_stream is a generated GoMock package.
Package mock_stream 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.
grpc
Package mock_grpc is a generated GoMock package.
Package mock_grpc 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.
storage
Package mock_storage is a generated GoMock package.
Package mock_storage is a generated GoMock package.
streams
Package mock_streams is a generated GoMock package.
Package mock_streams is a generated GoMock package.
update
Package mock_update is a generated GoMock package.
Package mock_update is a generated GoMock package.

Jump to

Keyboard shortcuts

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