diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2023-06-27 10:01:37 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-07-28 18:55:55 +0000 |
commit | 543cd57ea2fa2191804e0e1893fa2c34a37f0088 (patch) | |
tree | d53fdfba324433d60103a6c1970d43bc62d3d45d /extras/hs-test/vppinstance.go | |
parent | 8f3147d102a47135f953eeca22375300c8d00dde (diff) |
hs-test: improve get stats
Type: test
Change-Id: Ie681ee43007f4fe787d51d80bda9b433dcb6c09a
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'extras/hs-test/vppinstance.go')
-rw-r--r-- | extras/hs-test/vppinstance.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/extras/hs-test/vppinstance.go b/extras/hs-test/vppinstance.go index c871697cb44..bed084c42ed 100644 --- a/extras/hs-test/vppinstance.go +++ b/extras/hs-test/vppinstance.go @@ -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") |