From f113998db1b15e67832551e6e28b1c3736425713 Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Fri, 15 Sep 2023 19:37:46 +0300 Subject: [PATCH] fix redis tests --- .github/workflows/benchmark.yml | 18 ++++++------------ .github/workflows/test-redis.yml | 3 ++- .github/workflows/test-rueidis.yml | 3 ++- badger/badger_test.go | 2 +- bbolt/bbolt_test.go | 2 +- memory/memory_test.go | 29 ----------------------------- sqlite3/sqlite3_test.go | 2 +- 7 files changed, 13 insertions(+), 46 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7276a3e1..adcdcd2a 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -90,10 +90,12 @@ jobs: - name: Install Azurite run: | docker run -d -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0 --blobPort 10000 + - name: Install Coherence run: | docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5 sleep 30 + - name: Install couchbase run: | docker run --name couchbase -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11207:11207 -p 11210:11210 -p 11280:11280 -p 18091-18097:18091-18097 couchbase:enterprise-7.1.1 @@ -101,6 +103,7 @@ jobs: docker exec --tty couchbase couchbase-cli cluster-init -c localhost:8091 --cluster-username admin --cluster-password 123456 --cluster-ramsize 256 --services data sleep 10 docker exec --tty couchbase couchbase-cli bucket-create -c localhost:8091 --username admin --password 123456 --bucket fiber_storage --bucket-type couchbase --bucket-ramsize 100 --enable-flush 1 + - name: Install etcd run: | docker run -d --name Etcd-server \ @@ -109,17 +112,10 @@ jobs: --env ALLOW_NONE_AUTHENTICATION=yes \ --env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379 \ bitnami/etcd:latest + - name: Install MinIO run: | docker run -d --restart always -p 9000:9000 --name storage-minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server /data - - name: Generate TLS certs - run: ./.github/scripts/gen-test-certs.sh - - - name: Add Custom CA cert - run: sudo cp /home/runner/work/storage/storage/tls/ca.crt /usr/local/share/ca-certificates/custom.crt - - - name: Trust Custom CA Cert - run: sudo update-ca-certificates - name: Setup Redis uses: shogo82148/actions-setup-redis@v1 @@ -129,10 +125,7 @@ jobs: - name: Run Redis run: | - redis-server --tls-port 6380 --port 6379 \ - --tls-cert-file /home/runner/work/storage/storage/tls/redis.crt \ - --tls-key-file /home/runner/work/storage/storage/tls/redis.key \ - --tls-ca-cert-file /home/runner/work/storage/storage/tls/ca.crt & + redis-server --port 6379 & - name: Run Benchmarks run: | @@ -169,6 +162,7 @@ jobs: output-file-path: output.txt github-token: ${{ secrets.GITHUB_TOKEN }} benchmark-data-dir-path: "benchmarks" + alert-threshold: "300%" fail-on-alert: true comment-on-alert: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} #summary-always: ${{ github.event_name != 'push' && github.event_name != 'workflow_dispatch' }} diff --git a/.github/workflows/test-redis.yml b/.github/workflows/test-redis.yml index 507ea8d6..a4e58b6f 100644 --- a/.github/workflows/test-redis.yml +++ b/.github/workflows/test-redis.yml @@ -56,7 +56,7 @@ jobs: --tls-auth-clients no & - name: Setup Redis Cluster - uses: vishnudxb/redis-cluster@1.0.8 + uses: vishnudxb/redis-cluster@1.0.9 with: master1-port: 7000 master2-port: 7001 @@ -64,6 +64,7 @@ jobs: slave1-port: 7003 slave2-port: 7004 slave3-port: 7005 + sleep-duration: 10 - name: Install Go uses: actions/setup-go@v4 diff --git a/.github/workflows/test-rueidis.yml b/.github/workflows/test-rueidis.yml index bf96d39a..71307b50 100644 --- a/.github/workflows/test-rueidis.yml +++ b/.github/workflows/test-rueidis.yml @@ -43,7 +43,7 @@ jobs: --tls-ca-cert-file /home/runner/work/storage/storage/tls/ca.crt & - name: Setup Redis Cluster - uses: vishnudxb/redis-cluster@1.0.8 + uses: vishnudxb/redis-cluster@1.0.9 with: master1-port: 7000 master2-port: 7001 @@ -51,6 +51,7 @@ jobs: slave1-port: 7003 slave2-port: 7004 slave3-port: 7005 + sleep-duration: 10 - name: Install Go uses: actions/setup-go@v4 diff --git a/badger/badger_test.go b/badger/badger_test.go index 3e90ae9e..d393d36c 100644 --- a/badger/badger_test.go +++ b/badger/badger_test.go @@ -147,7 +147,7 @@ func Benchmark_Badger_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Badger_Delete(b *testing.B) { +func Benchmark_Badger_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() diff --git a/bbolt/bbolt_test.go b/bbolt/bbolt_test.go index e53918c9..565dd173 100644 --- a/bbolt/bbolt_test.go +++ b/bbolt/bbolt_test.go @@ -136,7 +136,7 @@ func Benchmark_Bbolt_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Bbolt_Delete(b *testing.B) { +func Benchmark_Bbolt_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() diff --git a/memory/memory_test.go b/memory/memory_test.go index c5f75a24..c80fce93 100644 --- a/memory/memory_test.go +++ b/memory/memory_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/gofiber/utils/v2" "github.com/stretchr/testify/require" ) @@ -120,34 +119,6 @@ func Test_Storage_Memory_Conn(t *testing.T) { require.True(t, testStore.Conn() != nil) } -// go test -v -run=^$ -bench=Benchmark_Storage_Memory -benchmem -count=4 -func Benchmark_Storage_Memory(b *testing.B) { - keyLength := 1000 - keys := make([]string, keyLength) - for i := 0; i < keyLength; i++ { - keys[i] = utils.UUID() - } - value := []byte("joe") - - ttl := 2 * time.Second - b.Run("fiber_memory", func(b *testing.B) { - d := New() - b.ReportAllocs() - b.ResetTimer() - for n := 0; n < b.N; n++ { - for _, key := range keys { - d.Set(key, value, ttl) - } - for _, key := range keys { - _, _ = d.Get(key) - } - for _, key := range keys { - d.Delete(key) - } - } - }) -} - func Benchmark_Memory_Set(b *testing.B) { b.ReportAllocs() b.ResetTimer() diff --git a/sqlite3/sqlite3_test.go b/sqlite3/sqlite3_test.go index c07689be..c7965ac1 100644 --- a/sqlite3/sqlite3_test.go +++ b/sqlite3/sqlite3_test.go @@ -182,7 +182,7 @@ func Benchmark_SQLite3_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_SQLite3_Delete(b *testing.B) { +func Benchmark_SQLite3_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer()