cloud

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 13 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 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(testRun *cloudapi.Config) string

func FinishTestRun

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

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"`
	InstanceCount int    `json:"instance_count"`
	ArchiveURL    string `json:"k6_archive_temp_public_url"`
}

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"`
	// 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 PLZ controller

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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