Skip to content

Commit

Permalink
Merge branch 'main' into vsukhin/feature/rerun-test-worklow
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Feb 17, 2025
2 parents c076965 + 450ce57 commit 4bf1593
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
14 changes: 14 additions & 0 deletions pkg/repository/testworkflow/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type FilterImpl struct {
FLabelSelector *LabelSelector
FActorName string
FActorType testkube.TestWorkflowRunningContextActorType
FGroupID string
}

func NewExecutionsFilter() *FilterImpl {
Expand Down Expand Up @@ -101,6 +102,11 @@ func (f *FilterImpl) WithLabelSelector(selector *LabelSelector) *FilterImpl {
return f
}

func (f *FilterImpl) WithGroupID(groupID string) *FilterImpl {
f.FGroupID = groupID
return f
}

func (f FilterImpl) Name() string {
return f.FName
}
Expand Down Expand Up @@ -192,3 +198,11 @@ func (f FilterImpl) ActorNameDefined() bool {
func (f FilterImpl) ActorTypeDefined() bool {
return f.FActorType != ""
}

func (f FilterImpl) GroupIDDefined() bool {
return f.FGroupID != ""
}

func (f FilterImpl) GroupID() string {
return f.FGroupID
}
2 changes: 2 additions & 0 deletions pkg/repository/testworkflow/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type Filter interface {
ActorNameDefined() bool
ActorType() testkube.TestWorkflowRunningContextActorType
ActorTypeDefined() bool
GroupID() string
GroupIDDefined() bool
}

//go:generate mockgen -destination=./mock_repository.go -package=testworkflow "github.com/kubeshop/testkube/pkg/repository/testworkflow" Repository
Expand Down
10 changes: 10 additions & 0 deletions pkg/repository/testworkflow/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ func composeQueryAndOpts(filter Filter) (bson.M, *options.FindOptions) {
query["runningcontext.actor.type_"] = filter.ActorType()
}

if filter.GroupIDDefined() {
query = bson.M{"$and": bson.A{
bson.M{"$expr": bson.M{"$or": bson.A{
bson.M{"$eq": bson.A{"$id", filter.GroupID()}},
bson.M{"$eq": bson.A{"$groupid", filter.GroupID()}},
}}},
query,
}}
}

opts.SetSkip(int64(filter.Page() * filter.PageSize()))
opts.SetLimit(int64(filter.PageSize()))
opts.SetSort(bson.D{{Key: "scheduledat", Value: -1}})
Expand Down
6 changes: 6 additions & 0 deletions test/cypress/executor-tests/crd-workflow/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ spec:
env:
- name: CYPRESS_CUSTOM_ENV # currently only possible on this level
value: "CYPRESS_CUSTOM_ENV_value"
- name: UV_USE_IO_URING # workaround for NPM being stuck
value: "0"
content:
git:
uri: https://github.com/kubeshop/testkube
Expand Down Expand Up @@ -156,6 +158,8 @@ spec:
env:
- name: CYPRESS_CUSTOM_ENV # currently only possible on this level
value: "CYPRESS_CUSTOM_ENV_value"
- name: UV_USE_IO_URING # workaround for NPM being stuck
value: "0"
steps:
- name: Run from template
content:
Expand Down Expand Up @@ -187,6 +191,8 @@ spec:
env:
- name: CYPRESS_CUSTOM_ENV # currently only possible on this level
value: "CYPRESS_CUSTOM_ENV_value"
- name: UV_USE_IO_URING # workaround for NPM being stuck
value: "0"
steps:
- name: Run cypress test
content:
Expand Down
15 changes: 12 additions & 3 deletions test/cypress/executor-tests/crd/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ spec:
name: CYPRESS_CUSTOM_ENV
value: CYPRESS_CUSTOM_ENV_value
type: basic
UV_USE_IO_URING:
name: UV_USE_IO_URING
value: "0"
type: basic
args:
- --env
- NON_CYPRESS_ENV=NON_CYPRESS_ENV_value
Expand Down Expand Up @@ -48,6 +52,10 @@ spec:
name: CYPRESS_CUSTOM_ENV
value: CYPRESS_CUSTOM_ENV_value
type: basic
UV_USE_IO_URING:
name: UV_USE_IO_URING
value: "0"
type: basic
args:
- --browser
- chrome
Expand Down Expand Up @@ -79,6 +87,10 @@ spec:
name: CYPRESS_CUSTOM_ENV
value: CYPRESS_CUSTOM_ENV_value
type: basic
UV_USE_IO_URING:
name: UV_USE_IO_URING
value: "0"
type: basic
args:
- --browser
- chrome
Expand All @@ -89,9 +101,6 @@ spec:
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: \"{{ .Name }}\"\n image: {{ .Image }}\n resources:\n requests:\n memory: 2Gi\n cpu: 2\n"
activeDeadlineSeconds: 600
---



apiVersion: tests.testkube.io/v3
kind: Test
metadata:
Expand Down

0 comments on commit 4bf1593

Please sign in to comment.