From 5502599f1d4ea8caac5f1490e3107a2d4ef79b87 Mon Sep 17 00:00:00 2001 From: Mason Malone <651224+MasonM@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:27:20 -0700 Subject: [PATCH] test: basic benchmarks for workflow archive This adds basic benchmarks for listing and counting archived workflows so we can evaluate potential optimizations, e.g. https://github.com/argoproj/argo-workflows/issues/13601 ``` $ make BenchmarkWorkflowArchive GIT_COMMIT=f218fc540367840d013a99642590d3509560de51 GIT_BRANCH=feat-postgresql-jsonb GIT_TAG=untagged GIT_TREE_STATE=dirty RELEASE_TAG=false DEV_BRANCH=true VERSION=latest KUBECTX=k3d-k3s-default DOCKER_DESKTOP=false K3D=true DOCKER_PUSH=false TARGET_PLATFORM=linux/amd64 RUN_MODE=local PROFILE=minimal AUTH_MODE=hybrid SECURE=false STATIC_FILES=false ALWAYS_OFFLOAD_NODE_STATUS=false UPPERIO_DB_DEBUG=0 LOG_LEVEL=debug NAMESPACED=true go test --tags api,cli,cron,executor,examples,corefunctional,functional,plugins ./test/e2e -run='BenchmarkWorkflowArchive' -benchmem -bench . WARN[0000] Non-transient error: WARN[0000] Non-transient error: goos: linux goarch: amd64 pkg: github.com/argoproj/argo-workflows/v3/test/e2e cpu: 12th Gen Intel(R) Core(TM) i5-12400 BenchmarkWorkflowArchive/ListWorkflows-12 6 167109091 ns/op 527468 B/op 8614 allocs/op --- BENCH: BenchmarkWorkflowArchive/ListWorkflows-12 workflow_archive_test.go:27: Found 100 workflows workflow_archive_test.go:27: Found 100 workflows workflow_archive_test.go:27: Found 100 workflows workflow_archive_test.go:27: Found 100 workflows workflow_archive_test.go:27: Found 100 workflows workflow_archive_test.go:27: Found 100 workflows workflow_archive_test.go:27: Found 100 workflows BenchmarkWorkflowArchive/CountWorkflows-12 31 36799882 ns/op 9022 B/op 212 allocs/op --- BENCH: BenchmarkWorkflowArchive/CountWorkflows-12 workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows workflow_archive_test.go:37: Found 100756 workflows ... [output truncated] PASS ok github.com/argoproj/argo-workflows/v3/test/e2e 3.392s ``` 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 | 42 +++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 test/e2e/workflow_archive_test.go diff --git a/Makefile b/Makefile index 9abf36c6b114..4b3f2786820a 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)) @@ -608,8 +609,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 2aa3fec83511..ff608b417f92 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -154,7 +154,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..ce00e5ccf064 --- /dev/null +++ b/test/e2e/workflow_archive_test.go @@ -0,0 +1,42 @@ +//go:build functional + +package e2e + +import ( + "testing" + + 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() + + 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("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() +}