Skip to content

Commit 38bbfe4

Browse files
committed
acceptance: Change rpk registry schema list to fail eventually
In the execution sometimes the schema registry subsystem is not ready to handle requests. To make test suite more stable single assertion was replaced with Eventually function. To add more the stdout was not reset after each rpk command. Now it will be truncated.
1 parent 92d6e13 commit 38bbfe4

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

acceptance/steps/rpk.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"strings"
7+
"time"
78

89
"github.com/cucumber/godog"
910
"github.com/stretchr/testify/require"
@@ -105,15 +106,31 @@ func checkRPKCommands(ctx context.Context, t framework.TestingT, clusterName str
105106
Stderr: &stderr,
106107
}), "\nStdout: %s\nStderr: %s\n", stdout.String(), stderr.String())
107108
require.Len(t, stderr.Bytes(), 0)
108-
109-
require.NoErrorf(t, ctl.Exec(ctx, &p, kube.ExecOptions{
110-
Container: "redpanda",
111-
Command: []string{"rpk", "registry", "schema", "list"},
112-
Stdin: nil,
113-
Stdout: &stdout,
114-
Stderr: &stderr,
115-
}), "\nStdout: %s\nStderr: %s\n", stdout.String(), stderr.String())
116-
require.Len(t, stderr.Bytes(), 0)
109+
stdout.Reset()
110+
111+
require.Eventually(t, func() bool {
112+
command := []string{"rpk", "registry", "schema", "list"}
113+
err := ctl.Exec(ctx, &p, kube.ExecOptions{
114+
Container: "redpanda",
115+
Command: command,
116+
Stdin: nil,
117+
Stdout: &stdout,
118+
Stderr: &stderr,
119+
})
120+
if err != nil {
121+
t.Logf("rpk command %q failed with error: %v\nStdout: %s\nStderr: %s\n", strings.Join(command, " "), err, stdout.String(), stderr.String())
122+
stdout.Reset()
123+
return false
124+
}
125+
if len(stderr.Bytes()) != 0 {
126+
t.Logf("rpk command %q failed with \nStdout: %s\nStderr: %s\n", strings.Join(command, " "), stdout.String(), stderr.String())
127+
stderr.Reset()
128+
stdout.Reset()
129+
return false
130+
}
131+
return true
132+
}, time.Minute, 10*time.Second)
133+
stdout.Reset()
117134

118135
require.NoErrorf(t, ctl.Exec(ctx, &p, kube.ExecOptions{
119136
Container: "redpanda",
@@ -123,5 +140,6 @@ func checkRPKCommands(ctx context.Context, t framework.TestingT, clusterName str
123140
Stderr: &stderr,
124141
}), "\nStdout: %s\nStderr: %s\n", stdout.String(), stderr.String())
125142
require.Len(t, stderr.Bytes(), 0)
143+
126144
}
127145
}

0 commit comments

Comments
 (0)