http: add send get and close test 87/43887/2
authorFlorin Coras <[email protected]>
Tue, 14 Oct 2025 08:04:43 +0000 (04:04 -0400)
committerDave Barach <[email protected]>
Tue, 14 Oct 2025 20:15:59 +0000 (20:15 +0000)
Attempt to catch potential close/cleanup races with received
data/request.

Type: test

Change-Id: Ic07b034272e11103669d8eb5a2fe56e1af3c0da7
Signed-off-by: Florin Coras <[email protected]>
Signed-off-by: Matus Fabian <[email protected]>
test-c/hs-test/http1_test.go
test-c/hs-test/infra/utils.go

index 8361772..83063d0 100644 (file)
@@ -38,7 +38,7 @@ func init() {
                HttpRequestLineTest, HttpClientGetTimeout, HttpStaticFileHandlerWrkTest, HttpStaticUrlHandlerWrkTest, HttpConnTimeoutTest,
                HttpClientGetRepeatTest, HttpClientPostRepeatTest, HttpIgnoreH2UpgradeTest, HttpInvalidAuthorityFormUriTest, HttpHeaderErrorConnectionDropTest,
                HttpClientInvalidHeaderNameTest, HttpStaticHttp1OnlyTest, HttpTimerSessionDisable, HttpClientBodySizeTest,
-               HttpStaticRedirectTest, HttpClientNoPrintTest, HttpClientChunkedDownloadTest, HttpClientPostRejectedTest)
+               HttpStaticRedirectTest, HttpClientNoPrintTest, HttpClientChunkedDownloadTest, HttpClientPostRejectedTest, HttpSendGetAndCloseTest)
        RegisterHttp1SoloTests(HttpStaticPromTest, HttpGetTpsTest, HttpGetTpsInterruptModeTest, PromConcurrentConnectionsTest,
                PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest, HttpPostTpsTest, HttpPostTpsInterruptModeTest,
                PromConsecutiveConnectionsTest, HttpGetTpsTlsTest, HttpPostTpsTlsTest)
@@ -1948,3 +1948,22 @@ func HttpIgnoreH2UpgradeTest(s *Http1Suite) {
        s.AssertHttpStatus(resp, 200)
        s.AssertHttpHeaderNotPresent(resp, "Upgrade")
 }
+
+func HttpSendGetAndCloseTest(s *Http1Suite) {
+       vpp := s.Containers.Vpp.VppInstance
+       serverAddress := s.VppAddr() + ":" + s.Ports.Http
+
+       vpp.Container.Exec(false, "mkdir -p "+wwwRootPath)
+       content := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+       err := vpp.Container.CreateFile(wwwRootPath+"/index.html", content)
+       s.AssertNil(err, fmt.Sprint(err))
+       s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + " private-segment-size 256m"))
+
+       err = TcpSendAndClose(serverAddress, "GET http://www.example.com/index.html HTTP/1.1\r\nHost: example.com\r\n\r\n")
+       s.AssertNil(err, fmt.Sprint(err))
+
+       // mostly to verify that vpp is still up
+       o := vpp.Vppctl("show session verbose proto http")
+       s.Log(o)
+       s.AssertNotContains(o, "established")
+}
index 3be3220..41e328b 100644 (file)
@@ -144,6 +144,20 @@ func TcpSendReceive(address, data string) (string, error) {
        return string(reply), nil
 }
 
+func TcpSendAndClose(address, data string) error {
+       conn, err := net.DialTimeout("tcp", address, time.Second*30)
+       if err != nil {
+               return err
+       }
+       defer conn.Close()
+       _, err = conn.Write([]byte(data))
+       if err != nil {
+               return err
+       }
+
+       return nil
+}
+
 /*
 RunCurlContainer execute curl command with given args.
 Container with name "curl" must be available.