Skip to content

Commit 0558d82

Browse files
committed
update app integration test result processing
The TestApplicationGoCounter in app_test.go is a little flaky, occasionally failing. Seems to be failing more often with the recent changes in bpfman. Turns out the log processing was always looking at the oldest retrieved log, so if it didn't pass on the first read, it would never pass. It was just random timing if the first log contained packet counts or not. Signed-off-by: Billy McFall <[email protected]>
1 parent 1cc7c2c commit 0558d82

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

test/integration/app_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ func TestApplicationGoCounter(t *testing.T) {
6969
require.Eventually(t, func() bool {
7070
logs, err := req.Stream(ctx)
7171
require.NoError(t, err)
72-
defer logs.Close()
7372
output := new(bytes.Buffer)
7473
_, err = io.Copy(output, logs)
7574
require.NoError(t, err)
75+
logs.Close()
7676

7777
if f(t, output) {
7878
return true
7979
}
8080
t.Logf("check %d failed retrying, output %s", idx, output.String())
8181
return false
8282
}, 30*time.Second, time.Second)
83+
req.Close()
8384
}
8485
}

test/integration/common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ func doAppXdpCheck(t *testing.T, output *bytes.Buffer) bool {
121121
func doProbeCommonCheck(t *testing.T, output *bytes.Buffer, str string) (bool, int) {
122122
want := regexp.MustCompile(str)
123123
matches := want.FindAllStringSubmatch(output.String(), -1)
124-
if len(matches) >= 1 && len(matches[0]) >= 2 {
125-
count, err := strconv.Atoi(matches[0][1])
124+
numMatches := len(matches)
125+
if numMatches >= 1 && len(matches[numMatches-1]) >= 2 {
126+
count, err := strconv.Atoi(matches[numMatches-1][1])
126127
require.NoError(t, err)
127128
if count > 0 {
128129
return true, count

0 commit comments

Comments
 (0)