cloud

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SetupError      = ErrorCode(8030)
	TeardownError   = ErrorCode(8031)
	OOMError        = ErrorCode(8032)
	PanicError      = ErrorCode(8033)
	UnknownError    = ErrorCode(8034)
	ScriptException = ErrorCode(8035)

	K6OperatorStartError  = ErrorCode(8050)
	K6OperatorAbortError  = ErrorCode(8051)
	K6OperatorRunnerError = ErrorCode(8052)
)
View Source
var (
	OriginUser = Origin("user")
	OriginK6   = Origin("k6")
)

Functions

func AggregationEnvVars added in v1.0.0

func AggregationEnvVars(runtimeConfig *cloudapi.Config) []corev1.EnvVar

AggregationEnvVars is a quick shortcut to encode-decode all at once, for times when we don't care to store aggregation env vars anywhere.

func ApiURL added in v0.0.10

func ApiURL(k6CloudHostEnvVar string) string

temporary hack!

func CreateTestRun

func CreateTestRun(opts InspectOutput, instances int32, host, token string, log logr.Logger) (*cloudapi.CreateTestRunResponse, error)

func DeRegisterPLZ added in v0.0.10

func DeRegisterPLZ(client *cloudapi.Client, name string) error

func DecodeAggregationConfig added in v0.0.10

func DecodeAggregationConfig(encoded string) ([]corev1.EnvVar, error)

func EncodeAggregationConfig added in v0.0.10

func EncodeAggregationConfig(runtimeConfig *cloudapi.Config) string

func FinishTestRun

func FinishTestRun(c *cloudapi.Client, refID string) error

func K6CloudHost added in v0.0.21

func K6CloudHost() string

func NewClient added in v0.0.10

func NewClient(log logr.Logger, token, host string) *cloudapi.Client

func RegisterPLZ added in v0.0.10

func RegisterPLZ(client *cloudapi.Client, data PLZRegistrationData) error

func SendTestRunEvents added in v0.0.12

func SendTestRunEvents(client *cloudapi.Client, refID string, log logr.Logger, events *Events)

called by TestRun controller If there's an error, it'll be logged.

Types

type ErrorCode added in v0.0.12

type ErrorCode uint

type Event added in v0.0.12

type Event struct {
	Origin    `json:"origin,omitempty"`
	ErrorCode `json:"error_code,omitempty"`

	// reason is used for abort events,
	// while details are for any non-abort event
	Reason       string `json:"reason,omitempty"`
	Detail       string `json:"error_detail,omitempty"`
	PublicDetail string `json:"error_detail_public,omitempty"`
}

type EventPayload added in v0.0.12

type EventPayload struct {
	EventType `json:"event_type"`
	Event     `json:"event"`
}

func AbortEvent added in v0.0.12

func AbortEvent(o Origin) *EventPayload

type EventType added in v0.0.12

type EventType string

type Events added in v0.0.12

type Events []*EventPayload

func ErrorEvent added in v0.0.12

func ErrorEvent(ec ErrorCode) *Events

func (*Events) WithAbort added in v0.0.12

func (e *Events) WithAbort() *Events

WithAbort adds abortEvent to errorEvent if it already exists.

func (*Events) WithDetail added in v0.0.12

func (e *Events) WithDetail(s string) *Events

WithDetail sets detail only for the 1st event. If it's abort, WithDetail sets reason field.

type InspectOutput

type InspectOutput struct {
	External struct {
		Loadimpact struct {
			Name      string `json:"name"`
			ProjectID int64  `json:"projectID"`
		} `json:"loadimpact"`
	} `json:"ext"`
	Cloud struct {
		Name      string `json:"name"`
		ProjectID int64  `json:"projectID"`
	} `json:"cloud"`
	TotalDuration types.NullDuration             `json:"totalDuration"`
	MaxVUs        uint64                         `json:"maxVUs"`
	Thresholds    map[string]*metrics.Thresholds `json:"thresholds,omitempty"`
}

InspectOutput is the parsed output from `k6 inspect --execution-requirements`.

func (*InspectOutput) ProjectID added in v0.0.14

func (io *InspectOutput) ProjectID() int64

ProjectID returns the project ID from the inspect output.

func (*InspectOutput) SetTestName added in v0.0.14

func (io *InspectOutput) SetTestName(name string)

SetTestName sets the name in the inspect output.

func (*InspectOutput) TestName added in v0.0.14

func (io *InspectOutput) TestName() string

TestName returns the test name from the inspect output.

type LZConfig added in v0.0.10

type LZConfig struct {
	RunnerImage   string            `json:"load_runner_image,omitempty"`
	InstanceCount int               `json:"instance_count,omitempty"`
	ArchiveURL    string            `json:"k6_archive_temp_public_url,omitempty"`
	Environment   map[string]string `json:"environment,omitempty"`
}

func (*LZConfig) EnvVars added in v0.0.16

func (lz *LZConfig) EnvVars() []corev1.EnvVar

type Origin added in v0.0.12

type Origin string

type PLZRegistrationData added in v0.0.10

type PLZRegistrationData struct {
	// defined by user as `name`
	LoadZoneID string       `json:"k6_load_zone_id"`
	Resources  PLZResources `json:"pod_tiers"`

	LZConfig `json:"config"`

	// Unique identifier of PLZ, generated by k6-operator
	// during PLZ registration. It's purpose is to distinguish
	// between PLZs with accidentally duplicate names.
	UID string `json:"provider_id"`
}

PLZRegistrationData holds info that needs to be sent to /v1/load-zones

type PLZResources added in v0.0.10

type PLZResources struct {
	CPU    string `json:"cpu"`
	Memory string `json:"memory"`
}

type TestRun

type TestRun struct {
	Name              string              `json:"name"`
	ProjectID         int64               `json:"project_id,omitempty"`
	VUsMax            int64               `json:"vus"`
	Thresholds        map[string][]string `json:"thresholds"`
	Duration          int64               `json:"duration"`
	ProcessThresholds bool                `json:"process_thresholds"`
	Instances         int32               `json:"instances"`
}

type TestRunData added in v0.0.10

type TestRunData struct {
	TestRunId     int `json:"id"`
	Instances     int `json:"instances"`
	LZConfig      `json:"k8s_load_zones_config"`
	RunStatus     cloudapi.RunStatus `json:"run_status"`
	RuntimeConfig cloudapi.Config    `json:"k6_runtime_config"`
}

TestRunData holds the output from /loadtests/v4/test_runs(%s)

func GetTestRunData added in v0.0.10

func GetTestRunData(client *cloudapi.Client, refID string) (*TestRunData, error)

called by PLZworker

func (*TestRunData) TestRunID added in v0.0.10

func (trd *TestRunData) TestRunID() string

type TestRunPoller added in v0.0.10

type TestRunPoller struct {
	*conn.Poller

	Client *cloudapi.Client
	// contains filtered or unexported fields
}

func NewTestRunPoller added in v0.0.10

func NewTestRunPoller(host, token, plzName string, logger logr.Logger) *TestRunPoller

func (*TestRunPoller) GetTestRuns added in v0.0.10

func (poller *TestRunPoller) GetTestRuns() chan string

type TestRunStatus added in v0.0.10

type TestRunStatus cloudapi.RunStatus

func GetTestRunState added in v0.0.10

func GetTestRunState(client *cloudapi.Client, refID string, log logr.Logger) (TestRunStatus, error)

called by TestRun controller

func (TestRunStatus) Aborted added in v0.0.10

func (trs TestRunStatus) Aborted() bool

type TokenInfo added in v0.0.23

type TokenInfo struct {

	// Ready shows whether token was loaded yet or there should be a retry.
	// If it's false, either there was no attempt to load the token or there was
	// an attempt that ended in a recoverable error, and a caller should try again.
	Ready bool
	// contains filtered or unexported fields
}

k6-operator has to handle authentication tokens for Cloud tests. This struct contains key utilities to encapsulate that logic.

func NewTokenInfo added in v0.0.23

func NewTokenInfo(name, namespace string) *TokenInfo

func (*TokenInfo) InjectValue added in v0.0.23

func (ti *TokenInfo) InjectValue(v string) *TokenInfo

InjectValue: this is only for unit tests! If you see it elsewhere, it's likely a bug or an attack.

func (*TokenInfo) Load added in v0.0.23

func (ti *TokenInfo) Load(ctx context.Context, log logr.Logger, c k8sClient.Client) (returnErr error)

Load attempts to load the Secret and populate TokenInfo. returnErr means a non-recoverable error and requires the caller to take action or propagate it further.

func (TokenInfo) SecretName added in v0.0.23

func (ti TokenInfo) SecretName() string

func (TokenInfo) Value added in v0.0.23

func (ti TokenInfo) Value() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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