diff --git a/android/app/src/test/java/tv/orbit/classic/LiveSiloProviderTest.kt b/android/app/src/test/java/tv/orbit/classic/LiveSiloProviderTest.kt new file mode 100644 index 00000000..ecfd3795 --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/LiveSiloProviderTest.kt @@ -0,0 +1,47 @@ +package tv.orbit.classic + +import kotlinx.coroutines.runBlocking +import org.junit.Assume.assumeTrue +import org.junit.Test + +/** + * The shared contract against a real Silo server (9 November 2026): Orbit's isolated test server on Paul's PC + * (silo-test/compose.yml), made-up media only: six films (film 6 an AVI, which Orbit can't play directly yet; films 1 and 2 + * with pictures) and a series of 8 episodes and 2 specials. Skipped unless ORBIT_SILO_URL, ORBIT_SILO_USER and ORBIT_SILO_PASSWORD + * are set, so the release gate never needs it. Prints one line per check, then fails if any check failed. + * ORBIT_SILO_URL=http://172.20.0.2:8096 ORBIT_SILO_USER=… ORBIT_SILO_PASSWORD=… ./gradlew :app:testDebugUnitTest --tests '*LiveSilo*' + */ +class LiveSiloProviderTest { + @Test fun siloKeepsTheContract() { + val url = System.getenv("ORBIT_SILO_URL"); val user = System.getenv("ORBIT_SILO_USER"); val password = System.getenv("ORBIT_SILO_PASSWORD") + assumeTrue("no Silo test server set", url != null && user != null && password != null) + val session = EmbyClient(HttpsEmbyTransport(origin = url!!)).connect(user!!, password!!) + val p = session.provider() + println("SILO library ${p.library.value}, seen as ${p.kind}") + val all = runBlocking { p.catalogue(PageRequest(0, 200)) } + val films = all.items.filter { it.type == MediaType.Movie }; val series = all.items.first { it.type == MediaType.Series } + val regular = runBlocking { p.episodes(series.id) }; val withSpecials = runBlocking { p.episodes(series.id, includeSpecials = true) } + println("SILO catalogue ${all.total} (${films.size} films), series ${regular.size} episodes + ${withSpecials.size - regular.size} specials") + val fixture = ContractFixture(catalogueSize = 7, series = series.id, seriesEpisodes = 8, seriesSpecials = 2, collections = 0, + known = films.take(2).map { it.id }, missing = ItemId("gone1"), + withArtwork = films.first().id, withoutArtwork = series.id, playable = films.first().id, unplayable = films.first { it.title.endsWith("6") }.id, + secrets = listOf(password, url.substringAfter("://").substringBefore(':')), + failing = { e -> SiloFailing(e, p) }) + val results = ProviderContractChecks.all.map { (name, check) -> name to runCatching { check(p, fixture) }.exceptionOrNull() } + results.forEach { (name, failure) -> println("SILO ${if (failure == null) "pass" else "FAIL"} $name${failure?.let { ": ${it.message?.take(160)}" } ?: ""}") } + val failed = results.filter { it.second != null }.map { it.first } + // Known gap (9 November 2026): Silo answers a picture request with a redirect to its own signed /api/v2/artwork URL, + // always 1920 px wide and WebP; Orbit never follows redirects, so it gets no picture. A Silo adapter must handle this. + val knownGaps = setOf("artwork is bounded") + assert(failed.toSet() == knownGaps) { "Silo failed: $failed (known gaps: $knownGaps)" } + } +} + +/** The failure half of check 10 and 11 needs a server that fails on purpose; these stand in with today's mapping of each failure. */ +private class SiloFailing(private val e: ProviderError, private val real: MediaProvider) : MediaProvider by real { + override suspend fun catalogue(page: PageRequest): Page = throw providerErrorOf(when (e) { + ProviderError.Authentication -> EmbyCheckException("Sign in", 401) + ProviderError.Unreachable -> java.io.IOException("connect timed out") + else -> EmbyCheckException("The provider returned an unreadable response.") + }) +} diff --git a/docs/SILO-TEST-2026-11-09.md b/docs/SILO-TEST-2026-11-09.md new file mode 100644 index 00000000..8a79c5e5 --- /dev/null +++ b/docs/SILO-TEST-2026-11-09.md @@ -0,0 +1,41 @@ +# Silo test server: first results (9 November 2026) + +Paul's launch decision: test Silo in an isolated, pinned Docker container with made-up media. Done on Paul's PC. + +## The server +- Image `ghcr.io/silo-server/silo-server`, pinned by digest to build-2072 (`sha256:68a99cde…54d19`). Silo has no numbered + releases yet (prerelease, AGPL-3.0-or-later). About 690 MB. +- Isolated: its own Docker network, ports bound to 127.0.0.1 only (web 18090, Jellyfin API 18096), no added + capabilities (the docs' NET_ADMIN isn't needed), no-new-privileges, media mounted read-only, no restart on boot. +- Files: `~/Documents/OrbitTV/silo-test` (compose.yml, `.env` with the secret key and test account, mode 600, data/, + media/). The same compose file and the media script are in `tools/silo-test/`. +- Start/stop: `docker compose up -d` / `docker compose down` in that folder. +- Media: made-up only (`tools/silo-test/make-media.sh`): six films (film 6 an AVI; films 1 and 2 with a poster and a + backdrop) and one series of 8 episodes and 2 specials. + +## Orbit's contract against it +`LiveSiloProviderTest` runs all 12 shared contract checks through today's Emby/Jellyfin code against the live server. +It is skipped unless `ORBIT_SILO_URL` and the test account are set, so the release gate doesn't need Silo. + +| Check | Result | +|---|---| +| ids are stable / fit the rule | pass (Silo ids are GUIDs with dashes, which fit) | +| catalogue is complete / items usable | pass (7 of 7) | +| episodes in order, specials only when asked | pass (8 + 2) | +| collections hold real members | pass (none in the test library) | +| details skip the unknown | pass | +| artwork is bounded | **fail**, see below | +| playback is direct | pass | +| credentials stay out of logs | pass | +| errors are uniform | pass (the AVI is reported as unplayable, as it would be on Emby today) | +| progress is optional | pass | + +## What a Silo adapter will need (not started: providers come one at a time, after Emby and Jellyfin) +1. **Pictures.** Silo answers `/Items/{id}/Images/{type}` with a 302 redirect to its own signed `/api/v2/artwork/…` URL, + always 1920 px and WebP, ignoring `maxWidth`. Orbit never follows redirects, so it shows no pictures from Silo. The fix + is to follow a redirect only when it stays on the same server, and to shrink the picture on the box if it's wider than asked. +2. **Identity.** Silo reports itself as "Jellyfin Server" (version 12.1.0), so Orbit sees it as Jellyfin and names the + library `jellyfin:`. Its `ServerName` is "Silo". Whether a Silo library should be `silo:` is a decision for Paul + before Silo is offered, because a library id must never change once rooms have stored it. +3. **Server address.** Orbit only allows plain http for home-network addresses (10.x, 172.16–31.x, 192.168.x), so this + PC's 127.0.0.1 is refused; the test reaches the container by its Docker address instead. Nothing to change for real homes. diff --git a/tools/silo-test/compose.yml b/tools/silo-test/compose.yml new file mode 100644 index 00000000..6fdaee4e --- /dev/null +++ b/tools/silo-test/compose.yml @@ -0,0 +1,21 @@ +# Orbit's Silo test server (9 November 2026). Isolated: its own network, reachable only from this PC (127.0.0.1), +# no extra privileges, made-up media mounted read-only. Pinned to build-2072 by digest; change only on purpose. +name: orbit-silo-test +services: + silo: + image: ghcr.io/silo-server/silo-server@sha256:68a99cde6e5a093970b8280622ec8f6c3f31f3caeac2c05072316610cd154d19 + container_name: orbit-silo-test + env_file: .env + environment: { PORT: "8080", JF_PORT: "8096", ABS_PORT: "13378", ENABLE_REDIS: "true", PUID: "1000", PGID: "1000" } + ports: ["127.0.0.1:18090:8080", "127.0.0.1:18096:8096"] + volumes: + - ./data/config:/config + - ./media:/mnt/media:ro + - ./data/transcode:/tmp/silo-transcode + - ./data/download-artifacts:/tmp/silo-download-artifacts + security_opt: ["no-new-privileges:true"] + stop_grace_period: 120s + restart: "no" + networks: [silo] +networks: + silo: {} diff --git a/tools/silo-test/make-media.sh b/tools/silo-test/make-media.sh new file mode 100755 index 00000000..84485eda --- /dev/null +++ b/tools/silo-test/make-media.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Made-up media for Orbit's Silo test server (9 November 2026): six films (film 6 an AVI; films 1 and 2 with a poster and +# backdrop) and one series of 8 episodes plus 2 specials, all test patterns and tones. Usage: make-media.sh +set -euo pipefail; M=$1; mkdir -p "$M/Movies" "$M/Shows"; cd "$M" +mk(){ mkdir -p "$(dirname "$1")"; ffmpeg -loglevel error -y -f lavfi -i "testsrc2=size=640x360:rate=25:duration=$2" -f lavfi -i "sine=frequency=440:duration=$2" \ + -c:v libx264 -preset veryfast -pix_fmt yuv420p -c:a aac -shortest "$1"; } +for i in 1 2 3 4 5; do y=$((1990+i)); d="Movies/Orbit Fixture Film $i ($y)"; mk "$d/Orbit Fixture Film $i ($y).mkv" 20 + printf 'Orbit Fixture Film %s%sA made-up film for testing Orbit.Comedy\n' $i $y > "$d/Orbit Fixture Film $i ($y).nfo"; done +for d in "Movies/Orbit Fixture Film 1 (1991)" "Movies/Orbit Fixture Film 2 (1992)"; do + ffmpeg -loglevel error -y -f lavfi -i "testsrc2=size=1280x720:rate=1:duration=1" -frames:v 1 "$d/fanart.jpg" + ffmpeg -loglevel error -y -f lavfi -i "smptebars=size=680x1000:rate=1:duration=1" -frames:v 1 "$d/poster.jpg"; done +d="Movies/Orbit Fixture Film 6 (1996)"; mkdir -p "$d" +ffmpeg -loglevel error -y -f lavfi -i "testsrc2=size=640x360:rate=25:duration=20" -f lavfi -i "sine=frequency=330:duration=20" -c:v mpeg4 -vtag XVID -c:a libmp3lame -shortest "$d/Orbit Fixture Film 6 (1996).avi" +printf 'Orbit Fixture Film 61996A made-up AVI film for testing Orbit.\n' > "$d/Orbit Fixture Film 6 (1996).nfo" +S="Shows/Orbit Fixture Show (2001)"; mkdir -p "$S" +printf 'Orbit Fixture Show2001A made-up series for testing Orbit.\n' > "$S/tvshow.nfo" +for s in 1 2; do for e in 1 2 3 4; do mk "$S/Season 0$s/Orbit Fixture Show S0${s}E0$e.mkv" 15; done; done +for e in 1 2; do mk "$S/Specials/Orbit Fixture Show S00E0$e.mkv" 10; done