Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Update balancer test
Browse files Browse the repository at this point in the history
  • Loading branch information
feymartynov committed Aug 20, 2020
1 parent 1c8854d commit 78c1e42
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/app/endpoint/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,21 +719,39 @@ mod test {
let backend1 = shared_helpers::insert_janus_backend(&conn);
let backend2 = shared_helpers::insert_janus_backend(&conn);

// The first backend has 1 active stream.
// The first backend has 1 active stream with 1 agent.
let rtc1 = shared_helpers::insert_rtc(&conn);

let stream1 = factory::JanusRtcStream::new(USR_AUDIENCE)
.rtc(&rtc1)
.backend(&backend1)
.insert(&conn);

crate::db::janus_rtc_stream::start(stream1.id(), &conn).unwrap();

// The second backend has 1 stream that is not started
// so it's free and should be selected by the balancer.
let s1a1 = TestAgent::new("web", "s1a1", USR_AUDIENCE);
shared_helpers::insert_agent(&conn, s1a1.agent_id(), rtc1.room_id());

// The second backend has 1 stream with 2 agents but it's not started
// so it doesn't make any load on the backend and should be selected
// by the balancer.
let rtc2 = shared_helpers::insert_rtc(&conn);

let _stream2 = factory::JanusRtcStream::new(USR_AUDIENCE)
.rtc(&rtc2)
.backend(&backend2)
.insert(&conn);

let rtc = shared_helpers::insert_rtc(&conn);
(rtc, backend2)
let s2a1 = TestAgent::new("web", "s2a1", USR_AUDIENCE);
shared_helpers::insert_agent(&conn, s2a1.agent_id(), rtc2.room_id());

let s2a2 = TestAgent::new("web", "s2a2", USR_AUDIENCE);
shared_helpers::insert_agent(&conn, s2a2.agent_id(), rtc2.room_id());

// The new rtc for which we will balance the stream.
let rtc3 = shared_helpers::insert_rtc(&conn);

(rtc3, backend2)
})
.unwrap();

Expand Down

0 comments on commit 78c1e42

Please sign in to comment.