Documentation ¶
Index ¶
- Constants
- func ChannelIsOpen(ch <-chan struct{}) bool
- func EnterIdleState(stopChan chan os.Signal)
- func InformerSynced(syncFunc func() bool, informerName string) error
- func MetaNameIndexFunc(obj interface{}) ([]string, error)
- func NewK8sClient() (*clientset.Clientset, error)
- func RecordFirstSuccessfulRequest(target *TargetSpec, stopChan chan os.Signal, ...)
- func Retry(attempts int, backoff time.Duration, fn func() error) error
- func ShutDownMetricsServer(ctx context.Context, metricsServer *http.Server)
- func VerifyHostConfig(hostConfig *HostConfig) error
- func VerifyTargetConfig(targetConfig *TargetConfig) error
- type BaseTestClientConfig
- type BoolMapWithLock
- type HostConfig
- type PodEvent
- type TargetConfig
- type TargetSpec
- type TimeMapWithLock
- type TimeWithLock
Constants ¶
const ( NameIndex = "name" MaxRetryBackoff = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func ChannelIsOpen ¶
func ChannelIsOpen(ch <-chan struct{}) bool
ChannelIsOpen checks if the specified channel is open.
func EnterIdleState ¶
EnterIdleState is used for preventing the pod from exiting after the test is completed, because it then gets restarted. The test client enters the idle state as soon as it has finished the setup and has run the test goroutines.
func InformerSynced ¶
InformerSynced verifies that the provided sync function is successful.
func MetaNameIndexFunc ¶
MetaNameIndexFunc is an index function that indexes based on object's name.
func NewK8sClient ¶
NewK8sClient returns a K8s client for the K8s cluster where this application runs inside a pod.
func RecordFirstSuccessfulRequest ¶
func RecordFirstSuccessfulRequest(target *TargetSpec, stopChan chan os.Signal, successFunc func(*TargetSpec, time.Time))
RecordFirstSuccessfulRequest sends curl requests continuously to the provided target IP and target port from the test client config, at 1 second intervals, until the first successful response. It records the latency between the provided start time in the targetSpec, and the time of the first successful response.
func Retry ¶
Retry runs a function until it succeeds, with specified number of attempts and base for exponential backoff.
func ShutDownMetricsServer ¶
ShutDownMetricsServer stops the specified metrics server.
func VerifyHostConfig ¶
func VerifyHostConfig(hostConfig *HostConfig) error
VerifyHostConfig ensures that host configuration is valid.
func VerifyTargetConfig ¶
func VerifyTargetConfig(targetConfig *TargetConfig) error
VerifyTargetConfig ensures that target configuration is valid.
Types ¶
type BaseTestClientConfig ¶
type BaseTestClientConfig struct { HostConfig *HostConfig TargetConfig *TargetConfig MainStopChan chan os.Signal MetricsServer *http.Server K8sClient *clientset.Clientset }
BaseTestClientConfig contains the common configuration required for a test client to run.
func CreateBaseTestClientConfig ¶
func CreateBaseTestClientConfig(stopChan chan os.Signal) (*BaseTestClientConfig, error)
CreateBaseTestClientConfig creates base test client configuration based on command-line flags. It parses the flags with "flag.Parse()". All flags need to be defined before calling this function.
type HostConfig ¶
type HostConfig struct { // HostNamespace is the namespace of test client pods. HostNamespace string // MetricsPort is the port number where Prometheus metrics are exposed. MetricsPort int }
HostConfig holds information about the pod specification where the application runs.
type TargetConfig ¶
type TargetConfig struct { // TargetLabelSelector is the label selector of target pods to send requests // to. TargetLabelSelector string // TargetNamespace is the namespace of target pods to send requests to. TargetNamespace string // TargetPort is the port number of target pods to send requests to. TargetPort int // MaxTargets is the maximum number of target pods to send requests to. MaxTargets int }
TargetConfig is configuration for target pods.