fix(e2e): Address flake due to timing (#2774)
Observed a flake in this test where a session was still reporting 0 bytes up/down on the first read. Modifying the checks to be more resilient.
This commit is contained in:
1 parent
8c33582627
commit
461b194cde
2 files changed
+60
-12
No files matched your search
@@ -66,11 +66,33 @@ func TestCliBytesUpDownEmpty(t *testing.T) {
|
||||
// Confirm that bytesUp and bytesDown do not change
|
||||
bytesUp := 0
|
||||
bytesDown := 0
|
||||
|
||||
// Wait until bytes up and down is greater than 0
|
||||
t.Log("Waiting for bytes_up/bytes_down to be greater than 0...")
|
||||
for i := 0; i < 3; i++ {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("sessions", "read", "-id", session.Id, "-format", "json"),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
var newSessionReadResult sessions.SessionReadResult
|
||||
err = json.Unmarshal(output.Stdout, &newSessionReadResult)
|
||||
require.NoError(t, err)
|
||||
bytesUp = int(newSessionReadResult.Item.Connections[0].BytesUp)
|
||||
bytesDown = int(newSessionReadResult.Item.Connections[0].BytesDown)
|
||||
t.Logf("bytes_up: %d, bytes_down: %d", bytesUp, bytesDown)
|
||||
|
||||
if bytesUp > 0 && bytesDown > 0 {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
require.Greater(t, bytesUp, 0)
|
||||
require.Greater(t, bytesDown, 0)
|
||||
|
||||
t.Log("Reading bytes_up/bytes_down values...")
|
||||
for i := 0; i < 3; i++ {
|
||||
if i != 0 {
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("sessions", "read", "-id", session.Id, "-format", "json"),
|
||||
|
||||
@@ -66,15 +66,12 @@ func TestCliBytesUpDownTransferData(t *testing.T) {
|
||||
assert.Equal(t, newTargetId, session.TargetId)
|
||||
assert.Equal(t, newHostId, session.HostId)
|
||||
|
||||
// Confirm that bytesDown is increasing
|
||||
bytesUp := 0
|
||||
bytesDown := 0
|
||||
t.Log("Reading bytes_up/bytes_down values...")
|
||||
for i := 0; i < 3; i++ {
|
||||
if i != 0 {
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
// Wait until bytes up and down is greater than 0
|
||||
t.Log("Waiting for bytes_up/bytes_down to be greater than 0...")
|
||||
for i := 0; i < 3; i++ {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("sessions", "read", "-id", session.Id, "-format", "json"),
|
||||
)
|
||||
@@ -82,11 +79,40 @@ func TestCliBytesUpDownTransferData(t *testing.T) {
|
||||
var newSessionReadResult sessions.SessionReadResult
|
||||
err = json.Unmarshal(output.Stdout, &newSessionReadResult)
|
||||
require.NoError(t, err)
|
||||
require.GreaterOrEqual(t, int(newSessionReadResult.Item.Connections[0].BytesUp), bytesUp)
|
||||
bytesUp = int(newSessionReadResult.Item.Connections[0].BytesUp)
|
||||
require.Greater(t, int(newSessionReadResult.Item.Connections[0].BytesDown), bytesDown)
|
||||
bytesDown = int(newSessionReadResult.Item.Connections[0].BytesDown)
|
||||
|
||||
t.Logf("bytes_up: %d, bytes_down: %d", bytesUp, bytesDown)
|
||||
|
||||
if bytesUp > 0 && bytesDown > 0 {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
require.Greater(t, bytesUp, 0)
|
||||
require.Greater(t, bytesDown, 0)
|
||||
|
||||
// Confirm that bytes up and down increases
|
||||
t.Log("Waiting for bytes_up/bytes_down to increase...")
|
||||
var newBytesUp, newBytesDown int
|
||||
for i := 0; i < 3; i++ {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("sessions", "read", "-id", session.Id, "-format", "json"),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
var newSessionReadResult sessions.SessionReadResult
|
||||
err = json.Unmarshal(output.Stdout, &newSessionReadResult)
|
||||
require.NoError(t, err)
|
||||
newBytesUp = int(newSessionReadResult.Item.Connections[0].BytesUp)
|
||||
newBytesDown = int(newSessionReadResult.Item.Connections[0].BytesDown)
|
||||
t.Logf("bytes_up: %d, bytes_down: %d", newBytesUp, newBytesDown)
|
||||
|
||||
if newBytesDown > bytesDown {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
require.GreaterOrEqual(t, newBytesUp, bytesUp)
|
||||
require.Greater(t, newBytesDown, bytesDown)
|
||||
}
|
||||
Reference in new issue
Block a user