satori-com / mzbench

MZ Benchmarking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

http_worker: PUT opeartions with "Content-Type: application/json" header

rahulx411 opened this issue · comments

I am unable to get PUT operations with "Content-Type: application/json" working with mzbench.
Please advise on the approach for getting the below hackney-like option work with http_worker using BDL:
ReqHeaders = [{<<"Content-Type">>, <<"application/json">>}]

Hi, sorry for the delay, I have added "post" method, please try the following script and let me know if it works for you:

#!benchDL

make_install(
        git = "https://github.com/machinezone/mzbench.git",
        dir = "workers/http")

pool(size = 5,
     worker_type = http_worker):
    set_options("Content-type" = "mytype")

    connect("localhost", 4800)
    loop(time = 1 min,
         rate = 10 rps):
            put("/", "data")

it turned out that options here are not hackney options, but headers

Thanks. I could get the POST method to work for 1 and 2 workers successfully. However, when the workers are set any higher (like 5) , I get failures with the following stacktrace:

02:26:11.264 [error] <0.229.0> Worker <0.247.0> on 'mzb_director119_0@127.0.0.1' has crashed: function_clause Stacktrace: [{hackney_connect,maybe_connect,[ok],[{file,"/home/ridrisov/mzbench/workers/http/_build/default/deps/hackney/src/hackney_connect.erl"},{line,98}]},{hackney,send_request,2,[{file,"/home/ridrisov/mzbench/workers/http/_build/default/deps/hackney/src/hackney.erl"},{line,364}]},{http_worker,'-post/4-fun-0-',5,[{file,"/home/ridrisov/mzbench/workers/http/_build/default/deps/http_worker/src/http_worker.erl"},{line,81}]},{http_worker,post,4,[{file,"/home/ridrisov/mzbench/workers/http/_build/default/deps/http_worker/src/http_worker.erl"},{line,81}]},{mzb_erl_worker,apply,4,[{file,"/home/ridrisov/mzbench/node/_build/default/deps/mzbench/src/mzb_erl_worker.erl"},{line,52}]},{mzbl_interpreter,'-eval/4-fun-0-',4,[{file,"/home/ridrisov/mzbench/node/_build/default/deps/mzbench_language/src/mzbl_interpreter.erl"},{line,19}]},{lists,foldl,3,[{file,"lists.erl"},{line,1262}]},{mzbl_interpreter,eval_std_function,6,[{file,"/home/ridrisov/mzbench/node/_build/default/deps/mzbench_language/src/mzbl_interpreter.erl"},{line,59}]}] 02:26:11.276 [error] [ API ] <0.2674.0> Benchmark result: FAILED 5 of 5 workers failed 02:26:11.297 [error] [ API ] <0.2644.0> Stage 'pipeline - running': failed Benchmark has failed on running with reason: {benchmark_failed,{workers_failed,5}} Stacktrace: [{mzb_pipeline,error,2, [{file,"/home/ridrisov/mzbench/server/_build/default/deps/mzbench_api/src/mzb_pipeline.erl"}, {line,90}]}, {mzb_pipeline,'-handle_cast/2-fun-0-',6, [{file,"/home/ridrisov/mzbench/server/_build/default/deps/mzbench_api/src/mzb_pipeline.erl"}, {line,172}]}]

Also, for PUT method the run fails to start (even with 1 worker):

_02:54:03.401 [error] <0.214.0> gen_server <0.214.0> terminated with reason: no try clause matching {{error,{noproc,{gen_server,call,[mzb_metrics,get_metrics]}}}} in mzb_management_tcp_protocol:dispatch/2 line 33

02:54:03.405 [error] <0.214.0> CRASH REPORT Process <0.214.0> with 0 neighbours exited with reason: no try clause matching {{error,{noproc,{gen_server,call,[mzb_metrics,get_metrics]}}}} in mzb_management_tcp_protocol:dispatch/2 line 33 in gen_server:terminate/7 line 826

02:54:03.406 [error] <0.214.0> Ranch listener management_tcp_server terminated with reason: no try clause matching {{error,{noproc,{gen_server,call,[mzb_metrics,get_metrics]}}}} in mzb_management_tcp_protocol:dispatch/2 line 33_

The BDL spec used for PUT is:

`
pool(size = numvar("worker_count", 1),

worker_type = http_worker):

    set_options("content-type" = "application/json")

    connect(var("host", "10.10.192.16"),numvar("port", 80))

    loop(time = 120 sec, 

        rate = 200 rps):    

        dump(put("/keys/k4", "{\"value\" : \"something\"}"))

`
PS: Im running mzbench from the docker image.