summaryrefslogtreecommitdiffstats
path: root/extras/hs-test
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-08-26 18:26:58 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-08-28 06:08:04 +0000
commit56cefc89e22112071b382fbeb06be839fef1e0ed (patch)
treea19a096f1e1f75b36750b42b757c776a9175f0ac /extras/hs-test
parentd01a63abd41dfd2359e18ca559a0309cfe8c0018 (diff)
http: http_state_wait_app_reply improvement
set http status according to whether app also sent the body Type: improvement Change-Id: Ia41603cc21b410ca6929ec3d3e7c4c6808305769 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras/hs-test')
-rw-r--r--extras/hs-test/http_test.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index 5a33964a079..733ca46934d 100644
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -85,24 +85,39 @@ func HttpPersistentConnectionTest(s *NoTopoSuite) {
return http.ErrUseLastResponse
}}
- req, err := http.NewRequest("GET", "http://"+serverAddress+":80/test1", nil)
+ body := []byte("{\"sandwich\": {\"spam\": 2, \"eggs\": 1}}")
+ req, err := http.NewRequest("POST", "http://"+serverAddress+":80/test3", bytes.NewBuffer(body))
s.AssertNil(err, fmt.Sprint(err))
resp, err := client.Do(req)
s.AssertNil(err, fmt.Sprint(err))
s.Log(DumpHttpResp(resp, true))
s.AssertHttpStatus(resp, 200)
s.AssertEqual(false, resp.Close)
- s.AssertHttpBody(resp, "hello")
+ s.AssertHttpContentLength(resp, int64(0))
o1 := vpp.Vppctl("show session verbose proto http state ready")
s.Log(o1)
s.AssertContains(o1, "ESTABLISHED")
- req, err = http.NewRequest("GET", "http://"+serverAddress+":80/test2", nil)
+ req, err = http.NewRequest("GET", "http://"+serverAddress+":80/test1", nil)
+ s.AssertNil(err, fmt.Sprint(err))
clientTrace := &httptrace.ClientTrace{
GotConn: func(info httptrace.GotConnInfo) {
s.AssertEqual(true, info.Reused, "connection not reused")
},
}
+ req = req.WithContext(httptrace.WithClientTrace(req.Context(), clientTrace))
+ resp, err = client.Do(req)
+ s.AssertNil(err, fmt.Sprint(err))
+ s.Log(DumpHttpResp(resp, true))
+ s.AssertHttpStatus(resp, 200)
+ s.AssertEqual(false, resp.Close)
+ s.AssertHttpBody(resp, "hello")
+ o2 := vpp.Vppctl("show session verbose proto http state ready")
+ s.Log(o2)
+ s.AssertContains(o2, "ESTABLISHED")
+ s.AssertEqual(o1, o2)
+
+ req, err = http.NewRequest("GET", "http://"+serverAddress+":80/test2", nil)
s.AssertNil(err, fmt.Sprint(err))
req = req.WithContext(httptrace.WithClientTrace(req.Context(), clientTrace))
resp, err = client.Do(req)
@@ -111,7 +126,7 @@ func HttpPersistentConnectionTest(s *NoTopoSuite) {
s.AssertHttpStatus(resp, 200)
s.AssertEqual(false, resp.Close)
s.AssertHttpBody(resp, "some data")
- o2 := vpp.Vppctl("show session verbose proto http state ready")
+ o2 = vpp.Vppctl("show session verbose proto http state ready")
s.Log(o2)
s.AssertContains(o2, "ESTABLISHED")
s.AssertEqual(o1, o2)