Skip to content

Commit f5b5caf

Browse files
committed
Run all e2e tests with and without cache
1 parent b39b581 commit f5b5caf

File tree

1 file changed

+50
-19
lines changed

1 file changed

+50
-19
lines changed

backend/test/e2e.go

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/cschleiden/go-workflows/client"
1212
"github.com/cschleiden/go-workflows/internal/core"
1313
"github.com/cschleiden/go-workflows/internal/history"
14+
internalwf "github.com/cschleiden/go-workflows/internal/workflow"
1415
"github.com/cschleiden/go-workflows/worker"
1516
"github.com/cschleiden/go-workflows/workflow"
1617
"github.com/google/uuid"
@@ -364,30 +365,60 @@ func EndToEndBackendTest(t *testing.T, setup func() TestBackend, teardown func(b
364365
},
365366
}
366367

367-
for _, tt := range tests {
368-
t.Run(tt.name, func(t *testing.T) {
369-
b := setup()
370-
ctx := context.Background()
371-
ctx, cancel := context.WithCancel(ctx)
368+
run := func(suffix string, workerOptions *worker.Options) {
369+
for _, tt := range tests {
370+
t.Run(tt.name+suffix, func(t *testing.T) {
371+
b := setup()
372+
ctx := context.Background()
373+
ctx, cancel := context.WithCancel(ctx)
372374

373-
c := client.New(b)
374-
w := worker.New(b, &worker.DefaultWorkerOptions)
375+
c := client.New(b)
376+
w := worker.New(b, workerOptions)
375377

376-
t.Cleanup(func() {
377-
cancel()
378-
if err := w.WaitForCompletion(); err != nil {
379-
log.Println("Worker did not stop in time")
380-
t.FailNow()
381-
}
378+
t.Cleanup(func() {
379+
cancel()
380+
if err := w.WaitForCompletion(); err != nil {
381+
log.Println("Worker did not stop in time")
382+
t.FailNow()
383+
}
382384

383-
if teardown != nil {
384-
teardown(b)
385-
}
386-
})
385+
if teardown != nil {
386+
teardown(b)
387+
}
388+
})
387389

388-
tt.f(t, ctx, c, w, b)
389-
})
390+
tt.f(t, ctx, c, w, b)
391+
})
392+
}
390393
}
394+
395+
options := worker.DefaultWorkerOptions
396+
397+
// Run with cache
398+
run("", &options)
399+
400+
// Disable cache for this execution
401+
options.WorkflowExecutorCache = &noopWorkflowExecutorCache{}
402+
run("_without_cache", &options)
403+
}
404+
405+
type noopWorkflowExecutorCache struct {
406+
}
407+
408+
var _ internalwf.ExecutorCache = (*noopWorkflowExecutorCache)(nil)
409+
410+
// Get implements workflow.ExecutorCache
411+
func (*noopWorkflowExecutorCache) Get(ctx context.Context, instance *core.WorkflowInstance) (internalwf.WorkflowExecutor, bool, error) {
412+
return nil, false, nil
413+
}
414+
415+
// StartEviction implements workflow.ExecutorCache
416+
func (*noopWorkflowExecutorCache) StartEviction(ctx context.Context) {
417+
}
418+
419+
// Store implements workflow.ExecutorCache
420+
func (*noopWorkflowExecutorCache) Store(ctx context.Context, instance *core.WorkflowInstance, workflow internalwf.WorkflowExecutor) error {
421+
return nil
391422
}
392423

393424
func register(t *testing.T, ctx context.Context, w worker.Worker, workflows []interface{}, activities []interface{}) {

0 commit comments

Comments
 (0)