loadtest

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

Load testing Cluster controller

Load test requires 3 components:

  • Test server that simulates cluster-hub and the scenarios.
  • Kwok controller to simulate nodes/pods
  • Cluster controller itself.

Right now this is extremely basic and you have to run those manually locally.

Start kwok:

 kwok --kubeconfig=~/.kube/config \
    --manage-all-nodes=false \
    --manage-nodes-with-annotation-selector=kwok.x-k8s.io/node=fake-node \
    --node-lease-duration-seconds=40 \
    --cidr=10.0.0.1/24 \
    --node-ip=10.0.0.1

Run the test server on port 8080 against your current kubeconfig context:

KUBECONFIG=~/.kube/config PORT=8080 go run . test-server

After starting, start cluster controller with some dummy values and point it to the test server:

API_KEY=dummy API_URL=http://localhost:8080 CLUSTER_ID=D30A163C-C5DF-4CC8-985C-D1449398295E KUBECONFIG=~/.kube/config LOG_LEVEL=4 LEADER_ELECTION_NAMESPACE=default METRICS_ENABLED=true go run .                     

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpServer

func NewHttpServer(ctx context.Context, cfg Config, testServer *CastAITestServer) error

Types

type CastAITestServer

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

CastAITestServer acts as simple cluster hub mock replacement. It exposes a way to "push" actions to the cluster controller via GetActionsPushChannel and can be used as an implementation of the server interface that cluster controller expects to call.

func NewTestServer

func NewTestServer(logger *slog.Logger, cfg TestServerConfig) *CastAITestServer

func (*CastAITestServer) AckAction

func (c *CastAITestServer) AckAction(ctx context.Context, actionID string, req *castai.AckClusterActionRequest) error

func (*CastAITestServer) ExecuteActions

func (c *CastAITestServer) ExecuteActions(ctx context.Context, actions []castai.ClusterAction)

ExecuteActions pushes the list of actions to the queue for cluster controller to process. This method returns when all actions are acked or context is cancelled.

func (*CastAITestServer) GetActions

func (c *CastAITestServer) GetActions(ctx context.Context, _ string) ([]*castai.ClusterAction, error)

func (*CastAITestServer) SendLog

func (c *CastAITestServer) SendLog(ctx context.Context, e *castai.LogEntry) error

type Config

type Config struct {
	// Port where the mock server to listen on.
	Port int

	// KubeConfig can point to a kubeconfig file. If empty, InCluster client will be assumed.
	KubeConfig string
}

Config for the HTTP server.

func GetConfig

func GetConfig() Config

type TestServerConfig

type TestServerConfig struct {
	// MaxActionsPerCall is the upper limit of actions to return in one CastAITestServer.GetActions call.
	MaxActionsPerCall int
	// TimeoutWaitingForActions controls how long to wait for at least 1 action to appear on server side.
	// This mimics CH behavior of not returning early if there are no pending actions and keeping the request "running".
	TimeoutWaitingForActions time.Duration
}

TestServerConfig has settings for the mock server instance.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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