From 5bdcd86fa70f734501240b004c8cee124cee1a68 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Fri, 10 Jul 2020 09:10:01 +0300 Subject: [PATCH] ci: test benchmarks This runs each benchmark for one iteration to ensure that they are valid. Unfortunately, it does not give any useful metrics as output. Change-Id: I68940398c8dd849aed656bd12656f48d5df10128 --- Jenkinsfile.public | 13 ++++++++++ satellite/gracefulexit/chore_test.go | 26 ++++++++++--------- .../piecedeletion/combiner_bench_test.go | 13 ++++++++-- satellite/orders/orders_test.go | 8 +++++- satellite/overlay/benchmark_test.go | 9 ++++++- satellite/overlay/piececount_test.go | 7 ++++- storage/postgreskv/client_test.go | 2 ++ 7 files changed, 61 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile.public b/Jenkinsfile.public index 8206629e6..446f4d685 100644 --- a/Jenkinsfile.public +++ b/Jenkinsfile.public @@ -97,6 +97,19 @@ pipeline { } } + stage('Check Benchmark') { + environment { + STORJ_COCKROACH_TEST = 'cockroach://root@localhost:26256/benchcockroach?sslmode=disable' + STORJ_POSTGRES_TEST = 'postgres://postgres@localhost/benchstorj?sslmode=disable' + } + steps { + sh 'cockroach sql --insecure --host=localhost:26256 -e \'create database benchcockroach;\'' + + sh 'psql -U postgres -c \'create database benchstorj;\'' + sh 'go test -parallel 1 -p 1 -vet=off -timeout 20m -short -run XYZXYZXYZXYZ -bench . -benchtime 1x ./...' + } + } + stage('Integration') { environment { // use different hostname to avoid port conflicts diff --git a/satellite/gracefulexit/chore_test.go b/satellite/gracefulexit/chore_test.go index 026f9a961..a5fdce3dd 100644 --- a/satellite/gracefulexit/chore_test.go +++ b/satellite/gracefulexit/chore_test.go @@ -233,18 +233,20 @@ func BenchmarkChore(b *testing.B) { b.Run("BatchUpdateStats-100", func(b *testing.B) { batch(ctx, b, gracefulexitdb, 100) }) - b.Run("BatchUpdateStats-250", func(b *testing.B) { - batch(ctx, b, gracefulexitdb, 250) - }) - b.Run("BatchUpdateStats-500", func(b *testing.B) { - batch(ctx, b, gracefulexitdb, 500) - }) - b.Run("BatchUpdateStats-1000", func(b *testing.B) { - batch(ctx, b, gracefulexitdb, 1000) - }) - b.Run("BatchUpdateStats-5000", func(b *testing.B) { - batch(ctx, b, gracefulexitdb, 5000) - }) + if !testing.Short() { + b.Run("BatchUpdateStats-250", func(b *testing.B) { + batch(ctx, b, gracefulexitdb, 250) + }) + b.Run("BatchUpdateStats-500", func(b *testing.B) { + batch(ctx, b, gracefulexitdb, 500) + }) + b.Run("BatchUpdateStats-1000", func(b *testing.B) { + batch(ctx, b, gracefulexitdb, 1000) + }) + b.Run("BatchUpdateStats-5000", func(b *testing.B) { + batch(ctx, b, gracefulexitdb, 5000) + }) + } }) } func batch(ctx context.Context, b *testing.B, db gracefulexit.DB, size int) { diff --git a/satellite/metainfo/piecedeletion/combiner_bench_test.go b/satellite/metainfo/piecedeletion/combiner_bench_test.go index bc2eb68db..2332d326a 100644 --- a/satellite/metainfo/piecedeletion/combiner_bench_test.go +++ b/satellite/metainfo/piecedeletion/combiner_bench_test.go @@ -59,8 +59,17 @@ func BenchmarkCombiner(b *testing.B) { minWait = 1 * time.Millisecond maxWait = 20 * time.Millisecond ) - activeLimits := []int{8, 32, 64, -1} - queueSizes := []int{1, 8, 64, 128, -1} + + var activeLimits []int + var queueSizes []int + + if testing.Short() { + activeLimits = []int{8, 64, -1} + queueSizes = []int{8, 128, -1} + } else { + activeLimits = []int{8, 32, 64, -1} + queueSizes = []int{1, 8, 64, 128, -1} + } nodes := []storj.NodeURL{} for i := 0; i < nodeCount; i++ { diff --git a/satellite/orders/orders_test.go b/satellite/orders/orders_test.go index 432e7aa41..6d54b95aa 100644 --- a/satellite/orders/orders_test.go +++ b/satellite/orders/orders_test.go @@ -301,7 +301,13 @@ func BenchmarkOrders(b *testing.B) { ctx := testcontext.New(b) defer ctx.Cleanup() - counts := []int{50, 100, 250, 500, 1000} + var counts []int + if testing.Short() { + counts = []int{50, 100} + } else { + counts = []int{50, 100, 250, 500, 1000} + } + for _, c := range counts { c := c satellitedbtest.Bench(b, func(b *testing.B, db satellite.DB) { diff --git a/satellite/overlay/benchmark_test.go b/satellite/overlay/benchmark_test.go index 4a38d393a..65da0ce11 100644 --- a/satellite/overlay/benchmark_test.go +++ b/satellite/overlay/benchmark_test.go @@ -193,7 +193,7 @@ func BenchmarkOverlay(b *testing.B) { func BenchmarkNodeSelection(b *testing.B) { satellitedbtest.Bench(b, func(b *testing.B, db satellite.DB) { - const ( + var ( Total = 10000 Offline = 1000 NodesPerNet = 2 @@ -204,6 +204,13 @@ func BenchmarkNodeSelection(b *testing.B) { newNodeFraction = 0.05 ) + if testing.Short() { + Total /= 10 + Offline /= 10 + SelectCount /= 10 + ExcludedCount /= 10 + } + SelectNewCount := int(100 * newNodeFraction) now := time.Now() diff --git a/satellite/overlay/piececount_test.go b/satellite/overlay/piececount_test.go index 07238483d..739418475 100644 --- a/satellite/overlay/piececount_test.go +++ b/satellite/overlay/piececount_test.go @@ -82,10 +82,15 @@ func BenchmarkDB_PieceCounts(b *testing.B) { ctx := testcontext.New(b) defer ctx.Cleanup() + var NumberOfNodes = 10000 + if testing.Short() { + NumberOfNodes = 1000 + } + overlaydb := db.OverlayCache() counts := make(map[storj.NodeID]int) - for i := 0; i < 10000; i++ { + for i := 0; i < NumberOfNodes; i++ { counts[testrand.NodeID()] = testrand.Intn(100000) } diff --git a/storage/postgreskv/client_test.go b/storage/postgreskv/client_test.go index 0e83c864b..4e2667740 100644 --- a/storage/postgreskv/client_test.go +++ b/storage/postgreskv/client_test.go @@ -94,6 +94,8 @@ func TestThatMigrationActuallyHappened(t *testing.T) { } func BenchmarkSuite(b *testing.B) { + b.Skip("broken") + store, cleanup := newTestPostgres(b) defer cleanup()