diff --git a/testing/internal/e2e/tests/static/bytes_up_down_empty_test.go b/testing/internal/e2e/tests/static/bytes_up_down_empty_test.go index 664035041..e4929edf5 100644 --- a/testing/internal/e2e/tests/static/bytes_up_down_empty_test.go +++ b/testing/internal/e2e/tests/static/bytes_up_down_empty_test.go @@ -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"), diff --git a/testing/internal/e2e/tests/static/bytes_up_down_test.go b/testing/internal/e2e/tests/static/bytes_up_down_test.go index 3ffe93222..b0ab84856 100644 --- a/testing/internal/e2e/tests/static/bytes_up_down_test.go +++ b/testing/internal/e2e/tests/static/bytes_up_down_test.go @@ -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) }