livepeer / livepeer/go-livepeer

Refactor transcode loop context and improve tests stability

Open
#660 0 comments 0 reactions 0 assignees View on GitHub
status: icebox type: refactor type: tech debt
Dominant language
Go
Stars
586
Forks
226
Avg merge
1d 17h
Merged PRs (30d)
19

Description

**Is your feature request related to a problem? Please describe.**
We currently have little control/visibility on the transcode loop process, so our tests around the loop rely on waiting for the timeout. We want to refactor the context such that tests can inject their own stub. With a stub context we can write more reliable and readable tests.

**Describe the solution you'd like**
See @j0sh's suggestion [here](https://github.com/livepeer/go-livepeer/pull/657#discussion_r244917469). In short we want to refactor the creation of the transcode loop context into a function we can stub out in tests.

**Describe alternatives you've considered**
Currently tests rely on a combination of waiting for the timeout and checking for some post-timeout side effects, but we recognize the current approach as brittle and inflexible.

**Additional context**
None.

Contributor guide

Open the contributing guide

Research direction

Start by locating the transcode loop context creation and read the suggestion in pull request #657, discussion r244917469. Refactor that creation so tests can provide a stub context, then update the loop tests to avoid waiting on timeouts and verify the expected post-timeout behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, testing-qa
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.