Skip to content

Refactor duplicated hosts-file mount test harness setup#6300

Merged
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-code-in-tests
Jul 16, 2026
Merged

Refactor duplicated hosts-file mount test harness setup#6300
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-code-in-tests

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The hosts-file mount branch tests repeated the same temp-directory and filesystem-mock harness across three security-sensitive suites. This consolidates that setup so future changes to mock delegation, staging behavior, or cleanup stay consistent across all branches under test.

  • What changed

    • Added a file-local restoreDefaultFsMocks() helper to centralize delegation to the real readdirSync, statSync, and writeFileSync implementations
    • Added a file-local createHostsFileTestHarness() helper to own temp-dir creation, jest.clearAllMocks(), default FS mock setup, and cleanup
    • Replaced the duplicated beforeEach / afterEach blocks in:
      • localhostDetected coverage
      • pruneStaleChrootStageDirs error handling
      • EACCES writeFileSync fallback
  • Suite-specific behavior preserved

    • The staging-path suite still forces a /tmp-rooted work dir
    • The staging-path suite still installs its default mockExecaSync behavior through an extraSetup hook
    • Other suites continue to use the standard temp-dir root without additional behavior changes
  • Result

    • One source of truth for the harness used by these branch tests
    • Less drift risk when adjusting FS mocking or temp-dir lifecycle in future coverage updates
const { getTmpDir, setup, cleanup } = createHostsFileTestHarness('awf-prune-', {
  rootDir: '/tmp',
  extraSetup: () => {
    mockExecaSync.mockReturnValue({ stdout: '', stderr: '' });
  },
});

beforeEach(setup);
afterEach(cleanup);

Copilot AI changed the title [WIP] Refactor host-file mount tests to eliminate duplicate code Refactor duplicated hosts-file mount test harness setup Jul 16, 2026
Copilot finished work on behalf of lpcox July 16, 2026 14:25
Copilot AI requested a review from lpcox July 16, 2026 14:25
@lpcox
lpcox marked this pull request as ready for review July 16, 2026 14:44
Copilot AI review requested due to automatic review settings July 16, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors repeated hosts-file test setup into reusable file-local helpers while preserving suite-specific behavior.

Changes:

  • Centralizes filesystem mock delegation.
  • Consolidates temporary-directory setup and cleanup.
  • Retains /tmp staging and custom execa setup.
Show a summary per file
File Description
src/services/agent-volumes/hosts-file-branches.test.ts Consolidates duplicated test harness setup.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.92% 98.96% 📈 +0.04%
Statements 98.86% 98.90% 📈 +0.04%
Functions 99.35% 99.35% ➡️ +0.00%
Branches 95.06% 95.06% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the focused test-harness refactor. The code style, test organization, and documentation expectations are addressed; however, the PR description does not reference a related issue. CONTRIBUTING.md, under Pull Request Process → Pull request requirements, asks contributors to reference any related issues. Please add an issue reference if one exists (or note that there is none, if applicable).

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Contribution Check for #6300 · 3.27 AIC · ⊞ 19.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: PAT Auth — PASS ✅

Test Result
MCP connectivity
github.com HTTP ✅ 200
File write/read ⚠️ (template vars unexpanded in workflow)

Overall: PASS — Auth mode: PAT (COPILOT_GITHUB_TOKEN)
Author: @lpcox

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 PAT report filed by Smoke Copilot PAT
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API Status ✅ PASS
GH Check ✅ PASS
File Status ✅ PASS

Overall Result: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Smoke Claude for #6300 · 35.2 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

  • Redis PING: ❌ (host.docker.internal DNS resolution failed)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (DNS resolution failed)

Overall: FAILhost.docker.internal is not resolvable in this environment.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

Test Result
GitHub MCP ⚠️ MCP unavailable in sandbox
GitHub.com HTTP ✅ 200
File Write/Read ⚠️ Pre-step vars not expanded

Overall: PASS (connectivity confirmed)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

OTEL Smoke Test Results

Scenario Result Notes
1. Module Loading otel.js loads successfully; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, _provider, and exporter helpers
2. Test Suite 59 tests passed, 0 failed across otel.test.js + otel-fanout.test.js (2 test suites)
3. Env Var Forwarding src/services/agent-environment-credentials.ts auto-forwards OTEL_* vars (OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, etc.) — covered by tests
4. Token Tracker Integration onUsage callback present in token-tracker-http.js (line 285) as the OTEL hook point
5. OTEL Diagnostics No OTLP endpoint configured in this run; graceful fallback to FileSpanExporter (/var/log/api-proxy/otel.jsonl) confirmed by test suite

All 5 scenarios pass. OTEL tracing integration is functional.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode

Test Result
GitHub MCP (list PRs)
GitHub.com connectivity
File write/read
BYOK inference

Mode: Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com

Overall: PASS@lpcox

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results: Gemini Engine

  • GitHub MCP Testing: ❌ (Access to PR titles blocked by secrecy policy)
  • GitHub.com Connectivity: ❌ (Connection failed, Exit Code 7)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.18.0 v22.23.1
Go go1.22.12 go1.22.12

⚠️ Not all runtimes match. Python and Node.js versions differ between host and chroot environment.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color passed ✅ PASS
Go env passed ✅ PASS
Go uuid passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Note: Java required using a writable Maven local repository (/tmp/gh-aw/agent/m2-repo) due to default ~/.m2/repository directory permissions in this environment.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Build Test Suite for #6300 · 33.8 AIC · ⊞ 6.9K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Merged PRs:

  • Upgrade gh-aw extension to latest pre-release and recompile workflows
  • chore: upgrade gh-aw extension to v0.82.10 (pre-release)

Checks:

  • GitHub reads: ✅
  • File write/read: ✅
  • Discussion query/comment: ✅
  • Playwright: ❌ unavailable
  • Build: ❌ npm ci failed (403 yocto-queue)

Overall: FAIL

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • awmgmcpg
  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test Results — Docker Sbx

Test Result
GitHub MCP connectivity ✅ Connected (PR data filtered by secrecy policy)
GitHub.com HTTP ✅ 200 OK
File write/read ⚠️ Pre-step template vars not expanded

Overall: PASS (core connectivity tests passed; pre-step data unavailable due to unexpanded template variables)

@lpcox

📰 BREAKING: Report filed by Smoke Docker Sbx
Add label ready-for-aw to run again

@lpcox
lpcox merged commit 49256a2 into main Jul 16, 2026
133 of 139 checks passed
@lpcox
lpcox deleted the copilot/fix-duplicate-code-in-tests branch July 16, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] Host-file mount tests repeat filesystem mock and temp-directory harness setup

3 participants