hs-test: improve get stats

Type: test

Change-Id: Ie681ee43007f4fe787d51d80bda9b433dcb6c09a
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
This commit is contained in:
Filip Tehlar
2023-06-27 10:01:37 +02:00
committed by Florin Coras
parent 8f3147d102
commit 543cd57ea2
2 changed files with 19 additions and 4 deletions

View File

@ -15,9 +15,6 @@ func (s *NginxSuite) TestMirroring() {
s.log(string(o))
s.assertNotEmpty(o)
// Check if log output from VPP contains 'no lcl port' warnings
// TODO: Need to change after adding session worker counter
vppProxyContainer := s.getContainerByName(vppProxyContainerName)
logContent := vppProxyContainer.log()
s.assertNotContains(logContent, "no lcl port")
s.assertEqual(0, vppProxyContainer.vppInstance.GetSessionStat("no lcl port"))
}

View File

@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"os/signal"
"strconv"
"strings"
"syscall"
"time"
@ -192,6 +193,23 @@ func (vpp *VppInstance) vppctl(command string, arguments ...any) string {
return string(output)
}
func (vpp *VppInstance) GetSessionStat(stat string) int {
o := vpp.vppctl("show session stats")
vpp.getSuite().log(o)
for _, line := range strings.Split(o, "\n") {
if strings.Contains(line, stat) {
tokens := strings.Split(strings.TrimSpace(line), " ")
val, err := strconv.Atoi(tokens[0])
if err != nil {
vpp.getSuite().FailNow("failed to parse stat value %s", err)
return 0
}
return val
}
}
return 0
}
func (vpp *VppInstance) waitForApp(appName string, timeout int) {
for i := 0; i < timeout; i++ {
o := vpp.vppctl("show app")