Test runner: log start time, seed hit/miss and install time per environment
Merges the v73 changelog section into v74. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
87eafb3108
commit
6804139be7
3 files changed
+27
-13
No files matched your search
@@ -35,12 +35,16 @@ const CACHE_LABEL: &str = "codecraft.testrunner.cache=1";
|
||||
/// What every environment container runs: link the shared directories, restore a matching seed, run
|
||||
/// `install`, store a new seed (only after a successful install, so it is pristine), start the app.
|
||||
const ENTRY_SCRIPT: &str = r#"cd /app
|
||||
hit=0
|
||||
if [ -d /cache ]; then
|
||||
for d in $CC_CACHE_DIRS; do mkdir -p "/cache/dirs/$d" "$(dirname "$d")" && rm -rf "$d" && ln -s "/cache/dirs/$d" "$d"; done
|
||||
if [ -d /usr/local/cargo ]; then for d in registry git; do mkdir -p "/cache/cargo/$d"; rm -rf "/usr/local/cargo/$d"; ln -s "/cache/cargo/$d" "/usr/local/cargo/$d"; done; fi
|
||||
if [ -n "$CC_SEED_KEY" ]; then for p in $CC_SEED_PATHS; do if [ -e "/cache/seed/$CC_SEED_KEY/$p" ]; then mkdir -p "$(dirname "$p")" && cp -a "/cache/seed/$CC_SEED_KEY/$p" "$p" && echo "[runner] restored $p from the cache"; fi; done; fi
|
||||
if [ -n "$CC_SEED_KEY" ]; then for p in $CC_SEED_PATHS; do if [ -e "/cache/seed/$CC_SEED_KEY/$p" ]; then mkdir -p "$(dirname "$p")" && cp -a "/cache/seed/$CC_SEED_KEY/$p" "$p" && hit=1 && echo "[runner] restored $p from the cache"; fi; done; fi
|
||||
fi
|
||||
if [ -n "$CC_SEED_KEY" ]; then if [ "$hit" = 1 ]; then echo "[runner] seed $CC_SEED_KEY: hit"; else echo "[runner] seed $CC_SEED_KEY: miss"; fi; fi
|
||||
t0=$(date +%s)
|
||||
if [ -n "$CC_INSTALL" ]; then sh -c "$CC_INSTALL" || exit 1; fi
|
||||
echo "[runner] install took $(( $(date +%s) - t0 )) s"
|
||||
if [ -d /cache ] && [ -n "$CC_SEED_KEY" ] && [ ! -d "/cache/seed/$CC_SEED_KEY" ]; then
|
||||
t="/cache/seed/.tmp-$$"; rm -rf "$t"; mkdir -p "$t"; ok=1
|
||||
for p in $CC_SEED_PATHS; do if [ -e "$p" ]; then mkdir -p "$t/$(dirname "$p")" && cp -a "$p" "$t/$p" || ok=0; fi; done
|
||||
@@ -434,6 +438,7 @@ async fn start_env(State(r): State<Arc<Runner>>, h: HeaderMap, Json(req): Json<S
|
||||
}
|
||||
|
||||
async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Result<Started> {
|
||||
let began = Instant::now();
|
||||
let net = format!("cc-run-{id}");
|
||||
let app = format!("cc-run-{id}");
|
||||
// Register first, so a failure at any step is cleaned up by stop().
|
||||
@@ -542,6 +547,11 @@ async fn create(r: &Arc<Runner>, id: &str, req: &StartReq, work: &Path) -> Resul
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(700)).await;
|
||||
}
|
||||
// Report what the cache brought: seed hit/miss, install time, total time until the app answered.
|
||||
let facts: Vec<String> = logs(&app).await.lines().filter(|l| l.starts_with("[runner] seed ") || l.starts_with("[runner] install took")).map(|l| l.trim_start_matches("[runner] ").to_string()).collect();
|
||||
let took = began.elapsed().as_secs();
|
||||
let cache = if cached { "on" } else { "off" };
|
||||
tracing::info!("test env {id} ({}) ready after {took} s; cache {cache}{}{}", req.cache_id, if facts.is_empty() { "" } else { "; " }, facts.join("; "));
|
||||
let (listener, port) = bind_forward(r).await?;
|
||||
let (target, tport) = (ip, req.port);
|
||||
let fwd = tokio::spawn(async move {
|
||||
|
||||
Reference in new issue
Block a user