mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
caac9838d8
* Build: Fix integration cache tests * Allow REDIS_URL with scheme * Reduce cache integration tests timeout to 5m * Apply suggestion from code review * Run redis/memcached integration tests in OSS pipelines * Change redis image
42 lines
791 B
Go
42 lines
791 B
Go
package remotecache
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/go-redis/redis/v8"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
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))
|
|
}
|
|
|
|
opts := &setting.RemoteCacheOptions{Name: redisCacheType, ConnStr: b.String()}
|
|
client := createTestClient(t, opts, nil)
|
|
runTestsForClient(t, client)
|
|
runCountTestsForClient(t, opts, nil)
|
|
}
|