2016-06-22 44 views
-1

我正在嘗試使用測試REST API。使用gatling進行REST API測試:獲取狀態400

我配置都在我的gatling腳本(),但我正在逐漸

11:54:41.466 [WARN ] i.g.h.a.ResponseProcessor - Request 'Top Speed' failed: status.find.in(200,304,201,202,203,204,205,206,207,208,209), but actually found 400

以下是我的代碼。

package computerdatabase 
import io.gatling.core.Predef._ 
import io.gatling.core.session.Expression 
import io.gatling.http.Predef._ 
import io.gatling.jdbc.Predef._ 
import scala.concurrent.duration._ 
class TopSpeedSimulation extends Simulation { 
    val httpConf = http.baseURL("http://192.168.0.10:23180/highresvu") 

    val headers_1 = Map("Content-Type" -> "application/vnd.com.wirelesscar.highresolution-vehicleutilization.hrvu.v1+xml") 

    val scn = scenario("My Scenario") 
    .exec(http("Top Speed") 
    .post("/topspeed") 
    .headers(headers_1) 
    .body(StringBody("""{"highResVehicleUtilization": 
       {"-xmlns": "http://wirelesscar.com/highresvu/highresvehicleutilization/1_0","request":{"vehicleDetails":{"vin": "RIGUD000000000057","chassisId":"RIGUD-000057"},"driveSessions":{ "driveSessionId": "1460453954" },"duration":{"fromDate": "2016-05-27T10:30:10.000Z","toDate": "2016-05-16T10:55:10.000Z"}}}}""")) 
    ) 
    setUp(scn.inject(atOnceUsers(5)).protocols(httpConf)) 
} 
+0

嗨Naveen,歡迎來到SO。這只是一個警告。你遇到任何其他功能障礙?請更準確地說明您可能已更改的內容,以使其停止工作等等。 –

回答

1

啓用通過啓用以下記錄器的請求和響應的日誌記錄:

<logger name="io.gatling.http.ahc" level="DEBUG" /> 
    <logger name="io.gatling.http.response" level="DEBUG" /> 

然後你會看到正在發出的查詢和失敗響應。例如

========================= 
HTTP request: 
GET http://myapp/endpoint?course=173.125183%E2%80%A8 
headers= 
Connection: keep-alive 
Accept: image/png,image/*;q=0.8,*/*;q=0.5 
Accept-Language: en-US,en;q=0.5 
Accept-Encoding: gzip, deflate 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36 
Host: myapp 
========================= 
HTTP response: 
status= 
400 Bad Request 
headers= 
Server: nginx/1.8.1 
Date: Mon, 27 Jun 2016 04:55:59 GMT 
Content-Type: text/plain; charset=UTF-8 
Content-Length: 95 
Connection: keep-alive 

body= 
The query parameter 'course' was malformed: 
'173.125183
 ' is not a valid floating point value 
<<<<<<<<<<<<<<<<<<<<<<<<<