Refactor the test_qos.QoSTestMixin._check_bw function

Improved the robustness of this function:
- The remote process ("nc"), will be stopped both at the beginning and
  the end of this function, just to ensure the process is not left
  running at the beginning of the next check.
- The socket connection is closed when the file is received (or in case
  of exception). This will close the client socket and will end the "nc"
  process in the remote VM.
- Set a socket timeout. This timeout, specifically defined for each
  iteration, depending on the expected bandwidth, will force a quick
  timeout while receiving from the remote VM. The check will fail and it
  will be tested again, if the "FILE_DOWNLOAD_TIMEOUT" didn't happen yet.

Change-Id: I5ce1a34f7d5d635002baa1e5b14c288e6d2bc43e
Closes-Bug: #1838068
1 file changed