diff options
author | Matus Fabian <matfabia@cisco.com> | 2024-07-24 12:56:14 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-07-24 15:38:46 +0000 |
commit | c712de5a8eb8736f8d043659dbc5b60efd5ce998 (patch) | |
tree | 6caaa473251151823c72a9dc2b7c32112fbfbdce /extras | |
parent | 936c83db957805dec91b70379780241f0c75a3f6 (diff) |
prom: mem leak test
Type: test
Change-Id: Ibca5680778c9e27eb7b1ddbdba52f870852452fe
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/hs-test/http_test.go | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index 2983ba38fa0..dcfe56199ed 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -26,7 +26,8 @@ func init() { HttpStaticMacTimeTest, HttpStaticBuildInUrlGetVersionVerboseTest, HttpVersionNotSupportedTest, HttpInvalidContentLengthTest, HttpInvalidTargetSyntaxTest, HttpStaticPathTraversalTest, HttpUriDecodeTest, HttpHeadersTest, HttpStaticFileHandler) - RegisterNoTopoSoloTests(HttpStaticPromTest, HttpTpsTest, HttpTpsInterruptModeTest, PromConcurrentConnections) + RegisterNoTopoSoloTests(HttpStaticPromTest, HttpTpsTest, HttpTpsInterruptModeTest, PromConcurrentConnections, + PromMemLeakTest) } const wwwRootPath = "/tmp/www_root" @@ -205,9 +206,7 @@ func HttpStaticPromTest(s *NoTopoSuite) { _, err = io.ReadAll(resp.Body) } -func promReq(s *NoTopoSuite, url string, wg *sync.WaitGroup) { - defer GinkgoRecover() - defer wg.Done() +func promReq(s *NoTopoSuite, url string) { client := NewHttpClient() req, err := http.NewRequest("GET", url, nil) s.AssertNil(err, fmt.Sprint(err)) @@ -218,6 +217,12 @@ func promReq(s *NoTopoSuite, url string, wg *sync.WaitGroup) { _, err = io.ReadAll(resp.Body) } +func promReqWg(s *NoTopoSuite, url string, wg *sync.WaitGroup) { + defer GinkgoRecover() + defer wg.Done() + promReq(s, url) +} + func PromConcurrentConnections(s *NoTopoSuite) { vpp := s.GetContainerByName("vpp").VppInstance serverAddress := s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString() @@ -230,12 +235,47 @@ func PromConcurrentConnections(s *NoTopoSuite) { var wg sync.WaitGroup for i := 0; i < 20; i++ { wg.Add(1) - go promReq(s, url, &wg) + go promReqWg(s, url, &wg) } wg.Wait() s.Log(vpp.Vppctl("show session verbose proto http")) } +func PromMemLeakTest(s *NoTopoSuite) { + s.SkipUnlessLeakCheck() + + vpp := s.GetContainerByName("vpp").VppInstance + serverAddress := s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString() + url := "http://" + serverAddress + ":80/stats.prom" + + /* no goVPP less noise */ + vpp.Disconnect() + + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + s.Log(vpp.Vppctl("prom enable")) + time.Sleep(time.Second * 3) + + /* warmup request (FIB) */ + promReq(s, url) + + vpp.EnableMemoryTrace() + traces1, err := vpp.GetMemoryTrace() + s.AssertNil(err, fmt.Sprint(err)) + + /* collect stats couple of times */ + for i := 0; i < 5; i++ { + time.Sleep(time.Second * 1) + promReq(s, url) + } + + /* let's give it some time to clean up sessions */ + time.Sleep(time.Second * 5) + + traces2, err := vpp.GetMemoryTrace() + s.AssertNil(err, fmt.Sprint(err)) + vpp.MemLeakCheck(traces1, traces2) +} + func HttpStaticFileHandler(s *NoTopoSuite) { content := "<http><body><p>Hello</p></body></http>" content2 := "<http><body><p>Page</p></body></http>" |