Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat support k6 artillery triggers #3745

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/workers/trigger/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/kubeshop/tracetest/server/pkg/kafka"
"github.com/kubeshop/tracetest/agent/workers/trigger/kafka"
"go.opentelemetry.io/otel/propagation"
)

Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion agent/workers/trigger/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ func (t *traceidTriggerer) Type() TriggerType {
const TriggerTypeTraceID TriggerType = "traceid"
const TriggerTypeCypress TriggerType = "cypress"
const TriggerTypePlaywright TriggerType = "playwright"
const TriggerTypeArtillery TriggerType = "artillery"
const TriggerTypeK6 TriggerType = "k6"

var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress, TriggerTypePlaywright}
var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress, TriggerTypePlaywright, TriggerTypeArtillery, TriggerTypeK6}
var traceIDBasedIntegrationsTriggers = []TriggerType{TriggerTypeCypress, TriggerTypePlaywright, TriggerTypeArtillery, TriggerTypeK6}

type TraceIDRequest struct {
ID string `json:"id,omitempty" expr_enabled:"true"`
Expand Down
4 changes: 2 additions & 2 deletions agent/workers/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func (t TriggerType) IsTraceIDBased() bool {
return slices.Contains(traceIDBasedTriggers, t)
}

func (t TriggerType) IsFrontendE2EBased() bool {
return t == TriggerTypeCypress || t == TriggerTypePlaywright
func (t TriggerType) IsIntegration() bool {
return slices.Contains(traceIDBasedIntegrationsTriggers, t)
}

type (
Expand Down
2 changes: 1 addition & 1 deletion agent/workers/trigger/trigger_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (v3 triggerJSONV3) valid() bool {
(v3.HTTP != nil ||
v3.GRPC != nil ||
v3.TraceID != nil ||
v3.Kafka != nil)) || (v3.Type == TriggerTypeCypress || v3.Type == TriggerTypePlaywright)
v3.Kafka != nil)) || (v3.Type == TriggerTypeCypress || v3.Type == TriggerTypePlaywright || v3.Type == TriggerTypeArtillery || v3.Type == TriggerTypeK6)
}

type triggerJSONV2 struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ spec:
id: artillery-plugin-import-pokemon
name: "Artillery Plugin: Import a Pokemon"
trigger:
type: traceid
traceid:
id: ${var:TRACE_ID}
type: artillery
specs:
- selector: span[tracetest.span.type="general" name = "validate request"] span[tracetest.span.type="http"]
name: "All HTTP Spans: Status code is 200"
Expand Down
2 changes: 1 addition & 1 deletion examples/quick-start-artillery/plugin-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ config:
tool: "Artillery"
tracetest:
token: <YOUR_TRACETES_ENV_TOKEN>
definition: import-pokemon-trace-id.yaml
definition: import-pokemon-plugin.yaml
runInfo:
variables:
- key: POKEMON_ID
Expand Down
2 changes: 1 addition & 1 deletion server/executor/trigger/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/server/pkg/kafka"
"github.com/kubeshop/tracetest/agent/workers/trigger/kafka"
"github.com/kubeshop/tracetest/server/test"

"go.opentelemetry.io/otel/propagation"
Expand Down
2 changes: 1 addition & 1 deletion server/executor/trigger/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (t *traceidTriggerer) Type() trigger.TriggerType {
}

func (t *traceidTriggerer) Resolve(ctx context.Context, test test.Test, opts *ResolveOptions) (test.Test, error) {
if test.Trigger.Type.IsFrontendE2EBased() {
if test.Trigger.Type.IsIntegration() {
test.Trigger.TraceID = &trigger.TraceIDRequest{ID: TRACEID_EXPRESSION}
}

Expand Down