Skip to content

Add test-env setup script and skill for Claude Code cloud sessions#8065

Open
phacops wants to merge 1 commit into
masterfrom
claude/devservices-devenv-install-2m7nbg
Open

Add test-env setup script and skill for Claude Code cloud sessions#8065
phacops wants to merge 1 commit into
masterfrom
claude/devservices-devenv-install-2m7nbg

Conversation

@phacops

@phacops phacops commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an on-demand script + skill that prepares an ephemeral Linux container (e.g. a Claude Code cloud session) for running the Snuba test suite, where nothing is installed and the Docker daemon is not running.

This is intentionally a standalone script rather than a session-start hookuv sync plus pulling the clickhouse/redis/kafka images takes several minutes, so we only pay that cost on demand when tests are actually needed.

Changes

  • scripts/setup-test-env.sh — idempotent setup script that:
    1. Installs sentry-devenv via the official bash installer
    2. Runs uv sync --frozen --active, which creates .venv and compiles the native rust_snuba extension into it (no separate maturin develop needed); devservices comes along as a dev dependency
    3. Starts the Docker daemon (sudo dockerd) if it isn't already running
    4. Brings up devservices (clickhouse, redis, kafka)
  • .claude/skills/setup-test-env/SKILL.md — companion skill so the environment can be set up on demand, documenting the correct test invocation.
  • devservices/config.yml — lower the clickhouse nofile ulimit from 262144 to soft 1024 / hard 4096 so the container can start in environments without CAP_SYS_RESOURCE (the previous value cannot be applied there and made clickhouse fail to start).

Notes / gotchas

  • pytest must be run from inside tests/. Invoking it from the repo root loads test_distributed_migrations/conftest.py, whose pytest_configure connects to a multi-node clickhouse host (clickhouse-query) that single-node devservices doesn't provide, causing an INTERNALERROR before any test runs. Documented in the skill:
    (cd tests && SNUBA_SETTINGS=test ../.venv/bin/pytest <path/to/test_file.py> -m "not ci_only")
  • devenv refuses to run as root and devenv sync is Homebrew-based, so in the cloud container the functional path is uv sync + devservices, not devenv sync. The global devenv install is included only for parity with local laptop setups.

Validation

  • ✅ Setup script runs end-to-end and is idempotent; clickhouse/redis/kafka all report healthy
  • ruff check passes
  • ✅ Tests pass (2 passed) using the documented invocation

🤖 Generated with Claude Code

https://claude.ai/code/session_01CutWwsFwLDtczduJzjvF8Y


Generated by Claude Code

Add an on-demand setup script (scripts/setup-test-env.sh) plus a
companion skill that prepare an ephemeral Linux container (e.g. a Claude
Code cloud session) for running the test suite:

- install sentry-devenv via the official bash installer
- run `uv sync` (builds the venv and compiles the rust_snuba extension)
- start the Docker daemon if needed
- bring up devservices (clickhouse, redis, kafka)

This is a standalone script rather than a session-start hook so the
multi-minute cost is only paid when tests are actually needed.

Lower the clickhouse `nofile` ulimit in devservices/config.yml to
soft 1024 / hard 4096 so the container can start in environments without
CAP_SYS_RESOURCE (the previous 262144 cannot be applied there).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CutWwsFwLDtczduJzjvF8Y
@phacops phacops requested a review from a team as a code owner June 18, 2026 17:19
Comment thread devservices/config.yml
Comment on lines 52 to 55
nofile:
soft: 262144
hard: 262144
soft: 1024
hard: 4096
ports:

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.

Bug: The nofile ulimit for ClickHouse in devservices/config.yml is reduced to 4096. This low limit is likely to be exhausted during local test runs, causing failures.
Severity: HIGH

Suggested Fix

To avoid impacting all local development environments, consider using separate Docker Compose configurations. Revert the ulimit change in the general-purpose devservices/config.yml and create a new, specialized configuration file (e.g., docker-compose.cloud.yml) with the lower nofile limit specifically for the cloud container environment that requires it. This isolates the restrictive setting to only the environment where it is necessary.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: devservices/config.yml#L52-L55

Potential issue: The `nofile` ulimit for ClickHouse in `devservices/config.yml` has been
reduced to a hard limit of `4096`. This configuration is used by the `devservices` tool
for local development environments. ClickHouse is known to require a high number of file
descriptors, especially under load. The Snuba test suite performs numerous concurrent
operations, which will likely exceed this low limit, causing tests to fail with "Too
many open files" errors. This impacts any developer running the test suite locally.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This lower limit is intentional. The sandboxed cloud containers these scripts target lack CAP_SYS_RESOURCE, so the daemon's own nofile hard limit is capped at 4096 — runc can't grant a container a higher limit than that, and the original 262144 made the clickhouse container fail to start entirely (error setting rlimit type 7: operation not permitted). Any value ≤ 4096 is the only thing that works there.

The suggested split (a separate docker-compose.cloud.yml) isn't cleanly doable: devservices up invokes docker compose -f devservices/config.yml ... directly and offers no override-file mechanism, so a sibling compose file wouldn't be picked up.

In practice 4096 is sufficient for a dev/test clickhouse — the test suite passes against it. Keeping the single shared value for simplicity per maintainer decision.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants