Documentation
¶
Index ¶
- Constants
- func CreateResultsDir(testName, version string) (string, error)
- func CreateResultsFile(filename string) (*os.File, error)
- func CreateResultsFilename(ext, base string, plusEnabled bool) string
- func GenerateCPUPNG(resultsDir, inputFilename, outputFilename string) error
- func GenerateMemoryPNG(resultsDir, inputFilename, outputFilename string) error
- func GenerateRequestsPNG(resultsDir, inputFilename, outputFilename string) error
- func GenerateTTRPNG(resultsDir, inputFilename, outputFilename string) error
- func Get(url, address string, timeout time.Duration) (int, string, error)
- func GetCollectorPodName(resourceManager ResourceManager) (string, error)
- func GetFirstValueOfPrometheusVector(val model.Value) (float64, error)
- func GetReadyNGFPodNames(k8sClient client.Client, namespace, releaseName string, timeout time.Duration) ([]string, error)
- func InstallCollector() ([]byte, error)
- func InstallGatewayAPI(apiVersion string) ([]byte, error)
- func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error)
- func NewCSVResultsWriter(resultsDir, fileName string, resultHeaders ...string) (*os.File, *csv.Writer, error)
- func NewVegetaCSVEncoder(w io.Writer) vegeta.Encoder
- func PortForward(config *rest.Config, namespace, podName string, ports []string, ...) error
- func Post(url, address string, body io.Reader, timeout time.Duration) (*http.Response, error)
- func UninstallCollector(resourceManager ResourceManager) ([]byte, error)
- func UninstallGatewayAPI(apiVersion string) ([]byte, error)
- func UninstallNGF(cfg InstallationConfig, k8sClient client.Client) ([]byte, error)
- func UninstallPrometheus(rm ResourceManager) error
- func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error)
- func WriteContent(resultsFile *os.File, content string) error
- func WriteMetricsResults(resultsFile *os.File, metrics *Metrics) error
- func WritePrometheusMatrixToCSVFile(fileName string, value model.Value) error
- func WriteSystemInfoToFile(file *os.File, ci ClusterInfo, plus bool) error
- type ClusterInfo
- type InstallationConfig
- type LoadTestConfig
- type Metrics
- type PrometheusConfig
- type PrometheusInstance
- func (ins *PrometheusInstance) PortForward(config *rest.Config, stopCh <-chan struct{}) error
- func (ins *PrometheusInstance) Query(query string) (model.Value, error)
- func (ins *PrometheusInstance) QueryRange(query string, promRange v1.Range) (model.Value, error)
- func (ins *PrometheusInstance) QueryRangeWithCtx(ctx context.Context, query string, promRange v1.Range) (model.Value, error)
- func (ins *PrometheusInstance) QueryWithCtx(ctx context.Context, query string) (model.Value, error)
- type ResourceManager
- func (rm *ResourceManager) Apply(resources []client.Object) error
- func (rm *ResourceManager) ApplyFromFiles(files []string, namespace string) error
- func (rm *ResourceManager) Delete(resources []client.Object, opts ...client.DeleteOption) error
- func (rm *ResourceManager) DeleteFromFiles(files []string, namespace string) error
- func (rm *ResourceManager) DeleteNamespace(name string) error
- func (rm *ResourceManager) GetClusterInfo() (ClusterInfo, error)
- func (rm *ResourceManager) GetFileContents(file string) (*bytes.Buffer, error)
- func (rm *ResourceManager) GetLBIPAddress(namespace string) (string, error)
- func (rm *ResourceManager) GetNGFDeployment(namespace, releaseName string) (*apps.Deployment, error)
- func (rm *ResourceManager) GetPod(namespace, name string) (*core.Pod, error)
- func (rm *ResourceManager) GetPodLogs(namespace, name string, opts *core.PodLogOptions) (string, error)
- func (rm *ResourceManager) GetPodNames(namespace string, labels client.MatchingLabels) ([]string, error)
- func (rm *ResourceManager) GetPods(namespace string, labels client.MatchingLabels) ([]core.Pod, error)
- func (rm *ResourceManager) ScaleDeployment(namespace, name string, replicas int32) error
- func (rm *ResourceManager) WaitForAppsToBeReady(namespace string) error
- func (rm *ResourceManager) WaitForAppsToBeReadyWithCtx(ctx context.Context, namespace string) error
- func (rm *ResourceManager) WaitForAppsToBeReadyWithCtxWithPodCount(ctx context.Context, namespace string, podCount int) error
- func (rm *ResourceManager) WaitForAppsToBeReadyWithPodCount(namespace string, podCount int) error
- func (rm *ResourceManager) WaitForGatewayObservedGeneration(ctx context.Context, namespace, name string, generation int) error
- func (rm *ResourceManager) WaitForPodsToBeReady(ctx context.Context, namespace string) error
- func (rm *ResourceManager) WaitForPodsToBeReadyWithCount(ctx context.Context, namespace string, count int) error
- type ScaleObjects
- type Target
- type TimeoutConfig
Constants ¶
const (
CollectorNamespace = "collector"
)
const (
// PrometheusPortForwardPort is the local port that will forward to the Prometheus API.
PrometheusPortForwardPort = 9090
)
Variables ¶
This section is empty.
Functions ¶
func CreateResultsDir ¶
CreateResultsDir creates and returns the name of the results directory for a test.
func CreateResultsFile ¶
CreateResultsFile creates and returns the results file for a test.
func CreateResultsFilename ¶
CreateResultsFilename returns the name of the results file.
func GenerateCPUPNG ¶
GenerateCPUPNG generates a CPU usage PNG using gnuplot.
func GenerateMemoryPNG ¶
GenerateMemoryPNG generates a Memory usage PNG using gnuplot.
func GenerateRequestsPNG ¶
GenerateRequestsPNG generates a Requests PNG using gnuplot.
func GenerateTTRPNG ¶
GenerateTTRPNG generates a TTR PNG using gnuplot.
func Get ¶
Get sends a GET request to the specified url. It resolves to the specified address instead of using DNS. The status and body of the response is returned, or an error.
func GetCollectorPodName ¶
func GetCollectorPodName(resourceManager ResourceManager) (string, error)
GetCollectorPodName returns the name of the collector Pod.
func GetFirstValueOfPrometheusVector ¶
GetFirstValueOfPrometheusVector returns the first value of a Prometheus vector.
func GetReadyNGFPodNames ¶
func GetReadyNGFPodNames( k8sClient client.Client, namespace, releaseName string, timeout time.Duration, ) ([]string, error)
GetReadyNGFPodNames returns the name(s) of the NGF Pod(s).
func InstallCollector ¶
InstallCollector installs the otel-collector.
func InstallGatewayAPI ¶
InstallGatewayAPI installs the specified version of the Gateway API resources.
func InstallNGF ¶
func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error)
InstallNGF installs NGF.
func NewCSVResultsWriter ¶
func NewCSVResultsWriter(resultsDir, fileName string, resultHeaders ...string) (*os.File, *csv.Writer, error)
NewCSVResultsWriter creates and returns a CSV results file and writer.
func NewVegetaCSVEncoder ¶
NewVegetaCSVEncoder returns a vegeta CSV encoder.
func PortForward ¶
func PortForward(config *rest.Config, namespace, podName string, ports []string, stopCh <-chan struct{}) error
PortForward starts a port-forward to the specified Pod.
func Post ¶
Post sends a POST request to the specified url with the body as the payload. It resolves to the specified address instead of using DNS.
func UninstallCollector ¶
func UninstallCollector(resourceManager ResourceManager) ([]byte, error)
UninstallCollector uninstalls the otel-collector.
func UninstallGatewayAPI ¶
UninstallGatewayAPI uninstalls the specified version of the Gateway API resources.
func UninstallNGF ¶
func UninstallNGF(cfg InstallationConfig, k8sClient client.Client) ([]byte, error)
UninstallNGF uninstalls NGF.
func UninstallPrometheus ¶
func UninstallPrometheus(rm ResourceManager) error
UninstallPrometheus uninstalls Prometheus from the cluster.
func UpgradeNGF ¶
func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error)
UpgradeNGF upgrades NGF. CRD upgrades assume the chart is local.
func WriteContent ¶
WriteContent writes basic content to the results file.
func WriteMetricsResults ¶
WriteMetricsResults writes the metrics results to the results file in text format.
func WritePrometheusMatrixToCSVFile ¶
WritePrometheusMatrixToCSVFile writes a Prometheus matrix to a CSV file.
func WriteSystemInfoToFile ¶
func WriteSystemInfoToFile(file *os.File, ci ClusterInfo, plus bool) error
WriteSystemInfoToFile writes the cluster system info to the given file.
Types ¶
type ClusterInfo ¶
type ClusterInfo struct { K8sVersion string // ID is the UID of kube-system namespace ID string MemoryPerNode string GkeInstanceType string GkeZone string NodeCount int CPUCountPerNode int64 MaxPodsPerNode int64 IsGKE bool }
ClusterInfo holds the cluster metadata.
type InstallationConfig ¶
type InstallationConfig struct { ReleaseName string Namespace string ChartPath string NgfImageRepository string NginxImageRepository string ImageTag string ImagePullPolicy string ServiceType string IsGKEInternalLB bool Plus bool }
InstallationConfig contains the configuration for the NGF installation.
type LoadTestConfig ¶
type LoadTestConfig struct { Description string Proxy string ServerName string Targets []Target Rate int Duration time.Duration }
LoadTestConfig is the configuration to run a load test.
type Metrics ¶
Metrics is a wrapper around the vegeta Metrics.
func RunLoadTest ¶
func RunLoadTest(cfg LoadTestConfig) (vegeta.Results, Metrics)
RunLoadTest uses Vegeta to send traffic to the provided Targets at the given rate for the given duration and writes the results to the provided file.
type PrometheusConfig ¶
type PrometheusConfig struct { // ScrapeInterval is the interval at which Prometheus scrapes metrics. ScrapeInterval time.Duration // QueryTimeout is the timeout for Prometheus queries. // Default is 2s. QueryTimeout time.Duration }
PrometheusConfig is the configuration for installing Prometheus.
type PrometheusInstance ¶
type PrometheusInstance struct {
// contains filtered or unexported fields
}
PrometheusInstance represents a Prometheus instance in the cluster.
func InstallPrometheus ¶
func InstallPrometheus( rm ResourceManager, cfg PrometheusConfig, ) (PrometheusInstance, error)
InstallPrometheus installs Prometheus in the cluster. It waits for Prometheus pods to be ready before returning.
func (*PrometheusInstance) PortForward ¶
func (ins *PrometheusInstance) PortForward(config *rest.Config, stopCh <-chan struct{}) error
PortForward starts port forwarding to the Prometheus instance.
func (*PrometheusInstance) Query ¶
func (ins *PrometheusInstance) Query(query string) (model.Value, error)
Query sends a query to Prometheus.
func (*PrometheusInstance) QueryRange ¶
QueryRange sends a range query to Prometheus.
func (*PrometheusInstance) QueryRangeWithCtx ¶
func (ins *PrometheusInstance) QueryRangeWithCtx(ctx context.Context, query string, promRange v1.Range, ) (model.Value, error)
QueryRangeWithCtx sends a range query to Prometheus with the specified context.
func (*PrometheusInstance) QueryWithCtx ¶
QueryWithCtx sends a query to Prometheus with the specified context.
type ResourceManager ¶
type ResourceManager struct { K8sClient client.Client ClientGoClient kubernetes.Interface // used when k8sClient is not enough FS embed.FS TimeoutConfig TimeoutConfig }
ResourceManager handles creating/updating/deleting Kubernetes resources.
func (*ResourceManager) Apply ¶
func (rm *ResourceManager) Apply(resources []client.Object) error
Apply creates or updates Kubernetes resources defined as Go objects.
func (*ResourceManager) ApplyFromFiles ¶
func (rm *ResourceManager) ApplyFromFiles(files []string, namespace string) error
ApplyFromFiles creates or updates Kubernetes resources defined within the provided YAML files.
func (*ResourceManager) Delete ¶
func (rm *ResourceManager) Delete(resources []client.Object, opts ...client.DeleteOption) error
Delete deletes Kubernetes resources defined as Go objects.
func (*ResourceManager) DeleteFromFiles ¶
func (rm *ResourceManager) DeleteFromFiles(files []string, namespace string) error
DeleteFromFiles deletes Kubernetes resources defined within the provided YAML files.
func (*ResourceManager) DeleteNamespace ¶
func (rm *ResourceManager) DeleteNamespace(name string) error
func (*ResourceManager) GetClusterInfo ¶
func (rm *ResourceManager) GetClusterInfo() (ClusterInfo, error)
GetClusterInfo retrieves node info and Kubernetes version from the cluster.
func (*ResourceManager) GetFileContents ¶
func (rm *ResourceManager) GetFileContents(file string) (*bytes.Buffer, error)
GetFileContents takes a string that can either be a local file path or an https:// URL to YAML manifests and provides the contents.
func (*ResourceManager) GetLBIPAddress ¶
func (rm *ResourceManager) GetLBIPAddress(namespace string) (string, error)
GetLBIPAddress gets the IP or Hostname from the Loadbalancer service.
func (*ResourceManager) GetNGFDeployment ¶
func (rm *ResourceManager) GetNGFDeployment(namespace, releaseName string) (*apps.Deployment, error)
GetNGFDeployment returns the NGF Deployment in the specified namespace with the given release name.
func (*ResourceManager) GetPod ¶
func (rm *ResourceManager) GetPod(namespace, name string) (*core.Pod, error)
GetPod returns the Pod in the specified namespace with the given name.
func (*ResourceManager) GetPodLogs ¶
func (rm *ResourceManager) GetPodLogs(namespace, name string, opts *core.PodLogOptions) (string, error)
GetPodLogs returns the logs from the specified Pod.
func (*ResourceManager) GetPodNames ¶
func (rm *ResourceManager) GetPodNames(namespace string, labels client.MatchingLabels) ([]string, error)
GetPodNames returns the names of all Pods in the specified namespace that match the given labels.
func (*ResourceManager) GetPods ¶
func (rm *ResourceManager) GetPods(namespace string, labels client.MatchingLabels) ([]core.Pod, error)
GetPods returns all Pods in the specified namespace that match the given labels.
func (*ResourceManager) ScaleDeployment ¶
func (rm *ResourceManager) ScaleDeployment(namespace, name string, replicas int32) error
ScaleDeployment scales the Deployment to the specified number of replicas.
func (*ResourceManager) WaitForAppsToBeReady ¶
func (rm *ResourceManager) WaitForAppsToBeReady(namespace string) error
WaitForAppsToBeReady waits for all apps in the specified namespace to be ready, or until the ctx timeout is reached.
func (*ResourceManager) WaitForAppsToBeReadyWithCtx ¶
func (rm *ResourceManager) WaitForAppsToBeReadyWithCtx(ctx context.Context, namespace string) error
WaitForAppsToBeReadyWithCtx waits for all apps in the specified namespace to be ready or until the provided context is canceled.
func (*ResourceManager) WaitForAppsToBeReadyWithCtxWithPodCount ¶
func (*ResourceManager) WaitForAppsToBeReadyWithPodCount ¶
func (rm *ResourceManager) WaitForAppsToBeReadyWithPodCount(namespace string, podCount int) error
func (*ResourceManager) WaitForGatewayObservedGeneration ¶
func (rm *ResourceManager) WaitForGatewayObservedGeneration( ctx context.Context, namespace, name string, generation int, ) error
WaitForGatewayObservedGeneration waits for the provided Gateway's ObservedGeneration to equal the expected value.
func (*ResourceManager) WaitForPodsToBeReady ¶
func (rm *ResourceManager) WaitForPodsToBeReady(ctx context.Context, namespace string) error
WaitForPodsToBeReady waits for all Pods in the specified namespace to be ready or until the provided context is canceled.
func (*ResourceManager) WaitForPodsToBeReadyWithCount ¶
func (rm *ResourceManager) WaitForPodsToBeReadyWithCount(ctx context.Context, namespace string, count int) error
WaitForPodsToBeReady waits for all Pods in the specified namespace to be ready or until the provided context is canceled.
type ScaleObjects ¶
type ScaleObjects struct { // BaseObjects contains objects that are common to all scale iterations. BaseObjects []client.Object // ScaleIterationGroups contains objects for each scale iteration. ScaleIterationGroups [][]client.Object }
ScaleObjects contains objects for scale testing.
func GenerateScaleHTTPRouteObjects ¶
func GenerateScaleHTTPRouteObjects(numRoutes int) (ScaleObjects, error)
GenerateScaleHTTPRouteObjects generates objects for a given number of routes for the scale test.
func GenerateScaleListenerObjects ¶
func GenerateScaleListenerObjects(numListeners int, tls bool) (ScaleObjects, error)
GenerateScaleListenerObjects generates objects for a given number of listeners for the scale test.
type TimeoutConfig ¶
type TimeoutConfig struct { // CreateTimeout represents the maximum time for a Kubernetes object to be created. CreateTimeout time.Duration // UpdateTimeout represents the maximum time for a Kubernetes object to be updated. UpdateTimeout time.Duration // DeleteTimeout represents the maximum time for a Kubernetes object to be deleted. DeleteTimeout time.Duration // DeleteNamespaceTimeout represents the maximum time for a Kubernetes namespace to be deleted. DeleteNamespaceTimeout time.Duration // GetTimeout represents the maximum time to get a Kubernetes object. GetTimeout time.Duration // ManifestFetchTimeout represents the maximum time for getting content from a https:// URL. ManifestFetchTimeout time.Duration // RequestTimeout represents the maximum time for making an HTTP Request with the roundtripper. RequestTimeout time.Duration // ContainerRestartTimeout represents the maximum time for a Kubernetes Container to restart. ContainerRestartTimeout time.Duration // GetLeaderLeaseTimeout represents the maximum time for NGF to retrieve the leader lease. GetLeaderLeaseTimeout time.Duration // GetStatusTimeout represents the maximum time for NGF to update the status of a resource. GetStatusTimeout time.Duration }
func DefaultTimeoutConfig ¶
func DefaultTimeoutConfig() TimeoutConfig
DefaultTimeoutConfig populates a TimeoutConfig with the default values.