mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-26 23:50:00 -07:00
* replace redis keys with RawString encoded values (delete SerializedPeer) * merge peers got from pre-hools with store data
46 lines
1006 B
Go
46 lines
1006 B
Go
package redis
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/alicebob/miniredis"
|
|
|
|
s "github.com/sot-tech/mochi/storage"
|
|
"github.com/sot-tech/mochi/storage/test"
|
|
)
|
|
|
|
var conf = Config{
|
|
GarbageCollectionInterval: 10 * time.Minute,
|
|
PrometheusReportingInterval: 10 * time.Minute,
|
|
PeerLifetime: 30 * time.Minute,
|
|
ReadTimeout: 10 * time.Second,
|
|
WriteTimeout: 10 * time.Second,
|
|
ConnectTimeout: 10 * time.Second,
|
|
}
|
|
|
|
func createNew() s.Storage {
|
|
var ps s.Storage
|
|
var err error
|
|
ps, err = New(conf)
|
|
if err != nil {
|
|
fmt.Println("unable to create real Redis connection: ", err, " using simulator")
|
|
var rs *miniredis.Miniredis
|
|
rs, err = miniredis.Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
conf.Addresses = []string{rs.Addr()}
|
|
ps, err = New(conf)
|
|
}
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return ps
|
|
}
|
|
|
|
func TestStorage(t *testing.T) { test.RunTests(t, createNew()) }
|
|
|
|
func BenchmarkStorage(b *testing.B) { test.RunBenchmarks(b, createNew) }
|