Documentation
¶
Index ¶
- Variables
- func AggregationEnvVars(runtimeConfig *cloudapi.Config) []corev1.EnvVar
- func ApiURL(k6CloudHostEnvVar string) string
- func CreateTestRun(opts InspectOutput, instances int32, host, token string, log logr.Logger) (*cloudapi.CreateTestRunResponse, error)
- func DeRegisterPLZ(client *cloudapi.Client, name string) error
- func DecodeAggregationConfig(encoded string) ([]corev1.EnvVar, error)
- func EncodeAggregationConfig(runtimeConfig *cloudapi.Config) string
- func FinishTestRun(c *cloudapi.Client, refID string) error
- func K6CloudHost() string
- func NewClient(logger logr.Logger, token, host string) *cloudapi.Client
- func RegisterPLZ(client *cloudapi.Client, data PLZRegistrationData) error
- func SendTestRunEvents(client *cloudapi.Client, refID string, logger logr.Logger, events *Events)
- type ErrorCode
- type Event
- type EventPayload
- type EventType
- type Events
- type InspectOutput
- type LZConfig
- type Origin
- type PLZRegistrationData
- type PLZResources
- type TestRun
- type TestRunData
- type TestRunPoller
- type TestRunStatus
- type TokenInfo
Constants ¶
This section is empty.
Variables ¶
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) )
var ( OriginUser = Origin("user") OriginK6 = Origin("k6") )
Functions ¶
func AggregationEnvVars ¶ added in v1.0.0
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 CreateTestRun ¶
func CreateTestRun(opts InspectOutput, instances int32, host, token string, log logr.Logger) (*cloudapi.CreateTestRunResponse, error)
func DeRegisterPLZ ¶ added in v0.0.10
func DecodeAggregationConfig ¶ added in v0.0.10
func EncodeAggregationConfig ¶ added in v0.0.10
func K6CloudHost ¶ added in v0.0.21
func K6CloudHost() string
func NewClient ¶ added in v0.0.10
logger is currently unused, because of logrus dependency in cloudapi. This will have a re-visit during or after https://github.com/grafana/k6-operator/issues/571
func RegisterPLZ ¶ added in v0.0.10
func RegisterPLZ(client *cloudapi.Client, data PLZRegistrationData) error
Types ¶
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
func AbortEvent ¶ added in v0.0.12
func AbortEvent(o Origin) *EventPayload
type Events ¶ added in v0.0.12
type Events []*EventPayload
func ErrorEvent ¶ added in v0.0.12
func (*Events) WithAbort ¶ added in v0.0.12
WithAbort adds abortEvent to errorEvent if it already exists.
func (*Events) WithDetail ¶ added in v0.0.12
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 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 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
func GetTestRunState ¶ added in v0.0.10
func GetTestRunState(client *cloudapi.Client, refID string, logger logr.Logger) (TestRunStatus, error)
called by TestRun controller If there's an error, it'll be logged.
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 (*TokenInfo) InjectValue ¶ added in v0.0.23
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.