Skip to content

Commit

Permalink
solving conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouyihaiDing committed Jul 27, 2017
2 parents 8dd35b4 + 3ddcdc2 commit 3ce7ccb
Show file tree
Hide file tree
Showing 47 changed files with 1,146 additions and 495 deletions.
15 changes: 0 additions & 15 deletions benchmark/server/testdata/ca.pem

This file was deleted.

16 changes: 0 additions & 16 deletions benchmark/server/testdata/server1.key

This file was deleted.

16 changes: 0 additions & 16 deletions benchmark/server/testdata/server1.pem

This file was deleted.

7 changes: 2 additions & 5 deletions benchmark/worker/benchmark_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
)

var (
caFile = "benchmark/server/testdata/ca.pem"
"google.golang.org/grpc/testdata"
)

type lockingHistogram struct {
Expand Down Expand Up @@ -122,7 +119,7 @@ func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error

// Check and set security options.
if config.SecurityParams != nil {
creds, err := credentials.NewClientTLSFromFile(abs(caFile), config.SecurityParams.ServerHostOverride)
creds, err := credentials.NewClientTLSFromFile(testdata.Path("ca.pem"), config.SecurityParams.ServerHostOverride)
if err != nil {
return nil, nil, grpc.Errorf(codes.InvalidArgument, "failed to create TLS credentials %v", err)
}
Expand Down
9 changes: 2 additions & 7 deletions benchmark/worker/benchmark_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
)

var (
// File path related to google.golang.org/grpc.
certFile = "benchmark/server/testdata/server1.pem"
keyFile = "benchmark/server/testdata/server1.key"
"google.golang.org/grpc/testdata"
)

type benchmarkServer struct {
Expand Down Expand Up @@ -90,7 +85,7 @@ func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchma

// Set security options.
if config.SecurityParams != nil {
creds, err := credentials.NewServerTLSFromFile(abs(certFile), abs(keyFile))
creds, err := credentials.NewServerTLSFromFile(testdata.Path("server1.pem"), testdata.Path("server1.key"))
if err != nil {
grpclog.Fatalf("failed to generate credentials %v", err)
}
Expand Down
43 changes: 1 addition & 42 deletions benchmark/worker/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,7 @@

package main

import (
"log"
"os"
"path/filepath"
"syscall"
)

// abs returns the absolute path the given relative file or directory path,
// relative to the google.golang.org/grpc directory in the user's GOPATH.
// If rel is already absolute, it is returned unmodified.
func abs(rel string) string {
if filepath.IsAbs(rel) {
return rel
}
v, err := goPackagePath("google.golang.org/grpc")
if err != nil {
log.Fatalf("Error finding google.golang.org/grpc/testdata directory: %v", err)
}
return filepath.Join(v, rel)
}
import "syscall"

func cpuTimeDiff(first *syscall.Rusage, latest *syscall.Rusage) (float64, float64) {
var (
Expand All @@ -52,25 +33,3 @@ func cpuTimeDiff(first *syscall.Rusage, latest *syscall.Rusage) (float64, float6

return uTimeElapsed, sTimeElapsed
}

func goPackagePath(pkg string) (path string, err error) {
gp := os.Getenv("GOPATH")
if gp == "" {
return path, os.ErrNotExist
}
for _, p := range filepath.SplitList(gp) {
dir := filepath.Join(p, "src", filepath.FromSlash(pkg))
fi, err := os.Stat(dir)
if os.IsNotExist(err) {
continue
}
if err != nil {
return "", err
}
if !fi.IsDir() {
continue
}
return dir, nil
}
return path, os.ErrNotExist
}
Loading

0 comments on commit 3ce7ccb

Please sign in to comment.