Skip to content

Commit

Permalink
Cleanup riot
Browse files Browse the repository at this point in the history
  • Loading branch information
iknite committed Mar 14, 2019
1 parent 63ef719 commit e607b09
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions tests/riot.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,20 @@ type Config struct {

type Plan [][]Config

type kind string

const (
add kind = "add"
membership kind = "membership"
incremental kind = "incremental"
)

type Attack struct {
kind kind
balloonVersion uint64

config Config
client *client.HTTPClient
reqChan chan uint
senChan chan Task
}

Expand Down Expand Up @@ -139,7 +146,7 @@ func newRiotCommand() *cobra.Command {

if riot.Config.Profiling {
go func() {
log.Info("Go profiling enabled")
log.Info(" * Starting Riot Profiling server")
log.Info(http.ListenAndServe(":6060", nil))
}()
}
Expand Down Expand Up @@ -176,11 +183,9 @@ func (riot *Riot) Start(APIMode bool) {
Register(r)
riot.prometheusRegistry = r
metricsMux := metricshttp.NewMetricsHTTP(r)
log.Debug(" * Starting Riot Metrics server")
riot.metricsServer = &http.Server{Addr: ":17700", Handler: metricsMux}

b, _ := json.MarshalIndent(riot.Config, "", " ")
log.Debugf(">>>>>>>>>>>>> ATTACK: %s", b)

if APIMode {
riot.Serve()
} else {
Expand Down Expand Up @@ -252,28 +257,15 @@ func (riot *Riot) Serve() {
}
})

api := &http.Server{
Addr: ":7700",
Handler: mux,
}
api := &http.Server{Addr: ":7700", Handler: mux}

log.Debug(" * Starting Riot HTTP server")
if err := api.ListenAndServe(); err != http.ErrServerClosed {
log.Errorf("Can't start Riot API HTTP server: %s", err)
}
}

type kind string

const (
add kind = "add"
membership kind = "membership"
incremental kind = "incremental"
)

func newAttack(conf Config) {
b, _ := json.MarshalIndent(conf, "", " ")
log.Debugf(">>>>>>>>>>>>> ATTACK: %s", b)

cConf := client.DefaultConfig()
cConf.Endpoints = []string{conf.Endpoint}
Expand Down Expand Up @@ -304,23 +296,23 @@ func (a *Attack) Run() {
for {
task, ok := <-a.senChan
if !ok {
log.Infof("Closing #%d", rID)
log.Debugf("!!! clos: %d", rID)
wg.Done()
return
}

switch task.kind {
case add:
log.Debugf(">>> add: %s", task.event)
_, _ = a.client.Add(task.event)
log.Debugf("Sending #%s", task.event)
RiotEventAdd.Inc()
case membership:
log.Debugf(">>> mem: %s, %d", task.event, task.version)
_, _ = a.client.Membership(task.key, task.version)
log.Debugf("Membring #%s", task.event)
RiotQueryMembership.Inc()
case incremental:
log.Debugf(">>> inc: %s", task.event)
_, _ = a.client.Incremental(task.start, task.end)
log.Debugf("Incrming #%s", task.event)
RiotQueryIncremental.Inc()
}
}
Expand Down

0 comments on commit e607b09

Please sign in to comment.