* claim: #5287 * web-offline-test: wait only for the files the browser can ask for at once The fail-fast step waited for every other file of build v2 to reach the server. Chrome sends at most six requests to one server at a time, and the page's failure cancels the download, with it the files still waiting for a connection. A real build keeps nine files, so only six were ever asked for and the Pages job failed with "only 6 of 8 slow files were asked for" whenever the installing worker didn't happen to ask again. Wait for as many as can be in flight (less the page's connection), and give the stand-in app more files than that, so the default run covers it.
This commit is contained in:
@@ -48,7 +48,8 @@
|
||||
//! `CHROME` or the usual install locations; `cargo xtask ci` skips this test when there is none.
|
||||
//!
|
||||
//! The stand-in app has a content-named script, a `shared.js` whose name is the same in every
|
||||
//! build (a page must get its own build's), and an on-demand file under `fonts/` (not kept).
|
||||
//! build (a page must get its own build's), more files under `icons/` than the browser asks for
|
||||
//! at once, and an on-demand file under `fonts/` (not kept).
|
||||
|
||||
use std::io::{BufRead, BufReader, Read, Write};
|
||||
use std::net::{TcpListener, TcpStream};
|
||||
@@ -73,6 +74,9 @@ const LAUNCH_TIMEOUT: Duration = Duration::from_secs(240);
|
||||
const SLOW_NETWORK_WAIT: Duration = Duration::from_secs(3);
|
||||
/// Where Mode::SignIn redirects to (on `localhost`: another origin than the 127.0.0.1 app).
|
||||
const SIGN_IN: &str = "/sign-in";
|
||||
/// How many requests Chrome sends to one server at a time over HTTP/1.1; the rest wait for a
|
||||
/// free connection.
|
||||
const CONNECTIONS_PER_SERVER: usize = 6;
|
||||
|
||||
/// Exercise the real browser build's command bridge, using the same Chrome harness as the offline test.
|
||||
pub fn run_api(site: &str) -> Result<(), String> {
|
||||
@@ -280,7 +284,11 @@ pub fn run(root: &Path, site: Option<&str>, required: bool) -> Result<(), String
|
||||
server.set(Mode::FailFast(v2.clone()));
|
||||
let t = launch(&mut cdp, "v1")?;
|
||||
// The other files of v2 are asked for (and held) around the page's failure; let them go.
|
||||
server.wait_asked_slowly(asked + kept.get(1).map_or(0, |(_, n)| n.saturating_sub(1)))?;
|
||||
// Only as many as the browser sends at once (less the page's connection) are sure to be
|
||||
// asked for: the page's failure cancels the download, and with it the files still waiting
|
||||
// for a connection (a real build has more files than that).
|
||||
let others = kept.get(1).map_or(0, |(_, n)| n.saturating_sub(1));
|
||||
server.wait_asked_slowly(asked + others.min(CONNECTIONS_PER_SERVER - 1))?;
|
||||
server.release();
|
||||
wait_for(&mut cdp, &state_js, "no download is left marked in progress", |s| s["caches"].get(&name2_).is_some() && s["filling"] == json!([]))?;
|
||||
step("one file fails at once, others are still coming: v1 starts; v2's isn't left in progress", t);
|
||||
@@ -522,6 +530,11 @@ fn stand_in(dir: &Path, build: &str, registration: &str) -> Result<(), String> {
|
||||
write("index.html", mark(&page, build)?)?;
|
||||
write(&format!("app-{build}.js"), format!("document.documentElement.dataset.started = \"{build}\";\n"))?;
|
||||
write("shared.js", format!("document.documentElement.dataset.shared = \"{build}\";\n"))?;
|
||||
// More files than the browser asks for at once, as in a real build (icons, styles, wasm).
|
||||
std::fs::create_dir_all(dir.join("icons")).map_err(|e| format!("icons: {e}"))?;
|
||||
for i in 0..CONNECTIONS_PER_SERVER {
|
||||
write(&format!("icons/{i}.txt"), format!("{build} {i}\n"))?;
|
||||
}
|
||||
std::fs::create_dir_all(dir.join("fonts")).map_err(|e| format!("fonts: {e}"))?;
|
||||
write("fonts/on-demand.txt", format!("{build}\n"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user