http: large POST handling

Type: improvement
Change-Id: I28b8e8ccbff6f97e669b0048011b187decbfc892
Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
Matus Fabian
2024-09-04 18:04:54 +02:00
committed by Florin Coras
parent c4b5d10115
commit 9bb0762357
4 changed files with 246 additions and 77 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/onsi/gomega/ghttp"
"github.com/onsi/gomega/gmeasure"
"io"
"math/rand"
"net"
"net/http"
"net/http/httptrace"
@ -30,8 +31,8 @@ func init() {
HttpInvalidContentLengthTest, HttpInvalidTargetSyntaxTest, HttpStaticPathTraversalTest, HttpUriDecodeTest,
HttpHeadersTest, HttpStaticFileHandlerTest, HttpStaticFileHandlerDefaultMaxAgeTest, HttpClientTest, HttpClientErrRespTest, HttpClientPostFormTest,
HttpClientPostFileTest, HttpClientPostFilePtrTest, AuthorityFormTargetTest, HttpRequestLineTest)
RegisterNoTopoSoloTests(HttpStaticPromTest, HttpTpsTest, HttpTpsInterruptModeTest, PromConcurrentConnectionsTest,
PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest)
RegisterNoTopoSoloTests(HttpStaticPromTest, HttpGetTpsTest, HttpGetTpsInterruptModeTest, PromConcurrentConnectionsTest,
PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest, HttpPostTpsTest, HttpPostTpsInterruptModeTest)
}
const wwwRootPath = "/tmp/www_root"
@ -53,18 +54,51 @@ func httpDownloadBenchmark(s *HstSuite, experiment *gmeasure.Experiment, data in
experiment.RecordValue("Download Speed", (float64(resp.ContentLength)/1024/1024)/duration.Seconds(), gmeasure.Units("MB/s"), gmeasure.Precision(2))
}
func HttpTpsInterruptModeTest(s *NoTopoSuite) {
HttpTpsTest(s)
func HttpGetTpsInterruptModeTest(s *NoTopoSuite) {
HttpGetTpsTest(s)
}
func HttpTpsTest(s *NoTopoSuite) {
func HttpGetTpsTest(s *NoTopoSuite) {
vpp := s.GetContainerByName("vpp").VppInstance
serverAddress := s.VppAddr()
url := "http://" + serverAddress + ":8080/test_file_10M"
vpp.Vppctl("http tps uri tcp://0.0.0.0/8080")
s.RunBenchmark("HTTP tps 10M", 10, 0, httpDownloadBenchmark, url)
s.RunBenchmark("HTTP tps download 10M", 10, 0, httpDownloadBenchmark, url)
}
func httpUploadBenchmark(s *HstSuite, experiment *gmeasure.Experiment, data interface{}) {
url, isValid := data.(string)
s.AssertEqual(true, isValid)
body := make([]byte, 10485760)
_, err := rand.Read(body)
client := NewHttpClient()
req, err := http.NewRequest("POST", url, bytes.NewBuffer(body))
s.AssertNil(err, fmt.Sprint(err))
t := time.Now()
resp, err := client.Do(req)
s.AssertNil(err, fmt.Sprint(err))
defer resp.Body.Close()
s.AssertHttpStatus(resp, 200)
_, err = io.ReadAll(resp.Body)
s.AssertNil(err, fmt.Sprint(err))
duration := time.Since(t)
experiment.RecordValue("Upload Speed", (float64(req.ContentLength)/1024/1024)/duration.Seconds(), gmeasure.Units("MB/s"), gmeasure.Precision(2))
}
func HttpPostTpsInterruptModeTest(s *NoTopoSuite) {
HttpPostTpsTest(s)
}
func HttpPostTpsTest(s *NoTopoSuite) {
vpp := s.GetContainerByName("vpp").VppInstance
serverAddress := s.VppAddr()
url := "http://" + serverAddress + ":8080/test_file_10M"
vpp.Vppctl("http tps uri tcp://0.0.0.0/8080")
s.RunBenchmark("HTTP tps upload 10M", 10, 0, httpUploadBenchmark, url)
}
func HttpPersistentConnectionTest(s *NoTopoSuite) {