Allinea slate Cloud a AAC 48k mono e preferisce home in allocate.
Senza questo il telefono (mono 48k) veniva rifiutato sui nodi Hetzner e lo warm spare rubava le sessioni a home. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -49,7 +49,27 @@ RSpec.describe Streams::NodeRegistry do
|
||||
end
|
||||
end
|
||||
|
||||
it "allocates the least loaded ready node" do
|
||||
it "prefers home while it still has free slots even if cloud is idle" do
|
||||
with_env(home_env) do
|
||||
home = described_class.ensure_home_from_env!
|
||||
StreamNode.create!(
|
||||
slug: "ingest-01",
|
||||
hostname: "ingest-01.mltv-stream.net",
|
||||
role: "cloud",
|
||||
status: "ready",
|
||||
provider: "hetzner",
|
||||
rtmp_base_url: "rtmp://ingest-01.mltv-stream.net:1935",
|
||||
hls_base_url: "https://ingest-01.mltv-stream.net/hls",
|
||||
api_base_url: "http://10.0.0.2:9997",
|
||||
max_publishers: 2,
|
||||
max_relays: 2
|
||||
)
|
||||
|
||||
expect(described_class.allocate!).to eq(home)
|
||||
end
|
||||
end
|
||||
|
||||
it "allocates the least loaded cloud node when home is full" do
|
||||
with_env(home_env) do
|
||||
home = described_class.ensure_home_from_env!
|
||||
cloud = StreamNode.create!(
|
||||
@@ -64,14 +84,32 @@ RSpec.describe Streams::NodeRegistry do
|
||||
max_publishers: 2,
|
||||
max_relays: 2
|
||||
)
|
||||
cloud_busy = StreamNode.create!(
|
||||
slug: "ingest-02",
|
||||
hostname: "ingest-02.mltv-stream.net",
|
||||
role: "cloud",
|
||||
status: "ready",
|
||||
provider: "hetzner",
|
||||
rtmp_base_url: "rtmp://ingest-02.mltv-stream.net:1935",
|
||||
hls_base_url: "https://ingest-02.mltv-stream.net/hls",
|
||||
api_base_url: "http://10.0.0.3:9997",
|
||||
max_publishers: 2,
|
||||
max_relays: 2
|
||||
)
|
||||
|
||||
user = User.create!(email: "n@example.com", name: "N", password: "Password123", role: "coach")
|
||||
club = Club.create!(name: "C", sport: "volleyball")
|
||||
team = club.teams.create!(name: "T", sport: "volleyball", slug: "t-node")
|
||||
match = team.matches.create!(opponent_name: "X", scheduled_at: 1.hour.from_now)
|
||||
match2 = team.matches.create!(opponent_name: "Y", scheduled_at: 2.hours.from_now)
|
||||
|
||||
# Riempie home (max 2)
|
||||
StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "live", stream_node: home)
|
||||
StreamSession.create!(match: match2, user: user, platform: "matchlivetv", status: "live", stream_node: home)
|
||||
# Un publisher già su ingest-02 → least-loaded = ingest-01
|
||||
StreamSession.create!(
|
||||
match: match, user: user, platform: "matchlivetv", status: "live", stream_node: home
|
||||
match: team.matches.create!(opponent_name: "Z", scheduled_at: 3.hours.from_now),
|
||||
user: user, platform: "matchlivetv", status: "live", stream_node: cloud_busy
|
||||
)
|
||||
|
||||
expect(described_class.allocate!).to eq(cloud)
|
||||
|
||||
Reference in New Issue
Block a user