e2e

package
v0.0.0-...-12680da Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the default timeout for client operations
	DefaultClientTimeout = 30 * time.Second
	// DefaultPollInterval is the default interval for polling
	DefaultPollInterval = 5 * time.Second
	// DefaultPollTimeout is the default timeout for polling
	DefaultPollTimeout = 10 * time.Minute
)
View Source
const (
	// OLSNameSpace is the namespace where the operator is deployed
	OLSNameSpace = "openshift-lightspeed"
	// OperatorDeploymentName is the name of the operator deployment
	OperatorDeploymentName = "lightspeed-operator-controller-manager"
	// LLMTokenEnvVar is the environment variable containing the LLM API token
	LLMTokenEnvVar = "LLM_TOKEN"
	// LLMTokenFirstSecretName is the name of the first secret containing the LLM API token
	LLMTokenFirstSecretName = "llm-token-first" // #nosec G101
	// LLMTokenSecondSecretName is the name of the second secret containing the LLM API token
	LLMTokenSecondSecretName = "llm-token-second" // #nosec G101
	// LLMApiTokenFileName
	LLMApiTokenFileName = "apitoken"
	// LLMDefaultProvider
	LLMDefaultProvider = "openai"
	// LLMProviderEnvVar is the environment variable containing the LLM provider
	LLMProviderEnvVar = "LLM_PROVIDER"
	// LLMTypeEnvVar is the environment variable containing the LLM type
	LLMTypeEnvVar = "LLM_TYPE"
	// LLMDefaultType is the default LLM type
	LLMDefaultType = "openai"
	// OpenAIDefaultModel is the default model to use
	OpenAIDefaultModel = "gpt-3.5-turbo"
	// OpenAIAlternativeModel is the alternative model to test model change
	OpenAIAlternativeModel = "gpt-4-1106-preview"
	// LLMModelEnvVar is the environment variable containing the LLM model
	LLMModelEnvVar = "LLM_MODEL"
	// OLSCRName is the name of the OLSConfig CR
	OLSCRName = "cluster"
	// AppServerDeploymentName is the name of the OLS application server deployment
	AppServerDeploymentName = "lightspeed-app-server"
	// AppServerServiceName is the name of the OLS application server service
	AppServerServiceName = "lightspeed-app-server"
	// AppServerServiceHTTPSPort is the port number of the OLS application server service
	AppServerServiceHTTPSPort = 8443
	// ConsolePluginServiceName is the name of the OLS console plugin deployment
	ConsolePluginDeploymentName = "lightspeed-console-plugin"
	// ConsolePluginServiceName is the name of the OLS console plugin service
	ConsolePluginServiceName = "lightspeed-console-plugin"
	// ConsoleUIPluginName is the name of the OLS console plugin
	ConsoleUIPluginName = "lightspeed-console-plugin"
	// ConsoleUIConfigMapName is the name of the console UI nginx configmap
	ConsoleUIConfigMapName = "lightspeed-console-plugin"

	// OLSConsolePluginServiceHTTPSPort is the port number of the OLS console plugin service
	OLSConsolePluginServiceHTTPSPort = 9443
	// AppServerConfigMapName is the name of the OLS application server config map
	AppServerConfigMapName = "olsconfig"
	// AppServerConfigMapKey is the key of config file in the OLS application server config map
	AppServerConfigMapKey = "olsconfig.yaml"
	// AppServerTLSSecretName is the name of the OLS application server TLS secret
	AppServerTLSSecretName = "lightspeed-tls" // #nosec G101
	// ConditionTimeoutEnvVar is the environment variable containing the condition check timeout in seconds
	ConditionTimeoutEnvVar = "CONDITION_TIMEOUT"

	// TestCACert is for testing additional CA certificate
	TestCACert = `` /* 1513-byte string literal not displayed */

	// OLSAppCertsMountRoot is the directory hosting the cert files in the container
	OLSAppCertsMountRoot = "/etc/certs"
	// AdditionalCAVolumeName is the name of the additional CA volume in the app server container
	AdditionalCAVolumeName = "additional-ca"
	// AppAdditionalCACertDir is the directory for storing additional CA certificates in the app server container under OLSAppCertsMountRoot
	AppAdditionalCACertDir = "ols-additional-ca"
	// AdditionalCAHashKey is the key of the hash value of the additional CA certificates
	AdditionalCAHashKey = "hash/additionalca"
	// CertBundleVolumeName is the name of the volume for the certificate bundle
	CertBundleVolumeName = "cert-bundle"
	// CertBundleDir is the path of the volume for the certificate bundle
	CertBundleDir = "cert-bundle"
)
View Source
const MaxLength = 1000

MaxLength is the maximum string length returned by ClampMax().

Variables

This section is empty.

Functions

func ClampMax

func ClampMax(b []byte) string

ClampMax converts a slice of bytes to a string truncated to MaxLength.

func GetFirstValueFromPromQuery

func GetFirstValueFromPromQuery(body []byte) (float64, error)

GetFirstValueFromPromQuery takes a query api response body and returns the value of the first timeseries. If body contains multiple timeseries GetFirstValueFromPromQuery errors.

func GetResultSizeFromPromQuery

func GetResultSizeFromPromQuery(body []byte) (int, error)

GetResultSizeFromPromQuery takes a query api response body and returns the size of the result vector.

func Ptr

func Ptr[T any](v T) *T

Types

type Client

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

func GetClient

func GetClient(options *ClientOptions) (*Client, error)

func (*Client) Create

func (c *Client) Create(o client.Object) (err error)

func (*Client) CreateClusterRoleBinding

func (c *Client) CreateClusterRoleBinding(namespace, serviceAccount, clusterRole string) (func(), error)

func (*Client) CreateServiceAccount

func (c *Client) CreateServiceAccount(namespace, serviceAccount string) (func(), error)

func (*Client) Delete

func (c *Client) Delete(o client.Object) (err error)

func (*Client) ForwardPort

func (c *Client) ForwardPort(serviceName, namespaceName string, port int) (string, func(), error)

func (*Client) Get

func (c *Client) Get(o client.Object) (err error)

func (*Client) GetServiceAccountToken

func (c *Client) GetServiceAccountToken(namespace, name string) (string, error)

func (*Client) List

func (c *Client) List(o client.ObjectList, opts ...client.ListOption) (err error)

func (*Client) Update

func (c *Client) Update(o client.Object) (err error)

func (*Client) WaitForConfigMapContainString

func (c *Client) WaitForConfigMapContainString(cm *corev1.ConfigMap, key, substr string) error

func (*Client) WaitForDeploymentCondition

func (c *Client) WaitForDeploymentCondition(dep *appsv1.Deployment, condition func(*appsv1.Deployment) (bool, error)) error

func (*Client) WaitForDeploymentRollout

func (c *Client) WaitForDeploymentRollout(dep *appsv1.Deployment) error

func (*Client) WaitForObjectCreated

func (c *Client) WaitForObjectCreated(obj client.Object) error

func (*Client) WaitForSecretCreated

func (c *Client) WaitForSecretCreated(secret *corev1.Secret) error

func (*Client) WaitForServiceCreated

func (c *Client) WaitForServiceCreated(service *corev1.Service) error

type ClientOptions

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

type HTTPSClient

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

func NewHTTPSClient

func NewHTTPSClient(host, serverName string, caCertificate, clientCert, clientKey []byte) *HTTPSClient

func (*HTTPSClient) Get

func (c *HTTPSClient) Get(queryUrl string, headers ...map[string]string) (*http.Response, error)

func (*HTTPSClient) PostJson

func (c *HTTPSClient) PostJson(queryUrl string, body []byte, headers ...map[string]string) (*http.Response, error)

type HeaderInjector

type HeaderInjector struct {
	Name  string
	Value string
}

HeaderInjector injects a fixed HTTP header into the inbound request.

func (*HeaderInjector) WrapTransport

func (h *HeaderInjector) WrapTransport(rt http.RoundTripper) http.RoundTripper

WrapTransport implements the WrapTransporter interface.

type PrometheusClient

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

PrometheusClient provides access to the Prometheus, Thanos & Alertmanager API.

func NewPrometheusClient

func NewPrometheusClient(host, token string, wts ...WrapTransporter) *PrometheusClient

NewPrometheusClient creates and returns a new PrometheusClient.

func NewPrometheusClientFromRoute

func NewPrometheusClientFromRoute(
	ctx context.Context,
	routeClient routev1.RouteV1Interface,
	namespace, name string,
	token string,
) (*PrometheusClient, error)

NewPrometheusClientFromRoute creates and returns a new PrometheusClient from the given OpenShift route.

func (*PrometheusClient) Do

func (c *PrometheusClient) Do(method string, path string, body []byte) (*http.Response, error)

Do sends an HTTP request to the remote endpoint and returns the response.

func (*PrometheusClient) PrometheusLabel

func (c *PrometheusClient) PrometheusLabel(label string) ([]byte, error)

PrometheusLabel runs an HTTP GET request against the Prometheus label API and returns the response body.

func (*PrometheusClient) PrometheusQuery

func (c *PrometheusClient) PrometheusQuery(query string) ([]byte, error)

PrometheusQuery runs an HTTP GET request against the Prometheus query API and returns the response body.

func (*PrometheusClient) PrometheusQueryWithStatus

func (c *PrometheusClient) PrometheusQueryWithStatus(query string, status int) ([]byte, error)

func (*PrometheusClient) PrometheusTargets

func (c *PrometheusClient) PrometheusTargets() ([]byte, error)

PrometheusTargets runs an HTTP GET request against the Prometheus targets API and returns the response body.

func (*PrometheusClient) WaitForQueryReturn

func (c *PrometheusClient) WaitForQueryReturn(query string, timeout time.Duration, validate func(float64) error) error

WaitForQueryReturn waits for a given PromQL query for a given time interval and validates the **first and only** result with the given validate function.

func (*PrometheusClient) WaitForQueryReturnEmpty

func (c *PrometheusClient) WaitForQueryReturnEmpty(query string, timeout time.Duration) error

WaitForQueryReturnEmpty waits for a given PromQL query return an empty response for a given time interval

func (*PrometheusClient) WaitForQueryReturnGreaterEqualOne

func (c *PrometheusClient) WaitForQueryReturnGreaterEqualOne(query string, timeout time.Duration) error

WaitForQueryReturnGreaterEqualOne see WaitForQueryReturn.

func (*PrometheusClient) WaitForQueryReturnOne

func (c *PrometheusClient) WaitForQueryReturnOne(query string, timeout time.Duration) error

WaitForQueryReturnOne see WaitForQueryReturn.

type QueryParameterInjector

type QueryParameterInjector struct {
	Name  string
	Value string
}

QueryParameterInjector injects a fixed query parameter into the inbound request. It is typically used when querying kube-rbac-proxy.

func (*QueryParameterInjector) WrapTransport

WrapTransport implements the WrapTransporter interface.

type WrapTransporter

type WrapTransporter interface {
	WrapTransport(rt http.RoundTripper) http.RoundTripper
}

WrapTransporter wraps an http.RoundTripper with another.

Jump to

Keyboard shortcuts

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