From 9bb0762357015ca49ab8376308eda021d35d6f25 Mon Sep 17 00:00:00 2001 From: Matus Fabian Date: Wed, 4 Sep 2024 18:04:54 +0200 Subject: http: large POST handling Type: improvement Change-Id: I28b8e8ccbff6f97e669b0048011b187decbfc892 Signed-off-by: Matus Fabian --- extras/hs-test/http_test.go | 46 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'extras') diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index 733ca46934d..bfd2d34483c 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -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) { -- cgit 1.2.3-korg