Compare commits
50
Commits
No files matched your search
@@ -2,3 +2,5 @@
|
|||||||
/dev/.state/
|
/dev/.state/
|
||||||
/dist/
|
/dist/
|
||||||
/.cargo/
|
/.cargo/
|
||||||
|
# agent scratch of a worktree (the MAO policy in CLAUDE.md)
|
||||||
|
/.scratch/
|
||||||
Generated
+25
-25
@@ -1774,9 +1774,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-bigint"
|
name = "crypto-bigint"
|
||||||
version = "0.7.5"
|
version = "0.7.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271"
|
checksum = "cc907c45bb7e9ef8fc3778defd0f3cd8c81288f1b4e748eba064948f20c47122"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cpubits",
|
"cpubits",
|
||||||
"ctutils",
|
"ctutils",
|
||||||
@@ -1817,7 +1817,7 @@ version = "0.7.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f"
|
checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"rand_core 0.10.1",
|
"rand_core 0.10.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1871,9 +1871,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctutils"
|
name = "ctutils"
|
||||||
version = "0.4.2"
|
version = "0.4.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
|
checksum = "38d28fb6aa7dd680b3ffd1a3e64e115c177bdba63c0ae7f9cd48129ff05c4fa0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cmov",
|
"cmov",
|
||||||
"subtle",
|
"subtle",
|
||||||
@@ -2400,7 +2400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "9d65aa39b3a5c1c9c1b745c9a019234bb7a21b77abcb4f4d266d706e2d577d65"
|
checksum = "9d65aa39b3a5c1c9c1b745c9a019234bb7a21b77abcb4f4d266d706e2d577d65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct 1.0.0",
|
"base16ct 1.0.0",
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"crypto-common 0.2.2",
|
"crypto-common 0.2.2",
|
||||||
"digest 0.11.3",
|
"digest 0.11.3",
|
||||||
"ff 0.14.0",
|
"ff 0.14.0",
|
||||||
@@ -2512,7 +2512,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5676,7 +5676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -6271,7 +6271,7 @@ version = "0.14.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4"
|
checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"crypto-common 0.2.2",
|
"crypto-common 0.2.2",
|
||||||
"ff 0.14.0",
|
"ff 0.14.0",
|
||||||
"rand_core 0.10.1",
|
"rand_core 0.10.1",
|
||||||
@@ -6467,7 +6467,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tracing",
|
"tracing",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -6842,7 +6842,7 @@ version = "0.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b"
|
checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"hmac 0.13.0",
|
"hmac 0.13.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -6898,7 +6898,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "30b2aa4ba0d89f73d1e332df05be0eeab8840351c36ca5654341dfdb57bb3caf"
|
checksum = "30b2aa4ba0d89f73d1e332df05be0eeab8840351c36ca5654341dfdb57bb3caf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-oid 0.10.2",
|
"const-oid 0.10.2",
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"crypto-primes",
|
"crypto-primes",
|
||||||
"digest 0.11.3",
|
"digest 0.11.3",
|
||||||
"pkcs1",
|
"pkcs1",
|
||||||
@@ -6996,7 +6996,7 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"cbc",
|
"cbc",
|
||||||
"cipher 0.5.2",
|
"cipher 0.5.2",
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"ctr 0.10.1",
|
"ctr 0.10.1",
|
||||||
"curve25519-dalek 5.0.0",
|
"curve25519-dalek 5.0.0",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -7144,7 +7144,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.12.1",
|
"linux-raw-sys 0.12.1",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7201,7 +7201,7 @@ dependencies = [
|
|||||||
"security-framework",
|
"security-framework",
|
||||||
"security-framework-sys",
|
"security-framework-sys",
|
||||||
"webpki-root-certs",
|
"webpki-root-certs",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7212,9 +7212,9 @@ checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
version = "0.103.15"
|
version = "0.103.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
|
checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"ring",
|
"ring",
|
||||||
@@ -8061,7 +8061,7 @@ checksum = "7b54d0ed0498daf3f78d82e00e28c8eec9d75a067c4cfbcc7a0f7d0f4077749e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"base64ct",
|
"base64ct",
|
||||||
"bytes",
|
"bytes",
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.7.7",
|
||||||
"ctutils",
|
"ctutils",
|
||||||
"digest 0.11.3",
|
"digest 0.11.3",
|
||||||
"pem-rfc7468 1.0.0",
|
"pem-rfc7468 1.0.0",
|
||||||
@@ -8405,10 +8405,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"getrandom 0.4.3",
|
"getrandom 0.3.4",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.1.5",
|
"rustix 1.1.5",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -8589,9 +8589,9 @@ checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.53.1"
|
version = "1.54.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
|
checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -10082,9 +10082,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webpki-root-certs"
|
name = "webpki-root-certs"
|
||||||
version = "1.0.9"
|
version = "1.0.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b"
|
checksum = "e49d0e65abc00c142e8f9428da991da9f1a250c39be97459901eb12b9b49f62a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
@@ -10279,7 +10279,7 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
+12
-5
@@ -175,7 +175,7 @@ the crate's authors are listed as its copyright holders.
|
|||||||
|
|
||||||
| License | Crates |
|
| License | Crates |
|
||||||
|---|---|
|
|---|---|
|
||||||
| MIT License | 660 |
|
| MIT License | 667 |
|
||||||
| Apache License 2.0 | 31 |
|
| Apache License 2.0 | 31 |
|
||||||
| Unicode License v3 | 26 |
|
| Unicode License v3 | 26 |
|
||||||
| BSD 3-Clause "New" or "Revised" License | 22 |
|
| BSD 3-Clause "New" or "Revised" License | 22 |
|
||||||
@@ -2611,7 +2611,7 @@ THIS SOFTWARE.
|
|||||||
|
|
||||||
````
|
````
|
||||||
|
|
||||||
Used by: rustls-webpki 0.103.15
|
Used by: rustls-webpki 0.103.16
|
||||||
|
|
||||||
````text
|
````text
|
||||||
Except as otherwise noted, this project is licensed under the following
|
Except as otherwise noted, this project is licensed under the following
|
||||||
@@ -7308,7 +7308,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
````
|
````
|
||||||
|
|
||||||
Used by: argon2 0.6.0, crypto-bigint 0.7.5, pkcs5 0.8.1, scrypt 0.12.0, sec1 0.8.1, spki 0.8.0, ssh-encoding 0.3.0, ssh-key 0.7.0-rc.11
|
Used by: argon2 0.6.0, crypto-bigint 0.7.7, pkcs5 0.8.1, scrypt 0.12.0, sec1 0.8.1, spki 0.8.0, ssh-encoding 0.3.0, ssh-key 0.7.0-rc.11
|
||||||
|
|
||||||
````text
|
````text
|
||||||
Copyright (c) 2021-2026 The RustCrypto Project Developers
|
Copyright (c) 2021-2026 The RustCrypto Project Developers
|
||||||
@@ -7930,7 +7930,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
````
|
````
|
||||||
|
|
||||||
Used by: ctutils 0.4.2
|
Used by: ctutils 0.4.5
|
||||||
|
|
||||||
````text
|
````text
|
||||||
Copyright (c) 2025-2026 The RustCrypto Project Developers
|
Copyright (c) 2025-2026 The RustCrypto Project Developers
|
||||||
@@ -9833,15 +9833,22 @@ Standard text, used by:
|
|||||||
- windows-result 0.4.1 (https://github.com/microsoft/windows-rs)
|
- windows-result 0.4.1 (https://github.com/microsoft/windows-rs)
|
||||||
- windows-strings 0.4.2: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows-strings 0.4.2: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows-strings 0.5.1 (https://github.com/microsoft/windows-rs)
|
- windows-strings 0.5.1 (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows-sys 0.45.0: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows-sys 0.48.0: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows-sys 0.52.0: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows-sys 0.52.0: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows-sys 0.61.2 (https://github.com/microsoft/windows-rs)
|
- windows-sys 0.61.2 (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows-targets 0.42.2: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows-targets 0.48.5: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows-targets 0.52.6: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows-targets 0.52.6: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows-threading 0.1.0: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows-threading 0.1.0: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows-threading 0.2.1 (https://github.com/microsoft/windows-rs)
|
- windows-threading 0.2.1 (https://github.com/microsoft/windows-rs)
|
||||||
- windows-version 0.1.7 (https://github.com/microsoft/windows-rs)
|
- windows-version 0.1.7 (https://github.com/microsoft/windows-rs)
|
||||||
- windows 0.61.3: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows 0.61.3: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows 0.62.2 (https://github.com/microsoft/windows-rs)
|
- windows 0.62.2 (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows_x86_64_gnu 0.48.5: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows_x86_64_gnu 0.52.6: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows_x86_64_gnu 0.52.6: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows_x86_64_msvc 0.42.2: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
|
- windows_x86_64_msvc 0.48.5: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
- windows_x86_64_msvc 0.52.6: Microsoft (https://github.com/microsoft/windows-rs)
|
- windows_x86_64_msvc 0.52.6: Microsoft (https://github.com/microsoft/windows-rs)
|
||||||
|
|
||||||
````text
|
````text
|
||||||
@@ -9881,7 +9888,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
|
|
||||||
````
|
````
|
||||||
|
|
||||||
Used by: tokio-stream 0.1.19, tokio-util 0.7.19, tokio 1.53.1
|
Used by: tokio-stream 0.1.19, tokio-util 0.7.19, tokio 1.54.1
|
||||||
|
|
||||||
````text
|
````text
|
||||||
MIT License
|
MIT License
|
||||||
|
|||||||
@@ -453,10 +453,15 @@ mod tests {
|
|||||||
lookups
|
lookups
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `lookups` asking the real `/.well-known/tsgw` at `port`.
|
/// `lookups` asking the real `/.well-known/tsgw` at `port`. A name is
|
||||||
|
/// connected to through the system's resolver, except `localhost`: the
|
||||||
|
/// servers of the tests listen on 127.0.0.1, and some machines resolve
|
||||||
|
/// `localhost` to `::1` only. (The test cares that the gateway is asked at
|
||||||
|
/// the name `localhost`, not what the resolver makes of it.)
|
||||||
fn probing(mut lookups: Lookups, port: u16) -> Lookups {
|
fn probing(mut lookups: Lookups, port: u16) -> Lookups {
|
||||||
lookups.probe = Arc::new(move |name| {
|
lookups.probe = Arc::new(move |name| {
|
||||||
async move { timeout(PROBE_TIMEOUT, well_known(&name, port)).await.ok()?.ok() }.boxed()
|
let host = if name == "localhost" { "127.0.0.1".to_owned() } else { name };
|
||||||
|
async move { timeout(PROBE_TIMEOUT, well_known(&host, port)).await.ok()?.ok() }.boxed()
|
||||||
});
|
});
|
||||||
lookups
|
lookups
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,19 +199,22 @@ async fn receive<R: AsyncRead + Unpin>(
|
|||||||
let mut done = offset;
|
let mut done = offset;
|
||||||
match sink {
|
match sink {
|
||||||
Sink::File { part, dest, append } => {
|
Sink::File { part, dest, append } => {
|
||||||
|
// The directory and the file are made in one step, without a pause in
|
||||||
|
// which the task could be stopped: a cancel stops the task, waits for
|
||||||
|
// it and then removes the part file, so what the task made must be
|
||||||
|
// there by then (a pending open on the blocking pool would not be).
|
||||||
if let Some(dir) = part.parent().filter(|d| !d.as_os_str().is_empty()) {
|
if let Some(dir) = part.parent().filter(|d| !d.as_os_str().is_empty()) {
|
||||||
tokio::fs::create_dir_all(dir)
|
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||||
.await
|
|
||||||
.map_err(|e| format!("{}: {e}", dir.display()))?;
|
|
||||||
}
|
}
|
||||||
let mut file = tokio::fs::OpenOptions::new()
|
let mut file = tokio::fs::File::from_std(
|
||||||
.create(true)
|
std::fs::OpenOptions::new()
|
||||||
.write(true)
|
.create(true)
|
||||||
.append(*append)
|
.write(true)
|
||||||
.truncate(!*append)
|
.append(*append)
|
||||||
.open(part)
|
.truncate(!*append)
|
||||||
.await
|
.open(part)
|
||||||
.map_err(|e| format!("{}: {e}", part.display()))?;
|
.map_err(|e| format!("{}: {e}", part.display()))?,
|
||||||
|
);
|
||||||
let received = async {
|
let received = async {
|
||||||
while done < size {
|
while done < size {
|
||||||
let n = stream.read(&mut buf).await.map_err(|e| e.to_string())?;
|
let n = stream.read(&mut buf).await.map_err(|e| e.to_string())?;
|
||||||
|
|||||||
@@ -166,9 +166,13 @@ impl Backends {
|
|||||||
self.register_local(Arc::new(connector));
|
self.register_local(Arc::new(connector));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The device's Voelin account, for the connectors that use it (the QUIC
|
/// The device's Voelin account, which every connect hands the connector as
|
||||||
/// connector's certificate, the TeamSpeak connector's myTS ID proof).
|
/// `ConnectParams::account`. No connector reads it yet: the TeamSpeak
|
||||||
/// None is the default: nothing uses an account yet.
|
/// connector takes the myTeamSpeak account it presents from its own setters
|
||||||
|
/// ([`TsConnector::set_myts_identity`], [`TsConnector::set_myts_data`]), and a
|
||||||
|
/// Voelin host's connector (the QUIC one, for its certificate) does not exist
|
||||||
|
/// yet. Follow-up H4 of `docs/session-seam.md` (11.2) moves the myTeamSpeak
|
||||||
|
/// proof from those setters to this hook. None is the default.
|
||||||
pub fn set_account(&mut self, agent: Option<Arc<dyn AccountAgent>>) {
|
pub fn set_account(&mut self, agent: Option<Arc<dyn AccountAgent>>) {
|
||||||
self.account = agent;
|
self.account = agent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ pub struct VoiceOptions {
|
|||||||
/// scheme (`ts3server://`, `teamspeak://`, a Voelin host's `voelin://`)
|
/// scheme (`ts3server://`, `teamspeak://`, a Voelin host's `voelin://`)
|
||||||
/// that picks the connector ([`Backends`]).
|
/// that picks the connector ([`Backends`]).
|
||||||
pub address: String,
|
pub address: String,
|
||||||
|
/// The name shown on the server: `Hello.nickname` to a Voelin host, the
|
||||||
|
/// client name on a TeamSpeak server (which may refuse or change it). When
|
||||||
|
/// it is empty, the `nickname` parameter of an `address` that is a
|
||||||
|
/// TeamSpeak link applies.
|
||||||
pub nickname: String,
|
pub nickname: String,
|
||||||
/// The identity to connect with: a TeamSpeak identity
|
/// The identity to connect with: a TeamSpeak identity
|
||||||
/// ([`crate::ts::identity::to_blob`]) for a TeamSpeak server, a Voelin key
|
/// ([`crate::ts::identity::to_blob`]) for a TeamSpeak server, a Voelin key
|
||||||
@@ -76,6 +80,10 @@ pub struct VoiceOptions {
|
|||||||
/// `<platform>@<version>`); `None` is the native platform's. A spec that is
|
/// `<platform>@<version>`); `None` is the native platform's. A spec that is
|
||||||
/// none ends the connect with the reason. Other backends ignore it.
|
/// none ends the connect with the reason. Other backends ignore it.
|
||||||
pub client_version: Option<String>,
|
pub client_version: Option<String>,
|
||||||
|
/// The password of the server (`Hello.password`), for one that has a
|
||||||
|
/// password. When it is `None` or empty, the `password` parameter of an
|
||||||
|
/// `address` that is a TeamSpeak link applies. Not the password of
|
||||||
|
/// `channel` (that is `channel_password`).
|
||||||
pub server_password: Option<String>,
|
pub server_password: Option<String>,
|
||||||
/// Channel path to join, e.g. `Lobby/Sub`, or `/<id>`.
|
/// Channel path to join, e.g. `Lobby/Sub`, or `/<id>`.
|
||||||
pub channel: Option<String>,
|
pub channel: Option<String>,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::task::AbortHandle;
|
use tokio::task::JoinHandle;
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
use voelin_audio::EncodedVoice;
|
use voelin_audio::EncodedVoice;
|
||||||
use voelin_model::replica::{Replica, SCHEMA_GENERATION, ScopeId};
|
use voelin_model::replica::{Replica, SCHEMA_GENERATION, ScopeId};
|
||||||
@@ -325,7 +325,7 @@ async fn drive(
|
|||||||
|
|
||||||
/// A transfer a user can cancel.
|
/// A transfer a user can cancel.
|
||||||
struct Running {
|
struct Running {
|
||||||
task: AbortHandle,
|
task: JoinHandle<()>,
|
||||||
part: Option<PathBuf>,
|
part: Option<PathBuf>,
|
||||||
report: Report,
|
report: Report,
|
||||||
/// The server has opened it (a part file may exist).
|
/// The server has opened it (a part file may exist).
|
||||||
@@ -1479,7 +1479,7 @@ impl Conn {
|
|||||||
receive.await;
|
receive.await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.running(transfer, Running { task: task.abort_handle(), part, report, started });
|
self.running(transfer, Running { task, part, report, started });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upload(
|
fn upload(
|
||||||
@@ -1560,7 +1560,7 @@ impl Conn {
|
|||||||
let stored = async move { done.await.map(|_| ()).map_err(|e| text(&e, false)) };
|
let stored = async move { done.await.map(|_| ()).map_err(|e| text(&e, false)) };
|
||||||
files::upload_to(body, stored, from, size, offset, progress, task_report).await;
|
files::upload_to(body, stored, from, size, offset, progress, task_report).await;
|
||||||
});
|
});
|
||||||
self.running(transfer, Running { task: task.abort_handle(), part: None, report, started });
|
self.running(transfer, Running { task, part: None, report, started });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn running(&mut self, transfer: Option<TransferId>, running: Running) {
|
fn running(&mut self, transfer: Option<TransferId>, running: Running) {
|
||||||
@@ -1572,15 +1572,21 @@ impl Conn {
|
|||||||
|
|
||||||
fn cancel(&mut self, id: TransferId) {
|
fn cancel(&mut self, id: TransferId) {
|
||||||
match self.transfers.remove(&id) {
|
match self.transfers.remove(&id) {
|
||||||
Some(running) if !running.task.is_finished() => {
|
Some(Running { task, part, report, started }) if !task.is_finished() => {
|
||||||
running.task.abort();
|
task.abort();
|
||||||
// A part file exists once the server has opened the transfer.
|
// The part file goes once the task has stopped, not at once: the task
|
||||||
if running.started.load(Ordering::Acquire)
|
// opens it in one step (files::download), so it is there or it never
|
||||||
&& let Some(part) = running.part
|
// will be, and a removal that came before the open would leave it.
|
||||||
{
|
tokio::spawn(async move {
|
||||||
let _ = std::fs::remove_file(part);
|
let _ = task.await;
|
||||||
}
|
// A part file exists once the server has opened the transfer.
|
||||||
(running.report)(TransferState::Cancelled);
|
if started.load(Ordering::Acquire)
|
||||||
|
&& let Some(part) = part
|
||||||
|
{
|
||||||
|
let _ = std::fs::remove_file(part);
|
||||||
|
}
|
||||||
|
report(TransferState::Cancelled);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
_ => debug!(id, "cancel: no such transfer (finished?)"),
|
_ => debug!(id, "cancel: no such transfer (finished?)"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -607,6 +607,12 @@ async fn a_file_is_downloaded_through_the_connection_the_link_opens() {
|
|||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||||
}
|
}
|
||||||
|
assert!(
|
||||||
|
states.lock().unwrap().iter().any(|s| matches!(s, TransferState::Started { .. })),
|
||||||
|
"the transfer started: {:?}",
|
||||||
|
states.lock().unwrap()
|
||||||
|
);
|
||||||
|
// Cancelled the moment it is Started, when its part file may be opening.
|
||||||
rig.give(LinkCmd::CancelTransfer(3));
|
rig.give(LinkCmd::CancelTransfer(3));
|
||||||
assert_eq!(final_state(&states).await, TransferState::Cancelled);
|
assert_eq!(final_state(&states).await, TransferState::Cancelled);
|
||||||
rig.quiet();
|
rig.quiet();
|
||||||
@@ -981,6 +987,32 @@ async fn a_connect_that_fails_is_a_disconnect_with_the_reason() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An identity that cannot be read ends the connect with a disconnect whose
|
||||||
|
/// text says where it is wrong and holds none of the key: the JSON reader's
|
||||||
|
/// own message quotes a key that does not import, and the engine shows this
|
||||||
|
/// text as the error of the connection.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn an_identity_that_cannot_be_read_is_a_disconnect_without_the_key() {
|
||||||
|
let (json, cut) = crate::ts::identity::json_with_a_cut_key();
|
||||||
|
let mut options = VoiceOptions::new("ts3server://127.0.0.1:9", "tester");
|
||||||
|
options.identity = Some(IdentityBlob::teamspeak("uid=", 8, json));
|
||||||
|
let link = SessionLink::new(Backends::default());
|
||||||
|
let (_cmd_tx, cmd_rx) = mpsc::unbounded_channel();
|
||||||
|
let (event_tx, mut events) = mpsc::unbounded_channel();
|
||||||
|
link.spawn(options, LocalCtx::standalone().link, cmd_rx, event_tx);
|
||||||
|
let event = within("the end", events.recv()).await;
|
||||||
|
let LinkEvent::Disconnected(Some(text)) = event else {
|
||||||
|
panic!("a disconnect with the reason of the refusal")
|
||||||
|
};
|
||||||
|
assert!(
|
||||||
|
text.starts_with(
|
||||||
|
"the TeamSpeak identity cannot be read: not an identity at line 1, column "
|
||||||
|
),
|
||||||
|
"{text}"
|
||||||
|
);
|
||||||
|
crate::ts::identity::assert_holds_no_piece_of(&text, &cut);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- the TeamSpeak side alone ---------------------------------------------------
|
// ---- the TeamSpeak side alone ---------------------------------------------------
|
||||||
|
|
||||||
/// A `LinkSession` over a recorder, made the way a connector makes it.
|
/// A `LinkSession` over a recorder, made the way a connector makes it.
|
||||||
@@ -1930,20 +1962,38 @@ async fn a_scope_bigger_than_the_channel_is_sent_in_bigger_chunks() {
|
|||||||
const CHANNELS: u64 = 5_000;
|
const CHANNELS: u64 = 5_000;
|
||||||
let (conns, mut seen) = mpsc::unbounded_channel();
|
let (conns, mut seen) = mpsc::unbounded_channel();
|
||||||
let connector = LinkConnector::new(Arc::new(Recorder(conns)), &["ts3server"]);
|
let connector = LinkConnector::new(Arc::new(Recorder(conns)), &["ts3server"]);
|
||||||
let (mut params, _media) = connect_params("ts3server://fake.test?port=9987");
|
let (mut params, mut media) = connect_params("ts3server://fake.test?port=9987");
|
||||||
params.credential = Credential::Foreign { kind: "teamspeak", blob: Default::default() };
|
params.credential = Credential::Foreign { kind: "teamspeak", blob: Default::default() };
|
||||||
params.push_capacity = 1;
|
params.push_capacity = 1;
|
||||||
let connecting = tokio::spawn(connector.connect(params));
|
let connecting = tokio::spawn(connector.connect(params));
|
||||||
let inner = within("the link to be asked", seen.recv()).await;
|
let inner = within("the link to be asked", seen.recv()).await;
|
||||||
inner.events.send(connected(everything())).unwrap();
|
// Made before the link is told it is connected: the connector waits only
|
||||||
|
// 250 ms for the first snapshot, and making 5,000 channels can take longer
|
||||||
|
// than that on a busy machine, which left the session without them.
|
||||||
let mut big = presence();
|
let mut big = presence();
|
||||||
for id in 100..100 + CHANNELS {
|
for id in 100..100 + CHANNELS {
|
||||||
let channel = ChannelInfo { id, name: format!("c{id}"), ..Default::default() };
|
let channel = ChannelInfo { id, name: format!("c{id}"), ..Default::default() };
|
||||||
big.channels.insert(id, channel);
|
big.channels.insert(id, channel);
|
||||||
}
|
}
|
||||||
|
inner.events.send(connected(everything())).unwrap();
|
||||||
inner.events.send(LinkEvent::Presence(Box::new(big))).unwrap();
|
inner.events.send(LinkEvent::Presence(Box::new(big))).unwrap();
|
||||||
let connected = within("a session", async { connecting.await.ok().and_then(Result::ok) }).await;
|
let connected = within("a session", async { connecting.await.ok().and_then(Result::ok) }).await;
|
||||||
let (session, mut pushes) = (connected.session, connected.pushes);
|
let (session, mut pushes) = (connected.session, connected.pushes);
|
||||||
|
// The scope is sent whole only if the presence is in the host's state when
|
||||||
|
// it is asked for. The link takes its events in order, and a voice packet
|
||||||
|
// of one of the presence's clients comes through only once the presence
|
||||||
|
// is in: the packet says it is.
|
||||||
|
inner
|
||||||
|
.events
|
||||||
|
.send(LinkEvent::Audio(VoicePacket {
|
||||||
|
talker: TalkerId(8),
|
||||||
|
seq: 1,
|
||||||
|
codec: VoiceCodec::Voice,
|
||||||
|
whisper: false,
|
||||||
|
payload: OPUS_20_MS.to_vec(),
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
within("the voice", media.recv()).await;
|
||||||
|
|
||||||
let server = ScopeId::Server(1);
|
let server = ScopeId::Server(1);
|
||||||
session.request(subscribe(server)).await.unwrap();
|
session.request(subscribe(server)).await.unwrap();
|
||||||
@@ -2152,12 +2202,48 @@ async fn event_of<T>(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Asks for the file list of the lobby until the answer is one `wanted` takes,
|
||||||
|
/// one question at a time: the next goes out only when the last is answered.
|
||||||
|
/// Asked every few milliseconds instead, the answers fell behind the 16
|
||||||
|
/// events the bus holds (and the host's work), and the one that counted was
|
||||||
|
/// lost in the backlog.
|
||||||
|
async fn ask_files_until(
|
||||||
|
cmd_tx: &mpsc::UnboundedSender<LinkCmd>,
|
||||||
|
bus: &mut broadcast::Receiver<Event>,
|
||||||
|
request: &mut crate::files::RequestId,
|
||||||
|
wanted: impl Fn(&Result<Vec<FileEntry>, String>) -> bool,
|
||||||
|
) {
|
||||||
|
within("the file list to be answered as wanted", async {
|
||||||
|
loop {
|
||||||
|
*request += 1;
|
||||||
|
let dir = remote(10, None, "/");
|
||||||
|
cmd_tx.send(LinkCmd::ListFiles { request: *request, dir }).ok()?;
|
||||||
|
let result = loop {
|
||||||
|
match bus.recv().await {
|
||||||
|
Ok(Event::FileList { request: answered, result, .. })
|
||||||
|
if answered == *request =>
|
||||||
|
{
|
||||||
|
break result;
|
||||||
|
}
|
||||||
|
Ok(_) | Err(broadcast::error::RecvError::Lagged(_)) => {}
|
||||||
|
Err(broadcast::error::RecvError::Closed) => return None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if wanted(&result) {
|
||||||
|
return Some(());
|
||||||
|
}
|
||||||
|
tokio::time::sleep(Duration::from_millis(20)).await;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
/// `Server.features` narrows what the host offers (protocol 1.3,
|
/// `Server.features` narrows what the host offers (protocol 1.3,
|
||||||
/// `docs/session-seam.md` 4.7), and a `HostUpdate` changes what is narrowed.
|
/// `docs/session-seam.md` 4.7), and a `HostUpdate` changes what is narrowed.
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn the_features_of_a_server_are_the_hosts_narrowed_by_the_servers_list() {
|
async fn the_features_of_a_server_are_the_hosts_narrowed_by_the_servers_list() {
|
||||||
use v1::entity::Kind;
|
use v1::entity::Kind;
|
||||||
use voelin_proto::test_util::{FakeConnector, eventually};
|
use voelin_proto::test_util::FakeConnector;
|
||||||
|
|
||||||
let connector = FakeConnector::new();
|
let connector = FakeConnector::new();
|
||||||
let host = connector.host();
|
let host = connector.host();
|
||||||
@@ -2209,55 +2295,26 @@ async fn the_features_of_a_server_are_the_hosts_narrowed_by_the_servers_list() {
|
|||||||
})
|
})
|
||||||
.count()
|
.count()
|
||||||
};
|
};
|
||||||
let ask = |request| {
|
|
||||||
let dir = remote(10, None, "/");
|
|
||||||
cmd_tx.send(LinkCmd::ListFiles { request, dir }).unwrap();
|
|
||||||
};
|
|
||||||
let refusal = "not offered by this server: files";
|
let refusal = "not offered by this server: files";
|
||||||
let refused =
|
let refused =
|
||||||
|event: &Event| matches!(event, Event::FileList { result: Err(why), .. } if why == refusal);
|
|result: &Result<Vec<FileEntry>, String>| matches!(result, Err(why) if why == refusal);
|
||||||
|
let mut request = 0;
|
||||||
|
|
||||||
// Refused here: nothing reaches the host.
|
// Refused here: nothing reaches the host.
|
||||||
ask(1);
|
ask_files_until(&cmd_tx, &mut bus, &mut request, refused).await;
|
||||||
loop {
|
|
||||||
let event = within("the refusal", async { bus.recv().await.ok() }).await;
|
|
||||||
if refused(&event) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert_eq!(file_lists(), 0);
|
assert_eq!(file_lists(), 0);
|
||||||
|
|
||||||
// The server lifts its list (an empty one keeps all the host's): files work.
|
// The server lifts its list (an empty one keeps all the host's): files work.
|
||||||
put_server(&[]);
|
put_server(&[]);
|
||||||
let mut request = 1;
|
ask_files_until(&cmd_tx, &mut bus, &mut request, |result| !refused(result)).await;
|
||||||
eventually(WAIT, "a file list to reach the host", || {
|
assert!(file_lists() > 0, "the answer did not come from the host");
|
||||||
request += 1;
|
|
||||||
ask(request);
|
|
||||||
file_lists() > 0
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// The host narrows what it offers this user. A refusal counts only for a
|
// The host narrows what it offers this user. Every question is answered
|
||||||
// request made after the update: the earlier ones were answered by the host's
|
// before the next is asked, so those asked from here on are the ones the
|
||||||
// wider set (or, before the server lifted its list, refused for that).
|
// update can refuse; the earlier ones were answered by the host's wider set.
|
||||||
let update = v1::HostUpdate { features: vec!["voice".into(), "chat".into()], limits: None };
|
let update = v1::HostUpdate { features: vec!["voice".into(), "chat".into()], limits: None };
|
||||||
handle.push(v1::Push { body: Some(v1::push::Body::HostUpdate(update)) }).unwrap();
|
handle.push(v1::Push { body: Some(v1::push::Body::HostUpdate(update)) }).unwrap();
|
||||||
let after = request;
|
ask_files_until(&cmd_tx, &mut bus, &mut request, refused).await;
|
||||||
within("the narrower set to apply", async {
|
|
||||||
loop {
|
|
||||||
request += 1;
|
|
||||||
ask(request);
|
|
||||||
tokio::time::sleep(Duration::from_millis(20)).await;
|
|
||||||
while let Ok(event) = bus.try_recv() {
|
|
||||||
if matches!(&event, Event::FileList { request, .. } if *request > after)
|
|
||||||
&& refused(&event)
|
|
||||||
{
|
|
||||||
return Some(());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A port that is no port is refused in words, not dropped: the connection
|
/// A port that is no port is refused in words, not dropped: the connection
|
||||||
|
|||||||
+111
-38
@@ -3257,9 +3257,13 @@ impl LocalPreview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The first and last column of the rectangle in the middle row of a
|
/// The first and last column of the rectangle in the middle row of a
|
||||||
/// decoded test pattern. Checks that pixels further than two columns from
|
/// decoded test pattern, after checking the row's structure: background, one
|
||||||
/// its edges (which the codec blurs) have the colour of the rectangle or
|
/// run of the rectangle, background. A pixel is whichever of the pattern's two
|
||||||
/// the background.
|
/// colours it is nearer to; it is not asked to be within some distance of one,
|
||||||
|
/// because an encoder that falls behind lowers its quality (the VP8 speed
|
||||||
|
/// control of the streamer does) and then moves a flat colour by 30 and more
|
||||||
|
/// per channel, still nowhere near the other colour. The two columns at each
|
||||||
|
/// edge, which the codec blurs, may be either.
|
||||||
#[cfg(all(test, feature = "media-desktop"))]
|
#[cfg(all(test, feature = "media-desktop"))]
|
||||||
pub(crate) fn rectangle_span(picture: &VideoFrame) -> (u32, u32) {
|
pub(crate) fn rectangle_span(picture: &VideoFrame) -> (u32, u32) {
|
||||||
use voelin_media::capture::synthetic::{BACKGROUND, RECT_COLOR};
|
use voelin_media::capture::synthetic::{BACKGROUND, RECT_COLOR};
|
||||||
@@ -3270,15 +3274,23 @@ pub(crate) fn rectangle_span(picture: &VideoFrame) -> (u32, u32) {
|
|||||||
let i = ((y * picture.width + x) * 4) as usize;
|
let i = ((y * picture.width + x) * 4) as usize;
|
||||||
[rgba[i], rgba[i + 1], rgba[i + 2]]
|
[rgba[i], rgba[i + 1], rgba[i + 2]]
|
||||||
};
|
};
|
||||||
let close = |p: [u8; 3], c: [u8; 3]| p.iter().zip(c).all(|(a, b)| a.abs_diff(b) <= 24);
|
let distance = |p: [u8; 3], c: [u8; 3]| -> u32 {
|
||||||
let inside: Vec<u32> = (0..picture.width).filter(|&x| close(pixel(x), RECT_COLOR)).collect();
|
p.iter().zip(c).map(|(a, b)| u32::from(a.abs_diff(b)).pow(2)).sum()
|
||||||
let (&a, &b) = inside.first().zip(inside.last()).expect("no rectangle in the middle row");
|
};
|
||||||
for x in 0..picture.width {
|
let rectangle = |x: u32| {
|
||||||
if x + 2 < a || x > b + 2 {
|
let p = pixel(x);
|
||||||
assert!(close(pixel(x), BACKGROUND), "pixel {x},{y} is {:?}", pixel(x));
|
distance(p, RECT_COLOR) < distance(p, BACKGROUND)
|
||||||
} else if (a + 2..=b.saturating_sub(2)).contains(&x) {
|
};
|
||||||
assert!(close(pixel(x), RECT_COLOR), "pixel {x},{y} is {:?}", pixel(x));
|
let a = (0..picture.width).find(|&x| rectangle(x)).expect("no rectangle in the middle row");
|
||||||
}
|
let b = (0..picture.width).rfind(|&x| rectangle(x)).unwrap();
|
||||||
|
// One run: everything between its ends, but the blurred edges, is the
|
||||||
|
// rectangle's. Whatever is outside is the background by the choice of a and b.
|
||||||
|
for x in a + 2..=b.saturating_sub(2) {
|
||||||
|
assert!(
|
||||||
|
rectangle(x),
|
||||||
|
"pixel {x},{y} is {:?}, in the middle of the rectangle (columns {a} to {b})",
|
||||||
|
pixel(x)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
(a, b)
|
(a, b)
|
||||||
}
|
}
|
||||||
@@ -3536,11 +3548,30 @@ mod tests {
|
|||||||
};
|
};
|
||||||
told(30).await;
|
told(30).await;
|
||||||
assert_eq!(streamer.bitrate_kbps(), 1105);
|
assert_eq!(streamer.bitrate_kbps(), 1105);
|
||||||
// Not per frame.
|
// Not per frame. The sink is told when it is attached and again by the
|
||||||
let count = lock(&sink.formats).len();
|
// encoder before its first frame (the same format twice), so the count is
|
||||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
// taken once a frame has been handed over and compared after more have;
|
||||||
assert_eq!(lock(&sink.formats).len(), count);
|
// the frames, not a pause, are what "per frame" counts.
|
||||||
assert_eq!(streamer.stats().layers[0].bitrate, auto_bitrate(640, 480, 30));
|
let frames_by = |frames: u64| {
|
||||||
|
let streamer = &streamer;
|
||||||
|
async move {
|
||||||
|
let deadline = Instant::now() + Duration::from_secs(30);
|
||||||
|
while streamer.stats().layers[0].frames < frames {
|
||||||
|
assert!(Instant::now() < deadline, "{frames} frames: {:?}", streamer.stats());
|
||||||
|
tokio::time::sleep(Duration::from_millis(20)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
frames_by(1).await;
|
||||||
|
let (count, seen) = (lock(&sink.formats).len(), streamer.stats().layers[0].frames);
|
||||||
|
frames_by(seen + 5).await;
|
||||||
|
assert_eq!(lock(&sink.formats).len(), count, "told again within five frames");
|
||||||
|
// The stats follow the sink's being told, not the other way round.
|
||||||
|
let deadline = Instant::now() + Duration::from_secs(10);
|
||||||
|
while streamer.stats().layers[0].bitrate != auto_bitrate(640, 480, 30) {
|
||||||
|
assert!(Instant::now() < deadline, "{:?}", streamer.stats().layers);
|
||||||
|
tokio::time::sleep(Duration::from_millis(20)).await;
|
||||||
|
}
|
||||||
let update = StreamerConfigUpdate { fps: Some(15), ..StreamerConfigUpdate::default() };
|
let update = StreamerConfigUpdate { fps: Some(15), ..StreamerConfigUpdate::default() };
|
||||||
streamer.reconfigure(&codecs, update).unwrap();
|
streamer.reconfigure(&codecs, update).unwrap();
|
||||||
told(15).await;
|
told(15).await;
|
||||||
@@ -3711,15 +3742,35 @@ mod tests {
|
|||||||
assert!((60..=68).contains(&(b - a + 1)), "{spans:?}");
|
assert!((60..=68).contains(&(b - a + 1)), "{spans:?}");
|
||||||
}
|
}
|
||||||
assert_ne!(spans.first(), spans.last(), "the rectangle moves");
|
assert_ne!(spans.first(), spans.last(), "the rectangle moves");
|
||||||
let stats = preview.stats();
|
let (before_first, first) = (Instant::now(), preview.stats());
|
||||||
assert!(stats.decoded >= 10 && stats.error.is_none(), "{stats:?}");
|
let after_first = Instant::now();
|
||||||
assert_eq!(stats.codec, Some(Codec::Vp8));
|
assert!(first.decoded >= 10 && first.error.is_none(), "{first:?}");
|
||||||
|
assert_eq!(first.codec, Some(Codec::Vp8));
|
||||||
assert_eq!(preview.streamer().backend(), "synthetic");
|
assert_eq!(preview.streamer().backend(), "synthetic");
|
||||||
// Rates over the second since: the pattern's rate, its bitrate.
|
// The rates are the counters over the time since the call before. How
|
||||||
|
// long that was the test does not say (a busy machine stretches a second,
|
||||||
|
// and the rate of pictures it manages is not what is tested), but it lies
|
||||||
|
// between the two spans the test timed around it.
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
let stats = preview.stats();
|
let before_second = Instant::now();
|
||||||
assert!((20..=40).contains(&stats.fps), "{stats:?}");
|
let second = preview.stats();
|
||||||
assert!((100_000..5_000_000).contains(&stats.bitrate), "{stats:?}");
|
let after_second = Instant::now();
|
||||||
|
let longest = after_second.duration_since(before_first).as_secs_f64();
|
||||||
|
let shortest = before_second.duration_since(after_first).as_secs_f64();
|
||||||
|
let frames = (second.decoded - first.decoded) as f64;
|
||||||
|
let bits = (second.bytes - first.bytes) as f64 * 8.0;
|
||||||
|
assert!(frames > 0.0, "no picture in the second: {first:?} {second:?}");
|
||||||
|
// (The pictures per second are rounded, the bits per second cut off.)
|
||||||
|
let fps = f64::from(second.fps);
|
||||||
|
assert!(
|
||||||
|
(frames / longest - 0.5..=frames / shortest + 0.5).contains(&fps),
|
||||||
|
"{frames} pictures in {shortest} to {longest} s are not {fps} a second"
|
||||||
|
);
|
||||||
|
let bitrate = second.bitrate as f64;
|
||||||
|
assert!(
|
||||||
|
(bits / longest - 1.0..=bits / shortest).contains(&bitrate),
|
||||||
|
"{bits} bits in {shortest} to {longest} s are not {bitrate} a second"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A VP8 decoder for the pipeline tests: fails (with errors, or giving
|
/// A VP8 decoder for the pipeline tests: fails (with errors, or giving
|
||||||
@@ -4143,7 +4194,8 @@ mod tests {
|
|||||||
};
|
};
|
||||||
let streamer = Streamer::start(&codecs, config).await.unwrap();
|
let streamer = Streamer::start(&codecs, config).await.unwrap();
|
||||||
let wait = |what: &str, done: &dyn Fn(&StreamerStats) -> bool| {
|
let wait = |what: &str, done: &dyn Fn(&StreamerStats) -> bool| {
|
||||||
let deadline = Instant::now() + Duration::from_secs(5);
|
// What is waited for is a state; the deadline only ends a hang.
|
||||||
|
let deadline = Instant::now() + Duration::from_secs(30);
|
||||||
loop {
|
loop {
|
||||||
let stats = streamer.stats();
|
let stats = streamer.stats();
|
||||||
if done(&stats) {
|
if done(&stats) {
|
||||||
@@ -4153,15 +4205,18 @@ mod tests {
|
|||||||
std::thread::sleep(Duration::from_millis(20));
|
std::thread::sleep(Duration::from_millis(20));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// The SineSource tone is 0.05; the second at half gain.
|
// The SineSource tone is 0.05; the second at half gain. The sources are metered
|
||||||
|
// before the mixer has made anything of them: the mix and the state of the
|
||||||
|
// sources are waited for too, not taken to be there with the meters.
|
||||||
let near = |level: f32, want: f32| (level - want).abs() < want * 0.1;
|
let near = |level: f32, want: f32| (level - want).abs() < want * 0.1;
|
||||||
let stats = wait("both tones", &|s| {
|
let stats = wait("both tones, mixed", &|s| {
|
||||||
s.audio_sources.len() == 2
|
s.audio_sources.len() == 2
|
||||||
&& near(s.audio_sources[0].level.peak, 0.05)
|
&& near(s.audio_sources[0].level.peak, 0.05)
|
||||||
&& near(s.audio_sources[1].level.peak, 0.025)
|
&& near(s.audio_sources[1].level.peak, 0.025)
|
||||||
|
&& s.audio_sources.iter().all(|s| s.state == SourceState::Playing)
|
||||||
|
&& s.audio_level.peak > 0.05
|
||||||
|
&& s.audio_limiter == 1.0
|
||||||
});
|
});
|
||||||
assert!(stats.audio_sources.iter().all(|s| s.state == SourceState::Playing));
|
|
||||||
assert!(stats.audio_level.peak > 0.05 && stats.audio_limiter == 1.0, "{stats:?}");
|
|
||||||
let first = stats.audio_sources[0].id;
|
let first = stats.audio_sources[0].id;
|
||||||
|
|
||||||
// Mute the first (kept: same id), drop the second, add the
|
// Mute the first (kept: same id), drop the second, add the
|
||||||
@@ -4177,19 +4232,31 @@ mod tests {
|
|||||||
streamer.reconfigure(&codecs, update).unwrap();
|
streamer.reconfigure(&codecs, update).unwrap();
|
||||||
assert_eq!(streamer.audio_sources().len(), 3);
|
assert_eq!(streamer.audio_sources().len(), 3);
|
||||||
let publisher = tap::publisher_id();
|
let publisher = tap::publisher_id();
|
||||||
let speak = std::thread::spawn(move || {
|
let heard = Arc::new(AtomicBool::new(false));
|
||||||
// 20 ms of a 0.2 tone every 20 ms, for a second.
|
let speak = std::thread::spawn({
|
||||||
let chunk: Vec<f32> = (0..960).map(|i| 0.2 * (i as f32 * 0.1).sin()).collect();
|
let heard = heard.clone();
|
||||||
for _ in 0..50 {
|
move || {
|
||||||
tap::microphone().publish(publisher, &chunk);
|
// 20 ms of a 0.2 tone every 20 ms, until the test has heard it: the
|
||||||
std::thread::sleep(Duration::from_millis(20));
|
// source takes what is published only from when it runs, which a
|
||||||
|
// busy machine delays by any time (the cap ends a thread whose test
|
||||||
|
// failed first).
|
||||||
|
let cap = Instant::now() + Duration::from_secs(120);
|
||||||
|
let chunk: Vec<f32> = (0..960).map(|i| 0.2 * (i as f32 * 0.1).sin()).collect();
|
||||||
|
while !heard.load(Ordering::Relaxed) && Instant::now() < cap {
|
||||||
|
tap::microphone().publish(publisher, &chunk);
|
||||||
|
std::thread::sleep(Duration::from_millis(20));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let stats = wait("microphone in, tone muted", &|s| {
|
let stats = wait("microphone in, tone muted", &|s| {
|
||||||
s.audio_sources.len() == 3
|
s.audio_sources.len() == 3
|
||||||
&& s.audio_sources[1].level.peak > 0.15
|
&& s.audio_sources[1].level.peak > 0.15
|
||||||
&& s.audio_level.peak > 0.15
|
&& s.audio_level.peak > 0.15
|
||||||
|
&& s.audio_sources[2].error.as_deref().is_some_and(|e| e.contains("no window"))
|
||||||
|
// Muted, and still metered: the tone's own level is read again.
|
||||||
|
&& near(s.audio_sources[0].level.peak, 0.05)
|
||||||
});
|
});
|
||||||
|
heard.store(true, Ordering::Relaxed);
|
||||||
speak.join().unwrap();
|
speak.join().unwrap();
|
||||||
assert_eq!(stats.audio_sources[0].id, first, "the kept tone keeps its source");
|
assert_eq!(stats.audio_sources[0].id, first, "the kept tone keeps its source");
|
||||||
assert!(stats.audio_sources[0].spec.muted);
|
assert!(stats.audio_sources[0].spec.muted);
|
||||||
@@ -4221,9 +4288,15 @@ mod tests {
|
|||||||
assert!(streamer.has_audio(), "{:?}", streamer.audio_error());
|
assert!(streamer.has_audio(), "{:?}", streamer.audio_error());
|
||||||
let mut source = EncodedSource::new(streamer);
|
let mut source = EncodedSource::new(streamer);
|
||||||
let mut frames = Vec::new();
|
let mut frames = Vec::new();
|
||||||
let deadline = Instant::now() + Duration::from_secs(5);
|
// Ten frames of audio and one of video, whichever the encoders make first:
|
||||||
while frames.iter().filter(|f: &&EncodedFrame| f.kind == MediaKind::Audio).count() < 10 {
|
// 20 ms of audio is quickly made, and a busy machine can keep the video
|
||||||
assert!(Instant::now() < deadline, "no audio");
|
// encoder from its first frame for longer than that. The deadline only ends
|
||||||
|
// a hang.
|
||||||
|
let deadline = Instant::now() + Duration::from_secs(30);
|
||||||
|
let count =
|
||||||
|
|frames: &[EncodedFrame], kind| frames.iter().filter(|f| f.kind == kind).count();
|
||||||
|
while count(&frames, MediaKind::Audio) < 10 || count(&frames, MediaKind::Video) < 1 {
|
||||||
|
assert!(Instant::now() < deadline, "no audio or no video in {} frames", frames.len());
|
||||||
tokio::time::sleep(Duration::from_millis(20)).await;
|
tokio::time::sleep(Duration::from_millis(20)).await;
|
||||||
source.poll_frames(Instant::now(), &mut frames);
|
source.poll_frames(Instant::now(), &mut frames);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1295,9 +1295,21 @@ mod tests {
|
|||||||
// Before the viewer asks: its offer is made after this.
|
// Before the viewer asks: its offer is made after this.
|
||||||
sink.layer_format(0, format(60_000_000));
|
sink.layer_format(0, format(60_000_000));
|
||||||
handles[1].send(StreamCmd::Watch { stream_id: "s-1".into() });
|
handles[1].send(StreamCmd::Watch { stream_id: "s-1".into() });
|
||||||
wait(&mut rx, |e| match e {
|
// Connected for the viewer and for the streamer, in either order: the
|
||||||
Event::WatchState { session: 2, state: WatchState::Connected, .. } => Some(()),
|
// streamer asks for a keyframe when its viewer connects, a moment after
|
||||||
_ => None,
|
// the viewer has seen the connection.
|
||||||
|
let (mut watching, mut served) = (false, false);
|
||||||
|
wait(&mut rx, |e| {
|
||||||
|
match e {
|
||||||
|
Event::WatchState { session: 2, state: WatchState::Connected, .. } => {
|
||||||
|
watching = true;
|
||||||
|
}
|
||||||
|
Event::StreamViewers { session: 1, viewers } => {
|
||||||
|
served |= viewers.iter().any(|v| v.state == ViewerState::Connected);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
(watching && served).then_some(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
// 3840x2160 at 60 fps is level 5.2 (0x34) in both profiles.
|
// 3840x2160 at 60 fps is level 5.2 (0x34) in both profiles.
|
||||||
@@ -1312,7 +1324,15 @@ mod tests {
|
|||||||
sink.take_layer_keyframes(&mut layers);
|
sink.take_layer_keyframes(&mut layers);
|
||||||
layers.contains(0)
|
layers.contains(0)
|
||||||
};
|
};
|
||||||
keyframes();
|
// What asked for a keyframe so far (going live, the viewer's connecting
|
||||||
|
// and its first picture request) is done when a moment longer than the
|
||||||
|
// merging interval of requests (250 ms) passes with none.
|
||||||
|
for _ in 0..50 {
|
||||||
|
tokio::time::sleep(Duration::from_millis(300)).await;
|
||||||
|
if !keyframes() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
sink.layer_format(0, format(9_000_000));
|
sink.layer_format(0, format(9_000_000));
|
||||||
timeout(Duration::from_secs(5), async {
|
timeout(Duration::from_secs(5), async {
|
||||||
while !keyframes() {
|
while !keyframes() {
|
||||||
@@ -1322,7 +1342,11 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.expect("the layer did not change");
|
.expect("the layer did not change");
|
||||||
sink.layer_format(0, format(9_000_000));
|
sink.layer_format(0, format(9_000_000));
|
||||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
// The stream task takes its commands in order: its answer to this one
|
||||||
|
// (an error, nobody is viewer 65535) comes after all that the format
|
||||||
|
// above set going, and nothing is left to wait out.
|
||||||
|
handles[0].send(StreamCmd::Kick { viewer: u16::MAX });
|
||||||
|
wait(&mut rx, |e| matches!(e, Event::Error { session: 1, .. }).then_some(())).await;
|
||||||
assert!(!keyframes(), "nothing changed");
|
assert!(!keyframes(), "nothing changed");
|
||||||
handles[0].send(StreamCmd::Stop);
|
handles[0].send(StreamCmd::Stop);
|
||||||
}
|
}
|
||||||
@@ -1701,7 +1725,16 @@ mod tests {
|
|||||||
let stats = pipeline.stats();
|
let stats = pipeline.stats();
|
||||||
assert_eq!(stats.codec, Some(Codec::Vp8));
|
assert_eq!(stats.codec, Some(Codec::Vp8));
|
||||||
assert!(stats.error.is_none(), "{stats:?}");
|
assert!(stats.error.is_none(), "{stats:?}");
|
||||||
let sent = streamer.stats();
|
// The encoder counts a frame once the sink has taken it, so the picture
|
||||||
|
// can be at the viewer before the count has moved.
|
||||||
|
let mut sent = streamer.stats();
|
||||||
|
for _ in 0..500 {
|
||||||
|
if sent.video_frames >= 15 && sent.audio_frames > 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||||
|
sent = streamer.stats();
|
||||||
|
}
|
||||||
assert!(sent.video_frames >= 15 && sent.audio_frames > 0, "{sent:?}");
|
assert!(sent.video_frames >= 15 && sent.audio_frames > 0, "{sent:?}");
|
||||||
|
|
||||||
handles[0].send(StreamCmd::Stop);
|
handles[0].send(StreamCmd::Stop);
|
||||||
|
|||||||
@@ -255,8 +255,21 @@ pub fn from_blob(blob: &IdentityBlob) -> Result<Identity, IdentityError> {
|
|||||||
blob.kind
|
blob.kind
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
serde_json::from_str(&blob.json).map_err(|e| {
|
from_json(&blob.json)
|
||||||
// Where the JSON is wrong, not what it says: it holds a private key.
|
}
|
||||||
|
|
||||||
|
/// The TeamSpeak identity in `json`, the text [`to_blob`] writes and the key
|
||||||
|
/// store keeps; voelin-core reads that text only through here (voelin-store
|
||||||
|
/// parses it too, for its own checks of a stored row).
|
||||||
|
///
|
||||||
|
/// What does not read is refused in words that say how it is wrong
|
||||||
|
/// (malformed, cut short, not an identity, unreadable) and where (line and
|
||||||
|
/// column), and never what it holds: the text holds a private key, and the
|
||||||
|
/// message of the JSON reader quotes a value it refuses (`tsproto` reports a
|
||||||
|
/// key that does not import as an invalid value, the key string and all), so
|
||||||
|
/// that message is never shown, not in an error, an event or a log.
|
||||||
|
pub(crate) fn from_json(json: &str) -> Result<Identity, IdentityError> {
|
||||||
|
serde_json::from_str(json).map_err(|e| {
|
||||||
let what = match e.classify() {
|
let what = match e.classify() {
|
||||||
serde_json::error::Category::Syntax => "malformed",
|
serde_json::error::Category::Syntax => "malformed",
|
||||||
serde_json::error::Category::Eof => "cut short",
|
serde_json::error::Category::Eof => "cut short",
|
||||||
@@ -271,6 +284,27 @@ pub fn from_blob(blob: &IdentityBlob) -> Result<Identity, IdentityError> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The JSON of a fresh identity whose key lost its last two characters (a key
|
||||||
|
/// that does not import), and that cut key.
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) fn json_with_a_cut_key() -> (String, String) {
|
||||||
|
let mut json = serde_json::to_value(Identity::create()).unwrap();
|
||||||
|
let key = json["key"].as_str().unwrap().to_owned();
|
||||||
|
let cut = key[..key.len() - 2].to_owned();
|
||||||
|
json["key"] = cut.clone().into();
|
||||||
|
(json.to_string(), cut)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fail if `text` holds any 8 characters in a row of `secret`.
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) fn assert_holds_no_piece_of(text: &str, secret: &str) {
|
||||||
|
assert!(secret.len() >= 8 && secret.is_ascii());
|
||||||
|
for piece in secret.as_bytes().windows(8) {
|
||||||
|
let piece = std::str::from_utf8(piece).unwrap();
|
||||||
|
assert!(!text.contains(piece), "{text:?} holds {piece:?} of the key");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The TeamSpeak 3 `.ini` export of an identity, which the official client
|
/// The TeamSpeak 3 `.ini` export of an identity, which the official client
|
||||||
/// and every other tool reads.
|
/// and every other tool reads.
|
||||||
pub fn export(nickname: &str, identity: &Identity) -> String {
|
pub fn export(nickname: &str, identity: &Identity) -> String {
|
||||||
@@ -615,18 +649,43 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The JSON reader's own message quotes a key that does not import, so the
|
||||||
|
/// refusal is worded by `from_json` and holds none of the key.
|
||||||
|
#[test]
|
||||||
|
fn a_key_that_does_not_import_is_refused_without_quoting_it() {
|
||||||
|
let (json, cut) = json_with_a_cut_key();
|
||||||
|
let raw = serde_json::from_str::<Identity>(&json).unwrap_err().to_string();
|
||||||
|
assert!(raw.contains(&cut), "the reader's own message quotes the key: {raw}");
|
||||||
|
for error in [
|
||||||
|
from_json(&json).unwrap_err().to_string(),
|
||||||
|
from_blob(&IdentityBlob::teamspeak("x", 8, json.clone())).unwrap_err().to_string(),
|
||||||
|
] {
|
||||||
|
assert!(
|
||||||
|
error.starts_with(
|
||||||
|
"the TeamSpeak identity cannot be read: not an identity at line 1, column "
|
||||||
|
),
|
||||||
|
"{error}"
|
||||||
|
);
|
||||||
|
assert_holds_no_piece_of(&error, &cut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn improve_level_keeps_the_key() {
|
fn improve_level_keeps_the_key() {
|
||||||
let identity = synthetic();
|
let identity = synthetic();
|
||||||
|
// A fresh identity stops at the first counter whose level is 8 or more,
|
||||||
|
// and about one in 32 has 13 or more already, which `improve_level`
|
||||||
|
// returns as it is: ask for more than this one has, whatever it has.
|
||||||
|
let target = identity.level() + 3;
|
||||||
let levels = std::sync::Mutex::new(Vec::new());
|
let levels = std::sync::Mutex::new(Vec::new());
|
||||||
let better = improve_level(&identity, 13, &AtomicBool::new(false), |l| {
|
let better = improve_level(&identity, target, &AtomicBool::new(false), |l| {
|
||||||
levels.lock().unwrap().push(l);
|
levels.lock().unwrap().push(l);
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(better.level() >= 13);
|
assert!(better.level() >= target);
|
||||||
assert_eq!(better.key().to_pub().get_uid(), identity.key().to_pub().get_uid());
|
assert_eq!(better.key().to_pub().get_uid(), identity.key().to_pub().get_uid());
|
||||||
assert!(better.counter() > identity.counter());
|
assert!(better.counter() > identity.counter());
|
||||||
assert!(levels.into_inner().unwrap().iter().any(|l| *l >= 13));
|
assert!(levels.into_inner().unwrap().iter().any(|l| *l >= target));
|
||||||
// Cancelled: nothing.
|
// Cancelled: nothing.
|
||||||
assert!(improve_level(&identity, 60, &AtomicBool::new(true), |_| {}).is_none());
|
assert!(improve_level(&identity, 60, &AtomicBool::new(true), |_| {}).is_none());
|
||||||
// Already there: the same identity.
|
// Already there: the same identity.
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ use voelin_proto::link::{
|
|||||||
use voelin_proto::v1::{self, response::Result as Answer};
|
use voelin_proto::v1::{self, response::Result as Answer};
|
||||||
|
|
||||||
use self::driver::{Cmd, Config, Driver, Parts, rejected};
|
use self::driver::{Cmd, Config, Driver, Parts, rejected};
|
||||||
use super::{ConnectOptions, ServerLink, TsLink, versions};
|
use super::{ConnectOptions, ServerLink, TsLink, identity, versions};
|
||||||
use crate::BackendInfo;
|
use crate::BackendInfo;
|
||||||
use crate::link::{
|
use crate::link::{
|
||||||
BoxDuplex, LinkCmd, LinkCtx, LinkEvent, LocalConnected, LocalConnector, LocalCtx, StreamPort,
|
BoxDuplex, LinkCmd, LinkCtx, LinkEvent, LocalConnected, LocalConnector, LocalCtx, StreamPort,
|
||||||
@@ -82,9 +82,14 @@ fn inner_options(params: &ConnectParams, ctx: &LocalCtx) -> Result<ConnectOption
|
|||||||
let identity = match ¶ms.credential {
|
let identity = match ¶ms.credential {
|
||||||
Credential::Foreign { kind: IDENTITY_KIND, blob } if blob.is_empty() => None,
|
Credential::Foreign { kind: IDENTITY_KIND, blob } if blob.is_empty() => None,
|
||||||
Credential::Foreign { kind: IDENTITY_KIND, blob } => {
|
Credential::Foreign { kind: IDENTITY_KIND, blob } => {
|
||||||
Some(serde_json::from_slice(blob).map_err(|e| {
|
// The refusal never quotes the JSON: it holds the private key, and the
|
||||||
SessionError::Protocol(format!("the TeamSpeak identity cannot be read: {e}"))
|
// JSON reader's own message would show a key that does not import.
|
||||||
})?)
|
let json = std::str::from_utf8(blob).map_err(|_| {
|
||||||
|
SessionError::Protocol(
|
||||||
|
"the TeamSpeak identity cannot be read: it is not text".into(),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
Some(identity::from_json(json).map_err(|e| SessionError::Protocol(e.to_string()))?)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(SessionError::Protocol(
|
return Err(SessionError::Protocol(
|
||||||
@@ -754,6 +759,33 @@ mod tests {
|
|||||||
assert!(!futures::executor::block_on(confirm));
|
assert!(!futures::executor::block_on(confirm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An identity that cannot be read ends the connect with words that say
|
||||||
|
/// where it is wrong and hold none of the key: the JSON reader's own
|
||||||
|
/// message quotes a key that does not import, and this text reaches the
|
||||||
|
/// event bus and the status line.
|
||||||
|
#[test]
|
||||||
|
fn an_identity_that_cannot_be_read_is_refused_without_the_key() {
|
||||||
|
let (json, cut) = identity::json_with_a_cut_key();
|
||||||
|
let mut sent = params(&VoiceOptions::new("ts.example.com", "nick"));
|
||||||
|
sent.credential = Credential::Foreign { kind: "teamspeak", blob: Bytes::from(json) };
|
||||||
|
let error = inner_options(&sent, &LocalCtx::standalone()).unwrap_err();
|
||||||
|
let SessionError::Protocol(text) = error else { panic!("a protocol error: {error:?}") };
|
||||||
|
assert!(
|
||||||
|
text.starts_with(
|
||||||
|
"the TeamSpeak identity cannot be read: not an identity at line 1, column "
|
||||||
|
),
|
||||||
|
"{text}"
|
||||||
|
);
|
||||||
|
identity::assert_holds_no_piece_of(&text, &cut);
|
||||||
|
|
||||||
|
// Not even text.
|
||||||
|
sent.credential =
|
||||||
|
Credential::Foreign { kind: "teamspeak", blob: Bytes::from_static(&[b'{', 0xff]) };
|
||||||
|
let error = inner_options(&sent, &LocalCtx::standalone()).unwrap_err();
|
||||||
|
let SessionError::Protocol(text) = error else { panic!("a protocol error: {error:?}") };
|
||||||
|
assert_eq!(text, "the TeamSpeak identity cannot be read: it is not text");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn the_params_carry_what_the_session_needs_and_no_account_yet() {
|
fn the_params_carry_what_the_session_needs_and_no_account_yet() {
|
||||||
let sent = params(&VoiceOptions::new("ts.example.com", "nick"));
|
let sent = params(&VoiceOptions::new("ts.example.com", "nick"));
|
||||||
|
|||||||
@@ -1650,8 +1650,10 @@ mod account_tests {
|
|||||||
events,
|
events,
|
||||||
));
|
));
|
||||||
let mut packet = [0; 2048];
|
let mut packet = [0; 2048];
|
||||||
let (_, first) =
|
let (_, first) = timeout(Duration::from_secs(5), server.recv_from(&mut packet))
|
||||||
timeout(Duration::from_secs(5), server.recv_from(&mut packet)).await.unwrap().unwrap();
|
.await
|
||||||
|
.expect("the first handshake packet within 5 s")
|
||||||
|
.unwrap();
|
||||||
// A logout/clear notification must cancel the old socket and restart.
|
// A logout/clear notification must cancel the old socket and restart.
|
||||||
account.send_replace(None);
|
account.send_replace(None);
|
||||||
let second = timeout(Duration::from_secs(5), async {
|
let second = timeout(Duration::from_secs(5), async {
|
||||||
@@ -1663,11 +1665,14 @@ mod account_tests {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.expect("a handshake packet from a new socket within 5 s of the account change");
|
||||||
assert_ne!(first, second);
|
assert_ne!(first, second);
|
||||||
// Losing the account authority fails closed immediately, not after connect timeout.
|
// Losing the account authority fails closed immediately, not after connect timeout.
|
||||||
drop(account);
|
drop(account);
|
||||||
timeout(Duration::from_secs(2), task).await.unwrap().unwrap();
|
timeout(Duration::from_secs(2), task)
|
||||||
|
.await
|
||||||
|
.expect("the connection to end within 2 s of the account source closing")
|
||||||
|
.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
matches!(received.recv().await, Some(LinkEvent::Disconnected(Some(reason))) if reason == "account source closed")
|
matches!(received.recv().await, Some(LinkEvent::Disconnected(Some(reason))) if reason == "account source closed")
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -960,11 +960,27 @@ pub(crate) mod tests {
|
|||||||
|
|
||||||
/// What `f` logs at info (and above) on this thread: each line its
|
/// What `f` logs at info (and above) on this thread: each line its
|
||||||
/// message, then its fields (` name=value`).
|
/// message, then its fields (` name=value`).
|
||||||
|
///
|
||||||
|
/// One recording subscriber is installed for the whole test process, the
|
||||||
|
/// first time this is called, and each call records into a buffer of its
|
||||||
|
/// own thread. A scoped one (`tracing::subscriber::with_default`) loses
|
||||||
|
/// lines: while it is the only subscriber alive, a callsite that another
|
||||||
|
/// test's thread meets first is registered against that thread's own
|
||||||
|
/// default, which is none, and stays disabled for every thread, so the
|
||||||
|
/// lines of the test that reads them are gone
|
||||||
|
/// (`session::banner_tests::a_failing_banner_is_logged_once_with_its_address`
|
||||||
|
/// failed with no lines at all, once in about thirty runs of the suite).
|
||||||
pub(crate) fn info_lines<T>(f: impl FnOnce() -> T) -> (T, Vec<String>) {
|
pub(crate) fn info_lines<T>(f: impl FnOnce() -> T) -> (T, Vec<String>) {
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::sync::Once;
|
||||||
use tracing::field::{Field, Visit};
|
use tracing::field::{Field, Visit};
|
||||||
use tracing::span;
|
use tracing::span;
|
||||||
|
|
||||||
struct Lines(Arc<Mutex<Vec<String>>>);
|
thread_local! {
|
||||||
|
/// The lines of the `info_lines` running on this thread, if any.
|
||||||
|
static LINES: RefCell<Option<Vec<String>>> = const { RefCell::new(None) };
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Line(String, String);
|
struct Line(String, String);
|
||||||
impl Visit for Line {
|
impl Visit for Line {
|
||||||
@@ -975,7 +991,8 @@ pub(crate) mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl tracing::Subscriber for Lines {
|
struct Recorder;
|
||||||
|
impl tracing::Subscriber for Recorder {
|
||||||
fn enabled(&self, metadata: &tracing::Metadata<'_>) -> bool {
|
fn enabled(&self, metadata: &tracing::Metadata<'_>) -> bool {
|
||||||
*metadata.level() <= tracing::Level::INFO
|
*metadata.level() <= tracing::Level::INFO
|
||||||
}
|
}
|
||||||
@@ -985,19 +1002,57 @@ pub(crate) mod tests {
|
|||||||
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
|
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
|
||||||
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
|
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
|
||||||
fn event(&self, event: &tracing::Event<'_>) {
|
fn event(&self, event: &tracing::Event<'_>) {
|
||||||
let mut line = Line::default();
|
LINES.with(|lines| {
|
||||||
event.record(&mut line);
|
if let Some(lines) = lines.borrow_mut().as_mut() {
|
||||||
self.0.lock().unwrap().push(line.0 + &line.1);
|
let mut line = Line::default();
|
||||||
|
event.record(&mut line);
|
||||||
|
lines.push(line.0 + &line.1);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
fn enter(&self, _: &span::Id) {}
|
fn enter(&self, _: &span::Id) {}
|
||||||
fn exit(&self, _: &span::Id) {}
|
fn exit(&self, _: &span::Id) {}
|
||||||
}
|
}
|
||||||
let lines = Arc::new(Mutex::new(Vec::new()));
|
/// Ends the recording of this thread, also when `f` panics.
|
||||||
let result = tracing::subscriber::with_default(Lines(lines.clone()), f);
|
struct Recording;
|
||||||
let lines = lines.lock().unwrap().clone();
|
impl Drop for Recording {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
LINES.with(|lines| lines.borrow_mut().take());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static INSTALL: Once = Once::new();
|
||||||
|
INSTALL.call_once(|| {
|
||||||
|
tracing::subscriber::set_global_default(Recorder)
|
||||||
|
.expect("no other global tracing subscriber in the tests");
|
||||||
|
// Makes every callsite decide again with the subscriber in place, also
|
||||||
|
// one that a thread was registering while it was being installed
|
||||||
|
// (creating a `Dispatch` rebuilds the cached interest of all of them).
|
||||||
|
drop(tracing::Dispatch::new(Recorder));
|
||||||
|
});
|
||||||
|
|
||||||
|
LINES.with(|lines| *lines.borrow_mut() = Some(Vec::new()));
|
||||||
|
let _recording = Recording;
|
||||||
|
let result = f();
|
||||||
|
let lines = LINES.with(|lines| lines.borrow_mut().take().unwrap_or_default());
|
||||||
(result, lines)
|
(result, lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The lines of `info_lines` do not depend on which thread met a callsite
|
||||||
|
/// first: this one is met on another thread, which records nothing, before
|
||||||
|
/// the thread that reads the lines meets it.
|
||||||
|
#[test]
|
||||||
|
fn info_lines_see_a_callsite_another_thread_met_first() {
|
||||||
|
fn log() {
|
||||||
|
tracing::info!("met");
|
||||||
|
}
|
||||||
|
let ((), lines) = info_lines(|| {
|
||||||
|
std::thread::spawn(log).join().unwrap();
|
||||||
|
log();
|
||||||
|
});
|
||||||
|
assert_eq!(lines, ["met"]);
|
||||||
|
}
|
||||||
|
|
||||||
fn temp_dir(tag: &str) -> std::path::PathBuf {
|
fn temp_dir(tag: &str) -> std::path::PathBuf {
|
||||||
let dir = std::env::temp_dir().join(format!("voelin-web-{tag}-{}", std::process::id()));
|
let dir = std::env::temp_dir().join(format!("voelin-web-{tag}-{}", std::process::id()));
|
||||||
let _ = std::fs::remove_dir_all(&dir);
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
@@ -1375,9 +1430,15 @@ pub(crate) mod tests {
|
|||||||
};
|
};
|
||||||
let mut port = [0u8; 2];
|
let mut port = [0u8; 2];
|
||||||
client.read_exact(&mut port).await.unwrap();
|
client.read_exact(&mut port).await.unwrap();
|
||||||
let target = format!("{host}:{}", u16::from_be_bytes(port));
|
let port = u16::from_be_bytes(port);
|
||||||
|
let target = format!("{host}:{port}");
|
||||||
targets.send(target.clone()).unwrap();
|
targets.send(target.clone()).unwrap();
|
||||||
let mut server = TcpStream::connect(target).await.unwrap();
|
// The proxy resolves the name it is given (SOCKS5h). `localhost` is
|
||||||
|
// 127.0.0.1 to it, whatever this machine's resolver says: some answer
|
||||||
|
// `::1` only, and the servers of the tests listen on 127.0.0.1.
|
||||||
|
let dial =
|
||||||
|
if host == "localhost" { format!("127.0.0.1:{port}") } else { target };
|
||||||
|
let mut server = TcpStream::connect(dial).await.unwrap();
|
||||||
client.write_all(&[5, 0, 0, 1, 0, 0, 0, 0, 0, 0]).await.unwrap();
|
client.write_all(&[5, 0, 0, 1, 0, 0, 0, 0, 0, 0]).await.unwrap();
|
||||||
let _ = tokio::io::copy_bidirectional(&mut client, &mut server).await;
|
let _ = tokio::io::copy_bidirectional(&mut client, &mut server).await;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//! What more than one integration test of this crate needs (a test binary
|
||||||
|
//! that uses it declares `mod common;`).
|
||||||
|
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
/// Wait until nothing has the SQLite database at `path` open any more, as when
|
||||||
|
/// the process that had it has ended: SQLite deletes the write-ahead log
|
||||||
|
/// (`<path>-wal`) when the last connection closes.
|
||||||
|
///
|
||||||
|
/// A dropped `Engine` is not that yet. Its task ends later, the history writer
|
||||||
|
/// is joined there, and closing the connection checkpoints the log under an
|
||||||
|
/// exclusive lock, with fsyncs. A connection opened meanwhile waits for the
|
||||||
|
/// lock only as long as the busy timeout (5 s) and then fails with
|
||||||
|
/// `DatabaseBusy`, which a loaded disk makes happen (with every fsync taking
|
||||||
|
/// 6 s it happens every time).
|
||||||
|
pub async fn closed(path: &Path) {
|
||||||
|
let mut wal = path.as_os_str().to_owned();
|
||||||
|
wal.push("-wal");
|
||||||
|
let wal = PathBuf::from(wal);
|
||||||
|
tokio::time::timeout(Duration::from_secs(120), async {
|
||||||
|
while wal.exists() {
|
||||||
|
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.expect("the engine's database connection closed");
|
||||||
|
}
|
||||||
@@ -24,6 +24,8 @@ use voelin_gateway_proto::{
|
|||||||
};
|
};
|
||||||
use voelin_model::{ChatMessage, ChatTarget, PresenceSnapshot};
|
use voelin_model::{ChatMessage, ChatTarget, PresenceSnapshot};
|
||||||
|
|
||||||
|
mod common;
|
||||||
|
|
||||||
const LOBBY: ChatTarget = ChatTarget::Channel(1);
|
const LOBBY: ChatTarget = ChatTarget::Channel(1);
|
||||||
const ME: &str = "me-uid";
|
const ME: &str = "me-uid";
|
||||||
|
|
||||||
@@ -529,6 +531,8 @@ async fn history_on_open_paging_and_offline_messages() {
|
|||||||
assert_eq!(texts(&stored), ["m1", "m2", "m3", "m4", "m5", "while away 1", "while away 2"]);
|
assert_eq!(texts(&stored), ["m1", "m2", "m3", "m4", "m5", "while away 1", "while away 2"]);
|
||||||
history.flush();
|
history.flush();
|
||||||
drop((engine, history));
|
drop((engine, history));
|
||||||
|
// Dropping the engine does not close the database yet (see `closed`).
|
||||||
|
common::closed(&path).await;
|
||||||
|
|
||||||
// After a restart, with the gateway down: the stored page, found by the
|
// After a restart, with the gateway down: the stored page, found by the
|
||||||
// gateway's URL, which is remembered with the server's id.
|
// gateway's URL, which is remembered with the server's id.
|
||||||
@@ -812,7 +816,16 @@ async fn not_found_proxy() -> String {
|
|||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn the_next_published_gateway_is_used_when_one_fails() {
|
async fn the_next_published_gateway_is_used_when_one_fails() {
|
||||||
let proxy = not_found_proxy().await;
|
let proxy = not_found_proxy().await;
|
||||||
let closed = std::net::TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port();
|
// A port that is taken and never listened on: connecting is refused at once,
|
||||||
|
// and no other test of this process can be given it meanwhile (one that was
|
||||||
|
// only free for a moment could be, the listeners of the others bind port 0).
|
||||||
|
let reserved = tokio::net::TcpSocket::new_v4().unwrap();
|
||||||
|
reserved.bind("127.0.0.1:0".parse().unwrap()).unwrap();
|
||||||
|
let closed = reserved.local_addr().unwrap().port();
|
||||||
|
assert!(
|
||||||
|
tokio::net::TcpStream::connect(("127.0.0.1", closed)).await.is_err(),
|
||||||
|
"something listens on port {closed}"
|
||||||
|
);
|
||||||
let gw = FakeGateway::start().await;
|
let gw = FakeGateway::start().await;
|
||||||
let path = temp_db("fallback");
|
let path = temp_db("fallback");
|
||||||
let engine = Engine::start_with(Settings::in_memory(), History::open(&path).unwrap());
|
let engine = Engine::start_with(Settings::in_memory(), History::open(&path).unwrap());
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
//! Engine against the development servers (dev/docker-compose.yml).
|
//! Engine against the development servers (dev/docker-compose.yml).
|
||||||
//! Runs only with `VOELIN_LIVE=1`; `scripts/it-smoke.sh` sets it.
|
//! Runs only with `VOELIN_LIVE=1`; `scripts/it-smoke.sh` sets it.
|
||||||
|
|
||||||
|
use std::sync::LazyLock;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use tokio::sync::RwLock;
|
||||||
use tokio::sync::broadcast::Receiver;
|
use tokio::sync::broadcast::Receiver;
|
||||||
use tokio::time::{Instant, timeout_at};
|
use tokio::time::{Instant, timeout_at};
|
||||||
use voelin_core::{
|
use voelin_core::{
|
||||||
@@ -15,6 +17,17 @@ fn live() -> bool {
|
|||||||
std::env::var("VOELIN_LIVE").is_ok_and(|v| v == "1")
|
std::env::var("VOELIN_LIVE").is_ok_and(|v| v == "1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The TeamSpeak 6 server's banners are the server's, and `ts6_banners` sets and
|
||||||
|
/// unsets them there. While it does, whatever else connects to the server is
|
||||||
|
/// told the addresses of those banners, and an engine fetches what it is told
|
||||||
|
/// (as it should): the requests of such an engine reached the HTTP server of
|
||||||
|
/// `ts6_banners`, which counts the requests of the engine under test, and the
|
||||||
|
/// test failed on `disabled policy must prevent HTTP requests` in every run
|
||||||
|
/// that had the tests of this file run side by side (as they do). The tests
|
||||||
|
/// that connect to the server hold this shared, `ts6_banners` exclusively: it
|
||||||
|
/// runs with the server to itself, and the others before or after it.
|
||||||
|
static TS6: LazyLock<RwLock<()>> = LazyLock::new(|| RwLock::new(()));
|
||||||
|
|
||||||
/// Wait for an event matching `f`, failing after 20 s.
|
/// Wait for an event matching `f`, failing after 20 s.
|
||||||
async fn wait_for(
|
async fn wait_for(
|
||||||
rx: &mut Receiver<Event>,
|
rx: &mut Receiver<Event>,
|
||||||
@@ -131,6 +144,7 @@ async fn ts6_engine() {
|
|||||||
if !live() {
|
if !live() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let _server = TS6.read().await;
|
||||||
engine_roundtrip("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022"))
|
engine_roundtrip("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022"))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -258,6 +272,7 @@ async fn ts6_channel_joins() {
|
|||||||
if !live() {
|
if !live() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let _server = TS6.read().await;
|
||||||
channel_joins("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022")).await;
|
channel_joins("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022")).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +344,7 @@ async fn ts6_banners() {
|
|||||||
if !live() {
|
if !live() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let _server = TS6.write().await;
|
||||||
let voice_addr =
|
let voice_addr =
|
||||||
std::env::var("VOELIN_BANNER_VOICE_ADDR").unwrap_or_else(|_| "127.0.0.1:9988".into());
|
std::env::var("VOELIN_BANNER_VOICE_ADDR").unwrap_or_else(|_| "127.0.0.1:9988".into());
|
||||||
let query_addr =
|
let query_addr =
|
||||||
@@ -512,6 +528,7 @@ async fn ts6_avatars() {
|
|||||||
if !live() {
|
if !live() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let _server = TS6.read().await;
|
||||||
let voice_addr =
|
let voice_addr =
|
||||||
std::env::var("VOELIN_BANNER_VOICE_ADDR").unwrap_or_else(|_| "127.0.0.1:9988".into());
|
std::env::var("VOELIN_BANNER_VOICE_ADDR").unwrap_or_else(|_| "127.0.0.1:9988".into());
|
||||||
let dir = std::env::temp_dir().join(format!("voelin-live-avatars-{}", std::process::id()));
|
let dir = std::env::temp_dir().join(format!("voelin-live-avatars-{}", std::process::id()));
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
//! dedup of a message that comes twice, history, transfers, offline messages,
|
//! dedup of a message that comes twice, history, transfers, offline messages,
|
||||||
//! the features of a host, a reconnect and the media of a session are the
|
//! the features of a host, a reconnect and the media of a session are the
|
||||||
//! engine's own behaviour; nothing here needs a TeamSpeak server or a
|
//! engine's own behaviour; nothing here needs a TeamSpeak server or a
|
||||||
//! TeamSpeak type.
|
//! TeamSpeak type, except `a_teamspeak_identity_that_cannot_be_read_is_refused_without_the_key`,
|
||||||
|
//! which runs the engine's own TeamSpeak connector up to its refusal of an
|
||||||
|
//! identity.
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -163,6 +165,12 @@ impl Harness {
|
|||||||
fn on(connector: FakeConnector) -> Self {
|
fn on(connector: FakeConnector) -> Self {
|
||||||
let mut backends = Backends::empty();
|
let mut backends = Backends::empty();
|
||||||
backends.register(Arc::new(connector.clone()));
|
backends.register(Arc::new(connector.clone()));
|
||||||
|
Self::with_backends(backends, connector)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The engine on `backends`; `connector` is the fake host the test may
|
||||||
|
/// have registered in them (a test that registers none leaves it unused).
|
||||||
|
fn with_backends(backends: Backends, connector: FakeConnector) -> Self {
|
||||||
let engine =
|
let engine =
|
||||||
Engine::start_with_backends(Settings::in_memory(), History::in_memory(), backends);
|
Engine::start_with_backends(Settings::in_memory(), History::in_memory(), backends);
|
||||||
let events = engine.subscribe();
|
let events = engine.subscribe();
|
||||||
@@ -1502,3 +1510,46 @@ async fn a_teamspeak_identity_without_json_is_refused_and_no_session_is_made() {
|
|||||||
assert!(handle.close_reason().is_none());
|
assert!(handle.close_reason().is_none());
|
||||||
assert_eq!(h.connector.connects().len(), 1);
|
assert_eq!(h.connector.connects().len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A TeamSpeak identity whose key does not import ends the connect with words
|
||||||
|
/// that say where the JSON is wrong and never show the key: the JSON reader's
|
||||||
|
/// own message quotes it, and the text is the reason of the disconnect, the
|
||||||
|
/// `Error` event and the status line the UI makes of it. This is the one test
|
||||||
|
/// of the file that runs the engine's own TeamSpeak connector
|
||||||
|
/// (`Backends::default()`): the refusal is that connector's and comes before
|
||||||
|
/// any network.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn a_teamspeak_identity_that_cannot_be_read_is_refused_without_the_key() {
|
||||||
|
let mut json = serde_json::to_value(tsclientlib::Identity::create()).unwrap();
|
||||||
|
let key = json["key"].as_str().unwrap().to_owned();
|
||||||
|
// The key lost its last two characters.
|
||||||
|
let cut = key[..key.len() - 2].to_owned();
|
||||||
|
json["key"] = cut.clone().into();
|
||||||
|
let mut options = VoiceOptions::new("ts3server://127.0.0.1:9", "tester");
|
||||||
|
options.identity = Some(IdentityBlob::teamspeak("uid=", 8, json.to_string()));
|
||||||
|
|
||||||
|
let mut h = Harness::with_backends(Backends::default(), FakeConnector::new());
|
||||||
|
h.engine.send(Command::ConnectVoice { session: SESSION, options: Box::new(options) });
|
||||||
|
let state = h.state(|s| s.voice == VoiceState::Disconnected).await;
|
||||||
|
assert_eq!((state.own_channel, state.own_client), (None, None));
|
||||||
|
let error = h.error().await;
|
||||||
|
assert!(
|
||||||
|
error.starts_with(
|
||||||
|
"voice: the TeamSpeak identity cannot be read: not an identity at line 1, column "
|
||||||
|
),
|
||||||
|
"{error}"
|
||||||
|
);
|
||||||
|
// Nothing the engine reported afterwards holds a piece of the key either.
|
||||||
|
let mut shown = vec![error];
|
||||||
|
while let Ok(Ok(event)) =
|
||||||
|
tokio::time::timeout(Duration::from_millis(300), h.events.recv()).await
|
||||||
|
{
|
||||||
|
shown.push(format!("{event:?}"));
|
||||||
|
}
|
||||||
|
for text in &shown {
|
||||||
|
for piece in cut.as_bytes().windows(8) {
|
||||||
|
let piece = std::str::from_utf8(piece).unwrap();
|
||||||
|
assert!(!text.contains(piece), "{text:?} holds {piece:?} of the key");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,10 @@ use voelin_core::settings::Settings;
|
|||||||
use voelin_core::{Command, Contact, DownloadTo, Engine, Event, History, Relation, TransferState};
|
use voelin_core::{Command, Contact, DownloadTo, Engine, Event, History, Relation, TransferState};
|
||||||
use voelin_model::FileRef;
|
use voelin_model::FileRef;
|
||||||
|
|
||||||
|
mod common;
|
||||||
|
|
||||||
|
use common::closed;
|
||||||
|
|
||||||
async fn next<T>(rx: &mut broadcast::Receiver<Event>, mut f: impl FnMut(Event) -> Option<T>) -> T {
|
async fn next<T>(rx: &mut broadcast::Receiver<Event>, mut f: impl FnMut(Event) -> Option<T>) -> T {
|
||||||
tokio::time::timeout(Duration::from_secs(10), async {
|
tokio::time::timeout(Duration::from_secs(10), async {
|
||||||
loop {
|
loop {
|
||||||
@@ -165,6 +169,7 @@ async fn contacts_are_kept_in_the_database() {
|
|||||||
engine.history().flush();
|
engine.history().flush();
|
||||||
}
|
}
|
||||||
// A new engine attaches the database later: the contacts come back.
|
// A new engine attaches the database later: the contacts come back.
|
||||||
|
closed(&path).await;
|
||||||
let engine = Engine::start();
|
let engine = Engine::start();
|
||||||
let mut rx = engine.subscribe();
|
let mut rx = engine.subscribe();
|
||||||
engine.send(Command::AttachHistory(History::open(&path).unwrap()));
|
engine.send(Command::AttachHistory(History::open(&path).unwrap()));
|
||||||
|
|||||||
@@ -1180,19 +1180,32 @@ mod tests {
|
|||||||
scenes
|
scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The first preview frame that `wanted` takes. The preview keeps the latest
|
||||||
|
/// frame only, so few older ones are waiting or on their way: the number of
|
||||||
|
/// frames looked at is the bound (the work), and the wait for each, which a
|
||||||
|
/// busy machine can stretch, only ends a hang.
|
||||||
|
fn preview_until(
|
||||||
|
preview: &Handoff<VideoFrame>,
|
||||||
|
wanted: impl Fn(&VideoFrame) -> bool,
|
||||||
|
) -> Arc<VideoFrame> {
|
||||||
|
for _ in 0..20 {
|
||||||
|
let frame = preview.wait_timeout(Duration::from_secs(30)).expect("a preview frame");
|
||||||
|
if wanted(&frame) {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic!("the preview never showed what was asked for");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn it_composes_into_the_preview_and_follows_commands() {
|
async fn it_composes_into_the_preview_and_follows_commands() {
|
||||||
let studio = Studio::start(one_colour_scene()).await.unwrap();
|
let studio = Studio::start(one_colour_scene()).await.unwrap();
|
||||||
let preview = studio.preview();
|
let preview = studio.preview();
|
||||||
studio.apply(Command::SetPreview { width: 32, height: 24, fps: 60 }).await.unwrap();
|
studio.apply(Command::SetPreview { width: 32, height: 24, fps: 60 }).await.unwrap();
|
||||||
let started = Instant::now();
|
// The studio composes from the moment it starts, at the size and rate the
|
||||||
let frame = loop {
|
// preview has then (480x270, 15 fps): a frame of that size can be the
|
||||||
if let Some(frame) = preview.wait_timeout(Duration::from_millis(200)) {
|
// first one there is.
|
||||||
break frame;
|
let frame = preview_until(&preview, |f| (f.width, f.height) == (32, 24));
|
||||||
}
|
|
||||||
assert!(started.elapsed() < Duration::from_secs(5), "no preview frame");
|
|
||||||
};
|
|
||||||
assert_eq!((frame.width, frame.height), (32, 24));
|
|
||||||
let crate::frame::FrameData::Rgba(p) = &frame.data else { panic!("not RGBA") };
|
let crate::frame::FrameData::Rgba(p) = &frame.data else { panic!("not RGBA") };
|
||||||
assert_eq!(&p.data[..4], &[9, 8, 7, 255]);
|
assert_eq!(&p.data[..4], &[9, 8, 7, 255]);
|
||||||
|
|
||||||
@@ -1211,15 +1224,12 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
studio.apply(Command::SetActiveScene { scene: break_id }).await.unwrap();
|
studio.apply(Command::SetActiveScene { scene: break_id }).await.unwrap();
|
||||||
assert_eq!(studio.status().active_scene, break_id);
|
assert_eq!(studio.status().active_scene, break_id);
|
||||||
// The new scene's source draws.
|
// The new scene's source draws, from the first frame composed after the
|
||||||
let frame = loop {
|
// command.
|
||||||
let frame = preview.wait_timeout(Duration::from_secs(2)).expect("a preview frame");
|
let frame = preview_until(
|
||||||
let crate::frame::FrameData::Rgba(p) = &frame.data else { panic!() };
|
&preview,
|
||||||
if p.data[..3] == [1, 2, 3] {
|
|f| matches!(&f.data, crate::frame::FrameData::Rgba(p) if p.data[..3] == [1, 2, 3]),
|
||||||
break frame;
|
);
|
||||||
}
|
|
||||||
assert!(started.elapsed() < Duration::from_secs(10), "the scene never switched");
|
|
||||||
};
|
|
||||||
drop(frame);
|
drop(frame);
|
||||||
|
|
||||||
studio.apply(Command::RemoveScene { scene: break_id }).await.unwrap();
|
studio.apply(Command::RemoveScene { scene: break_id }).await.unwrap();
|
||||||
@@ -1402,9 +1412,16 @@ mod tests {
|
|||||||
assert_eq!((listed[0].width, listed[0].height), (64, 48));
|
assert_eq!((listed[0].width, listed[0].height), (64, 48));
|
||||||
let frames = capture.start(&SourceId::Studio, &CaptureOptions::default()).await.unwrap();
|
let frames = capture.start(&SourceId::Studio, &CaptureOptions::default()).await.unwrap();
|
||||||
let mut frames = frames;
|
let mut frames = frames;
|
||||||
let frame = frames.recv_timeout(Duration::from_secs(5)).expect("a composed frame");
|
// (The wait only ends a hang.)
|
||||||
|
let frame = frames.recv_timeout(Duration::from_secs(30)).expect("a composed frame");
|
||||||
assert_eq!((frame.width, frame.height), (64, 48));
|
assert_eq!((frame.width, frame.height), (64, 48));
|
||||||
assert!(studio.shared.delivered.load(Ordering::Relaxed) > 0);
|
// A frame is counted once it has been handed over, so the count can still be
|
||||||
|
// behind when the frame is in the hands of the test.
|
||||||
|
let deadline = Instant::now() + Duration::from_secs(30);
|
||||||
|
while studio.shared.delivered.load(Ordering::Relaxed) == 0 {
|
||||||
|
assert!(Instant::now() < deadline, "the frame handed over was never counted");
|
||||||
|
std::thread::sleep(Duration::from_millis(5));
|
||||||
|
}
|
||||||
capture.stop();
|
capture.stop();
|
||||||
std::fs::remove_dir_all(&dir).ok();
|
std::fs::remove_dir_all(&dir).ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -350,7 +350,22 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn an_unwritable_path_fails_at_once() {
|
fn an_unwritable_path_fails_at_once() {
|
||||||
assert!(Recorder::start("/nonexistent-root-dir/x/clip.webm", 0, 2).is_err());
|
let dir = dir("unwritable");
|
||||||
assert!(Recorder::start("clip.mp4", 0, 2).is_err());
|
// A path below a regular file fails for every user, root included
|
||||||
|
// (ENOTDIR). A directory that is merely missing would be created, and
|
||||||
|
// a read-only one is written to by root.
|
||||||
|
let file = dir.join("not-a-directory");
|
||||||
|
std::fs::write(&file, b"x").unwrap();
|
||||||
|
assert!(Recorder::start(file.join("x").join("clip.webm"), 0, 2).is_err());
|
||||||
|
// The directory is there and the file cannot be created because the
|
||||||
|
// path names a directory (EISDIR, again for every user).
|
||||||
|
let named_like_a_file = dir.join("clip.webm");
|
||||||
|
std::fs::create_dir(&named_like_a_file).unwrap();
|
||||||
|
assert!(Recorder::start(&named_like_a_file, 0, 2).is_err());
|
||||||
|
// A name that asks for no known container is refused before any file
|
||||||
|
// is created.
|
||||||
|
assert!(Recorder::start(dir.join("clip.mp4"), 0, 2).is_err());
|
||||||
|
assert!(!dir.join("clip.mp4").exists());
|
||||||
|
std::fs::remove_dir_all(&dir).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
//! The desktop's proxy through a stand-in xdg-desktop-portal on the
|
//! The desktop's proxy through a stand-in xdg-desktop-portal on a session
|
||||||
//! session bus. Run it on a private bus:
|
//! bus. The test runs itself again under `dbus-run-session` on a bus of its
|
||||||
//! `dbus-run-session -- cargo test -p voelin-platform --test proxy`;
|
//! own that starts no services: on a desktop's bus the real portal is running
|
||||||
//! without a session bus it checks nothing. Its own test binary: answers
|
//! or startable, and when the stand-in leaves the bus (as the test has it do)
|
||||||
//! are kept process-wide.
|
//! the real one is started and answers instead. Without `dbus-run-session`,
|
||||||
|
//! or a bus daemon for it, the test says so and checks nothing. Its own test
|
||||||
|
//! binary: answers are kept process-wide.
|
||||||
|
|
||||||
#![cfg(all(unix, not(target_os = "macos"), feature = "portal"))]
|
#![cfg(all(unix, not(target_os = "macos"), feature = "portal"))]
|
||||||
|
|
||||||
@@ -11,6 +13,9 @@ use std::sync::atomic::{AtomicU32, Ordering};
|
|||||||
|
|
||||||
use voelin_platform::proxy::proxy_for;
|
use voelin_platform::proxy::proxy_for;
|
||||||
|
|
||||||
|
/// Set for the run on the bus of its own.
|
||||||
|
const ON_ITS_OWN_BUS: &str = "VOELIN_PROXY_TEST_ON_ITS_OWN_BUS";
|
||||||
|
|
||||||
/// What the GNOME portal answers: a SOCKS proxy for one host, none for the
|
/// What the GNOME portal answers: a SOCKS proxy for one host, none for the
|
||||||
/// others.
|
/// others.
|
||||||
struct Resolver {
|
struct Resolver {
|
||||||
@@ -34,10 +39,72 @@ impl Resolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The configuration of the bus of its own: a session bus without the service
|
||||||
|
/// directories, so that nothing on it can be started by name. Its socket is
|
||||||
|
/// made in `dir`.
|
||||||
|
fn bus_config(dir: &std::path::Path) -> String {
|
||||||
|
format!(
|
||||||
|
r#"<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||||
|
<busconfig>
|
||||||
|
<type>session</type>
|
||||||
|
<listen>unix:tmpdir={}</listen>
|
||||||
|
<auth>EXTERNAL</auth>
|
||||||
|
<policy context="default">
|
||||||
|
<allow send_destination="*" eavesdrop="true"/>
|
||||||
|
<allow eavesdrop="true"/>
|
||||||
|
<allow own="*"/>
|
||||||
|
</policy>
|
||||||
|
</busconfig>
|
||||||
|
"#,
|
||||||
|
dir.display()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Run this test again under `dbus-run-session` on a bus of its own, and say
|
||||||
|
/// nothing was checked when that bus cannot be had.
|
||||||
|
fn on_a_bus_of_its_own() {
|
||||||
|
let dir = std::env::temp_dir();
|
||||||
|
let config = dir.join(format!("voelin-proxy-test-bus-{}.conf", std::process::id()));
|
||||||
|
std::fs::write(&config, bus_config(&dir)).unwrap();
|
||||||
|
let run = std::process::Command::new("dbus-run-session")
|
||||||
|
.arg(format!("--config-file={}", config.display()))
|
||||||
|
.arg("--")
|
||||||
|
.arg(std::env::current_exe().unwrap())
|
||||||
|
.args(["--exact", "the_portal_names_the_proxy", "--nocapture", "--test-threads=1"])
|
||||||
|
.env(ON_ITS_OWN_BUS, "1")
|
||||||
|
.output();
|
||||||
|
let _ = std::fs::remove_file(&config);
|
||||||
|
let run = match run {
|
||||||
|
Ok(run) => run,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("skipped, nothing was checked: dbus-run-session cannot be run ({e})");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let text =
|
||||||
|
format!("{}{}", String::from_utf8_lossy(&run.stdout), String::from_utf8_lossy(&run.stderr));
|
||||||
|
if run.status.success() {
|
||||||
|
// A child that ran no test (its filter matched nothing) exits 0 as well.
|
||||||
|
assert!(
|
||||||
|
text.contains("test result: ok. 1 passed;"),
|
||||||
|
"the run on its own bus exited 0 without reporting `1 passed`:\n{text}"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The test ran and failed, or the bus never came up.
|
||||||
|
assert!(
|
||||||
|
!text.contains("running 1 test"),
|
||||||
|
"the test failed on its own bus ({}):\n{text}",
|
||||||
|
run.status
|
||||||
|
);
|
||||||
|
eprintln!("skipped, nothing was checked: no bus of its own could be started:\n{text}");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn the_portal_names_the_proxy() {
|
async fn the_portal_names_the_proxy() {
|
||||||
if std::env::var_os("DBUS_SESSION_BUS_ADDRESS").is_none() {
|
if std::env::var_os(ON_ITS_OWN_BUS).is_none() {
|
||||||
eprintln!("no session bus: run under dbus-run-session");
|
on_a_bus_of_its_own();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let lookups = Arc::new(AtomicU32::new(0));
|
let lookups = Arc::new(AtomicU32::new(0));
|
||||||
|
|||||||
@@ -7,6 +7,13 @@ all-features = false
|
|||||||
# Unmaintained crates are reported but only fail for direct dependencies.
|
# Unmaintained crates are reported but only fail for direct dependencies.
|
||||||
unmaintained = "workspace"
|
unmaintained = "workspace"
|
||||||
ignore = [
|
ignore = [
|
||||||
|
# TIME-LIMITED, remove by 2026-12-20 (entered 2026-10-25). `crypto-bigint` 0.5.5
|
||||||
|
# (through `elliptic-curve` 0.13 / `p256` 0.13 of `tsproto-types`) and 0.6.1
|
||||||
|
# (`tsproto` directly) have no fixed release on their lines; the fix is to move
|
||||||
|
# the tsclientlib fork to the `p256` 0.14 / `crypto-bigint` 0.7 line. The affected
|
||||||
|
# arithmetic serves the TeamSpeak identity (ECDH, ECDSA) in a client that holds
|
||||||
|
# only its own key, so the timing variability is a local concern.
|
||||||
|
{ id = "RUSTSEC-2026-0387", reason = "tsproto and tsproto-types pin crypto-bigint 0.5/0.6; fork upgrade to p256 0.14 is the follow-up" },
|
||||||
# Marvin attack: timing side channel in RSA *private-key* operations of the
|
# Marvin attack: timing side channel in RSA *private-key* operations of the
|
||||||
# `rsa` crate, pulled in by russh. TeamSpeak SSH query servers use RSA host
|
# `rsa` crate, pulled in by russh. TeamSpeak SSH query servers use RSA host
|
||||||
# keys, so russh needs RSA to verify the server's signature (a public-key
|
# keys, so russh needs RSA to verify the server's signature (a public-key
|
||||||
|
|||||||
+95
-6
@@ -46,17 +46,20 @@ the separate `release.yml` workflow below.
|
|||||||
this label (the left side must match the workflow's `runs-on`):
|
this label (the left side must match the workflow's `runs-on`):
|
||||||
|
|
||||||
```text
|
```text
|
||||||
ubuntu-24.04:docker://ghcr.io/catthehacker/ubuntu:act-24.04
|
ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04
|
||||||
```
|
```
|
||||||
|
|
||||||
Configure this in the runner's labels when registering/configuring it;
|
Configure this in the runner's labels when registering/configuring it;
|
||||||
an `ubuntu-latest` label alone does not match. The job image must provide
|
an `ubuntu-latest` label alone does not match. This is the image of the
|
||||||
Bash, Git, the OpenSSH client, Node.js for checkout v4, and root or
|
runner that runs this repository's CI, and the one the tests are checked
|
||||||
passwordless sudo for apt.
|
against ([Tests under the job image](#tests-under-the-job-image)). The job
|
||||||
|
image must provide Bash, Git, the OpenSSH client, Node.js for checkout v4,
|
||||||
|
and root or passwordless sudo for apt.
|
||||||
3. Allow network access from the runner and job container to the Gitea
|
3. Allow network access from the runner and job container to the Gitea
|
||||||
instance, GitHub (checkout action, dependencies and RustSec advisories),
|
instance, GitHub (checkout action, dependencies and RustSec advisories),
|
||||||
GHCR (runner image), Ubuntu apt mirrors, rustup distribution servers,
|
`docker.gitea.com` (runner image), Ubuntu apt mirrors, rustup
|
||||||
crates.io and dependency/license sources used by cargo-about. The
|
distribution servers, crates.io and dependency/license sources used by
|
||||||
|
cargo-about. The
|
||||||
workspace also depends on the **private** VoelinProtocol repository
|
workspace also depends on the **private** VoelinProtocol repository
|
||||||
(`voelin-identity`, over SSH), so the job needs read access to it and the
|
(`voelin-identity`, over SSH), so the job needs read access to it and the
|
||||||
server's SSH port. The workflows set that up themselves from a repository
|
server's SSH port. The workflows set that up themselves from a repository
|
||||||
@@ -102,6 +105,92 @@ all step results. Local YAML/shell checks do not prove that a particular
|
|||||||
Gitea instance, runner registration, network policy or resource allocation
|
Gitea instance, runner registration, network policy or resource allocation
|
||||||
can complete this job.
|
can complete this job.
|
||||||
|
|
||||||
|
### Tests under the job image
|
||||||
|
|
||||||
|
The test step runs as **root** in an Ubuntu 24.04 container of the
|
||||||
|
`ubuntu-24.04` label ([Runner setup](#runner-setup):
|
||||||
|
`docker.gitea.com/runner-images:ubuntu-24.04`, `HOME=/root`) to which only
|
||||||
|
the apt packages of the system-dependencies action are added. A test that
|
||||||
|
assumes a developer machine fails there, and a run takes about an hour, so
|
||||||
|
check a change to the tests the way CI runs them, with every failing test of
|
||||||
|
every crate listed in one go (`--no-fail-fast`):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# A bare clone of the private VoelinProtocol repository (see below the block):
|
||||||
|
# git clone --bare ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git <dir>
|
||||||
|
: "${PROTOCOL_GIT:?path of a bare clone of VoelinProtocol}"
|
||||||
|
# Root owns what the container writes: keep it in a directory of its own
|
||||||
|
# (.scratch/ is in .gitignore; see below the block for its removal).
|
||||||
|
mkdir -p .scratch
|
||||||
|
docker run --rm --init -v "$PWD":/src -w /src -e HOME=/root \
|
||||||
|
-v "$PROTOCOL_GIT":/protocol.git:ro -e CARGO_NET_GIT_FETCH_WITH_CLI=true \
|
||||||
|
-e CARGO_HOME=/src/.scratch/cargo -e RUSTUP_HOME=/src/.scratch/rustup \
|
||||||
|
-e CARGO_TARGET_DIR=/src/.scratch/target \
|
||||||
|
docker.gitea.com/runner-images:ubuntu-24.04 bash -c '
|
||||||
|
git -C / config --global url."file:///protocol.git".insteadOf \
|
||||||
|
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential ca-certificates cmake curl git jq pkg-config python3 \
|
||||||
|
libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev \
|
||||||
|
libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev xvfb xauth
|
||||||
|
curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | \
|
||||||
|
sh -s -- -y --profile minimal --default-toolchain none
|
||||||
|
. "$CARGO_HOME/env" && rustup toolchain install
|
||||||
|
xvfb-run -a bash -c "VOELIN_X11_TEST_DISPLAY=\$DISPLAY \
|
||||||
|
cargo test --workspace --locked --no-fail-fast"'
|
||||||
|
```
|
||||||
|
|
||||||
|
`--init` is required: `bash -c` runs its last command, `xvfb-run`, as the
|
||||||
|
container's process 1, and that never gets to start `cargo` (the command
|
||||||
|
hangs). The runner starts its steps with `docker exec` in a container whose
|
||||||
|
process 1 is something else, so CI itself is not affected.
|
||||||
|
|
||||||
|
The private VoelinProtocol dependency needs the deploy key
|
||||||
|
([below](#voelinprotocol-access)). The block reads it from a local bare clone
|
||||||
|
instead: `PROTOCOL_GIT` is mounted at `/protocol.git` and git is told to use
|
||||||
|
it in place of the SSH URL (with `CARGO_NET_GIT_FETCH_WITH_CLI=true`, as in CI,
|
||||||
|
so that cargo runs the `git` command), which leaves `Cargo.lock` as it is.
|
||||||
|
The `git config` is run with `-C /` because a git worktree's `.git` file points
|
||||||
|
outside the mount, and `git config` in `/src` then fails with `fatal: not a git
|
||||||
|
repository: (null)` (exit 128). To use the deploy key instead, set it up as
|
||||||
|
described below and leave out the `PROTOCOL_GIT` lines and the `git config`
|
||||||
|
command. What the container wrote under `.scratch/` belongs to root; remove it
|
||||||
|
from a container as well:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker run --rm -v "$PWD/.scratch":/s alpine:3.20 rm -rf /s/target /s/cargo /s/rustup
|
||||||
|
```
|
||||||
|
|
||||||
|
What the image lacks, and what the tests do about it. A test that is about
|
||||||
|
the missing piece returns without testing it, in most cases after printing a
|
||||||
|
line that says it skipped and names the piece (the wording differs from test
|
||||||
|
to test), or is `#[ignore]`d with the reason, and passes; any other test does
|
||||||
|
not need the piece.
|
||||||
|
|
||||||
|
| A test cannot count on | What the tests do |
|
||||||
|
|---|---|
|
||||||
|
| Regular user (root writes anywhere and creates missing directories) | Nothing relies on a permission bit or a missing directory failing. A path that cannot be written is built from something that fails for root too: below a regular file (`ENOTDIR`) or naming a directory (`EISDIR`), as `an_unwritable_path_fails_at_once` of the recorder does. |
|
||||||
|
| Sound card (`/dev/snd`), PipeWire and WirePlumber daemons | `libpipewire` and ALSA are there to build against only. `tests/pipewire_apps.rs` needs `pipewire`, `wireplumber` and `dbus-daemon` and, without them, prints a skipped line that names them. The camera tests are `#[ignore]`d (a camera and PipeWire). |
|
||||||
|
| D-Bus session bus | `voelin-platform`'s portal proxy test runs itself again under `dbus-run-session` on a bus of its own and, where that cannot be run, prints `skipped, nothing was checked: dbus-run-session cannot be run`; the notification and capture-portal tests run only where no bus is configured, and check that talking to a missing service fails cleanly. |
|
||||||
|
| GPU, `/dev/dri`, VA-API, `/dev/udmabuf` | The VA-API and DMA-BUF tests print a skipped line that names what is missing: a usable `h264_vaapi`, `/dev/udmabuf` or VA-API surfaces to export. |
|
||||||
|
| FFmpeg libraries, `ffmpeg` and `ffprobe` | The FFmpeg tests of `voelin-media` and `voelin-core` print a skipped line that names what is missing (the libraries, `ffmpeg`, `ffprobe`). The studio tests that read a recording back with `ffprobe` write and check the file themselves and skip only the `ffprobe` check; the RTMP tests need all three and skip. |
|
||||||
|
| H.264 encoder (no FFmpeg, no GPU, no OpenH264 library: `VOELIN_OPENH264_LIB` is unset and the download test is `#[ignore]`d) | Tests that need an H.264 encoder print a skipped line that says no H.264 encoder is there. Tests of codec choice state what `preferred_codec` promises with whatever the machine can encode. VP8 and VP9 (libvpx) are built in, so their round trips run. |
|
||||||
|
| X11 or Wayland display | `xvfb-run` supplies one X11 display and the step hands it over as `VOELIN_X11_TEST_DISPLAY` to the X11 capture and hotkey tests. `VOELIN_WLROOTS_TEST_DISPLAY` is unset, so the wlroots capture test prints `skipped`. |
|
||||||
|
| Playwright and Chromium (the image has Node) | The browser interop tests print `skipped: set VOELIN_INTEROP=1 (needs node, Playwright and Chromium)`. |
|
||||||
|
| TeamSpeak dev servers | Without `VOELIN_LIVE=1` the live tests return at once (some print `skipped: set VOELIN_LIVE=1 with the dev servers running`); the gateway's live test is `#[ignore]`d (`needs a running tsgw and TeamSpeak server`). |
|
||||||
|
| DNS and internet while the tests run (the job needs the network for apt, rustup and crates before they start) | The tests use no DNS or internet; those that would are `#[ignore]`d with the reason: four resolver tests of `tsclientlib` (`needs DNS and the internet`) and the OpenH264 download test. |
|
||||||
|
|
||||||
|
`localhost` resolves to `::1` first in this image (it also has `127.0.0.1`).
|
||||||
|
The tests that reach a server of their own go to `127.0.0.1` by name, not
|
||||||
|
through `localhost`, so a machine where connections to `::1` hang (a
|
||||||
|
development machine with a VPN does that) changes nothing for them.
|
||||||
|
|
||||||
|
A test that passes in the image and fails now and then on a busy runner or
|
||||||
|
development machine is another kind of failure, a test of the machine's load:
|
||||||
|
[testing/load.md](testing/load.md) says how to make a machine busy to
|
||||||
|
reproduce one, what the tests that failed that way assert now, and which are
|
||||||
|
known and left alone.
|
||||||
|
|
||||||
### VoelinProtocol access
|
### VoelinProtocol access
|
||||||
|
|
||||||
The workspace depends on `voelin-identity` from the **private** repository
|
The workspace depends on `voelin-identity` from the **private** repository
|
||||||
|
|||||||
+206
-6
@@ -3,8 +3,10 @@
|
|||||||
Status: design (2026-10-20); slices 1, 2 and 3 are implemented (section 13
|
Status: design (2026-10-20); slices 1, 2 and 3 are implemented (section 13
|
||||||
says how slice 1 differs from this text, sections 14 and 15 what its reviews
|
says how slice 1 differs from this text, sections 14 and 15 what its reviews
|
||||||
changed, section 16 what slice 2 built, found and corrected, section 17 what
|
changed, section 16 what slice 2 built, found and corrected, section 17 what
|
||||||
slice 3 moved, changed and ran, and 17.7 the round after its review, which
|
slice 3 moved, changed and ran, 17.7 the round after its review, which
|
||||||
brought the branch onto main `ad20979`); section 10 has the slices.
|
brought the branch onto main `ad20979`, and 17.8 the round after the gate of the
|
||||||
|
merge; 17.6 has the complete edge list for the second half); section 10 has
|
||||||
|
the slices.
|
||||||
|
|
||||||
Design for the first half of plan step 7 (Phase 4): the engine consumes
|
Design for the first half of plan step 7 (Phase 4): the engine consumes
|
||||||
`voelin_proto::link::Session`, `ServerLink` becomes an adapter over it, and
|
`voelin_proto::link::Session`, `ServerLink` becomes an adapter over it, and
|
||||||
@@ -929,7 +931,7 @@ Nothing here blocks this half: each has a workaround above.
|
|||||||
| H6 | Avatars and icons as attachments (`Image.attachment_id`, content-addressed cache) instead of channel-0 paths. |
|
| H6 | Avatars and icons as attachments (`Image.attachment_id`, content-addressed cache) instead of channel-0 paths. |
|
||||||
| H7 | The UI on the replica (Phase 5): the old-model projection and F1-F10 go; `u16` client ids widen to `u32` participants. |
|
| H7 | The UI on the replica (Phase 5): the old-model projection and F1-F10 go; `u16` client ids widen to `u32` participants. |
|
||||||
| H8 | Reconnect with backoff, resume tokens and persisted cursors move to `voelin-sdk` once it exists; the engine consumes the SDK. |
|
| H8 | Reconnect with backoff, resume tokens and persisted cursors move to `voelin-sdk` once it exists; the engine consumes the SDK. |
|
||||||
| H9 | Move `src/ts/` (with its live tests) to `voelin-gateway-ts` (features `basic`, `streams`), first behind a `ts` feature of `voelin-core`, then by git tag; the exit check of plan step 6, `cargo tree -p voelin-core -e normal \| grep -E 'tsclientlib\|tsproto'` empty, holds after H1-H3 and this. Two edges run from the engine into `src/ts/` and have to be cut first: `Backends::default` registers `ts::TsConnector` (the `ts` feature makes it optional), and `link/project.rs` and `link/session_link.rs` import `ts::ts_session::{entities::user_uid, ids}`, the id and uid rule that the projection undoes the synthetic ids with (it moves to the engine side, or into `voelin-model`'s replica conversion, which already has `uid_text`). |
|
| H9 | Move `src/ts/` (with its live tests) to `voelin-gateway-ts` (features `basic`, `streams`), first behind a `ts` feature of `voelin-core`, then by git tag; the exit check of plan step 6, `cargo tree -p voelin-core -e normal \| grep -E 'tsclientlib\|tsproto'` empty, holds after H1-H3, H5 and this (17.6 has the complete list of the edges between the engine and `src/ts/`, the stream split and the other crates that carry `tsclientlib`). The first two to cut run from the engine into `src/ts/`: `Backends::default` registers `ts::TsConnector` (the `ts` feature makes it optional), and `link/project.rs` and `link/session_link.rs` import `ts::ts_session::{entities::user_uid, ids}`, the id and uid rule that the projection undoes the synthetic ids with (it moves to the engine side, or into `voelin-model`'s replica conversion, which already has `uid_text`). |
|
||||||
|
|
||||||
### 11.3 Coordination
|
### 11.3 Coordination
|
||||||
|
|
||||||
@@ -1634,9 +1636,112 @@ were fresh compose projects (`down -v`, `up -d`) for each smoke run.
|
|||||||
|
|
||||||
### 17.6 Follow-ups
|
### 17.6 Follow-ups
|
||||||
|
|
||||||
- **H9 gains two edges to cut** (11.2): `Backends::default` and the use of
|
- **H9 starts from the complete edge list below.** The Opus gate of the merge
|
||||||
`ts::ts_session::{entities::user_uid, ids}` in `link/project.rs` and
|
(2026-10-24) found that 11.2 names two edges and the tree has more. Each
|
||||||
`link/session_link.rs`.
|
line was checked with `rg` and `cargo tree` on the tree of the follow-up
|
||||||
|
round (`phase4/seam-followups`); file lines are given where the file did not
|
||||||
|
change in the round, items by name where it did.
|
||||||
|
|
||||||
|
1. **From the engine into `src/ts/`**: what has to be cut or moved before
|
||||||
|
`ts` can leave the crate.
|
||||||
|
|
||||||
|
| Where | What | Goes with |
|
||||||
|
|---|---|---|
|
||||||
|
| `link/backends.rs` | `use crate::ts::TsConnector`; `Backends::default` registers `TsConnector::new()`; `Backends::register_teamspeak(TsConnector)` is the only public way to register an in-process connector and goes through the crate-private `register_local(Arc<dyn LocalConnector>)` | H9: the `ts` feature makes `default` optional |
|
||||||
|
| `link/project.rs:20-21`, `link/session_link.rs:565, 973, 1328` | `ts::ts_session::entities::user_uid` and `ts::ts_session::ids::{self, FOREIGN_SYSTEM}`: the id and uid rule the projection undoes the synthetic ids with | H9: to the engine side, or into `voelin-model`'s replica conversion (`uid_text`) |
|
||||||
|
| `gateway.rs:98, 1209` | `ts::identity::{from_blob, to_blob}`: 98 is `login_identity` (the blob to the `tsclientlib::Identity` the gateway login is made of), 1209 is a test | H5: the gateway becomes a `Session` and takes the blob as a credential |
|
||||||
|
| `lib.rs:69` | `pub mod ts`: the public paths `voelin_core::ts::{identity, versions, TsConnector}` | H9: they move or are re-exported |
|
||||||
|
| outside the crate: `tools/voelinctl/src/{engine,identity,versions,client}.rs`, `crates/voelin-ui/src/{app,servers}.rs` and `settings_pages/bind.rs`, `crates/voelin-ui-vm/src/settings_pages/logic.rs`, `crates/voelin-core/tests/gateway.rs` | users of `voelin_core::ts::identity::*` and `ts::versions::*` (`to_blob`, `Found`, `import`, `import_new`, `discover`, `read`, `write_export`, `improve_level`, `LaunchImport`, `DEFAULT_NICKNAME`, `resolve`, `native_version`, `known_versions`, `client_metadata`) | H9: re-point to the new crate (`crates/voelin-ui*` belong to `phase5/ui-vm-2`) |
|
||||||
|
| docs: `lib.rs:8` (`ts::TsConnector`), `lib.rs:129` (`Command::ObserveGateway`: `ts::identity::to_blob`), `gateway.rs:103` (`to_blob`), `settings.rs:1138` (`import_new`); in `link/mod.rs` the module doc (`TsConnector`), `VoiceOptions::identity` (`to_blob`) and `VoiceOptions::client_version` (`ts::versions::resolve`) | intra-doc links into `ts`, which `cargo doc` with `-D warnings` resolves only while `ts` is in the crate | H9: reworded, or pointed at the new crate's docs |
|
||||||
|
|
||||||
|
A TeamSpeak connector in another crate has only
|
||||||
|
`Backends::register(Arc<dyn Connector>)`: `register_teamspeak` takes the
|
||||||
|
crate's own `TsConnector`, and `LocalConnector`, `LocalCtx`,
|
||||||
|
`LocalConnected` and `StreamPort` are crate-private. A plain `Connector`
|
||||||
|
is handed neither the `LocalCtx` (the event bus, `audio`, `stream_peer`)
|
||||||
|
nor a `StreamPort` (`Backends::connect` makes its `LocalConnected` with
|
||||||
|
`streams: None`), so its sessions have no TeamSpeak 6 streams. Streams
|
||||||
|
across the crate boundary need H2 first, or a public extension trait that
|
||||||
|
takes the place of `LocalConnector`.
|
||||||
|
|
||||||
|
*Test-only* edges, which move with the tests of each side:
|
||||||
|
`link/tests.rs` and `link/fake_link_tests.rs` (lines 30-31 of both) use
|
||||||
|
`ts::ts_session::LinkConnector` and `ts::{ConnectOptions, ServerLink}`;
|
||||||
|
the tests of `link/session_link.rs` use `ts_session::{backend_to_v1,
|
||||||
|
features_of}`; `link/tests.rs` uses the helpers
|
||||||
|
`ts::identity::{json_with_a_cut_key, assert_holds_no_piece_of}` and
|
||||||
|
`tests/session_fake.rs` builds a `tsclientlib::Identity` and runs
|
||||||
|
`Backends::default()` in one test (both from this round, with the gate's
|
||||||
|
minor).
|
||||||
|
|
||||||
|
2. **From `src/ts/` into engine-private items**: the reverse edges.
|
||||||
|
|
||||||
|
| Module of the engine | Items `src/ts/` uses |
|
||||||
|
|---|---|
|
||||||
|
| `crate::link` | `LinkCmd`, `LinkEvent`, `LinkCtx` (its `session`, `events`, `frames`, `settings`, `emit`, `done`), `Remote`, `BoxRead`, `BoxDuplex` (`ts/voice.rs`, `ts/ts_link.rs`, `ts/ts_session/driver.rs`); `LocalConnector`, `LocalCtx`, `LocalConnected`, `StreamPort`, `VERSION_PARAM`, `without_query` (`ts/ts_session/mod.rs`); `StreamEvent` (`driver.rs`) |
|
||||||
|
| `crate::stream` | `StreamCmd` (`voice.rs`, `driver.rs`), `StreamHandle`, `StreamInput` (`voice.rs`) |
|
||||||
|
| `crate::files` | `FileEntry`, `RequestId`, `TransferState`, and the functions `normalize_dir` and `join_path` (`voice.rs`, `driver.rs`) |
|
||||||
|
| `crate::offline` | `OfflineMessage`, `OfflineMessageInfo` (`voice.rs`, `driver.rs`) |
|
||||||
|
| the crate root | `Event`, `JoinFailure`, `BackendInfo`, `POKE_MESSAGE_MAX` |
|
||||||
|
| `crate::settings` | `SharedSettings`, through `LinkCtx.settings`, which `voice.rs` hands to the stream task |
|
||||||
|
| tests only | `crate::link::{Backends, VoiceOptions, connect_params}` (`ts_session/mod.rs`, `live_tests.rs`), `crate::link::media::TalkTracker` and `crate::link::project::{View, presence}` (`ts/book.rs`), `crate::settings::{SharedSettings, Settings}` and `crate::files::{Report, Sink}` (`ts/voice.rs`) |
|
||||||
|
|
||||||
|
Together with the first list this is a cycle: `voelin-core` would need
|
||||||
|
`voelin-gateway-ts` for `TsConnector` and the uid rule, and
|
||||||
|
`voelin-gateway-ts` needs `voelin-core` for every item above. So the "by
|
||||||
|
git tag" step of H9 needs **H1 and H2** (the TeamSpeak side speaks v1
|
||||||
|
through `Session`, which takes the place of `LinkCmd`, `LinkEvent`,
|
||||||
|
`LinkCtx`, `StreamPort` and the stream task's input) **or a shared
|
||||||
|
vocabulary crate** that holds the items above for both sides. Without
|
||||||
|
one of the two, only the first step, the `ts` feature of `voelin-core`,
|
||||||
|
is possible.
|
||||||
|
|
||||||
|
3. **What else keeps `tsclientlib` and `tsproto` in the tree.** The exit
|
||||||
|
check (`cargo tree -p voelin-core -e normal | grep -E 'tsclientlib|tsproto'`
|
||||||
|
empty) is not met by moving `src/ts/` alone:
|
||||||
|
- `voelin-core` itself: its four direct dependencies (`tsclientlib`,
|
||||||
|
`tsproto`, `tsproto-packets`, `tsproto-types`) leave with `src/ts/`,
|
||||||
|
but `gateway.rs` uses `tsclientlib::Identity` (`login_identity`,
|
||||||
|
`connect_watched`, `attempt`: H5) and `stream.rs` uses
|
||||||
|
`tsclientlib::ClientId` (item 4).
|
||||||
|
- Three more crates of `voelin-core`'s tree carry the dependency:
|
||||||
|
`voelin-store` (`store.rs` and `keystore.rs` take, read and check a
|
||||||
|
`tsclientlib::Identity`), `voelin-stream` (`proto.rs`, `session.rs`,
|
||||||
|
`discovery.rs`: `tsclientlib::{ClientId, InMessage, messages::c2s}` and
|
||||||
|
`tsproto_packets::packets::OutCommand`; H3 splits it) and
|
||||||
|
`voelin-gateway-proto` (`auth.rs`, `client.rs`:
|
||||||
|
`tsproto_types::crypto::EccKeyPrivP256`, the key of the gateway login;
|
||||||
|
H5). `cargo tree -p <crate> -e normal` shows it for each of the three.
|
||||||
|
- `voelin-query` and `voelin-observer` have none, so `query.rs` using
|
||||||
|
`voelin_query` is not an edge of the exit check; it goes with H5
|
||||||
|
because the query observer becomes a `Session` of a gateway daemon.
|
||||||
|
- So the exit check needs H1-H3, **H5**, a way for `voelin-store` to
|
||||||
|
handle a TeamSpeak identity without `tsclientlib`'s type, and H9.
|
||||||
|
|
||||||
|
4. **`stream.rs` must be split.** Stays with the engine: `StreamState`,
|
||||||
|
`WatchState`, `StreamFrame`, `StreamSink` and `LayerFormat` (public API),
|
||||||
|
`StreamCmd`, `OwnStreamEvent`, `kind_name`, `parse_kind` and
|
||||||
|
`parse_srtp_profiles` (`session.rs`), `media_codec` (`media.rs`) and the
|
||||||
|
re-exports of `stream_types` (`StreamInfo`, `StreamKind`, `StreamSetup`,
|
||||||
|
`ViewerInfo`, ...). Goes with the TeamSpeak 6 task: `StreamHandle`,
|
||||||
|
`StreamTask` and its helpers, `StreamInput`, the `StreamLookup` over the
|
||||||
|
gateway directory, and every use of `tsclientlib::ClientId` (the engine's
|
||||||
|
own ids are `u16`; `stream.rs` wraps them for `voelin-stream`).
|
||||||
|
|
||||||
|
5. **The engine API docs that link into `ts` move with it** (the last row of
|
||||||
|
the table of item 1): `VoiceOptions::identity` and
|
||||||
|
`Command::ObserveGateway` link `ts::identity::to_blob`,
|
||||||
|
`VoiceOptions::client_version` links `ts::versions::resolve`.
|
||||||
|
|
||||||
|
- **The same leak in `voelin-store`, not closed.** `Store::identity` and
|
||||||
|
`Store::identities` read the stored JSON of a TeamSpeak identity with `?`, so
|
||||||
|
an `Error::Json` whose text is the `serde_json` message, which quotes a key
|
||||||
|
that does not import, as the gate's minor did in the connector. The rows are
|
||||||
|
written from a `tsclientlib::Identity` (`add_identity`), so a damaged
|
||||||
|
database is the only way to such a row; the key store (`keystore.rs`) drops
|
||||||
|
the parse error for the same reason. `ts::identity::from_json` cannot be
|
||||||
|
used there (`voelin-core` depends on `voelin-store`); the fix is the same
|
||||||
|
classification in `voelin-store`, or `from_json` moved down.
|
||||||
- The bookmark tests of `link/connect.rs` that still sit in
|
- The bookmark tests of `link/connect.rs` that still sit in
|
||||||
`ts/ts_session/mod.rs` (17.2) belong next to it.
|
`ts/ts_session/mod.rs` (17.2) belong next to it.
|
||||||
- `QueryLogin.allowlisted` goes with the query observer (H5), which becomes a
|
- `QueryLogin.allowlisted` goes with the query observer (H5), which becomes a
|
||||||
@@ -1720,3 +1825,98 @@ included.
|
|||||||
|
|
||||||
The last bullet of 17.6 (documents that still name the old paths) is closed by
|
The last bullet of 17.6 (documents that still name the old paths) is closed by
|
||||||
`76a884a`; the others stand.
|
`76a884a`; the others stand.
|
||||||
|
|
||||||
|
### 17.8 The round after the gate (`phase4/seam-followups`)
|
||||||
|
|
||||||
|
The Opus gate of the merge (`c60acf9`) accepted it with one minor and notes for
|
||||||
|
H9. This round, on `phase4/seam-followups` from `c60acf9`, closes the minor,
|
||||||
|
writes the notes down (17.6) and deals with the five tests that failed on
|
||||||
|
their own on `main`. No history was rewritten. The `mao-*` agents were not
|
||||||
|
registered in the session, so a general-purpose agent played
|
||||||
|
`mao-implementer`, attempt 1.
|
||||||
|
|
||||||
|
| Commit | What |
|
||||||
|
|---|---|
|
||||||
|
| `a856f90` | The gate's minor. `ts::identity::from_json` is the classification `from_blob` had (malformed, cut short, not an identity, unreadable, with line and column, never the value), taking the JSON text; `from_blob` and `ts_session::inner_options` both use it. `inner_options` had put the `serde_json` error into the text, and `tsproto`'s key reader reports a key that does not import as `invalid_value(Unexpected::Str(key), ..)`, so the key reached `LinkEvent::Disconnected(Some(text))`, `Event::Error` and the status line. A credential that is not UTF-8 is "it is not text". Four tests, each with a key that lost its last two characters and none holding 8 characters in a row of the key: `identity::tests` (which also asserts that the reader's own message does quote it), `ts_session::tests` (`inner_options`), `link::tests` (the `Disconnected` text through `SessionLink` and the real connector) and `session_fake` (`ConnectVoice` through the engine with `Backends::default()`: the `Disconnected` state, the `Error` event and every event after it). The three connector-side ones fail with the `serde_json` text put back. |
|
||||||
|
| `563482d` | `VoiceOptions::nickname` and `server_password` have their docs; `Backends::set_account` says that no connector reads `ConnectParams.account` yet and that H4 moves the myTeamSpeak proof to it. |
|
||||||
|
| `96ff0e0` | The edge list of 17.6, and the H9 row of 11.2 pointing to it. |
|
||||||
|
| `9254e08` | `identity::tests::improve_level_keeps_the_key`. |
|
||||||
|
| `0d67dd7` | `voice_features::contacts_are_kept_in_the_database`. |
|
||||||
|
| `4be37e1` | `session::banner_tests::a_failing_banner_is_logged_once_with_its_address`, through `web::tests::info_lines`. |
|
||||||
|
| `e614a1c` | `discover::tests::without_records_the_gateway_itself_is_asked`. |
|
||||||
|
| `a90bb70` | `web::tests::pictures_go_through_the_proxy_named_for_each_hop`. |
|
||||||
|
| `c35bbb5` | `voelin-platform`'s `proxy::the_portal_names_the_proxy`. |
|
||||||
|
|
||||||
|
**The five flakes: all fixed, none recorded as known.** Two of the fixes are
|
||||||
|
rewrites of a test helper and a test, not one-line edits.
|
||||||
|
|
||||||
|
- `improve_level_keeps_the_key`: a fresh `Identity::create()` stops at the first
|
||||||
|
counter of level 8 or more and about one in 32 has 13 already, which
|
||||||
|
`improve_level` returns as it is. The test asks for three levels above what
|
||||||
|
its identity has. 8 failures in 300 runs of the single test before, 0 in 300
|
||||||
|
after.
|
||||||
|
- `contacts_are_kept_in_the_database`: dropping an `Engine` does not close the
|
||||||
|
history database. The engine task ends later, the history writer is joined
|
||||||
|
there, and closing the connection checkpoints the write-ahead log under an
|
||||||
|
exclusive lock with fsyncs; the second `History::open` waits for that lock
|
||||||
|
for the 5 s busy timeout only and fails with `DatabaseBusy` when a loaded
|
||||||
|
disk makes the close slower. A connection was still open (the `-wal` file
|
||||||
|
still there) in 23 of 24 instrumented runs, and 10 of those 24 (eight at a
|
||||||
|
time on a loaded machine) failed. The test now waits for the `-wal` file to
|
||||||
|
go (SQLite deletes it when the last connection closes) before it reopens.
|
||||||
|
With every fsync of the test process delayed by 6 s (`strace -f -e
|
||||||
|
inject=fsync,fdatasync:delay_enter=6000000`) the old test fails every time at
|
||||||
|
the reopen, and the new one passes.
|
||||||
|
- `a_failing_banner_is_logged_once_with_its_address` (`lines == []`):
|
||||||
|
`web::tests::info_lines` read the log with `tracing::subscriber::with_default`.
|
||||||
|
While that scoped subscriber is the only one alive, `tracing-core` registers
|
||||||
|
a callsite that another test's thread meets first against that thread's own
|
||||||
|
default (none) and the callsite stays disabled for every thread
|
||||||
|
(`callsite::Dispatchers::rebuilder`, `has_just_one`). Several tests of
|
||||||
|
`banner_tests` reach the same callsite through `image_finished`. The helper
|
||||||
|
now installs one recording subscriber as the global default the first time
|
||||||
|
and records into a buffer per thread. A new test (`info_lines_see_a_callsite_
|
||||||
|
another_thread_met_first`) fails with the old helper (`lines == []`, the
|
||||||
|
failure that was seen) and passes with the new one. The old helper failed 1 of
|
||||||
|
300 runs of `banner_tests`, the new one 0 of 600. The failure of the whole
|
||||||
|
suite did not occur in the twenty full runs below, so the evidence for this
|
||||||
|
fix is the mechanism, the new test and these rates.
|
||||||
|
- The two `localhost` tests fail where `localhost` resolves to `::1` only (the
|
||||||
|
servers of the tests listen on 127.0.0.1). The discovery test's `probing`
|
||||||
|
helper and the test SOCKS proxy dial `localhost` at 127.0.0.1; what the tests
|
||||||
|
check (the name the gateway is asked at, the name the proxy is given) is
|
||||||
|
unchanged.
|
||||||
|
- `the_portal_names_the_proxy` did not need `dbus-run-session` only: with a
|
||||||
|
session bus, on the desktop's or on a private one made by plain
|
||||||
|
`dbus-run-session`, it failed here three times out of three at "the portal
|
||||||
|
leaves the bus", because the bus can start the real `xdg-desktop-portal` by
|
||||||
|
name, which the first call after the stand-in has left does, and the real
|
||||||
|
one answers instead of the "missing for a minute" the test expects. The test
|
||||||
|
now runs itself again under `dbus-run-session` with a bus configuration of
|
||||||
|
its own, a session bus without service directories. Without
|
||||||
|
`dbus-run-session`, or when the bus does not come up, it prints "skipped,
|
||||||
|
nothing was checked" and the reason and passes. On the bus with the default
|
||||||
|
services the same test still fails (checked by hand).
|
||||||
|
|
||||||
|
**What ran.** The environment of 17.7, taken again: `nix shell` of `gcc cmake
|
||||||
|
gnumake pkg-config jq` and the `.dev` outputs of `alsa-lib openssl libvpx dav1d
|
||||||
|
pipewire fontconfig freetype libxkbcommon expat`, with `PKG_CONFIG_PATH` (the
|
||||||
|
`.dev` outputs), `LIBCLANG_PATH`, `BINDGEN_EXTRA_CLANG_ARGS` (`-isystem` the
|
||||||
|
`glibc.dev` headers: `libspa-sys` fails without) and, to run the binaries it
|
||||||
|
builds, `LD_LIBRARY_PATH` (the `.out` outputs of those: `libvpx.so.12`) set by
|
||||||
|
hand, and the 1.94 and nightly toolchains from their store paths in front of
|
||||||
|
`PATH`. The `dev rust-nightly` shell does not build here (`cargo-llvm-cov`).
|
||||||
|
With that, `cargo check --workspace --all-targets --locked` passes on 1.94, the
|
||||||
|
`voelin-ui`, `voelin-ui-vm`, `voelinctl`, `voelin-gateway` and `voelin-android`
|
||||||
|
targets included.
|
||||||
|
|
||||||
|
| Check | Result |
|
||||||
|
|---|---|
|
||||||
|
| `cargo fmt $(scripts/own-crates.sh) --check` | 1.94: clean at the head and at each of the nine commits, checked out detached one by one. `cargo fmt --all --check` as such is not clean at `c60acf9` on any toolchain: it includes the vendored `crates/proto`, which formats with upstream's nightly configuration, and the nightly `rustfmt` also reformats own files that 1.94's leaves alone (the CI runs the form above). |
|
||||||
|
| `cargo clippy -p voelin-core -p voelin-platform --all-targets --locked --no-deps -- -D warnings` | 1.94: clean at each of the nine commits, checked out detached one by one. |
|
||||||
|
| `cargo test -p voelin-core --locked --lib`, ten times in a row, no exclusions | Nightly: ten runs, each 252 passed, 2 ignored. 1.94: the same ten times. (The baseline of 17.5 and 17.7 had two failures in each run and needed `--skip`.) |
|
||||||
|
| `cargo test -p voelin-core --locked`, once | Both toolchains: green. Integration tests: `gateway` 9, `live` 6 and `stream_live` 3 (they skip without `VOELIN_LIVE`), `session_backends` 2, `session_fake` 20 passed and 2 ignored, `settings` 1, `voice_features` 3. |
|
||||||
|
| `cargo test -p voelin-platform --locked` | Both toolchains: 24 lib tests, `crash` 3, `proxy` 1 (on its own bus), `x11` 1 (skipped without a display), 2 doc tests. |
|
||||||
|
| `RUSTDOCFLAGS=-D warnings cargo doc --no-deps -p voelin-core --locked` | 1.94 and nightly: clean. |
|
||||||
|
| `Cargo.lock`, `THIRD_PARTY_NOTICES.md` | Unchanged: `git diff c60acf9 -- Cargo.lock Cargo.toml` is empty, so there was nothing to regenerate. |
|
||||||
|
| `scripts/it-smoke.sh ts3 ts6`, on `c60acf9` (before) and at the head (after) | The stack of `VoelinGateWay/dev/docker-compose.yml` as a compose project of its own (`voelin-seam-followups`), the state directory under the scratch directory. On a fresh stack each (`down -v`, `up -d` before each): both pass every per-server scenario of ts3 and ts6 (connect and tree, server and channel chat, voice tone, invisible presence, relay, gateway, history, pins and reactions, the engine's voice features, the TeamSpeak 6 streams), the TeamSpeak session module stage (12 passed, 2 ignored; 16.38 s before, 16.73 s after) and fail in the same place, the engine stage at `ts6_banners` (`live.rs:396`, 5 passed, 1 failed), the failure 17.5 and 17.7 record. Two more runs on the first stack, which was no longer fresh (before, then after), gave the same: the outputs have 100 lines each and differ only in ids, counters, tone ratios and the number of tests filtered out of the module stage (236 before, 240 after: this round's four unit tests). The very first run, on `c60acf9` on the first stack, stopped earlier, at the first gateway request of the admin identity of ts3 (`config_set` not answered, observe stayed `Connecting`); it did not repeat on the fresh stack at `c60acf9`, nor in any later run, and was not chased. |
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
# Tests under load
|
||||||
|
|
||||||
|
A test that passes alone and fails one run in a hundred when the machine is
|
||||||
|
busy is a test of the machine. The runner shares its CPUs with other jobs, and
|
||||||
|
a developer's machine with whatever else runs on it, so the suite has to give
|
||||||
|
the same answer on a busy machine as on an idle one. This page says how to
|
||||||
|
make a machine busy, what the fixes of `phase5/test-hygiene` did about the
|
||||||
|
tests that failed only then, and what is known and left alone.
|
||||||
|
|
||||||
|
## The round of `phase5/test-hygiene`
|
||||||
|
|
||||||
|
The branch is `phase5/test-hygiene`, from `2ffe5ff` (main with the session
|
||||||
|
seam, its follow-ups, the CI deploy key and `phase5/tests-under-runner`). It
|
||||||
|
settles the left-overs of the review of the seam follow-ups and of the
|
||||||
|
tests-under-runner round. The `mao-*` agents were not registered in the
|
||||||
|
session, so a general-purpose agent played `mao-implementer` (Sonnet 5.5),
|
||||||
|
attempt 1; an earlier run of the same task was cut off by a restart of the
|
||||||
|
orchestrator, left four commits and an uncommitted tree, and this attempt
|
||||||
|
judged those, kept what was right and finished the rest. No history was
|
||||||
|
rewritten; `THIRD_PARTY_NOTICES.md` is untouched (`Cargo.lock` did not change).
|
||||||
|
|
||||||
|
| Commit | What | Whose |
|
||||||
|
|---|---|---|
|
||||||
|
| `e465a55` | Item 2: the fallback gateway test keeps its "closed" port bound | cut-off run, kept |
|
||||||
|
| `ac957a0` | Item 1: the history test of `gateway.rs` waits for the `-wal` file before it reopens (`tests/common/mod.rs`) | cut-off run, kept |
|
||||||
|
| `35408a3` | Item 5: the portal proxy test requires `1 passed` of its child | cut-off run, kept |
|
||||||
|
| `7e63092` | Item 4: `from_json`'s doc names voelin-core (voelin-store parses the text too: `keystore.rs` `check_teamspeak` and `level`, `store.rs` `list`) | cut-off run, kept |
|
||||||
|
| `0bc6aba` | Item 3: the account-change test names the step it timed out in | this attempt |
|
||||||
|
| `f9bfd5d` | Item 6: `rectangle_span` checks the pattern's structure | cut-off run's tree, committed |
|
||||||
|
| `25be433` | Item 6: the preview test checks its rates against its own timing | cut-off run's tree, committed |
|
||||||
|
| `81c40a4` | Item 6: `audio_sources_change_live` | cut-off run's tree, committed |
|
||||||
|
| `c5bb74f` | Item 6: the server-features test asks one question at a time | cut-off run's tree, committed |
|
||||||
|
| `7730460` | Item 6: the layer-format test waits for the stream task's answer | cut-off run's tree, committed |
|
||||||
|
| `9d04e01` | Item 6: the studio compose test waits for the frame it asks for | cut-off run's tree, committed |
|
||||||
|
| `92d02b0` | Beyond the list: the studio capture-backend test waits for the delivered count | cut-off run's tree, committed |
|
||||||
|
| `661a607` | Beyond the list: the scope test and `streamer_sends_opus` | cut-off run's tree, committed |
|
||||||
|
| `069fd2a` | Item 7: `ts6_banners` runs with the TeamSpeak 6 server to itself | cut-off run's tree, committed |
|
||||||
|
| `5c029a9` | Item 7: the smoke's `roundtrip` waits for its listener | cut-off run's tree, committed |
|
||||||
|
| `94195db` | rustfmt of four spots of the commits above | this attempt |
|
||||||
|
| `f508e5b` | Beyond the list: the automatic-bitrate test counts frames | this attempt |
|
||||||
|
| `ad80660` | The smoke script says which of its checks still flake | this attempt |
|
||||||
|
| `d4ccb8c`, `376925a` | `docs/testing/load.md` and the pointer in `docs/ci.md`; the record of the round, with the table of the checks | this attempt |
|
||||||
|
|
||||||
|
Two hunks of the cut-off run's tree were dropped: the timing instrumentation of
|
||||||
|
the account-change test (`Instant`s and an `eprintln!` of the steps, replaced
|
||||||
|
by the named `expect`s of `0bc6aba`; its numbers are below) and a
|
||||||
|
`#[cfg(test)] FIRST_SNAPSHOT` of 5 s in `ts_session` (it keeps the lib tests
|
||||||
|
from running the 250 ms the engine really has; see "Seen and left alone"). The
|
||||||
|
commits "beyond the list" are fixes of tests that failed in this round's own
|
||||||
|
runs, each in a commit of its own, and can be dropped without touching the
|
||||||
|
others.
|
||||||
|
|
||||||
|
What ran, on the final tree (the dev shell `dev rust-nightly -p cmake -p clang
|
||||||
|
-p pkg-config -p jq -p alsa-lib -p openssl -p libvpx -p dav1d -p pipewire -p
|
||||||
|
fontconfig -p freetype -p libxkbcommon -p expat -p dbus -p procps -p gnumake`
|
||||||
|
with the pinned 1.94 or the nightly of 2026-10-21 in front of `PATH`, and
|
||||||
|
`LIBCLANG_PATH`):
|
||||||
|
|
||||||
|
| Check | Result |
|
||||||
|
|---|---|
|
||||||
|
| `cargo fmt $(scripts/own-crates.sh) -- --check`, `cargo clippy $(scripts/own-crates.sh) --all-targets --locked --no-deps -- -D warnings` | 1.94: clean at the head |
|
||||||
|
| The same on nightly | clippy is blocked at sites of the baseline (none in a line of this branch): `chunks_exact_to_as_chunks` (voelin-core `audio.rs` and `media.rs:4057`, voelin-media), `manual_checked_ops`, `unnecessary_sort_by` (voelin-media), `result_large_err` (`ts/voice.rs:476`); with those four allowed the three touched crates are clean with all targets. voelin-platform is clean. `rustfmt` differs at `history.rs`, `ffmpeg/encoder.rs`, `discovery.rs`, `chat.rs` and `voelinctl/src/engine.rs`, none changed here |
|
||||||
|
| Clippy alone, at each of the 16 commits above that touch Rust, checked out detached | 1.94, `voelin-core`, `voelin-media`, `voelin-platform`, all targets, `media-desktop`: clean at each. `rustfmt` was not clean at seven commits from `c5bb74f` to `069fd2a` (the commits that wrote the four spots `94195db` formats, and the shell-only `5c029a9` that sits on that tree); per-commit rustfmt waived by the orchestrator, fixed forward, no history rewrite |
|
||||||
|
| `cargo test -p voelin-core -p voelin-platform -p voelin-media --locked --no-fail-fast`, ten times in a row | 516 tests passed and 13 ignored in each of ten runs, 33 test binaries each; load average 89 to 29 from other jobs |
|
||||||
|
| The same with `--features voelin-core/media-desktop` (the tests of this round's `media` fixes only exist there; `cargo test --workspace` has it on through `voelin-ui`) | 551 passed and 14 ignored in each of ten runs; load average 21 to 25 |
|
||||||
|
| `cargo check --workspace --all-targets --locked` | passes (1.94) |
|
||||||
|
| The tests of the tables below, 100 runs each of the binary of `2ffe5ff` and of the final tree, and the whole lib binaries | The tables below |
|
||||||
|
| `scripts/it-smoke.sh ts3 ts6` | Below, "The live smoke" |
|
||||||
|
|
||||||
|
## Making the machine busy
|
||||||
|
|
||||||
|
The recipe of that round: 32 busy loops beside the run (the machine had 32
|
||||||
|
threads), and the test binary started many times, a few at a time, so that
|
||||||
|
the tests of one binary also meet each other's load:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# 1. Build the test binaries once and note their paths (the "executable" of
|
||||||
|
# the lib and of each integration test); run those, not `cargo test`.
|
||||||
|
cargo test -p voelin-core --features media-desktop --lib --no-run --message-format=json
|
||||||
|
|
||||||
|
# 2. The busy loops, and 300 runs of one test, 8 at a time. (The
|
||||||
|
# whole binary, without --exact, is the better test of "under full
|
||||||
|
# load": every test of it runs at once.)
|
||||||
|
for _ in $(seq 32); do sh -c 'while :; do :; done' & done
|
||||||
|
trap 'kill $(jobs -p)' EXIT
|
||||||
|
seq 300 | xargs -P 8 -I{} sh -c '<executable> --exact <test> >/dev/null 2>&1 || echo FAIL' | sort | uniq -c
|
||||||
|
```
|
||||||
|
|
||||||
|
Compare a binary built before a change with one built after it, started
|
||||||
|
alternately in the same loop, so that both meet the same load. Write the load
|
||||||
|
average (`/proc/loadavg`) down with the result: other jobs on the shared
|
||||||
|
machine took it from the 32 loops' 32 to over 100 and, for minutes, to 250,
|
||||||
|
and some tests fail only above 150 (see below). A failure rate of one in a
|
||||||
|
hundred tests needs a few hundred runs to show; the whole binary shows its
|
||||||
|
flaky tests faster than each test alone, since its 275 tests compete.
|
||||||
|
|
||||||
|
## What the fixes assert
|
||||||
|
|
||||||
|
The rules the fixes of this round followed, in the order of preference:
|
||||||
|
|
||||||
|
1. **Wait for the state or event the test is about.** A deadline only ends a
|
||||||
|
hang (30 s), it never decides the result. A pause (`sleep`) is never what a
|
||||||
|
test waits for, and a "nothing happened" check waits for something that
|
||||||
|
comes after it (a command the same task answers in order, a count of
|
||||||
|
frames), not for time to pass.
|
||||||
|
2. **Derive a time from the work.** Where a rate is checked, the bounds come
|
||||||
|
from timestamps taken by the test around the calls, not from a constant.
|
||||||
|
3. **Check structure, not values within a tolerance**, where a lossy or
|
||||||
|
adaptive component is involved: an encoder that falls behind lowers its
|
||||||
|
quality, and a tolerance only moves the load at which the test fails.
|
||||||
|
4. **Keep what you reserved.** A port that is "free" because a listener was
|
||||||
|
bound and dropped can be handed to another test of the process at once;
|
||||||
|
a socket that stays bound and never listens refuses connections for the
|
||||||
|
whole test.
|
||||||
|
5. **A test that changes the state of a shared server runs with the server to
|
||||||
|
itself** (a lock in the test binary), however the harness schedules it.
|
||||||
|
|
||||||
|
## The load-only tests of the round
|
||||||
|
|
||||||
|
100 runs of each test alone, the binary of the commit before the round
|
||||||
|
(`2ffe5ff`) and the one after it, started alternately 8 at a time beside 32
|
||||||
|
busy loops (load average 34 to 81 during the runs), and 150 / 100 runs of the
|
||||||
|
whole lib binaries of `voelin-core` / `voelin-media`, 4 at a time beside the
|
||||||
|
same loops (load average 69 to 123). Failed runs, of the runs:
|
||||||
|
|
||||||
|
| Test | Why it failed | It checks now | Alone, before / after | Notes |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `media::tests::local_preview_decodes_the_pattern`, `stream::tests::test_pattern_through_stream_tasks` (`media::rectangle_span`) | The VP8 speed control lowers the quality when the encoder falls behind; flat colours moved by 30 and more per channel and failed the tolerance of 24 (one of 40 was tried and reverted) | Each pixel is the nearer of the pattern's two colours; the middle row is background, one run of the rectangle, background; the span's width and movement as before. The preview's `fps` and `bitrate` are the counters' change over the time between the two stats calls, which the test timed | 1 / 0 and 1 / 0 of 100 | In the whole lib binary, before: 6 and 4 failures in 150 runs; after: 0 |
|
||||||
|
| `media::tests::audio_sources_change_live` | The state, mix and limiter were asserted when the meters showed, not waited for; the microphone thread published for one second, which a busy machine delayed past | Waits for the state, the mix and the limiter with the meters; the microphone is fed until the test has heard it | 0 / 0 of 100 | In the whole lib binary, before: 2 failures in 150 runs |
|
||||||
|
| `link::tests::the_features_of_a_server_are_the_hosts_narrowed_by_the_servers_list` | The file list was asked for every 20 ms and the answers fell behind the 16 events of the bus | One question at a time, the next after the answer (`ask_files_until`) | 0 / 0 of 100 | In the whole lib binary, before: 1 failure in 150 runs |
|
||||||
|
| `stream::tests::layer_formats_reach_the_live_stream` | "Nothing changed" was a 200 ms sleep, short of the stream task on a busy machine | A command the task answers with an event, sent after the format, and waited for: the task takes its commands in order | 0 / 0 of 100 | The "late streamer-side keyframe request" of the runner round was never seen and is not proven; a request the viewer's side makes late is not covered |
|
||||||
|
| `studio::tests::it_composes_into_the_preview_and_follows_commands` | The first frame after `SetPreview` can be one composed at the studio's start size (480x270) before the command applied | `preview_until`: the first frame of the size and scene asked for, out of at most 20 | 0 / 0 of 100 | In the whole lib binary of `voelin-media`, before: 0 of 100 runs; seen 2 in 150 earlier in the round |
|
||||||
|
| `gateway.rs`: `the_next_published_gateway_is_used_when_one_fails` | The "closed" port was bound and dropped; another test of the binary could be given it | A socket kept bound without listening, checked to refuse | 0 / 0 of 100 | |
|
||||||
|
| `gateway.rs`: `history_on_open_paging_and_offline_messages` | Dropping an `Engine` does not close its database; reopening waited 5 s for the exclusive lock of the closing connection (`DatabaseBusy`) | Waits for the `-wal` file to go (`tests/common/mod.rs`, shared with `voice_features.rs`) | 0 / 0 of 100 | The same as `contacts_are_kept_in_the_database`, fixed in `0d67dd7`. Beside the busy loops it did not fail; with every fsync of the process delayed by 6 s (`strace -f -qq -e trace=fsync,fdatasync -e inject=fsync,fdatasync:delay_enter=6s`) the old test fails every time at the reopen with `DatabaseBusy` (`gateway.rs:536`), the new one passes |
|
||||||
|
| `voelin-platform` `proxy.rs`: `the_portal_names_the_proxy` | A child that ran no test (its `--exact` name matches none) exits 0 | The wrapper requires `test result: ok. 1 passed;` in the child's output | 0 / 0 of 100 | |
|
||||||
|
|
||||||
|
Found by the same runs, beyond the list, and fixed in their own commits:
|
||||||
|
|
||||||
|
| Test | Why it failed | It checks now | Alone, before / after | Notes |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `studio::tests::packets_reach_the_outputs_and_the_studio_is_a_capture_backend` | The studio counts a frame as delivered after handing it over, so the count could still be 0 | Waits for the count | 2 / 0 of 100 | Whole `voelin-media` binary, before: 11 of 150 runs (9 of them this test), then 2 of 100; after: 0 of 100 |
|
||||||
|
| `link::tests::a_scope_bigger_than_the_channel_is_sent_in_bigger_chunks` | 5,000 channels were made after the connector's 250 ms wait for a first snapshot began; the scope was sent before the presence was in | The channels are made first; a voice packet through the link shows the presence is in | 0 / 0 of 100 | 3 failures of about 500 whole-binary runs before, 7 of 300 at a load average of 150 to 250 with the first half of the fix only (the channels first, no voice packet); too rare to count a rate after |
|
||||||
|
| `media::tests::streamer_sends_opus` | Ten frames of audio came before the first frame of video, which a busy machine delays | Waits for ten of audio and one of video | 0 / 0 of 100 | 2 failures of about 500 whole-binary runs before |
|
||||||
|
| `media::tests::an_automatic_bitrate_follows_the_stream` | The sink is told the format at `attach` and again by the encoder before its first frame; the test counted in between after a 200 ms pause | Counts after a frame has come and compares after five more | 2 of 900 before; 0 of 600 after | 1 of 150 in the final whole-binary run of the old test |
|
||||||
|
|
||||||
|
The whole `voelin-core` lib binary failed 12 of 150 runs before and 1 of 150
|
||||||
|
after (the last test of the table, fixed since), the `voelin-media` binary 2
|
||||||
|
of 100 before and 0 of 100 after.
|
||||||
|
|
||||||
|
## `ts::voice::account_tests::account_change_cancels_pending_handshake`
|
||||||
|
|
||||||
|
Seen once in about 130 runs of the whole suite under load by the review of the
|
||||||
|
seam follow-ups; the failure was not kept. It did not fail again in this round
|
||||||
|
(it does not touch the test's code or the code it drives), neither alone nor
|
||||||
|
in the whole lib binary:
|
||||||
|
|
||||||
|
- 600 runs alone, 8 at a time beside 32 busy loops (300 of the unchanged
|
||||||
|
binary, 300 of the timed one): 600 passed; 100 more before and 100 after
|
||||||
|
in the table above, 200 passed.
|
||||||
|
- It is in each whole-binary run of `voelin-core`: about 1,300 runs under
|
||||||
|
the busy loops in this round (150 of them of the final tree), in none of
|
||||||
|
which it failed (load average up to 250), and in the ten full runs of
|
||||||
|
`cargo test -p voelin-core -p voelin-platform -p voelin-media` of each kind
|
||||||
|
(with and without `media-desktop`) of the final tree.
|
||||||
|
- The test, timed (a throw-away build): the first handshake packet after
|
||||||
|
12.5 ms (median; 34 ms at most), the packet of the new socket after an
|
||||||
|
account change 6.9 ms (33 ms at most), the end of the connection after the
|
||||||
|
account source closed 0.2 ms (9 ms at most), in the 300 runs beside the 32
|
||||||
|
loops. Its deadlines are 5 s, 5 s and 2 s: 60 times or more the longest
|
||||||
|
step seen.
|
||||||
|
|
||||||
|
The test and the code were read for a race and none was found: the account
|
||||||
|
watch has seen its version before the connection is made, so a change after
|
||||||
|
the first packet always restarts the connection; the restart opens a socket of
|
||||||
|
its own, so a packet from another port is the new connection's; and dropping
|
||||||
|
the sender makes `changed()` fail, which ends the loop with the reason the test
|
||||||
|
expects. The only ways the test can fail are its three deadlines. That is the
|
||||||
|
evidence for "only load": a failure needs a stall of seconds in one step, and
|
||||||
|
the machine's, not the test's, is the likelier source. The three timeouts now
|
||||||
|
say which step it was, so the next failure is attributable; if it is seen
|
||||||
|
again, keep the output and the load average (`/proc/loadavg`) and see which
|
||||||
|
of the three it names.
|
||||||
|
|
||||||
|
## Seen and left alone
|
||||||
|
|
||||||
|
These failed in the runs of an intermediate tree of this round at load
|
||||||
|
averages of 150 to 250 (other jobs on the machine as well as the 32 loops),
|
||||||
|
and not in the runs of the final tree at 35 to 120. None of them is among the
|
||||||
|
tests this round changed.
|
||||||
|
|
||||||
|
- `link::tests::the_welcome_names_the_host_the_user_and_what_the_link_can_do`:
|
||||||
|
the test tells the connection that it is connected and, in the next
|
||||||
|
statement, gives it the snapshot; the session waits 250 ms for the snapshot
|
||||||
|
(`FIRST_SNAPSHOT` in `ts_session`), and at a load average of 250 the gap was
|
||||||
|
longer: the welcome had the user made up from the uid. Raising that constant
|
||||||
|
in test builds was tried and dropped: it stops the lib tests from running the
|
||||||
|
250 ms the engine really has.
|
||||||
|
- `link::tests::what_the_link_reports_comes_back_as_events` (3 of 300 runs of
|
||||||
|
the whole lib binary), `link::tests::the_stream_tasks_reports_are_not_held_for_ever`
|
||||||
|
(2 of 300) and `stream::tests::layers_through_stream_tasks` (3 of 500): timing
|
||||||
|
of reports against the machine, not looked into further. None failed in the
|
||||||
|
500 runs of the tree before the round, which ran at load averages up to 150.
|
||||||
|
- `media::tests::undecodable_video_is_noticed_through_the_pipeline` (1 of 100
|
||||||
|
runs of the whole `voelin-core` lib binary of the final tree, four at a time
|
||||||
|
beside 32 busy loops, load average 106 to 146; the review's run):
|
||||||
|
`DecodeWatch` called a real VP8 stream undecodable because no picture was
|
||||||
|
decoded within 400 ms and 10 frames. Untouched by this round; it did not fail
|
||||||
|
in 150 before or 150 after runs of the interleaved A/B.
|
||||||
|
`stream::tests::layers_through_stream_tasks` failed again in the same 100.
|
||||||
|
|
||||||
|
## The live smoke (`scripts/it-smoke.sh`)
|
||||||
|
|
||||||
|
The engine stage (`voelin-core`'s `tests/live.rs`, with `stream_live` and
|
||||||
|
`media_live`) failed on `disabled policy must prevent HTTP requests`
|
||||||
|
(`ts6_banners`) in every run that reached it, while the six tests passed
|
||||||
|
one after the other. The cause was the test: it sets the TeamSpeak 6 server's
|
||||||
|
banners and counts the requests that reach its own HTTP server for them, and
|
||||||
|
the other tests of the file, which cargo runs side by side, connect engines to
|
||||||
|
the same server; the server tells each of them the banners' addresses and an
|
||||||
|
engine fetches what it is told, so their requests were counted. With the tests
|
||||||
|
in pairs against the development servers: `ts6_banners` alone passes (62 s),
|
||||||
|
with `ts6_avatars`, `ts6_engine` or `ts6_channel_joins` it fails. It is not
|
||||||
|
the engine (it should fetch what the server announces) and not the order of the
|
||||||
|
script's stages (the tests of one binary run side by side whatever the stage
|
||||||
|
before). The tests that connect to the TeamSpeak 6 server now hold a lock of
|
||||||
|
the binary shared, and `ts6_banners` holds it exclusively.
|
||||||
|
|
||||||
|
Before the change, on `2ffe5ff`'s tests and script (the TeamSpeak 3 and 6
|
||||||
|
dev servers of `dev/docker-compose.yml`, as a compose project of their own):
|
||||||
|
the `live` binary failed `ts6_banners` in each run that reached it, with the
|
||||||
|
six tests side by side (5 passed, 1 failed); the smoke
|
||||||
|
stopped at `FAIL: private message: the action failed` in its TeamSpeak 3 stage
|
||||||
|
(`the client is not on the server`) and, in its TeamSpeak 6 stage, at
|
||||||
|
`FAIL: gateway request {"config_set":...} was not answered`. After it, at the
|
||||||
|
head of the branch: `scripts/it-smoke.sh ts3 ts6`, three times in a row, the
|
||||||
|
`live` binary passing 6 of 6 (66 s) in each run that reached the engine stage:
|
||||||
|
two runs passed every stage (`all smoke tests passed`), one failed in its
|
||||||
|
TeamSpeak 6 stage at `FAIL: the directory did not list the stream`, below.
|
||||||
|
|
||||||
|
What the smoke still does not do reliably, and was not changed for:
|
||||||
|
|
||||||
|
- Each step that starts a background client and then a second one
|
||||||
|
(`roundtrip`) used to wait a fixed 3 s; a dev server that takes 4 s to
|
||||||
|
13 s to let a client in made the action run before the listener was on the
|
||||||
|
server (`the client is not on the server`). It now waits for the listener's
|
||||||
|
`connected:` line. The server's own slowness is not removed.
|
||||||
|
- The stream directory check (step 10, TeamSpeak 6): the late viewer ends as
|
||||||
|
soon as it has 30 frames, and the `"title"` line the script looks for is
|
||||||
|
printed only if the viewer's own gateway session had connected and been
|
||||||
|
told of the directory by then. In the run that failed it had not (the
|
||||||
|
viewer's state stayed `observe=Connecting`): the stream was watched, 30
|
||||||
|
frames came, and the stream was listed through TeamSpeak 6's own listing
|
||||||
|
(`streams: ...`), which says nothing about the gateway's directory. A fix is
|
||||||
|
in `voelinctl engine` (end the viewer when it has both) and was left out of a
|
||||||
|
round about tests.
|
||||||
|
- The gateway stage (`voelinctl gateway --engine`, step 8) has failed in a run
|
||||||
|
with `expected output did not appear` while the engine was still
|
||||||
|
`observe=Connecting`, before the change as well. That may be the same wait
|
||||||
|
for a gateway session; it was not looked into.
|
||||||
|
- `ts6_banners` alone takes 62 s, so the engine stage takes more than a
|
||||||
|
minute longer than the sum of the others.
|
||||||
+31
-2
@@ -379,6 +379,19 @@ features_check() {
|
|||||||
|
|
||||||
# TeamSpeak 6: an engine session streams; its stream registers in the
|
# TeamSpeak 6: an engine session streams; its stream registers in the
|
||||||
# gateway's directory; a viewer that connects later finds it and watches it.
|
# gateway's directory; a viewer that connects later finds it and watches it.
|
||||||
|
#
|
||||||
|
# Known to flake, not fixed: voelinctl engine ends the viewer as soon as it has
|
||||||
|
# the 30 frames (--expect-frames), and the `"title":"..."` line this checks is
|
||||||
|
# printed only when the viewer's own gateway session got connected and told
|
||||||
|
# of the directory before that. When the gateway session is still
|
||||||
|
# `observe=Connecting` at the 30th frame (seen once in three runs of the
|
||||||
|
# smoke, with the stream watched and the stream listed through TeamSpeak 6's
|
||||||
|
# own listing, `streams: ...`), the check fails with "the directory did not
|
||||||
|
# list the stream". The config_set of the gateway stage once failed ("expected
|
||||||
|
# output did not appear") with its engine still `observe=Connecting` too;
|
||||||
|
# that was not looked into. A fix for this one
|
||||||
|
# belongs in voelinctl (end the viewer on both), not here; see
|
||||||
|
# docs/testing/load.md.
|
||||||
directory_check() {
|
directory_check() {
|
||||||
local svc=$1 addr=$2 url=$3 user=$4 streamer="dir-$$-$RANDOM" title="directory-$RANDOM"
|
local svc=$1 addr=$2 url=$3 user=$4 streamer="dir-$$-$RANDOM" title="directory-$RANDOM"
|
||||||
local out="$STATE_DIR/directory-stream.log" viewer_out="$STATE_DIR/directory-watch.log"
|
local out="$STATE_DIR/directory-stream.log" viewer_out="$STATE_DIR/directory-watch.log"
|
||||||
@@ -413,12 +426,22 @@ server_uid() {
|
|||||||
"$VOELINCTL" identity show --identity "$id" | awk -v f="$field:" '$1 == f { print $2 }'
|
"$VOELINCTL" identity show --identity "$id" | awk -v f="$field:" '$1 == f { print $2 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run a background listener, then the action; both must succeed.
|
# Run a background listener, then the action; both must succeed. The action
|
||||||
|
# starts once the listener says it is on the server ("connected: N clients",
|
||||||
|
# which voelinctl engine prints for every action): a fixed pause of 3 s sent
|
||||||
|
# the poke, the private message or the avatar request to a client that was not
|
||||||
|
# on the server yet whenever the dev server was slow to let one in ("the
|
||||||
|
# client is not on the server"; a loaded dev server takes 4 to 13 s).
|
||||||
roundtrip() {
|
roundtrip() {
|
||||||
local what=$1 listen_log=$2 listener_cmd=$3 action_cmd=$4
|
local what=$1 listen_log=$2 listener_cmd=$3 action_cmd=$4
|
||||||
eval "$listener_cmd" >"$listen_log" 2>&1 &
|
eval "$listener_cmd" >"$listen_log" 2>&1 &
|
||||||
local listener=$!
|
local listener=$!
|
||||||
sleep 3
|
for _ in $(seq 1 240); do
|
||||||
|
grep -q '^connected:' "$listen_log" 2>/dev/null && break
|
||||||
|
kill -0 "$listener" 2>/dev/null || break
|
||||||
|
sleep 0.25
|
||||||
|
done
|
||||||
|
sleep 1
|
||||||
if ! eval "$action_cmd" >"$STATE_DIR/action.log" 2>&1; then
|
if ! eval "$action_cmd" >"$STATE_DIR/action.log" 2>&1; then
|
||||||
cat "$STATE_DIR/action.log" "$listen_log"
|
cat "$STATE_DIR/action.log" "$listen_log"
|
||||||
fail "$what: the action failed"
|
fail "$what: the action failed"
|
||||||
@@ -536,6 +559,12 @@ done
|
|||||||
log "TeamSpeak session (voelin-core ts_session) against both servers: link conformance subset, chat, refused moves, poke, voice, files"
|
log "TeamSpeak session (voelin-core ts_session) against both servers: link conformance subset, chat, refused moves, poke, voice, files"
|
||||||
VOELIN_LIVE=1 cargo test --quiet -p voelin-core --lib ts_session::live_tests -- --test-threads=1 2>&1 | grep -E "test result|panicked|timed out" || fail "TeamSpeak session tests failed"
|
VOELIN_LIVE=1 cargo test --quiet -p voelin-core --lib ts_session::live_tests -- --test-threads=1 2>&1 | grep -E "test result|panicked|timed out" || fail "TeamSpeak session tests failed"
|
||||||
|
|
||||||
|
# The engine tests of one binary run side by side and share the TeamSpeak 6
|
||||||
|
# server: ts6_banners sets the server's banners, which every other engine that
|
||||||
|
# connects meanwhile fetches, so crates/voelin-core/tests/live.rs lets it run
|
||||||
|
# alone (a lock the TS6 tests hold, ts6_banners exclusively). It used to fail
|
||||||
|
# on `disabled policy must prevent HTTP requests` in every run of this stage.
|
||||||
|
# Not run with --test-threads=1: that hid the problem, it did not remove it.
|
||||||
log "engine (voelin-core) against both servers, media pipeline through TS6"
|
log "engine (voelin-core) against both servers, media pipeline through TS6"
|
||||||
VOELIN_LIVE=1 cargo test --quiet -p voelin-core --features media-desktop --test live --test stream_live --test media_live 2>&1 | grep -E "test result|panicked|timed out" || fail "engine tests failed"
|
VOELIN_LIVE=1 cargo test --quiet -p voelin-core --features media-desktop --test live --test stream_live --test media_live 2>&1 | grep -E "test result|panicked|timed out" || fail "engine tests failed"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user