Skip to content

Commit

Permalink
Adds unit test for completeStreamSession (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuben Rodrigues committed Apr 25, 2021
1 parent 468b8b1 commit f6c6322
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#### Orchestrator

- \#1840 Re-use remote transcoders for a stream sessions (@reubenr0d)
- \#1842 Re-use remote transcoders for a stream sessions (@reubenr0d)

#### Transcoder

Expand Down
22 changes: 22 additions & 0 deletions core/orch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,28 @@ func TestSelectTranscoder(t *testing.T) {
assert.Equal(0, t1.load)
}

func TestCompleteStreamSession(t *testing.T) {
m := NewRemoteTranscoderManager()
strm := &StubTranscoderServer{manager: m, WithholdResults: false}
testSessionId := "testID"
assert := assert.New(t)

// register transcoders
go func() { m.Manage(strm, 1) }()
time.Sleep(1 * time.Millisecond) // allow time for first stream to register
t1 := m.liveTranscoders[strm]

// selectTranscoder and assert that session is added
m.selectTranscoder(testSessionId)
assert.Equal(t1, m.streamSessions[testSessionId])
assert.Equal(1, t1.load)

// complete session and assert that it is cleared
m.completeStreamSession(testSessionId)
assert.Nil(m.streamSessions[testSessionId])
assert.Equal(0, t1.load)
}

func TestTranscoderManagerTranscoding(t *testing.T) {
m := NewRemoteTranscoderManager()
s := &StubTranscoderServer{manager: m}
Expand Down

0 comments on commit f6c6322

Please sign in to comment.