framework

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateResultsDir added in v1.2.0

func CreateResultsDir(testName, version string) (string, error)

CreateResultsDir creates and returns the name of the results directory for a test.

func CreateResultsFile added in v1.2.0

func CreateResultsFile(filename string) (*os.File, error)

CreateResultsFile creates and returns the results file for a test.

func CreateResultsFilename added in v1.2.0

func CreateResultsFilename(ext, base string, plusEnabled bool) string

CreateResultsFilename returns the name of the results file.

func GeneratePNG added in v1.2.0

func GeneratePNG(resultsDir, inputFilename, outputFilename string) ([]byte, error)

GeneratePNG generates a PNG using gnuplot.

func Get

func Get(url, address string, timeout time.Duration) (int, string, error)

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 GetReadyNGFPodNames added in v1.2.0

func GetReadyNGFPodNames(
	k8sClient client.Client,
	namespace,
	releaseName string,
	timeout time.Duration,
) ([]string, error)

GetReadyNGFPodNames returns the name(s) of the NGF Pod(s).

func InstallGatewayAPI

func InstallGatewayAPI(
	k8sClient client.Client,
	apiVersion,
	k8sVersion string,
) ([]byte, error)

InstallGatewayAPI installs the specified version of the Gateway API resources.

func InstallNGF

func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error)

InstallNGF installs NGF.

func NewCSVEncoder added in v1.2.0

func NewCSVEncoder(w io.Writer) vegeta.Encoder

NewCSVEncoder returns a vegeta CSV encoder.

func PortForward

func PortForward(config *rest.Config, namespace, podName string, stopCh chan struct{}) (int, error)

PortForward starts a port-forward to the specified Pod and returns the local port being forwarded.

func UninstallGatewayAPI

func UninstallGatewayAPI(apiVersion, k8sVersion string) ([]byte, error)

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 UpgradeNGF added in v1.2.0

func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error)

UpgradeNGF upgrades NGF. CRD upgrades assume the chart is local.

func WriteContent added in v1.2.0

func WriteContent(resultsFile *os.File, content string) error

WriteContent writes basic content to the results file.

func WriteResults added in v1.2.0

func WriteResults(resultsFile *os.File, metrics *Metrics) error

WriteResults writes the vegeta metrics results to the results file in text format.

func WriteSystemInfoToFile added in v1.2.0

func WriteSystemInfoToFile(file *os.File, ci ClusterInfo, plus bool) error

WriteSystemInfoToFile writes the cluster system info to the given file.

Types

type ClusterInfo added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

type Metrics struct {
	vegeta.Metrics
}

Metrics is a wrapper around the vegeta Metrics.

func RunLoadTest added in v1.2.0

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 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) error

Delete deletes Kubernetes resources defined as Go objects.

func (*ResourceManager) DeleteFromFiles

func (rm *ResourceManager) DeleteFromFiles(files []string, namespace string) error

DeleteFromFile deletes Kubernetes resources defined within the provided YAML files.

func (*ResourceManager) GetClusterInfo added in v1.2.0

func (rm *ResourceManager) GetClusterInfo() (ClusterInfo, error)

GetClusterInfo retrieves node info and Kubernetes version from the cluster

func (*ResourceManager) GetLBIPAddress added in v1.2.0

func (rm *ResourceManager) GetLBIPAddress(namespace string) (string, error)

GetLBIPAddress gets the IP or Hostname from the Loadbalancer service.

func (*ResourceManager) GetNGFDeployment added in v1.2.0

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) GetPodLogs added in v1.2.0

func (rm *ResourceManager) GetPodLogs(namespace, name string, opts *core.PodLogOptions) (string, error)

GetPodLogs returns the logs from the specified Pod

func (*ResourceManager) GetPodNames added in v1.2.0

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) 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.

type Target added in v1.2.0

type Target struct {
	Header http.Header
	Method string
	URL    string
	Body   []byte
}

type TimeoutConfig

type TimeoutConfig struct {
	// CreateTimeout represents the maximum time for a Kubernetes object to be created.
	CreateTimeout time.Duration

	// DeleteTimeout represents the maximum time for a Kubernetes object to be deleted.
	DeleteTimeout 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
}

func DefaultTimeoutConfig

func DefaultTimeoutConfig() TimeoutConfig

DefaultTimeoutConfig populates a TimeoutConfig with the default values.

Jump to

Keyboard shortcuts

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