aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-02-15 00:09:19 -0800
committerChris Lu <chris.lu@gmail.com>2019-02-15 00:09:19 -0800
commit74fb237727267aa482ee07851f454ca03fbd1fdf (patch)
treeca1a25621f932c46618da103f1cb6d7b95801168 /weed/command
parenta3b0e39b06dcc284ff255d9c2a3c1f55c05ad19c (diff)
downloadseaweedfs-74fb237727267aa482ee07851f454ca03fbd1fdf.tar.xz
seaweedfs-74fb237727267aa482ee07851f454ca03fbd1fdf.zip
benchmark can work in secure mode
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/benchmark.go13
-rw-r--r--weed/command/filer_copy.go4
2 files changed, 13 insertions, 4 deletions
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go
index be76a3e2e..47fdc69a0 100644
--- a/weed/command/benchmark.go
+++ b/weed/command/benchmark.go
@@ -17,6 +17,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation"
+ "github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/wdclient"
)
@@ -40,6 +41,7 @@ var (
b BenchmarkOptions
sharedBytes []byte
masterClient *wdclient.MasterClient
+ isSecure bool
)
func init() {
@@ -194,7 +196,11 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) {
if df.enterTime.After(time.Now()) {
time.Sleep(df.enterTime.Sub(time.Now()))
}
- if e := util.Delete("http://"+df.fp.Server+"/"+df.fp.Fid, ""); e == nil {
+ var jwtAuthorization security.EncodedJwt
+ if isSecure {
+ jwtAuthorization = operation.LookupJwt(masterClient.GetMaster(), df.fp.Fid)
+ }
+ if e := util.Delete(fmt.Sprintf("http://%s/%s", df.fp.Server, df.fp.Fid), jwtAuthorization); e == nil {
s.completed++
} else {
s.failed++
@@ -219,7 +225,10 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) {
}
if assignResult, err := operation.Assign(masterClient.GetMaster(), ar); err == nil {
fp.Server, fp.Fid, fp.Collection = assignResult.Url, assignResult.Fid, *b.collection
- if _, err := fp.Upload(0, masterClient.GetMaster(), ""); err == nil {
+ if !isSecure && assignResult.Auth != "" {
+ isSecure = true
+ }
+ if _, err := fp.Upload(0, masterClient.GetMaster(), assignResult.Auth); err == nil {
if random.Intn(100) < *b.deletePercentage {
s.total++
delayedDeleteChan <- &delayedFile{time.Now().Add(time.Second), fp}
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go
index af121ca1d..39d83c31e 100644
--- a/weed/command/filer_copy.go
+++ b/weed/command/filer_copy.go
@@ -173,7 +173,7 @@ func uploadFileAsOne(filerAddress, filerGrpcAddress string, urlFolder string, f
targetUrl := "http://" + assignResult.Url + "/" + assignResult.Fid
- uploadResult, err := operation.Upload(targetUrl, fileName, f, false, mimeType, nil, "")
+ uploadResult, err := operation.Upload(targetUrl, fileName, f, false, mimeType, nil, assignResult.Auth)
if err != nil {
fmt.Printf("upload data %v to %s: %v\n", fileName, targetUrl, err)
return false
@@ -253,7 +253,7 @@ func uploadFileInChunks(filerAddress, filerGrpcAddress string, urlFolder string,
uploadResult, err := operation.Upload(targetUrl,
fileName+"-"+strconv.FormatInt(i+1, 10),
io.LimitReader(f, chunkSize),
- false, "application/octet-stream", nil, "")
+ false, "application/octet-stream", nil, assignResult.Auth)
if err != nil {
fmt.Printf("upload data %v to %s: %v\n", fileName, targetUrl, err)
return false