Skip to content

Commit

Permalink
adds support for full threshold syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mwain authored and yorugac committed Feb 3, 2023
1 parent d000520 commit 2d4c212
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/consts"
"go.k6.io/k6/lib/types"
"go.k6.io/k6/stats"
"gopkg.in/guregu/null.v3"
)

Expand All @@ -23,9 +24,9 @@ type InspectOutput struct {
ProjectID int64 `json:"projectID"`
} `json:"loadimpact"`
} `json:"ext"`
TotalDuration types.NullDuration `json:"totalDuration"`
MaxVUs uint64 `json:"maxVUs"`
Thresholds map[string][]string `json:"thresholds,omitempty"`
TotalDuration types.NullDuration `json:"totalDuration"`
MaxVUs uint64 `json:"maxVUs"`
Thresholds map[string]*stats.Thresholds `json:"thresholds,omitempty"`
}

type TestRun struct {
Expand Down Expand Up @@ -56,8 +57,11 @@ func CreateTestRun(opts InspectOutput, instances int32, host, token string, log
Level: logrus.InfoLevel,
}

if opts.Thresholds == nil {
opts.Thresholds = make(map[string][]string)
thresholds := make(map[string][]string, len(opts.Thresholds))
for name, t := range opts.Thresholds {
for _, threshold := range t.Thresholds {
thresholds[name] = append(thresholds[name], threshold.Source)
}
}

if len(host) == 0 {
Expand All @@ -69,7 +73,7 @@ func CreateTestRun(opts InspectOutput, instances int32, host, token string, log
Name: opts.External.Loadimpact.Name,
ProjectID: cloudConfig.ProjectID.Int64,
VUsMax: int64(opts.MaxVUs),
Thresholds: opts.Thresholds,
Thresholds: thresholds,
Duration: int64(opts.TotalDuration.TimeDuration().Seconds()),
ProcessThresholds: true,
Instances: instances,
Expand Down

0 comments on commit 2d4c212

Please sign in to comment.