From 5b6b461276f9cc7d8b12efe76cae0872e3e16cb9 Mon Sep 17 00:00:00 2001 From: Mason Malone <651224+MasonM@users.noreply.github.com> Date: Mon, 21 Oct 2024 07:07:31 -0700 Subject: [PATCH] test: basic benchmarks for workflow archive DB operations (#13767) Signed-off-by: Mason Malone <651224+MasonM@users.noreply.github.com> --- Makefile | 5 ++- docs/running-locally.md | 2 +- test/e2e/fixtures/e2e_suite.go | 2 +- test/e2e/fixtures/persistence.go | 6 +-- test/e2e/workflow_archive_test.go | 64 +++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 test/e2e/workflow_archive_test.go diff --git a/Makefile b/Makefile index 110407fb3aee..b324d746cc53 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,7 @@ E2E_WAIT_TIMEOUT ?= 90s # timeout for wait conditions E2E_PARALLEL ?= 20 E2E_SUITE_TIMEOUT ?= 15m GOTEST ?= go test -v -p 20 +ALL_BUILD_TAGS ?= api,cli,cron,executor,examples,corefunctional,functional,plugins # should we build the static files? ifneq (,$(filter $(MAKECMDGOALS),codegen lint test docs start)) @@ -619,8 +620,10 @@ test-%-sdk: make --directory sdks/$* install test -B Test%: - E2E_WAIT_TIMEOUT=$(E2E_WAIT_TIMEOUT) go test -failfast -v -timeout $(E2E_SUITE_TIMEOUT) -count 1 --tags api,cli,cron,executor,examples,corefunctional,functional,plugins -parallel $(E2E_PARALLEL) ./test/e2e -run='.*/$*' + E2E_WAIT_TIMEOUT=$(E2E_WAIT_TIMEOUT) go test -failfast -v -timeout $(E2E_SUITE_TIMEOUT) -count 1 --tags $(ALL_BUILD_TAGS) -parallel $(E2E_PARALLEL) ./test/e2e -run='.*/$*' +Benchmark%: + go test --tags $(ALL_BUILD_TAGS) ./test/e2e -run='$@' -benchmem -bench . # clean diff --git a/docs/running-locally.md b/docs/running-locally.md index 85f67f0ac5ac..2ddc19b1c2a6 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -168,7 +168,7 @@ To test SSO integration, use `PROFILE=sso`: make start UI=true PROFILE=sso ``` -## TLS +### TLS By default, `make start` will start Argo in [plain text mode](tls.md#plain-text). To simulate a TLS proxy in front of Argo, use `UI_SECURE=true` (which implies `UI=true`): diff --git a/test/e2e/fixtures/e2e_suite.go b/test/e2e/fixtures/e2e_suite.go index 8aa92d4696fc..9f4dab8b149a 100644 --- a/test/e2e/fixtures/e2e_suite.go +++ b/test/e2e/fixtures/e2e_suite.go @@ -175,7 +175,7 @@ func (s *E2ESuite) DeleteResources() { // delete archived workflows from the archive if s.Persistence.IsEnabled() { - archive := s.Persistence.workflowArchive + archive := s.Persistence.WorkflowArchive parse, err := labels.ParseToRequirements(Label) s.CheckError(err) workflows, err := archive.ListWorkflows(utils.ListOptions{ diff --git a/test/e2e/fixtures/persistence.go b/test/e2e/fixtures/persistence.go index 6d0309bec097..123e23d340cd 100644 --- a/test/e2e/fixtures/persistence.go +++ b/test/e2e/fixtures/persistence.go @@ -10,9 +10,9 @@ import ( ) type Persistence struct { + WorkflowArchive sqldb.WorkflowArchive session db.Session offloadNodeStatusRepo sqldb.OffloadNodeStatusRepo - workflowArchive sqldb.WorkflowArchive } func newPersistence(kubeClient kubernetes.Interface, wcConfig *config.Config) *Persistence { @@ -38,9 +38,9 @@ func newPersistence(kubeClient kubernetes.Interface, wcConfig *config.Config) *P } instanceIDService := instanceid.NewService(wcConfig.InstanceID) workflowArchive := sqldb.NewWorkflowArchive(session, persistence.GetClusterName(), Namespace, instanceIDService) - return &Persistence{session, offloadNodeStatusRepo, workflowArchive} + return &Persistence{workflowArchive, session, offloadNodeStatusRepo} } else { - return &Persistence{offloadNodeStatusRepo: sqldb.ExplosiveOffloadNodeStatusRepo, workflowArchive: sqldb.NullWorkflowArchive} + return &Persistence{offloadNodeStatusRepo: sqldb.ExplosiveOffloadNodeStatusRepo, WorkflowArchive: sqldb.NullWorkflowArchive} } } diff --git a/test/e2e/workflow_archive_test.go b/test/e2e/workflow_archive_test.go new file mode 100644 index 000000000000..fb38408b10f6 --- /dev/null +++ b/test/e2e/workflow_archive_test.go @@ -0,0 +1,64 @@ +//go:build functional + +package e2e + +import ( + "testing" + + "k8s.io/apimachinery/pkg/labels" + + sutils "github.com/argoproj/argo-workflows/v3/server/utils" + "github.com/argoproj/argo-workflows/v3/test/e2e/fixtures" +) + +func BenchmarkWorkflowArchive(b *testing.B) { + // Workaround for https://github.com/stretchr/testify/issues/811 + suite := fixtures.E2ESuite{} + suite.SetT(&testing.T{}) + suite.SetupSuite() + b.ResetTimer() + + // Uncomment the following line to log queries to stdout + //db.LC().SetLevel(db.LogLevelDebug) + + b.Run("ListWorkflows", func(b *testing.B) { + for range b.N { + wfs, err := suite.Persistence.WorkflowArchive.ListWorkflows(sutils.ListOptions{ + Limit: 100, + }) + if err != nil { + b.Fatal(err) + } + b.Logf("Found %d workflows", wfs.Len()) + } + }) + + b.Run("ListWorkflows with label selector", func(b *testing.B) { + requirements, err := labels.ParseToRequirements("workflows.argoproj.io/phase=Succeeded") + if err != nil { + b.Fatal(err) + } + for range b.N { + wfs, err := suite.Persistence.WorkflowArchive.ListWorkflows(sutils.ListOptions{ + Limit: 100, + LabelRequirements: requirements, + }) + if err != nil { + b.Fatal(err) + } + b.Logf("Found %d workflows", wfs.Len()) + } + }) + + b.Run("CountWorkflows", func(b *testing.B) { + for range b.N { + wfCount, err := suite.Persistence.WorkflowArchive.CountWorkflows(sutils.ListOptions{}) + if err != nil { + b.Fatal(err) + } + b.Logf("Found %d workflows", wfCount) + } + }) + + suite.TearDownSuite() +}