Skip to content

Commit

Permalink
update benchmark workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Sep 15, 2023
1 parent 6335aa4 commit 8e6e0a1
Show file tree
Hide file tree
Showing 22 changed files with 395 additions and 214 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,64 @@ name: Benchmark
jobs:
Compare:
runs-on: ubuntu-latest
services:
arangodb:
image: 'arangodb:latest'
env:
ARANGO_NO_AUTH: 1
ports:
- '8529:8529'
dynamodb:
image: 'amazon/dynamodb-local:latest'
ports:
- '8000:8000'
memcached:
image: 'memcached:latest'
ports:
- '11211:11211'
mongo:
image: 'mongo:latest'
ports:
- '27017:27017'
mssql:
image: 'mcmoe/mssqldocker:latest'
ports:
- '1433:1433'
env:
ACCEPT_EULA: Y
SA_PASSWORD: MsSql!1234
MSSQL_DB: master
MSSQL_USER: sa
MSSQL_PASSWORD: MsSql!1234
options: >-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD -Q 'select 1' -b -o /dev/null"
--health-interval 1s
--health-timeout 30s
--health-start-period 10s
--health-retries 20
mysql:
image: 'mysql:latest'
env:
MYSQL_DATABASE: fiber
MYSQL_USER: username
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- '3306:3306'
options: >-
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
5s --health-retries 5
postgres:
image: 'postgres:latest'
ports:
- '5432:5432'
env:
POSTGRES_DB: fiber
POSTGRES_USER: username
POSTGRES_PASSWORD: "pass#w%rd"
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
--health-retries 5
steps:
- name: Fetch Repository
uses: actions/checkout@v4
Expand All @@ -29,6 +87,53 @@ jobs:
# NOTE: Keep this in sync with the version from go.mod
go-version: "1.20.x"

- 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
sleep 10
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 \
--publish 2379:2379 \
--publish 2380:2380 \
--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
with:
redis-version: ${{ matrix.redis }}
auto-start: 'false'

- 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 &
- name: Run Benchmarks
run: |
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- 1.21.x
steps:
- name: Install MinIO
run: docker run -d -p 9000:9000 --name minio minio/minio server /data
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: Fetch Repository
uses: actions/checkout@v4
- name: Install Go
Expand Down
16 changes: 13 additions & 3 deletions arangodb/arangodb_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package arangodb

import (
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
)

var testStore = New(Config{
Reset: true,
})
var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Reset: true,
})

code := m.Run()

_ = testStore.Close()
os.Exit(code)
}

func Test_ArangoDB_Set(t *testing.T) {
var (
Expand Down
25 changes: 11 additions & 14 deletions azureblob/azureblob_test.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
package azureblob

import (
"os"
"testing"

"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror"
"github.com/stretchr/testify/require"
)

func newStore() *Storage {
return New(Config{
var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Account: "devstoreaccount1",
Container: "test",
Endpoint: "http://127.0.0.1:10000/devstoreaccount1",
Credentials: Credentials{
Account: "devstoreaccount1",
Key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
},
Reset: true,
})

code := m.Run()

_ = testStore.Close()
os.Exit(code)
}

func Test_AzureBlob_Get(t *testing.T) {
var (
key = "john"
val = []byte("doe")
)
testStore := newStore()

err := testStore.Set(key, val, 0)
require.NoError(t, err)
Expand All @@ -40,7 +48,6 @@ func Test_AzureBlob_Set(t *testing.T) {
val = []byte("doe")
)

testStore := newStore()
err := testStore.Set(key, val, 0)
require.NoError(t, err)
}
Expand All @@ -50,7 +57,6 @@ func Test_AzureBlob_Delete(t *testing.T) {
key = "john"
val = []byte("doe")
)
testStore := newStore()

err := testStore.Set(key, val, 0)
require.NoError(t, err)
Expand All @@ -73,7 +79,6 @@ func Test_AzureBlob_Override(t *testing.T) {
key = "john"
val = []byte("doe")
)
testStore := newStore()

err := testStore.Set(key, val, 0)
require.NoError(t, err)
Expand All @@ -83,7 +88,6 @@ func Test_AzureBlob_Override(t *testing.T) {
}

func Test_AzureBlob_Get_NotExist(t *testing.T) {
testStore := newStore()
result, err := testStore.Get("notexist")
if err != nil {
if bloberror.HasCode(err, bloberror.BlobNotFound) {
Expand All @@ -96,7 +100,6 @@ func Test_AzureBlob_Get_NotExist(t *testing.T) {

func Test_AzureBlob_Reset(t *testing.T) {
val := []byte("doe")
testStore := newStore()

err := testStore.Set("john1", val, 0)
require.NoError(t, err)
Expand Down Expand Up @@ -127,18 +130,14 @@ func Test_AzureBlob_Reset(t *testing.T) {
}

func Test_S3_Conn(t *testing.T) {
testStore := newStore()
require.True(t, testStore.Conn() != nil)
}

func Test_AzureBlob_Close(t *testing.T) {
testStore := newStore()
require.Nil(t, testStore.Close())
}

func Benchmark_AzureBlob_Set(b *testing.B) {
testStore := newStore()

b.ReportAllocs()
b.ResetTimer()

Expand All @@ -151,7 +150,6 @@ func Benchmark_AzureBlob_Set(b *testing.B) {
}

func Benchmark_AzureBlob_Get(b *testing.B) {
testStore := newStore()
err := testStore.Set("john", []byte("doe"), 0)
require.NoError(b, err)

Expand All @@ -166,7 +164,6 @@ func Benchmark_AzureBlob_Get(b *testing.B) {
}

func Benchmark_AzureBlob_Delete(b *testing.B) {
testStore := newStore()
err := testStore.Set("john", []byte("doe"), 0)
require.NoError(b, err)

Expand Down
14 changes: 13 additions & 1 deletion badger/badger_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
package badger

import (
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
)

var testStore = New()
var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Reset: true,
})

code := m.Run()

_ = testStore.Close()
os.Exit(code)
}

func Test_Badger_Set(t *testing.T) {
var (
Expand Down
14 changes: 13 additions & 1 deletion bbolt/bbolt_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package bbolt

import (
"os"
"testing"

"github.com/stretchr/testify/require"
)

var testStore = New()
var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Reset: true,
})

code := m.Run()

_ = testStore.Close()
os.Exit(code)
}

func Test_Bbolt_Set(t *testing.T) {
var (
Expand Down
Loading

0 comments on commit 8e6e0a1

Please sign in to comment.