diff options
author | Matus Fabian <matfabia@cisco.com> | 2024-09-04 18:04:54 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-09-08 22:41:27 +0000 |
commit | 9bb0762357015ca49ab8376308eda021d35d6f25 (patch) | |
tree | b7b7e3c0b4e53f6daf88e780f1e66bd16b1b0282 /extras | |
parent | c4b5d10115d4370488ac14eb0ba7295b049a0615 (diff) |
http: large POST handling
Type: improvement
Change-Id: I28b8e8ccbff6f97e669b0048011b187decbfc892
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/hs-test/http_test.go | 46 |
1 files changed, 40 insertions, 6 deletions
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) { |