hs-test: add h2load container to infra 07/42907/3
authorMatus Fabian <[email protected]>
Mon, 28 Apr 2025 11:38:32 +0000 (07:38 -0400)
committerFlorin Coras <[email protected]>
Tue, 6 May 2025 06:37:07 +0000 (06:37 +0000)
Type: test

Change-Id: I4b1dc2dc9eeefac095823180181b8ce6971c0b65
Signed-off-by: Matus Fabian <[email protected]>
extras/hs-test/docker/Dockerfile.h2load [new file with mode: 0644]
extras/hs-test/http2_test.go
extras/hs-test/infra/suite_h2.go
extras/hs-test/infra/utils.go
extras/hs-test/script/build_hst.sh
extras/hs-test/topo-containers/single.yaml

diff --git a/extras/hs-test/docker/Dockerfile.h2load b/extras/hs-test/docker/Dockerfile.h2load
new file mode 100644 (file)
index 0000000..de9d083
--- /dev/null
@@ -0,0 +1,9 @@
+ARG UBUNTU_VERSION=22.04
+
+FROM ubuntu:${UBUNTU_VERSION}
+
+RUN apt-get update \
+ && apt-get install -y nghttp2 \
+ && rm -rf /var/lib/apt/lists/*
+
+ENTRYPOINT ["h2load"]
index 1be1455..f62d5e3 100644 (file)
@@ -9,7 +9,7 @@ import (
 )
 
 func init() {
-       RegisterH2Tests(Http2TcpGetTest, Http2TcpPostTest)
+       RegisterH2Tests(Http2TcpGetTest, Http2TcpPostTest, Http2MultiplexingTest)
 }
 
 func Http2TcpGetTest(s *H2Suite) {
@@ -58,3 +58,21 @@ func Http2TcpPostTest(s *H2Suite) {
        _, log := s.RunCurlContainer(s.Containers.Curl, args)
        s.AssertContains(log, "HTTP/2 200")
 }
+
+func Http2MultiplexingTest(s *H2Suite) {
+       vpp := s.Containers.Vpp.VppInstance
+       serverAddress := s.VppAddr()
+       vpp.Vppctl("http tps uri tcp://0.0.0.0/80 no-zc")
+
+       args := fmt.Sprintf("--log-file=%s -T10 -n20 -c1 -m100 http://%s:80/test_file_20M", s.H2loadLogFileName(s.Containers.H2load), serverAddress)
+       s.Containers.H2load.ExtraRunningArgs = args
+       s.Containers.H2load.Run()
+
+       defer s.CollectH2loadLogs(s.Containers.H2load)
+
+       o, _ := s.Containers.H2load.GetOutput()
+       s.Log(o)
+       s.AssertContains(o, " 0 failed")
+       s.AssertContains(o, " 0 errored")
+       s.AssertContains(o, " 0 timeout")
+}
index 8f7426a..ba99286 100644 (file)
@@ -27,8 +27,9 @@ type H2Suite struct {
                Tap *NetInterface
        }
        Containers struct {
-               Vpp  *Container
-               Curl *Container
+               Vpp    *Container
+               Curl   *Container
+               H2load *Container
        }
 }
 
@@ -43,6 +44,7 @@ func (s *H2Suite) SetupSuite() {
        s.Interfaces.Tap = s.GetInterfaceByName("htaphost")
        s.Containers.Vpp = s.GetContainerByName("vpp")
        s.Containers.Curl = s.GetContainerByName("curl")
+       s.Containers.H2load = s.GetContainerByName("h2load")
 }
 
 func (s *H2Suite) SetupTest() {
@@ -50,9 +52,11 @@ func (s *H2Suite) SetupTest() {
 
        // Setup test conditions
        var sessionConfig Stanza
-       sessionConfig.NewStanza("session").Append("enable").Append("use-app-socket-api")
+       sessionConfig.NewStanza("session").Append("enable").Append("use-app-socket-api").Close()
+       var memoryConfig Stanza
+       memoryConfig.NewStanza("memory").Append("main-heap-size 2G").Close()
 
-       vpp, _ := s.Containers.Vpp.newVppInstance(s.Containers.Vpp.AllocatedCpus, sessionConfig)
+       vpp, _ := s.Containers.Vpp.newVppInstance(s.Containers.Vpp.AllocatedCpus, memoryConfig, sessionConfig)
 
        s.AssertNil(vpp.Start())
        s.AssertNil(vpp.CreateTap(s.Interfaces.Tap, 1, 1), "failed to create tap interface")
index 2f4328b..43aa51a 100644 (file)
@@ -20,6 +20,7 @@ const containerTopologyDir string = "topo-containers/"
 const HttpCapsuleTypeDatagram = uint64(0)
 const iperfLogFileName = "iperf.log"
 const redisLogFileName = "redis-server.log"
+const h2loadLogFileName = "h2load.tsv"
 
 type Stanza struct {
        content string
@@ -255,6 +256,21 @@ func (s *HstSuite) CollectRedisServerLogs(serverContainer *Container) {
        }
 }
 
+func (s *HstSuite) H2loadLogFileName(h2loadContainer *Container) string {
+       return h2loadContainer.GetContainerWorkDir() + "/" + h2loadContainer.Name + "-" + h2loadLogFileName
+}
+
+func (s *HstSuite) CollectH2loadLogs(h2loadContainer *Container) {
+       targetDir := h2loadContainer.Suite.getLogDirPath()
+       source := h2loadContainer.GetHostWorkDir() + "/" + h2loadContainer.Name + "-" + h2loadLogFileName
+       cmd := exec.Command("cp", "-t", targetDir, source)
+       s.Log(cmd.String())
+       err := cmd.Run()
+       if err != nil {
+               s.Log(fmt.Sprint(err))
+       }
+}
+
 func (s *HstSuite) StartIperfServerApp(running chan error, done chan struct{}, env []string) {
        cmd := exec.Command("iperf3", "-4", "-s", "-p", s.GetPortFromPpid())
        if env != nil {
index 7843361..ab482b0 100755 (executable)
@@ -98,6 +98,7 @@ docker_build hs-test/envoy envoy
 docker_build hs-test/nginx-http3 nginx-http3
 docker_build hs-test/ab ab
 docker_build hs-test/wrk wrk
+docker_build hs-test/h2load h2load
 
 # make it multi-user friendly
 if [ -d "${DOCKER_CACHE_DIR}" ] ; then
index 2f5f31b..7b2f91e 100644 (file)
@@ -52,4 +52,13 @@ containers:
       value: "/usr/local/lib"
     image: "hs-test/curl"
     is-optional: true
+    run-detached: false
+
+  - name: "h2load"
+    image: "hs-test/h2load"
+    volumes:
+      - <<: *shared-vol
+        container-dir: "/tmp/h2load"
+        is-default-work-dir: true
+    is-optional: true
     run-detached: false
\ No newline at end of file