Skip to content

Commit

Permalink
feat(frontend): add new test creation flow (#3350)
Browse files Browse the repository at this point in the history
* feat(frontend): add trigger type modal (#3326)

* feat(frontend): decouple test run page (#3338)

Co-authored-by: Oscar Reyes <[email protected]>

* Chore/component cleanup (#3357)

chore: component cleanup

* feat(frontend): UI updates to test trigger tab (#3354)

* feat(frontend): add new ux layout to test edit (#3359)

* feat: Import Modal (#3360)

* feat: Import Modal

* chore: component cleanup

* Feat/skip trace collection (#3351)

feat(BE): Skip Trace Collection

* Feat/skip trace collection 2 (#3353)

* feat(BE): Skip Trace Collection

* feat(FE): Skip Trace Collection

* fix: loading state

* feat(frontend): add edit test name form (#3363)

* feat(frontend): add edit test name form

* fix minor issue with form

* Fix/name update (#3366)

fix: UX improvements

* fix(frontend): fix e2e tests (#3365)

* fix(frontend): fix e2e tests

* fix

* feat: UX improvements

* fix: popover state

* fix(frontend): add variable set selector (#3380)

---------

Co-authored-by: Jorge Padilla <[email protected]>
  • Loading branch information
xoscar and jorgeepc committed Nov 21, 2023
1 parent 7a8a3e3 commit 0c26d99
Show file tree
Hide file tree
Showing 317 changed files with 3,113 additions and 2,675 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ server/html
docs/docs/cli/reference/

__debug*
web/cypress/downloads
16 changes: 16 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,22 @@ paths:
422:
description: could not stop execution, probably it's not running anymore

/tests/{testId}/run/{runId}/skipPolling:
post:
tags:
- api
parameters:
- $ref: "./parameters.yaml#/components/parameters/testId"
- $ref: "./parameters.yaml#/components/parameters/runId"
summary: "skips the trace collection of a test run"
description: "skips the trace collection of a test run"
operationId: skipTraceCollection
responses:
200:
description: successful operation
422:
description: could not stop execution, probably it's not running anymore

# Test events
/tests/{testId}/run/{runId}/events:
get:
Expand Down
3 changes: 3 additions & 0 deletions api/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ components:
format: date-time
trigger:
$ref: "./triggers.yaml#/components/schemas/Trigger"
skipTraceCollection:
type: boolean
description: If true, the test will not collect a trace
specs:
type: array
items:
Expand Down
96 changes: 96 additions & 0 deletions cli/openapi/api_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions cli/openapi/model_test_.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 41 additions & 12 deletions server/executor/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ func (q Queue) listenPreprocess(ctx context.Context, job Job) (context.Context,

ctx = context.WithValue(ctx, "LastInstanceID", job.Headers.Get("InstanceID"))

ctx, cancelCtx := context.WithCancel(ctx)
q.listenForStopRequests(context.Background(), cancelCtx, job)
ctx, cancelCtx := context.WithCancelCause(ctx)
q.listenForUserRequests(context.Background(), cancelCtx, job)

return ctx, Job{
Headers: job.Headers,
Expand All @@ -336,45 +336,74 @@ func (q Queue) listenPreprocess(ctx context.Context, job Job) (context.Context,
PollingProfile: q.resolvePollingProfile(ctx, job),
DataStore: q.resolveDataStore(ctx, job),
}

}

type StopRequest struct {
type UserRequestType string

var (
UserRequestTypeStop UserRequestType = "stop"
UserRequestSkipTraceCollection UserRequestType = "skip_trace_collection"
)

type UserRequest struct {
TestID id.ID
RunID int
}

func (sr StopRequest) ResourceID() string {
func (sr UserRequest) ResourceID(requestType UserRequestType) string {
runID := (test.Run{ID: sr.RunID, TestID: sr.TestID}).ResourceID()
return runID + "/stop"
return fmt.Sprintf("%s/%s", runID, requestType)
}

func (q Queue) listenForStopRequests(ctx context.Context, cancelCtx context.CancelFunc, job Job) {
var (
ErrSkipTraceCollection = errors.New("skip trace collection")
)

func (q Queue) listenForUserRequests(ctx context.Context, cancelCtx context.CancelCauseFunc, job Job) {
if q.subscriptor == nil {
return
}

sfn := subscription.NewSubscriberFunction(func(m subscription.Message) error {
cancelCtx()
stopRequest, ok := m.Content.(StopRequest)
cancelCtx(nil)
request, ok := m.Content.(UserRequest)
if !ok {
return nil
}

run, err := q.runs.GetRun(ctx, stopRequest.TestID, stopRequest.RunID)
run, err := q.runs.GetRun(ctx, request.TestID, request.RunID)
if err != nil {
return fmt.Errorf("failed to get run %d for test %s: %w", stopRequest.RunID, stopRequest.TestID, err)
return fmt.Errorf("failed to get run %d for test %s: %w", request.RunID, request.TestID, err)
}

if run.State == test.RunStateStopped {
return nil
}

return q.cancelRunHandlerFn(ctx, run)
})

spfn := subscription.NewSubscriberFunction(func(m subscription.Message) error {
request, ok := m.Content.(UserRequest)
if !ok {
return nil
}

run, err := q.runs.GetRun(ctx, request.TestID, request.RunID)
if err != nil {
return fmt.Errorf("failed to get run %d for test %s: %w", request.RunID, request.TestID, err)
}

if run.State == test.RunStateStopped || run.State.IsFinal() {
return nil
}

cancelCtx(ErrSkipTraceCollection)
return nil
})

q.subscriptor.Subscribe((StopRequest{job.Test.ID, job.Run.ID}).ResourceID(), sfn)
q.subscriptor.Subscribe((UserRequest{job.Test.ID, job.Run.ID}).ResourceID(UserRequestTypeStop), sfn)
q.subscriptor.Subscribe((UserRequest{job.Test.ID, job.Run.ID}).ResourceID(UserRequestSkipTraceCollection), spfn)
}

func (q Queue) resolveTestSuite(ctx context.Context, job Job) testsuite.TestSuite {
Expand Down
17 changes: 15 additions & 2 deletions server/executor/test_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (p *TestPipeline) Run(ctx context.Context, testObj test.Test, metadata test
requiredGates = &rg
}
run = run.ConfigureRequiredGates(*requiredGates)
run.SkipTraceCollection = testObj.SkipTraceCollection

run, err := p.runs.CreateRun(ctx, testObj, run)
p.handleDBError(run, err)
Expand Down Expand Up @@ -119,13 +120,25 @@ func (p *TestPipeline) Rerun(ctx context.Context, testObj test.Test, runID int)
}

func (p *TestPipeline) StopTest(ctx context.Context, testID id.ID, runID int) {
sr := StopRequest{
sr := UserRequest{
TestID: testID,
RunID: runID,
}

p.updatePublisher.PublishUpdate(subscription.Message{
ResourceID: sr.ResourceID(),
ResourceID: sr.ResourceID(UserRequestTypeStop),
Content: sr,
})
}

func (p *TestPipeline) SkipTraceCollection(ctx context.Context, testID id.ID, runID int) {
sr := UserRequest{
TestID: testID,
RunID: runID,
}

p.updatePublisher.PublishUpdate(subscription.Message{
ResourceID: sr.ResourceID(UserRequestSkipTraceCollection),
Content: sr,
})
}
Expand Down
Loading

0 comments on commit 0c26d99

Please sign in to comment.