Skip to content

Commit

Permalink
Unify test_service and store_clients
Browse files Browse the repository at this point in the history
  • Loading branch information
suizman committed Nov 23, 2018
1 parent 4f43f95 commit 0a89643
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 50 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 // indirect
github.com/stretchr/testify v1.2.2
github.com/tsenart/vegeta v8.0.1-0.20181009223527-f25ac6abb70a+incompatible
github.com/valyala/fasthttp v1.0.0
github.com/wcharczuk/go-chart v2.0.1+incompatible
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
golang.org/x/image v0.0.0-20181102021609-63626fb251ce // indirect
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/tdigest v0.0.0-20180711151920-a7d76c6f093a h1:vMqgISSVkIqWxCIZs8m1L4096temR7IbYyNdMiBxSPA=
github.com/influxdata/tdigest v0.0.0-20180711151920-a7d76c6f093a/go.mod h1:9GkyshztGufsdPQWjH+ifgnIr3xNUL5syI70g2dzU1o=
github.com/klauspost/compress v1.4.0 h1:8nsMz3tWa9SWWPL60G1V6CUsf4lLjWLTNEtibhe8gh8=
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e h1:+lIPJOWl+jSiJOc70QXJ07+2eg2Jy2EC7Mi11BWujeM=
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down Expand Up @@ -94,6 +98,11 @@ github.com/tsenart/vegeta v8.0.0+incompatible h1:B/R/ayQhKTxPvvHYfO3b2G8ExYrh+5S
github.com/tsenart/vegeta v8.0.0+incompatible/go.mod h1:Smz/ZWfhKRcyDDChZkG3CyTHdj87lHzio/HOCkbndXM=
github.com/tsenart/vegeta v8.0.1-0.20181009223527-f25ac6abb70a+incompatible h1:VDG+OUNhajJj8tCuLbBf2Li46eYJtKUvTVly0wNwzck=
github.com/tsenart/vegeta v8.0.1-0.20181009223527-f25ac6abb70a+incompatible/go.mod h1:Smz/ZWfhKRcyDDChZkG3CyTHdj87lHzio/HOCkbndXM=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.0.0 h1:BwIoZQbBsTo3v2F5lz5Oy3TlTq4wLKTLV260EVTEWco=
github.com/valyala/fasthttp v1.0.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/wcharczuk/go-chart v2.0.1+incompatible h1:0pz39ZAycJFF7ju/1mepnk26RLVLBCWz1STcD3doU0A=
github.com/wcharczuk/go-chart v2.0.1+incompatible/go.mod h1:PF5tmL4EIx/7Wf+hEkpCqYi5He4u90sw+0+6FhrryuE=
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b h1:2b9XGzhjiYsYPnKXoEfL7klWZQIt8IfyRCz62gCqqlQ=
Expand Down
50 changes: 0 additions & 50 deletions tests/gossip/store_clients.go

This file was deleted.

31 changes: 31 additions & 0 deletions tests/gossip/test_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/bbva/qed/gossip/member"
"github.com/go-redis/redis"
)

type stats struct {
Expand Down Expand Up @@ -52,6 +53,14 @@ type BatchSnapshots struct {
From *member.Peer
}

type StoreClient interface {
Put(key, value string)
}

type RedisCli struct {
rcli *redis.Client
}

func (s *stats) Add(nodeType string, id, v int) {
s.Lock()
defer s.Unlock()
Expand All @@ -61,6 +70,28 @@ func (s *stats) Add(nodeType string, id, v int) {
s.batch[nodeType][id] += v
}

func NewRedisClient() *RedisCli {
c := redis.NewClient(&redis.Options{
Addr: "127.0.0.1:6379",
Password: "", // no password set
DB: 0, // use default DB
})

pong, err := c.Ping().Result()
fmt.Println(pong, err)
// Output: PONG <nil>
return &RedisCli{rcli: c}
}

func (c *RedisCli) Put(key, value string) {
err := c.rcli.Set(key, value, 0).Err()
if err != nil {
panic(err)
}
}

// TODO: SeMaaS

func (s stats) Get(nodeType string, id int) int {
s.Lock()
defer s.Unlock()
Expand Down

0 comments on commit 0a89643

Please sign in to comment.