*: separate bench command

gRPC dependency conflict
This commit is contained in:
Gyu-Ho Lee 2016-03-15 22:44:24 -07:00
parent 0c007bd7c1
commit 6b7eb7cbbb
12 changed files with 42 additions and 17 deletions

View File

@ -30,9 +30,9 @@ import (
"time" "time"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra" "github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc"
"github.com/gyuho/psn/ps" "github.com/gyuho/psn/ps"
"golang.org/x/net/context"
"google.golang.org/grpc"
) )
type ( type (

View File

@ -20,8 +20,8 @@ import math "math"
import _ "github.com/gogo/protobuf/gogoproto" import _ "github.com/gogo/protobuf/gogoproto"
import ( import (
context "github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context" context "golang.org/x/net/context"
grpc "github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc" grpc "google.golang.org/grpc"
) )
import io "io" import io "io"

View File

@ -12,6 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Package bench is copied from https://github.com/coreos/etcd/tree/master/tools/benchmark // bench is copied from https://github.com/coreos/etcd/tree/master/tools/benchmark
// for the purpose of supporting other databases. // for the purpose of supporting other databases.
package bench package main

15
bench/main.go Normal file
View File

@ -0,0 +1,15 @@
// Copyright 2015 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package bench package main
import ( import (
"encoding/binary" "encoding/binary"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package bench package main
import ( import (
"fmt" "fmt"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package bench package main
import ( import (
"fmt" "fmt"

View File

@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package bench package main
import ( import (
"fmt"
"os"
"sync" "sync"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/cheggaaa/pb" "github.com/coreos/etcd/Godeps/_workspace/src/github.com/cheggaaa/pb"
@ -39,6 +41,10 @@ var (
wg sync.WaitGroup wg sync.WaitGroup
) )
func init() {
cobra.EnablePrefixMatching = true
}
func init() { func init() {
Command.PersistentFlags().StringVarP(&database, "database", "d", "etcd", "'etcd', 'zk'(zookeeper)") Command.PersistentFlags().StringVarP(&database, "database", "d", "etcd", "'etcd', 'zk'(zookeeper)")
Command.PersistentFlags().StringSliceVar(&endpoints, "endpoints", []string{"10.240.0.9:2181", "10.240.0.10:2181", "10.240.0.14:2181"}, "gRPC endpoints") Command.PersistentFlags().StringSliceVar(&endpoints, "endpoints", []string{"10.240.0.9:2181", "10.240.0.10:2181", "10.240.0.14:2181"}, "gRPC endpoints")
@ -46,3 +52,10 @@ func init() {
Command.PersistentFlags().UintVar(&totalClients, "clients", 1, "Total number of gRPC clients (only for etcd)") Command.PersistentFlags().UintVar(&totalClients, "clients", 1, "Total number of gRPC clients (only for etcd)")
Command.PersistentFlags().BoolVar(&sample, "sample", false, "'true' to sample requests for every second") Command.PersistentFlags().BoolVar(&sample, "sample", false, "'true' to sample requests for every second")
} }
func main() {
if err := Command.Execute(); err != nil {
fmt.Fprintln(os.Stdout, err)
os.Exit(1)
}
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package bench package main
import ( import (
"bytes" "bytes"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package bench package main
import ( import (
"crypto/rand" "crypto/rand"

View File

@ -22,8 +22,8 @@ import (
"github.com/coreos/dbtester/agent" "github.com/coreos/dbtester/agent"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra" "github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context" "golang.org/x/net/context"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc" "google.golang.org/grpc"
) )
type ( type (

View File

@ -19,7 +19,6 @@
// //
// Available Commands: // Available Commands:
// agent Database agent in remote servers. // agent Database agent in remote servers.
// bench Low-level benchmark tool for etcd, Zookeeper.
// start Starts database through RPC calls. // start Starts database through RPC calls.
// stop Stops database through RPC calls. // stop Stops database through RPC calls.
// restart Restarts database through RPC calls. // restart Restarts database through RPC calls.
@ -36,7 +35,6 @@ import (
"os" "os"
"github.com/coreos/dbtester/agent" "github.com/coreos/dbtester/agent"
"github.com/coreos/dbtester/bench"
"github.com/coreos/dbtester/control" "github.com/coreos/dbtester/control"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra" "github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
@ -56,7 +54,6 @@ func init() {
func init() { func init() {
rootCommand.AddCommand(agent.Command) rootCommand.AddCommand(agent.Command)
rootCommand.AddCommand(bench.Command)
rootCommand.AddCommand(control.StartCommand) rootCommand.AddCommand(control.StartCommand)
rootCommand.AddCommand(control.StopCommand) rootCommand.AddCommand(control.StopCommand)
rootCommand.AddCommand(control.RestartCommand) rootCommand.AddCommand(control.RestartCommand)