hs-test: remove assert in container.Exec 97/42597/3
authorAdrian Villin <[email protected]>
Fri, 28 Mar 2025 11:59:12 +0000 (12:59 +0100)
committerFlorin Coras <[email protected]>
Mon, 31 Mar 2025 18:03:41 +0000 (18:03 +0000)
- removed so we can ignore errors (e.g. vppinstance.Stop)

Type: test

Change-Id: Ib83057eaac7ae6e7338ae9cb59ab2af6239c47a5
Signed-off-by: Adrian Villin <[email protected]>
extras/hs-test/http_test.go
extras/hs-test/infra/container.go
extras/hs-test/infra/vppinstance.go
extras/hs-test/raw_session_test.go
extras/hs-test/vcl_test.go

index 760ca3c..93317bb 100644 (file)
@@ -412,7 +412,8 @@ func httpClientGet(s *NoTopoSuite, response string, size int) {
        s.AssertContains(o, response)
        s.AssertContains(o, "Content-Length: "+strconv.Itoa(size))
 
-       file_contents := vpp.Container.Exec(false, "cat /tmp/response.txt")
+       file_contents, err := vpp.Container.Exec(false, "cat /tmp/response.txt")
+       s.AssertNil(err)
        s.AssertContains(file_contents, response)
 }
 
@@ -463,7 +464,8 @@ func httpClientRepeat(s *NoTopoSuite, requestMethod string, clientArgs string) {
        o := vpp.Vppctl(cmd)
        s.Log(o)
 
-       replyCount := s.Containers.NginxServer.Exec(false, "awk 'END { print NR }' "+logPath)
+       replyCount, err := s.Containers.NginxServer.Exec(false, "awk 'END { print NR }' "+logPath)
+       s.AssertNil(err)
        if replyCount != "" {
                replyCountInt, err = strconv.Atoi(replyCount[:len(replyCount)-1])
                s.AssertNil(err)
@@ -485,7 +487,8 @@ func httpClientRepeat(s *NoTopoSuite, requestMethod string, clientArgs string) {
        o = vpp.Vppctl(cmd)
        s.Log(o)
 
-       replyCount = s.Containers.NginxServer.Exec(false, "awk 'END { print NR }' "+logPath)
+       replyCount, err = s.Containers.NginxServer.Exec(false, "awk 'END { print NR }' "+logPath)
+       s.AssertNil(err)
        if replyCount != "" {
                replyCountInt, err = strconv.Atoi(replyCount[:len(replyCount)-1])
                s.AssertNil(err)
index 918c19e..efc317f 100644 (file)
@@ -460,7 +460,7 @@ func (c *Container) ExecServer(useEnvVars bool, command string, arguments ...any
        c.Suite.AssertNil(exechelper.Run(containerExecCommand))
 }
 
-func (c *Container) Exec(useEnvVars bool, command string, arguments ...any) string {
+func (c *Container) Exec(useEnvVars bool, command string, arguments ...any) (string, error) {
        var envVars string
        serverCommand := fmt.Sprintf(command, arguments...)
        if useEnvVars {
@@ -472,8 +472,7 @@ func (c *Container) Exec(useEnvVars bool, command string, arguments ...any) stri
        GinkgoHelper()
        c.Suite.Log(containerExecCommand)
        byteOutput, err := exechelper.CombinedOutput(containerExecCommand)
-       c.Suite.AssertNil(err, fmt.Sprint(err))
-       return string(byteOutput)
+       return string(byteOutput), err
 }
 
 func (c *Container) saveLogs() {
index 370d2be..59d17de 100644 (file)
@@ -243,9 +243,11 @@ func (vpp *VppInstance) Start() error {
 }
 
 func (vpp *VppInstance) Stop() {
-       pid := strings.TrimSpace(vpp.Container.Exec(false, "pidof vpp"))
+       pid, err := vpp.Container.Exec(false, "pidof vpp")
+       pid = strings.TrimSpace(pid)
        // Stop VPP only if it's still running
-       if len(pid) > 0 {
+       if err == nil {
+               vpp.getSuite().Log("Stopping VPP")
                vpp.Container.Exec(false, "bash -c \"kill -15 "+pid+"\"")
        }
 }
index c104031..b93b27a 100644 (file)
@@ -35,6 +35,7 @@ func testVppEcho(s *VethsSuite, proto string) {
                " socket-name " + s.Containers.ClientApp.GetContainerWorkDir() + "/var/run/app_ns_sockets/default" +
                " use-app-socket-api uri " + uri
        s.Log(clientCommand)
-       o := s.Containers.ClientApp.Exec(true, clientCommand)
+       o, err := s.Containers.ClientApp.Exec(true, clientCommand)
+       s.AssertNil(err)
        s.Log(o)
 }
index 11e2be1..e88b6b7 100644 (file)
@@ -50,7 +50,8 @@ func testXEchoVclClient(s *VethsSuite, proto string) {
        testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + s.Interfaces.Server.Ip4AddressString() + " " + port
        s.Log(testClientCommand)
        echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
-       o := echoClnContainer.Exec(true, testClientCommand)
+       o, err := echoClnContainer.Exec(true, testClientCommand)
+       s.AssertNil(err)
        s.Log(o)
        s.AssertContains(o, "CLIENT RESULTS")
 }
@@ -97,7 +98,8 @@ func testVclEcho(s *VethsSuite, proto string) {
 
        testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port
        echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
-       o := echoClnContainer.Exec(true, testClientCommand)
+       o, err := echoClnContainer.Exec(true, testClientCommand)
+       s.AssertNil(err)
        s.Log(o)
 }
 
@@ -137,7 +139,8 @@ func testRetryAttach(s *VethsSuite, proto string) {
 
        testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346"
        echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
-       o := echoClnContainer.Exec(true, testClientCommand)
+       o, err := echoClnContainer.Exec(true, testClientCommand)
+       s.AssertNil(err)
        s.Log(o)
        s.Log("... First test ended. Stopping VPP server now.")
 
@@ -152,7 +155,8 @@ func testRetryAttach(s *VethsSuite, proto string) {
        time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen
 
        s.Log("... Running second echo client test, after disconnect and re-attachment.")
-       o = echoClnContainer.Exec(true, testClientCommand)
+       o, err = echoClnContainer.Exec(true, testClientCommand)
+       s.AssertNil(err)
        s.Log(o)
        s.Log("Done.")
 }