Give channel tuning more time and one retry (0.23.0)
Vortex failed to tune when the provider took over 15 seconds to answer. Allows 45 seconds, retries once, and records the health check results. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -39,4 +39,29 @@ class CatalogueStatsTest {
|
||||
assertEquals(102, channelAfter(lineup, 101, 1)); assertEquals(101, channelAfter(lineup, 103, 1)); assertEquals(103, channelAfter(lineup, 101, -1))
|
||||
assertEquals(999, channelAfter(lineup, 999, 1)); assertEquals(101, channelAfter(listOf(101), 101, 1))
|
||||
}
|
||||
private class SlowThenFine(val failures: Int, val failure: () -> EmbyReply) : EmbyTransport {
|
||||
val requests = mutableListOf<EmbyRequest>()
|
||||
override fun execute(request: EmbyRequest): EmbyReply {
|
||||
requests += request
|
||||
if (requests.size <= failures) return failure()
|
||||
return EmbyReply(200, org.json.JSONObject().put("MediaSources", org.json.JSONArray().put(org.json.JSONObject().put("Id", "source").put("Container", "mkv").put("SupportsDirectStream", true))).toString())
|
||||
}
|
||||
}
|
||||
private val item = SampleItem("Fixture", "Movie", 90, "mkv", "one")
|
||||
private fun session(transport: EmbyTransport) = EmbySampleSession(transport, "fixture-token", "fixture-user", EmbySample(listOf(item), 1))
|
||||
@Test fun tuningTriesOnceMoreAfterASlowAnswerWithALongerWait() {
|
||||
val transport = SlowThenFine(1) { throw EmbyCheckException("The provider took too long to answer.", retryable = true) }
|
||||
var pauses = 0
|
||||
assertEquals("source", session(transport).prepareForTuning(item, "source") { pauses++ }.sourceId)
|
||||
assertEquals(2, transport.requests.size); assertEquals(1, pauses)
|
||||
assertTrue(transport.requests.all { it.readTimeoutMs == PLAYBACK_INFO_TIMEOUT_MS })
|
||||
}
|
||||
@Test fun tuningGivesUpAfterTwoTriesAndNeverRetriesARefusal() {
|
||||
val slow = SlowThenFine(5) { throw EmbyCheckException("The provider took too long to answer.", retryable = true) }
|
||||
try { session(slow).prepareForTuning(item, "source"); fail("Endless failure accepted") } catch (_: EmbyCheckException) { }
|
||||
assertEquals(2, slow.requests.size)
|
||||
val refused = SlowThenFine(5) { EmbyReply(403, "") }
|
||||
try { session(refused).prepareForTuning(item, "source"); fail("Refusal accepted") } catch (_: EmbyCheckException) { }
|
||||
assertEquals(1, refused.requests.size)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user