-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
689ada1
commit 9105c1d
Showing
5 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package request_generators | ||
|
||
import ( | ||
"github.com/v3io/http_blaster/httpblaster/config" | ||
"github.com/v3io/http_blaster/httpblaster/data_generator" | ||
"runtime" | ||
"sync" | ||
) | ||
|
||
type Faker2KV struct { | ||
workload config.Workload | ||
RequestCommon | ||
} | ||
|
||
func (self *Faker2KV) UseCommon(c RequestCommon) { | ||
|
||
} | ||
|
||
func (self *Faker2KV) generate_request(ch_records chan []string, ch_req chan *Request, host string, | ||
wg *sync.WaitGroup, cpuNumber int, wl config.Workload) { | ||
defer wg.Done() | ||
var faker = data_generator.Fake{} | ||
for i := 0; i < wl.Count; i++ { | ||
|
||
var contentType string = "text/html" | ||
faker.GenerateRandomData() | ||
json_payload := faker.ConvertToIgzEmdItemJson() | ||
req := AcquireRequest() | ||
self.PrepareRequest(contentType, self.workload.Header, "PUT", | ||
self.base_uri, json_payload, host, req.Request) | ||
ch_req <- req | ||
} | ||
} | ||
|
||
func (self *Faker2KV) generate(ch_req chan *Request, payload string, host string, wl config.Workload) { | ||
defer close(ch_req) | ||
var ch_records chan []string = make(chan []string, 1000) | ||
wg := sync.WaitGroup{} | ||
wg.Add(runtime.NumCPU()) | ||
for c := 0; c < runtime.NumCPU(); c++ { | ||
go self.generate_request(ch_records, ch_req, host, &wg, c, wl) | ||
} | ||
|
||
close(ch_records) | ||
wg.Wait() | ||
} | ||
|
||
func (self *Faker2KV) GenerateRequests(global config.Global, wl config.Workload, tls_mode bool, host string, ret_ch chan *Response, worker_qd int) chan *Request { | ||
|
||
self.workload = wl | ||
|
||
if self.workload.Header == nil { | ||
self.workload.Header = make(map[string]string) | ||
} | ||
self.workload.Header["X-v3io-function"] = "PutItem" | ||
|
||
self.SetBaseUri(tls_mode, host, self.workload.Container, self.workload.Target) | ||
|
||
ch_req := make(chan *Request, worker_qd) | ||
|
||
go self.generate(ch_req, self.workload.Payload, host, wl) | ||
|
||
return ch_req | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tests | ||
|
||
import ( | ||
"fmt" | ||
"github.com/v3io/http_blaster/httpblaster/data_generator" | ||
"testing" | ||
) | ||
|
||
func Test_facker_generator(t *testing.T) { | ||
gen := data_generator.Faker{} | ||
gen.GenerateRandomData() | ||
} | ||
|
||
func Test_facker_generator_to_igzemditem(t *testing.T) { | ||
gen := data_generator.Faker{} | ||
gen.GenerateRandomData() | ||
str := gen.ConvertToIgzEmdItemJson() | ||
fmt.Println(str) | ||
} |