mirror of https://github.com/etcd-io/dbtester.git
agent: fix 'psn' usage
This commit is contained in:
parent
af350fe3f8
commit
5c47abd819
|
|
@ -23,6 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/coreos/dbtester/agent/agentpb"
|
||||
"github.com/gyuho/psn"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
|
@ -39,10 +40,13 @@ type transporterServer struct {
|
|||
proxyCmd *exec.Cmd
|
||||
proxyPid int64
|
||||
|
||||
metricsCSV *psn.CSV
|
||||
|
||||
// trigger log uploads to cloud storage
|
||||
// this should be triggered before we shut down
|
||||
// the agent server
|
||||
uploadSig chan struct{}
|
||||
csvReady chan struct{}
|
||||
|
||||
// notified after all tests finish
|
||||
notifier chan os.Signal
|
||||
|
|
@ -55,6 +59,7 @@ func NewServer() agentpb.TransporterServer {
|
|||
|
||||
return &transporterServer{
|
||||
uploadSig: make(chan struct{}, 1),
|
||||
csvReady: make(chan struct{}),
|
||||
notifier: notifier,
|
||||
}
|
||||
}
|
||||
|
|
@ -214,6 +219,7 @@ func (t *transporterServer) Transfer(ctx context.Context, r *agentpb.Request) (*
|
|||
}
|
||||
|
||||
t.uploadSig <- struct{}{}
|
||||
<-t.csvReady
|
||||
|
||||
if err := uploadLog(&globalFlags, t); err != nil {
|
||||
plog.Warningf("uploadLog error %v", err)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ func collectMetrics(fs *flags, t *transporterServer) error {
|
|||
if err := c.Add(); err != nil {
|
||||
return err
|
||||
}
|
||||
t.metricsCSV = c
|
||||
|
||||
go func() {
|
||||
for {
|
||||
|
|
@ -49,10 +50,16 @@ func collectMetrics(fs *flags, t *transporterServer) error {
|
|||
}
|
||||
|
||||
case <-t.uploadSig:
|
||||
plog.Info("upload signal received; returning")
|
||||
plog.Infof("upload signal received; saving CSV at %q", t.metricsCSV.FilePath)
|
||||
if err := t.metricsCSV.Save(); err != nil {
|
||||
plog.Errorf("psn.CSV.Save error %v", err)
|
||||
} else {
|
||||
plog.Infof("CSV saved at %q", t.metricsCSV.FilePath)
|
||||
}
|
||||
close(t.csvReady)
|
||||
return
|
||||
|
||||
case sig := <-notifier:
|
||||
case sig := <-t.notifier:
|
||||
plog.Infof("signal received %q", sig.String())
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue