hass-core/homeassistant/components/stream
Allen Porter 65e3661f88
Repair flaky and broken stream tests in test_hls.py, and turn back on (#45025)
* Unmark tests as flaky (though still flaky)

This put tests into the broken state where they are flaky and do not yet pass

* Fix bug in test_hls_stream with incorrect path

* Enable and de-flake HLS stream tests

Background: Tests encode a fake video them start a stream to be decoded. Test
assert on the decoded segments, however there is a race with the stream worker
which can finish decoding first, and end the stream which ereases all buffers.

Breadown of fixes:
- Fix the race conditions by adding synchronization points right before the
  stream is finalized.
- Refactor StreamOutput.put so that a patch() can block the worker
  thread.  Previously, the put call would happen in the event loop which was
  not safe to block. This is a bit of a hack, but it is the simplist possible
  code change to add this synchronization and arguably provides slightly better
  separation of responsibilities from the worker anyway.
- Fix bugs in the tests that make them not pass, likely due to changes
  introduced while the tests were disabled
- Fix case where the HLS stream view recv() call returns None, indicating
  the worker finished while the request was waiting.

The tests were previously failing anywhere from 2-5% of the time on a lightly
loaded machine doing 1k iterations.  Now, have 0% flake rate.  Tested with:
$ py.test --count=1000 tests/components/strema/test_hls.py
2021-01-11 14:34:45 +01:00
..
__init__.py Remove empty schema (#45044) 2021-01-11 14:25:09 +01:00
const.py Modify wait timeout in stream (#42794) 2020-11-11 12:32:56 -05:00
core.py Repair flaky and broken stream tests in test_hls.py, and turn back on (#45025) 2021-01-11 14:34:45 +01:00
fmp4utils.py Cap AVC profile level at 4.1 in stream master playlist (#41592) 2020-10-15 16:37:27 -04:00
hls.py Repair flaky and broken stream tests in test_hls.py, and turn back on (#45025) 2021-01-11 14:34:45 +01:00
manifest.json Set log level for libav.mp4 in stream (#39719) 2020-09-06 20:46:36 +02:00
recorder.py Remove pts adjustments in stream (#42399) 2020-11-16 15:13:33 -05:00
services.yaml Add yamllint (in pre-commit and CI) (#33676) 2020-04-05 10:33:45 +02:00
worker.py Repair flaky and broken stream tests in test_hls.py, and turn back on (#45025) 2021-01-11 14:34:45 +01:00