← Back to Pull requests

feat: Add per-child environment for test spawning #79

Closed
unknown closed this pull request without merging on Oct 05, 2026 19:00 UTC
View on GitHub
unknown unknown commented on Aug 19, 2026 21:20 UTC
Author

Summary

  • Add Env map[string]string to ExtensionTestSpec for per-test child-process environment variables.

  • Add AddBeforeSpawn, which runs immediately before RunParallel and can populate Env or adjust Timeout.

  • Add SpawnProcessToRunTestWithEnv and wire Ginkgo-generated runners to pass spec.Env to the child process.

  • Clone Env before BeforeEach so callback mutations cannot change the environment passed to the child.

  • Snapshot scheduler reservations at dispatch time and reject duplicate spec pointers, so mutable specs cannot corrupt resource accounting or share per-execution state.

  • Skip BeforeSpawn for in-process Run execution, including single-spec run-test children, while retaining the spawned-child marker as an additional guard.
  • Motivation

    OTE normally runs parallel tests in separate OS processes. Previously there was no supported way for the parent scheduler to pass per-test runtime data to a child. Consumers such as ARO-HCP therefore needed filesystem-based coordination to bind a scheduled test to a concrete shared resource.

    BeforeSpawn lets the parent allocate that resource after scheduler dispatch and place the assignment in spec.Env. The environment-aware runner then passes the assignment directly to the child process.

    Behavior and compatibility

  • SpawnProcessToRunTest keeps its existing signature and delegates to the environment-aware implementation.

  • BeforeSpawn runs only for specs that will use RunParallel; it does not run for the in-process Run path.

  • Ginkgo-generated RunParallel functions automatically merge spec.Env into the child environment. Custom runners must consume spec.Env themselves.

  • Hooks may populate Env and adjust Timeout, but must not mutate scheduler-owned resource fields after dispatch.

  • A nil Env is valid. Hooks that assign individual keys must initialize the map first.

  • Environment names must be non-empty and cannot contain = or NUL; values cannot contain NUL.

  • Caller-supplied environment values use last-wins semantics. The internal OTE_SPAWNED_CHILD marker cannot be overridden.

  • NewScheduler rejects nil specs and duplicate spec pointers because one pointer cannot safely identify multiple concurrent executions.
  • Test plan

  • Environment merge, inheritance, override, validation, and base-slice non-mutation tests.

  • Spawned-child marker preservation, override protection, and input-map non-mutation tests.

  • Real child-process environment and timeout propagation tests.

  • BeforeSpawn ordering, composition, in-process skip, and built-in/custom child-process lifecycle tests.

  • BeforeEach environment-isolation and JSON-omission tests.

  • Scheduler reservation snapshot, post-dispatch mutation, and duplicate-pointer rejection tests.

  • go build ./...

  • go test -race ./...
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

  • New Features

  • - Added configurable pre-spawn hooks for setting environment variables and timeouts per test.
    - Added support for passing spawn options to child test processes.
    - Child processes are now clearly identified during test execution.

  • Bug Fixes

  • - Prevented hook and setup changes from unintentionally leaking between tests.
    - Preserved scheduling and resource reservations even when test settings change.
    - Added validation for invalid environment variable names and values.

  • Tests

  • - Expanded coverage for hook ordering, subprocess behavior, environment handling, and scheduler safety.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 458 lines (+343 / -115) across 5 files Reviewer: mgahagan73 Review duration: 67540m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 458 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #79"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.0% · Safe to merge
    18.0%