hs-test: improve teardown reliability 79/43079/6
authorAdrian Villin <[email protected]>
Mon, 2 Jun 2025 14:53:41 +0000 (16:53 +0200)
committerDave Wallace <[email protected]>
Wed, 4 Jun 2025 15:18:22 +0000 (15:18 +0000)
- added defer to some teardown functions
- framework now recovers when Vppctl() is used before vppinstance
  is created

Type: test

Change-Id: Ia37cca0ef24f8936cbf350636e249efbf78b13ec
Signed-off-by: Adrian Villin <[email protected]>
extras/hs-test/infra/suite_cpu_pinning.go
extras/hs-test/infra/suite_envoy_proxy.go
extras/hs-test/infra/suite_ldp.go
extras/hs-test/infra/suite_nginx_proxy.go
extras/hs-test/infra/suite_no_topo.go
extras/hs-test/infra/suite_no_topo6.go
extras/hs-test/infra/suite_vpp_proxy.go
extras/hs-test/infra/suite_vpp_udp_proxy.go
extras/hs-test/infra/vppinstance.go

index 6808768..e80682d 100644 (file)
@@ -58,11 +58,10 @@ func (s *CpuPinningSuite) SetupTest() {
 }
 
 func (s *CpuPinningSuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        // reset vars
        s.CpuCount = *NConfiguredCpus
        s.CpuAllocator.maxContainerCount = s.previousMaxContainerCount
-       s.HstSuite.TeardownTest()
-
 }
 
 var _ = Describe("CpuPinningSuite", Ordered, ContinueOnFailure, func() {
index 7119b0f..2d18427 100644 (file)
@@ -151,11 +151,11 @@ func (s *EnvoyProxySuite) SetupTest() {
 }
 
 func (s *EnvoyProxySuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        if CurrentSpecReport().Failed() {
                s.CollectNginxLogs(s.Containers.NginxServerTransient)
                s.CollectEnvoyLogs(s.Containers.EnvoyProxy)
        }
-       s.HstSuite.TeardownTest()
 }
 
 func (s *EnvoyProxySuite) ProxyAddr() string {
index 0baeacd..78c9e14 100644 (file)
@@ -100,6 +100,7 @@ func (s *LdpSuite) SetupTest() {
 }
 
 func (s *LdpSuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        if CurrentSpecReport().Failed() {
                s.CollectIperfLogs(s.Containers.ServerApp)
                s.CollectRedisServerLogs(s.Containers.ServerApp)
@@ -111,8 +112,6 @@ func (s *LdpSuite) TeardownTest() {
                delete(container.EnvVars, "LD_PRELOAD")
                delete(container.EnvVars, "VCL_CONFIG")
        }
-       s.HstSuite.TeardownTest()
-
 }
 
 func (s *LdpSuite) CreateVclConfig(container *Container) {
index 8006e6f..05b0960 100644 (file)
@@ -117,11 +117,11 @@ func (s *NginxProxySuite) SetupTest() {
 }
 
 func (s *NginxProxySuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        if CurrentSpecReport().Failed() {
                s.CollectNginxLogs(s.Containers.NginxProxy)
                s.CollectNginxLogs(s.Containers.NginxServerTransient)
        }
-       s.HstSuite.TeardownTest()
 }
 
 func (s *NginxProxySuite) CreateNginxProxyConfig(container *Container, multiThreadWorkers bool) {
index 2d96ac9..e464ef7 100644 (file)
@@ -87,10 +87,10 @@ func (s *NoTopoSuite) SetupTest() {
 }
 
 func (s *NoTopoSuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        if CurrentSpecReport().Failed() {
                s.CollectNginxLogs(s.Containers.NginxHttp3)
        }
-       s.HstSuite.TeardownTest()
 }
 
 func (s *NoTopoSuite) CreateNginxConfig(container *Container, multiThreadWorkers bool) {
index 8b67791..1b21469 100644 (file)
@@ -85,10 +85,10 @@ func (s *NoTopo6Suite) SetupTest() {
 }
 
 func (s *NoTopo6Suite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        if CurrentSpecReport().Failed() {
                s.CollectNginxLogs(s.Containers.NginxHttp3)
        }
-       s.HstSuite.TeardownTest()
 }
 
 func (s *NoTopo6Suite) CreateNginxConfig(container *Container, multiThreadWorkers bool) {
index 92ca24c..2226358 100644 (file)
@@ -93,6 +93,7 @@ func (s *VppProxySuite) SetupTest() {
 }
 
 func (s *VppProxySuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        vpp := s.Containers.VppProxy.VppInstance
        if CurrentSpecReport().Failed() {
                s.Log(vpp.Vppctl("show session verbose 2"))
@@ -100,7 +101,6 @@ func (s *VppProxySuite) TeardownTest() {
                s.CollectNginxLogs(s.Containers.NginxServerTransient)
                s.CollectIperfLogs(s.Containers.IperfS)
        }
-       s.HstSuite.TeardownTest()
 }
 
 func (s *VppProxySuite) SetupNginxServer() {
index d6f58ac..aad821f 100644 (file)
@@ -88,12 +88,12 @@ func (s *VppUdpProxySuite) SetupTest() {
 }
 
 func (s *VppUdpProxySuite) TeardownTest() {
+       defer s.HstSuite.TeardownTest()
        vpp := s.Containers.VppProxy.VppInstance
        if CurrentSpecReport().Failed() {
                s.Log(vpp.Vppctl("show session verbose 2"))
                s.Log(vpp.Vppctl("show error"))
        }
-       s.HstSuite.TeardownTest()
 }
 
 func (s *VppUdpProxySuite) VppProxyAddr() string {
index 501eb41..ec32f85 100644 (file)
@@ -258,6 +258,14 @@ func (vpp *VppInstance) Stop() {
 }
 
 func (vpp *VppInstance) Vppctl(command string, arguments ...any) string {
+       defer func() {
+               if r := recover(); r != nil {
+                       fmt.Printf("\n*******************************************************************************\n"+
+                               "[%v]\nyou probably used Vppctl() without creating a vppinstance first or used Vppctl() on the wrong container\n"+
+                               "*******************************************************************************\n", r)
+               }
+       }()
+
        vppCliCommand := fmt.Sprintf(command, arguments...)
        containerExecCommand := fmt.Sprintf("docker exec --detach=false %[1]s vppctl -s %[2]s %[3]s",
                vpp.Container.Name, vpp.getCliSocket(), vppCliCommand)