2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-06-29 21:06:25 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-01-31 18:28:42 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
"storj.io/storj/storage/redis/redisserver"
|
|
|
|
"storj.io/storj/storage/testsuite"
|
2018-06-29 21:06:25 +01:00
|
|
|
)
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
func TestSuite(t *testing.T) {
|
2020-01-31 18:28:42 +00:00
|
|
|
redis, err := redisserver.Start()
|
2018-06-29 21:06:25 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
t.Fatal(err)
|
2018-06-29 21:06:25 +01:00
|
|
|
}
|
2020-01-31 18:28:42 +00:00
|
|
|
defer func() { require.NoError(t, redis.Close()) }()
|
2018-06-29 21:06:25 +01:00
|
|
|
|
2020-01-31 18:28:42 +00:00
|
|
|
client, err := NewClient(redis.Addr(), "", 1)
|
2018-06-29 21:06:25 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
t.Fatal(err)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
|
|
|
|
2020-01-22 19:00:46 +00:00
|
|
|
client.SetLookupLimit(500)
|
2018-09-05 17:10:35 +01:00
|
|
|
testsuite.RunTests(t, client)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
func TestInvalidConnection(t *testing.T) {
|
|
|
|
_, err := NewClient("", "", 1)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected connection error")
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-05 17:10:35 +01:00
|
|
|
func BenchmarkSuite(b *testing.B) {
|
2020-01-31 18:28:42 +00:00
|
|
|
redis, err := redisserver.Start()
|
2018-07-31 16:23:55 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
b.Fatal(err)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
2020-01-31 18:28:42 +00:00
|
|
|
defer func() { require.NoError(b, redis.Close()) }()
|
2018-07-31 16:23:55 +01:00
|
|
|
|
2020-01-31 18:28:42 +00:00
|
|
|
client, err := NewClient(redis.Addr(), "", 1)
|
2018-07-31 16:23:55 +01:00
|
|
|
if err != nil {
|
2018-09-05 17:10:35 +01:00
|
|
|
b.Fatal(err)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|
2018-09-05 17:10:35 +01:00
|
|
|
testsuite.RunBenchmarks(b, client)
|
2018-07-31 16:23:55 +01:00
|
|
|
}
|