mirror of https://github.com/etcd-io/dbtester.git
*: drop grpc port
This commit is contained in:
parent
72f6e5d815
commit
a3a29ca63e
|
|
@ -222,13 +222,11 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
|
|||
// generate flags from etcd server name
|
||||
clusterN := len(peerIPs)
|
||||
names := make([]string, clusterN)
|
||||
grpcURLs := make([]string, clusterN)
|
||||
clientURLs := make([]string, clusterN)
|
||||
peerURLs := make([]string, clusterN)
|
||||
members := make([]string, clusterN)
|
||||
for i, u := range peerIPs {
|
||||
names[i] = fmt.Sprintf("etcd-%d", i)
|
||||
grpcURLs[i] = fmt.Sprintf("%s:2378", u)
|
||||
clientURLs[i] = fmt.Sprintf("http://%s:2379", u)
|
||||
peerURLs[i] = fmt.Sprintf("http://%s:2380", u)
|
||||
members[i] = fmt.Sprintf("%s=%s", names[i], peerURLs[i])
|
||||
|
|
@ -249,7 +247,6 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
|
|||
"--initial-cluster-state", "new",
|
||||
|
||||
"--experimental-v3demo",
|
||||
"--experimental-gRPC-addr", grpcURLs[r.EtcdServerIndex],
|
||||
}
|
||||
flagString := strings.Join(flags, " ")
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/oauth2/google"
|
||||
"google.golang.org/cloud"
|
||||
"google.golang.org/cloud/storage"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// TODO: vendor gRPC and combine this into bench
|
||||
// Currently, we get:
|
||||
// panic: http: multiple registrations for /debug/requests
|
||||
|
||||
var Command = &cobra.Command{
|
||||
Use: "bench-uploader",
|
||||
Short: "Uploads to cloud storage.",
|
||||
RunE: CommandFunc,
|
||||
}
|
||||
|
||||
var (
|
||||
csvResultPath string
|
||||
googleCloudProjectName string
|
||||
googleCloudStorageJSONKeyPath string
|
||||
googleCloudStorageBucketName string
|
||||
)
|
||||
|
||||
func init() {
|
||||
cobra.EnablePrefixMatching = true
|
||||
}
|
||||
|
||||
func init() {
|
||||
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() {
|
||||
log.Printf("bench-uploader started at %s\n", time.Now().String()[:19])
|
||||
if err := Command.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stdout, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
log.Printf("bench-uploader ended at %s\n", time.Now().String()[:19])
|
||||
}
|
||||
|
||||
func CommandFunc(cmd *cobra.Command, args []string) error {
|
||||
kbts, err := ioutil.ReadFile(googleCloudStorageJSONKeyPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
conf, err := google.JWTConfigFromJSON(
|
||||
kbts,
|
||||
storage.ScopeFullControl,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx := context.Background()
|
||||
aclient, err := storage.NewAdminClient(ctx, googleCloudProjectName, cloud.WithTokenSource(conf.TokenSource(ctx)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer aclient.Close()
|
||||
|
||||
if err := aclient.CreateBucket(context.Background(), googleCloudStorageBucketName, nil); err != nil {
|
||||
if !strings.Contains(err.Error(), "You already own this bucket. Please select another name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sctx := context.Background()
|
||||
sclient, err := storage.NewClient(sctx, cloud.WithTokenSource(conf.TokenSource(sctx)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer sclient.Close()
|
||||
|
||||
log.Printf("Uploading %s\n", csvResultPath)
|
||||
|
||||
wc := sclient.Bucket(googleCloudStorageBucketName).Object(filepath.Base(csvResultPath)).NewWriter(context.Background())
|
||||
wc.ContentType = "text/plain"
|
||||
bts, err := ioutil.ReadFile(csvResultPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := wc.Write(bts); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := wc.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -39,10 +39,7 @@ var (
|
|||
sample bool
|
||||
noHistogram bool
|
||||
|
||||
csvResultPath string
|
||||
googleCloudProjectName string
|
||||
googleCloudStorageJSONKeyPath string
|
||||
googleCloudStorageBucketName string
|
||||
csvResultPath string
|
||||
|
||||
bar *pb.ProgressBar
|
||||
results chan result
|
||||
|
|
@ -61,9 +58,6 @@ func init() {
|
|||
Command.PersistentFlags().BoolVar(&sample, "sample", false, "'true' to sample requests for every second.")
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -18,17 +18,10 @@ import (
|
|||
"bytes"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/oauth2/google"
|
||||
"google.golang.org/cloud"
|
||||
"google.golang.org/cloud/storage"
|
||||
)
|
||||
|
||||
type timeSeries struct {
|
||||
|
|
@ -119,47 +112,7 @@ func (ts TimeSeries) String() string {
|
|||
if err := toFile(txt, csvResultPath); err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
log.Println("time series saved... uploading to Google cloud storage...")
|
||||
kbts, err := ioutil.ReadFile(googleCloudStorageJSONKeyPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
conf, err := google.JWTConfigFromJSON(
|
||||
kbts,
|
||||
storage.ScopeFullControl,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
aclient, err := storage.NewAdminClient(ctx, googleCloudProjectName, cloud.WithTokenSource(conf.TokenSource(ctx)))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer aclient.Close()
|
||||
|
||||
if err := aclient.CreateBucket(context.Background(), googleCloudStorageBucketName, nil); err != nil {
|
||||
if !strings.Contains(err.Error(), "You already own this bucket. Please select another name") {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
sctx := context.Background()
|
||||
sclient, err := storage.NewClient(sctx, cloud.WithTokenSource(conf.TokenSource(sctx)))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer sclient.Close()
|
||||
|
||||
log.Printf("Uploading %s\n", csvResultPath)
|
||||
wc := sclient.Bucket(googleCloudStorageBucketName).Object(csvResultPath).NewWriter(context.Background())
|
||||
wc.ContentType = "text/plain"
|
||||
if _, err := wc.Write([]byte(txt)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := wc.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Println("time series saved... Please upload to Google cloud storage...")
|
||||
}
|
||||
return fmt.Sprintf("\nSample in one second (unix latency throughput):\n%s", txt)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue