flood-io / ruby-jmeter

A Ruby based DSL for building JMeter test plans
MIT License
748 stars 139 forks source link

ruby-jmeter doesn't add query parameter in URL when forming Http Post with some raw_body #138

Open sjethvani opened 6 years ago

sjethvani commented 6 years ago

In jmeter we can't have parameters & body both at same time , instead we can have query parameters in URL path and request body in body field . So it would be like URL : http://{host}?param1=val1&param2=val2 Body will be of xml/json

I tried to replicate this in ruby-jmeter through following ruby-jmeter snippet

endPoint = "http://google.com?name=sameer&surname=jethvani"
submit name: 'mypostRequest', url: endPoint ,connect_timeout: '400000' ,raw_body: rawJsonBody, response_timeout: '400000' do
header mycustomHeaderArray
end

PS : 'submit' is alias for http post in ruby-jmeter

When I am compiling above snippet in ruby-jmeter , it generates jmeter file & it shows query parameter concatenated with request body & not in URL (which is wrong). Have a look at generated jmeter scenario

image

PS : I checked that this is happening when my post request has raw_body & url has query parameters

sjethvani commented 5 years ago

@90kts this seems to be an issue. parser.rb may require a fix for this . Let me know if you guys need any other information

Daniel-ltw commented 5 years ago

Not sure if this is related, but the parser does not do json body parsing properly.

https://github.com/flood-io/ruby-jmeter/blob/91d3cad535ac95930c3698e844647f744caa58b6/lib/ruby-jmeter/helpers/parser.rb#L80

From a jmeter generated jmx, the double quotes in a json body should be transform into ".

params[:raw_body].encode(:xml => :text).gsub(/\"/, '"')

This should handle double quotes.

Update: Nokogiri seem to escape the " and covert it back to ".