diff options
Diffstat (limited to 'extras/hs-test')
-rw-r--r-- | extras/hs-test/http_test.go | 78 | ||||
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 2 | ||||
-rw-r--r-- | extras/hs-test/infra/utils.go | 1 | ||||
-rw-r--r-- | extras/hs-test/ldp_test.go | 27 |
4 files changed, 101 insertions, 7 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index 902d6efacfc..cdc52a1f76c 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -7,6 +7,7 @@ import ( "math/rand" "net" "net/http" + "net/http/httptest" "net/http/httptrace" "os" "strconv" @@ -34,7 +35,8 @@ func init() { HttpHeadersTest, HttpStaticFileHandlerTest, HttpStaticFileHandlerDefaultMaxAgeTest, HttpClientTest, HttpClientErrRespTest, HttpClientPostFormTest, HttpClientGet128kbResponseTest, HttpClientGetResponseBodyTest, HttpClientGetNoResponseBodyTest, HttpClientPostFileTest, HttpClientPostFilePtrTest, HttpUnitTest, - HttpRequestLineTest, HttpClientGetTimeout, HttpStaticFileHandlerWrkTest, HttpStaticUrlHandlerWrkTest, HttpConnTimeoutTest) + HttpRequestLineTest, HttpClientGetTimeout, HttpStaticFileHandlerWrkTest, HttpStaticUrlHandlerWrkTest, HttpConnTimeoutTest, + HttpClientGetRepeat, HttpClientPostRepeat) RegisterNoTopoSoloTests(HttpStaticPromTest, HttpGetTpsTest, HttpGetTpsInterruptModeTest, PromConcurrentConnectionsTest, PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest, HttpPostTpsTest, HttpPostTpsInterruptModeTest, PromConsecutiveConnectionsTest) @@ -368,6 +370,80 @@ func httpClientGet(s *NoTopoSuite, response string, size int) { s.AssertContains(file_contents, response) } +func startSimpleServer(s *NoTopoSuite, replyCount *int, serverAddress string) (server *httptest.Server) { + var err error + server = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello") + *replyCount++ + })) + server.Listener, err = net.Listen("tcp", serverAddress+":80") + s.AssertNil(err, "Error while creating listener.") + + server.Start() + + return server +} + +func HttpClientGetRepeat(s *NoTopoSuite) { + httpClientRepeat(s, "") +} + +func HttpClientPostRepeat(s *NoTopoSuite) { + httpClientRepeat(s, "post") +} + +func httpClientRepeat(s *NoTopoSuite, requestMethod string) { + replyCount := 0 + vpp := s.GetContainerByName("vpp").VppInstance + serverAddress := s.HostAddr() + repeatAmount := 10000 + server := startSimpleServer(s, &replyCount, serverAddress) + defer server.Close() + + if requestMethod == "post" { + fileName := "/tmp/test_file.txt" + s.Log(vpp.Container.Exec(false, "fallocate -l 64 "+fileName)) + s.Log(vpp.Container.Exec(false, "ls -la "+fileName)) + requestMethod += " file /tmp/test_file.txt" + } + + uri := "http://" + serverAddress + "/80" + cmd := fmt.Sprintf("http client %s use-ptr duration 10 header Hello:World uri %s target /index.html", + requestMethod, uri) + + s.Log("Duration 10s") + o := vpp.Vppctl(cmd) + outputLen := len(o) + if outputLen > 500 { + s.Log(o[:500]) + s.Log("* HST Framework: output limited to 500 chars to avoid flooding the console. Output length: " + fmt.Sprint(outputLen)) + } else { + s.Log(o) + } + s.Log("Server response count: %d", replyCount) + s.AssertNotNil(o) + s.AssertNotContains(o, "error") + s.AssertGreaterThan(replyCount, 15000) + + cmd = fmt.Sprintf("http client %s use-ptr repeat %d header Hello:World uri %s target /index.html", + requestMethod, repeatAmount, uri) + + replyCount = 0 + s.Log("Repeat %d", repeatAmount) + o = vpp.Vppctl(cmd) + outputLen = len(o) + if outputLen > 500 { + s.Log(o[:500]) + s.Log("* HST Framework: output limited to 500 chars to avoid flooding the console. Output length: " + fmt.Sprint(outputLen)) + } else { + s.Log(o) + } + s.Log("Server response count: %d", replyCount) + s.AssertNotNil(o) + s.AssertNotContains(o, "error") + s.AssertEqual(repeatAmount, replyCount) +} + func HttpClientGetTimeout(s *NoTopoSuite) { serverAddress := s.HostAddr() vpp := s.GetContainerByName("vpp").VppInstance diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index 3aeeb24d14e..bf46dfdef7e 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -447,7 +447,7 @@ func (s *HstSuite) ResetContainers() { for _, container := range s.StartedContainers { container.stop() s.Log("Removing container " + container.Name) - if err := s.Docker.ContainerRemove(container.ctx, container.ID, containerTypes.RemoveOptions{RemoveVolumes: true}); err != nil { + if err := s.Docker.ContainerRemove(container.ctx, container.ID, containerTypes.RemoveOptions{RemoveVolumes: true, Force: true}); err != nil { s.Log(err) } } diff --git a/extras/hs-test/infra/utils.go b/extras/hs-test/infra/utils.go index 30abb6ac715..761fc178914 100644 --- a/extras/hs-test/infra/utils.go +++ b/extras/hs-test/infra/utils.go @@ -303,6 +303,7 @@ func (s *HstSuite) StartClientApp(c *Container, cmd string, o, err := cmd2.CombinedOutput() if err != nil { s.Log(err) + s.Log(string(o)) if nTries > 5 { clnRes <- "" clnCh <- fmt.Errorf("failed to start client app '%s'", err) diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go index e72fac4fbba..deba2141d08 100644 --- a/extras/hs-test/ldp_test.go +++ b/extras/hs-test/ldp_test.go @@ -9,17 +9,35 @@ import ( ) func init() { - RegisterLdpTests(LDPreloadIperfVppTest, LDPreloadIperfVppInterruptModeTest, RedisBenchmarkTest) + RegisterLdpTests(LDPreloadIperfVppTest, LDPreloadIperfVppInterruptModeTest, RedisBenchmarkTest, LDPreloadIperfTlsTcpTest) } func LDPreloadIperfVppInterruptModeTest(s *LdpSuite) { - LDPreloadIperfVppTest(s) + ldPreloadIperfVpp(s, true) +} + +func LDPreloadIperfTlsTcpTest(s *LdpSuite) { + for _, c := range s.Containers { + c.Exec(false, "openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.key -out crt.crt -subj \"/CN=test\"") + c.AddEnvVar("LDP_TRANSPARENT_TLS", "1") + c.AddEnvVar("LDP_TLS_CERT_FILE", "/crt.crt") + c.AddEnvVar("LDP_TLS_KEY_FILE", "/key.key") + } + ldPreloadIperfVpp(s, false) } func LDPreloadIperfVppTest(s *LdpSuite) { + ldPreloadIperfVpp(s, true) +} + +func ldPreloadIperfVpp(s *LdpSuite, useUdp bool) { + protocol := "" + if useUdp { + protocol = " -u " + } clientContainer := s.GetContainerByName("client-vpp") serverContainer := s.GetContainerByName("server-vpp") - + serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString() stopServerCh := make(chan struct{}, 1) srvCh := make(chan error, 1) clnCh := make(chan error) @@ -38,10 +56,9 @@ func LDPreloadIperfVppTest(s *LdpSuite) { err := <-srvCh s.AssertNil(err, fmt.Sprint(err)) - serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString() go func() { defer GinkgoRecover() - cmd := "iperf3 -c " + serverVethAddress + " -u -l 1460 -b 10g -p " + s.GetPortFromPpid() + cmd := "iperf3 -c " + serverVethAddress + " -l 1460 -b 10g -p " + s.GetPortFromPpid() + protocol s.StartClientApp(clientContainer, cmd, clnCh, clnRes) }() |