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"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/dbtester/agent/agentpb"
|
"github.com/coreos/dbtester/agent/agentpb"
|
||||||
|
"github.com/gyuho/psn"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -39,10 +40,13 @@ type transporterServer struct {
|
||||||
proxyCmd *exec.Cmd
|
proxyCmd *exec.Cmd
|
||||||
proxyPid int64
|
proxyPid int64
|
||||||
|
|
||||||
|
metricsCSV *psn.CSV
|
||||||
|
|
||||||
// trigger log uploads to cloud storage
|
// trigger log uploads to cloud storage
|
||||||
// this should be triggered before we shut down
|
// this should be triggered before we shut down
|
||||||
// the agent server
|
// the agent server
|
||||||
uploadSig chan struct{}
|
uploadSig chan struct{}
|
||||||
|
csvReady chan struct{}
|
||||||
|
|
||||||
// notified after all tests finish
|
// notified after all tests finish
|
||||||
notifier chan os.Signal
|
notifier chan os.Signal
|
||||||
|
|
@ -55,6 +59,7 @@ func NewServer() agentpb.TransporterServer {
|
||||||
|
|
||||||
return &transporterServer{
|
return &transporterServer{
|
||||||
uploadSig: make(chan struct{}, 1),
|
uploadSig: make(chan struct{}, 1),
|
||||||
|
csvReady: make(chan struct{}),
|
||||||
notifier: notifier,
|
notifier: notifier,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -214,6 +219,7 @@ func (t *transporterServer) Transfer(ctx context.Context, r *agentpb.Request) (*
|
||||||
}
|
}
|
||||||
|
|
||||||
t.uploadSig <- struct{}{}
|
t.uploadSig <- struct{}{}
|
||||||
|
<-t.csvReady
|
||||||
|
|
||||||
if err := uploadLog(&globalFlags, t); err != nil {
|
if err := uploadLog(&globalFlags, t); err != nil {
|
||||||
plog.Warningf("uploadLog error %v", err)
|
plog.Warningf("uploadLog error %v", err)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ func collectMetrics(fs *flags, t *transporterServer) error {
|
||||||
if err := c.Add(); err != nil {
|
if err := c.Add(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
t.metricsCSV = c
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
|
@ -49,10 +50,16 @@ func collectMetrics(fs *flags, t *transporterServer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-t.uploadSig:
|
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
|
return
|
||||||
|
|
||||||
case sig := <-notifier:
|
case sig := <-t.notifier:
|
||||||
plog.Infof("signal received %q", sig.String())
|
plog.Infof("signal received %q", sig.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue