mirror of https://github.com/etcd-io/dbtester.git
*: combine bench to main command
This commit is contained in:
parent
6a025843f0
commit
8e11f1d1e6
|
|
@ -586,19 +586,6 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
|
|||
if !strings.HasPrefix(filepath.Base(t.req.DatabaseLogPath), t.req.LogPrefix) {
|
||||
dstDatabaseLogPath = fmt.Sprintf("%s-%d-%s", t.req.LogPrefix, t.req.ServerIndex+1, filepath.Base(t.req.DatabaseLogPath))
|
||||
}
|
||||
|
||||
srcMonitorResultPath := t.req.MonitorResultPath
|
||||
dstMonitorResultPath := filepath.Base(t.req.MonitorResultPath)
|
||||
if !strings.HasPrefix(filepath.Base(t.req.MonitorResultPath), t.req.LogPrefix) {
|
||||
dstMonitorResultPath = fmt.Sprintf("%s-%d-%s", t.req.LogPrefix, t.req.ServerIndex+1, filepath.Base(t.req.MonitorResultPath))
|
||||
}
|
||||
|
||||
srcAgentLogPath := agentLogPath
|
||||
dstAgentLogPath := filepath.Base(agentLogPath)
|
||||
if !strings.HasPrefix(filepath.Base(agentLogPath), t.req.LogPrefix) {
|
||||
dstAgentLogPath = fmt.Sprintf("%s-%d-%s", t.req.LogPrefix, t.req.ServerIndex+1, filepath.Base(agentLogPath))
|
||||
}
|
||||
|
||||
log.Printf("Uploading %s to %s", srcDatabaseLogPath, dstDatabaseLogPath)
|
||||
var uerr error
|
||||
for k := 0; k < 5; k++ {
|
||||
|
|
@ -610,6 +597,11 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
|
|||
}
|
||||
}
|
||||
|
||||
srcMonitorResultPath := t.req.MonitorResultPath
|
||||
dstMonitorResultPath := filepath.Base(t.req.MonitorResultPath)
|
||||
if !strings.HasPrefix(filepath.Base(t.req.MonitorResultPath), t.req.LogPrefix) {
|
||||
dstMonitorResultPath = fmt.Sprintf("%s-%d-%s", t.req.LogPrefix, t.req.ServerIndex+1, filepath.Base(t.req.MonitorResultPath))
|
||||
}
|
||||
log.Printf("Uploading %s to %s", srcMonitorResultPath, dstMonitorResultPath)
|
||||
for k := 0; k < 5; k++ {
|
||||
if uerr = u.UploadFile(t.req.GoogleCloudStorageBucketName, srcMonitorResultPath, dstMonitorResultPath); uerr != nil {
|
||||
|
|
@ -620,6 +612,11 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
|
|||
}
|
||||
}
|
||||
|
||||
srcAgentLogPath := agentLogPath
|
||||
dstAgentLogPath := filepath.Base(agentLogPath)
|
||||
if !strings.HasPrefix(filepath.Base(agentLogPath), t.req.LogPrefix) {
|
||||
dstAgentLogPath = fmt.Sprintf("%s-%d-%s", t.req.LogPrefix, t.req.ServerIndex+1, filepath.Base(agentLogPath))
|
||||
}
|
||||
log.Printf("Uploading %s to %s", srcAgentLogPath, dstAgentLogPath)
|
||||
for k := 0; k < 5; k++ {
|
||||
if uerr = u.UploadFile(t.req.GoogleCloudStorageBucketName, srcAgentLogPath, dstAgentLogPath); uerr != nil {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// bench does benchmark, mostly copied from https://github.com/coreos/etcd/tree/master/tools/benchmark.
|
||||
package main
|
||||
// Package bench is modified based on https://github.com/coreos/etcd/tree/master/tools/benchmark.
|
||||
package bench
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -40,7 +40,10 @@ var (
|
|||
sample bool
|
||||
noHistogram bool
|
||||
|
||||
csvResultPath string
|
||||
csvResultPath string
|
||||
googleCloudProjectName string
|
||||
googleCloudStorageJSONKeyPath string
|
||||
googleCloudStorageBucketName string
|
||||
|
||||
bar *pb.ProgressBar
|
||||
results chan result
|
||||
|
|
@ -60,6 +63,9 @@ func init() {
|
|||
Command.PersistentFlags().BoolVar(&noHistogram, "no-histogram", false, "'true' to not show results in histogram.")
|
||||
|
||||
Command.PersistentFlags().StringVar(&csvResultPath, "csv-result-path", "timeseries.csv", "path to store csv results.")
|
||||
Command.PersistentFlags().StringVar(&googleCloudProjectName, "google-cloud-project-name", "", "Google cloud project name.")
|
||||
Command.PersistentFlags().StringVar(&googleCloudStorageJSONKeyPath, "google-cloud-storage-json-key-path", "", "Path of JSON key file.")
|
||||
Command.PersistentFlags().StringVar(&googleCloudStorageBucketName, "google-cloud-storage-bucket-name", "", "Google cloud storage bucket name.")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
package bench
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
package bench
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
package bench
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
|
|||
|
|
@ -12,16 +12,20 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
package bench
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/dbtester/remotestorage"
|
||||
)
|
||||
|
||||
type timeSeries struct {
|
||||
|
|
@ -112,7 +116,29 @@ func (ts TimeSeries) String() string {
|
|||
if err := toFile(txt, csvResultPath); err != nil {
|
||||
log.Fatal(err)
|
||||
} else {
|
||||
log.Println("time series saved... Please upload to Google cloud storage...")
|
||||
log.Println("time series saved... Uploading to Google cloud storage...")
|
||||
kbts, err := ioutil.ReadFile(googleCloudStorageJSONKeyPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
u, err := remotestorage.NewGoogleCloudStorage(kbts, googleCloudProjectName)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// set up file names
|
||||
srcCSVResultPath := csvResultPath
|
||||
dstCSVResultPath := filepath.Base(csvResultPath)
|
||||
log.Printf("Uploading %s to %s", srcCSVResultPath, dstCSVResultPath)
|
||||
var uerr error
|
||||
for k := 0; k < 5; k++ {
|
||||
if uerr = u.UploadFile(googleCloudStorageBucketName, srcCSVResultPath, dstCSVResultPath); uerr != nil {
|
||||
log.Println(uerr)
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("\nSample in one second (unix latency throughput):\n%s", txt)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
package bench
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
|
|
|||
5
main.go
5
main.go
|
|
@ -19,12 +19,13 @@
|
|||
//
|
||||
// Available Commands:
|
||||
// agent Database agent in remote servers.
|
||||
// bench Low-level benchmark tool for etcd, Zookeeper, etcd2, consul.
|
||||
// start Starts database through RPC calls.
|
||||
// stop Stops database through RPC calls.
|
||||
// restart Restarts database through RPC calls.
|
||||
//
|
||||
// Flags:
|
||||
// -h, --help[=false]: help for dbtester
|
||||
// -h, --help help for dbtester
|
||||
//
|
||||
// Use "dbtester [command] --help" for more information about a command.
|
||||
//
|
||||
|
|
@ -35,6 +36,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/coreos/dbtester/agent"
|
||||
"github.com/coreos/dbtester/bench"
|
||||
"github.com/coreos/dbtester/control"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -54,6 +56,7 @@ func init() {
|
|||
|
||||
func init() {
|
||||
rootCommand.AddCommand(agent.Command)
|
||||
rootCommand.AddCommand(bench.Command)
|
||||
rootCommand.AddCommand(control.StartCommand)
|
||||
rootCommand.AddCommand(control.StopCommand)
|
||||
rootCommand.AddCommand(control.RestartCommand)
|
||||
|
|
|
|||
Loading…
Reference in New Issue