utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfClusterExistsOrCreate

func CheckIfClusterExistsOrCreate(maxGPUs int) (string, error)

func CreateAcceleratorUnitCostConfigMap

func CreateAcceleratorUnitCostConfigMap(controllerNamespace string) *corev1.ConfigMap

createAcceleratorUnitCostConfigMap creates the accelerator unitcost ConfigMap

func CreateArrivalQuery

func CreateArrivalQuery(modelID, namespace string) string

The following utility functions are used to create Prometheus queries for testing

func CreateITLQuery

func CreateITLQuery(modelID, namespace string) string

func CreateInferenceModel

func CreateInferenceModel(name, namespace, modelName string) *unstructured.Unstructured

creates an InferenceModel resource for the specified model

func CreateServiceClassConfigMap

func CreateServiceClassConfigMap(controllerNamespace string) *corev1.ConfigMap

createServiceClassConfigMap creates the serviceclass ConfigMap

func CreateTokenQuery

func CreateTokenQuery(modelID, namespace string) string

func CreateVariantAutoscalingConfigMap

func CreateVariantAutoscalingConfigMap(controllerNamespace string) *corev1.ConfigMap

func CreateVariantAutoscalingResource

func CreateVariantAutoscalingResource(namespace, resourceName, modelId, acc string) *v1alpha1.VariantAutoscaling

creates a VariantAutoscaling resource with owner reference to deployment

func CreateVllmeDeployment

func CreateVllmeDeployment(namespace, deployName, modelName, appLabel string) *appsv1.Deployment

creates a vllme deployment with the specified configuration

func CreateVllmeService

func CreateVllmeService(namespace, serviceName, appLabel string, nodePort int) *corev1.Service

creates a service for the vllme deployment

func CreateVllmeServiceMonitor

func CreateVllmeServiceMonitor(name, namespace, appLabel string) *unstructured.Unstructured

creates a ServiceMonitor for vllme metrics collection

func CreateWaitQuery

func CreateWaitQuery(modelID, namespace string) string

func GetInfernoReplicaMetrics

func GetInfernoReplicaMetrics(variantName, namespace, acceleratorType string) (currentReplicas, desiredReplicas, desiredRatio float64, err error)

GetInfernoReplicaMetrics queries Prometheus for metrics emitted by the Inferno autoscaler

func GetNonEmptyLines

func GetNonEmptyLines(output string) []string

GetNonEmptyLines converts given command output string into individual objects according to line breakers, and ignores the empty elements in it.

func GetProjectDir

func GetProjectDir() (string, error)

GetProjectDir will return the directory where the project is

func InstallCertManager

func InstallCertManager() error

InstallCertManager installs the cert manager bundle.

func InstallPrometheusOperator

func InstallPrometheusOperator() error

InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. Includes TLS certificate generation and configuration for HTTPS support.

func IsCertManagerCRDsInstalled

func IsCertManagerCRDsInstalled() bool

IsCertManagerCRDsInstalled checks if any Cert Manager CRDs are installed by verifying the existence of key CRDs related to Cert Manager.

func IsPrometheusCRDsInstalled

func IsPrometheusCRDsInstalled() bool

IsPrometheusCRDsInstalled checks if any Prometheus CRDs are installed by verifying the existence of key CRDs related to Prometheus.

func LoadImageToKindClusterWithName

func LoadImageToKindClusterWithName(name string, maxGPUs int) error

LoadImageToKindClusterWithName loads a local docker image to the kind cluster

func LogVariantAutoscalingStatus

func LogVariantAutoscalingStatus(ctx context.Context, vaName, namespace string, crClient client.Client) error

func Run

func Run(cmd *exec.Cmd) (string, error)

Run executes the provided command within this context

func SetUpPortForward

func SetUpPortForward(k8sClient *kubernetes.Clientset, ctx context.Context, serviceName, namespace string, localPort, servicePort int) *exec.Cmd

func StartLoadGenerator

func StartLoadGenerator(rate, contentLength int, port int, modelName string) *exec.Cmd

StartLoadGenerator sets up and launches a load generator with rate and content specified, targeting the specified model, to the specified port

func StopCmd

func StopCmd(cmd *exec.Cmd) error

func UncommentCode

func UncommentCode(filename, target, prefix string) error

UncommentCode searches for target in the file and remove the comment prefix of the target content. The target content may span multiple lines.

func UninstallCertManager

func UninstallCertManager()

UninstallCertManager uninstalls the cert manager

func UninstallPrometheusOperator

func UninstallPrometheusOperator()

UninstallPrometheusOperator uninstalls the prometheus

func ValidateAppLabelUniqueness

func ValidateAppLabelUniqueness(namespace, appLabel string, k8sClient *kubernetes.Clientset, crClient client.Client)

ValidateAppLabelUniqueness checks if the appLabel is already in use by other resources and fails if it's not unique

func ValidateVariantAutoscalingUniqueness

func ValidateVariantAutoscalingUniqueness(namespace, modelId, acc string, crClient client.Client)

ValidateVariantAutoscalingUniqueness checks if the VariantAutoscaling configuration is unique within the namespace

func VerifyPortForwardReadiness

func VerifyPortForwardReadiness(ctx context.Context, localPort int, request string) error

Types

type MockPromAPI

type MockPromAPI struct {
	QueryResults map[string]model.Value
	QueryErrors  map[string]error
}

MockPromAPI is a mock implementation of promv1.API for testing

func (*MockPromAPI) AlertManagers

func (m *MockPromAPI) AlertManagers(ctx context.Context) (promv1.AlertManagersResult, error)

func (*MockPromAPI) Alerts

func (m *MockPromAPI) Alerts(ctx context.Context) (promv1.AlertsResult, error)

func (*MockPromAPI) Buildinfo

func (m *MockPromAPI) Buildinfo(ctx context.Context) (promv1.BuildinfoResult, error)

func (*MockPromAPI) CleanTombstones

func (m *MockPromAPI) CleanTombstones(ctx context.Context) error

func (*MockPromAPI) Config

func (m *MockPromAPI) Config(ctx context.Context) (promv1.ConfigResult, error)

func (*MockPromAPI) DeleteSeries

func (m *MockPromAPI) DeleteSeries(ctx context.Context, matches []string, startTime, endTime time.Time) error

func (*MockPromAPI) Flags

func (*MockPromAPI) GetValue

func (m *MockPromAPI) GetValue(ctx context.Context, timestamp time.Time, opts ...promv1.Option) (model.Value, promv1.Warnings, error)

func (*MockPromAPI) LabelNames

func (m *MockPromAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...promv1.Option) ([]string, promv1.Warnings, error)

func (*MockPromAPI) LabelValues

func (m *MockPromAPI) LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time, opts ...promv1.Option) (model.LabelValues, promv1.Warnings, error)

func (*MockPromAPI) Metadata

func (m *MockPromAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]promv1.Metadata, error)

func (*MockPromAPI) Query

func (m *MockPromAPI) Query(ctx context.Context, query string, ts time.Time, opts ...promv1.Option) (model.Value, promv1.Warnings, error)

func (*MockPromAPI) QueryExemplars

func (m *MockPromAPI) QueryExemplars(ctx context.Context, query string, startTime, endTime time.Time) ([]promv1.ExemplarQueryResult, error)

func (*MockPromAPI) QueryRange

func (m *MockPromAPI) QueryRange(ctx context.Context, query string, r promv1.Range, opts ...promv1.Option) (model.Value, promv1.Warnings, error)

func (*MockPromAPI) Rules

func (*MockPromAPI) Runtimeinfo

func (m *MockPromAPI) Runtimeinfo(ctx context.Context) (promv1.RuntimeinfoResult, error)

func (*MockPromAPI) Series

func (m *MockPromAPI) Series(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...promv1.Option) ([]model.LabelSet, promv1.Warnings, error)

func (*MockPromAPI) Snapshot

func (m *MockPromAPI) Snapshot(ctx context.Context, skipHead bool) (promv1.SnapshotResult, error)

func (*MockPromAPI) TSDB

func (m *MockPromAPI) TSDB(ctx context.Context, opts ...promv1.Option) (promv1.TSDBResult, error)

func (*MockPromAPI) Targets

func (m *MockPromAPI) Targets(ctx context.Context) (promv1.TargetsResult, error)

func (*MockPromAPI) TargetsMetadata

func (m *MockPromAPI) TargetsMetadata(ctx context.Context, matchTarget, metric, limit string) ([]promv1.MetricMetadata, error)

func (*MockPromAPI) WalReplay

func (m *MockPromAPI) WalReplay(ctx context.Context) (promv1.WalReplayStatus, error)

type PrometheusClient

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

PrometheusClient wraps the official Prometheus client

func NewPrometheusClient

func NewPrometheusClient(baseURL string, insecureSkipVerify bool) (*PrometheusClient, error)

creates a new Prometheus client for e2e tests

func (*PrometheusClient) QueryWithRetry

func (p *PrometheusClient) QueryWithRetry(ctx context.Context, query string) (float64, error)

QueryWithRetry queries Prometheus API with retries and returns the metric value

type PrometheusQueryResult

type PrometheusQueryResult struct {
	Status string `json:"status"`
	Data   struct {
		ResultType string `json:"resultType"`
		Result     []struct {
			Metric map[string]string `json:"metric"`
			Value  []any             `json:"value"`
		} `json:"result"`
	} `json:"data"`
}

PrometheusQueryResult represents the response from Prometheus API

Jump to

Keyboard shortcuts

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