grafana/pkg/infra/remotecache/redis_storage_integration_test.go

42 lines
791 B
Go
Raw Normal View History

2019-03-08 13:49:16 -06:00
package remotecache
2019-03-02 21:42:11 -06:00
2019-03-03 14:48:00 -06:00
import (
"fmt"
"os"
"strings"
2019-03-03 14:48:00 -06:00
"testing"
"github.com/go-redis/redis/v8"
2019-03-03 14:48:00 -06:00
"github.com/grafana/grafana/pkg/setting"
)
2019-03-02 21:42:11 -06:00
func TestIntegrationRedisCacheStorage(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
u, ok := os.LookupEnv("REDIS_URL")
if !ok || u == "" {
t.Skip("No redis URL supplied")
}
addr := u
db := 0
parsed, err := redis.ParseURL(u)
if err == nil {
addr = parsed.Addr
db = parsed.DB
}
b := strings.Builder{}
b.WriteString(fmt.Sprintf("addr=%s", addr))
if db != 0 {
b.WriteString(fmt.Sprintf(",db=%d", db))
}
2019-03-03 14:48:00 -06:00
opts := &setting.RemoteCacheOptions{Name: redisCacheType, ConnStr: b.String()}
2019-03-14 02:57:38 -05:00
client := createTestClient(t, opts, nil)
runTestsForClient(t, client)
runCountTestsForClient(t, opts, nil)
2019-03-02 21:42:11 -06:00
}