onebox-deploy-test
Skill18 starsChanged 2 months agoMITView on GitHub
Build the Rust SF samples, deploy them to a local onebox cluster (Linux devcontainer or Windows host), and run the integration test suite. Use when the user asks to "run the integration tests", "deploy to onebox and test", "redeploy and re-run", "verify on a real cluster", "bring up onebox", or after non-trivial changes to crates/samples/* or crates/libs/* that need end-to-end validation. Covers just builds, sfctl/PowerShell provisioning, cluster health waits, and `cargo test --all -- --nocapture`.
In this repositoryOne other file it gives its agents.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 37
Stop on the first failure unless the step is marked (best-effort).
- Distinctive: line 41
Run a quick check before doing anything else.
- Very specific: line 61
If any are missing, inspect the just log around the failing recipe.
- Distinctive: line 78
If the script fails:
- Very specific: line 96
If a test fails with FABRIC_E_APPLICATION_NOT_FOUND you skipped Step 2.
- Distinctive: line 100
Run after a successful test pass to leave the cluster clean for the next iteration.
- Distinctive: line 110
If state is irretrievably stuck, the onebox container needs to be restarted from the host — the devcontainer cannot reach the host's docker …
- Very specific: line 173
Use onebox/windows/StartOnebox.ps1.
- Very specific: line 181
After success: SF Explorer at http://localhost:19080/Explorer.
- Very specific: line 211
If New-ServiceFabricApplication fails with FABRIC_E_APPLICATION_TYPE_ALREADY_EXISTS, run the matching -Action Remove then retry.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Onebox Deploy & Test
End-to-end loop for validating changes against a real Service Fabric onebox
cluster. Mirrors what CI does in
.github/workflows/build.yaml:
- Linux devcontainer path →
build-devcontainerjob (u22andazl3matrix entries). - Windows host path →
buildjob (runs-on: windows-latest).
Pick the section that matches the user's environment. Detect with:
- Linux/devcontainer if
cat /etc/os-releaseshows Ubuntu/Azure Linux andcommand -v sfctlsucceeds → use Procedure (Linux). - Windows if
$env:OS -eq 'Windows_NT'andTest-Path 'C:\Program Files\Microsoft Service Fabric'→ use Procedure (Windows).
When to Use
- The user wants to validate a change end-to-end on a real cluster, not just
cargo test --lib. - Trigger phrases: "deploy and test", "run the integration tests", "redeploy onebox", "bring up the cluster and run", "full e2e", "what CI runs".
- Changes touched any of:
crates/samples/echomain/,crates/samples/echomain-stateful/,crates/samples/reflection/,crates/samples/kvstore/,crates/libs/com/,crates/libs/core/,crates/libs/util/,crates/libs/pal/, theproto/directories,manifests/, or build.rs. - A previous test run failed and you want to redeploy clean.
When NOT to Use
- Pure unit-test runs (
cargo test --libis enough). - Doc-only changes.
- Refactors that don't touch SF-facing code paths.
Procedure (Linux)
Devcontainer setup where the onebox and repo-u22/repo-azl3 containers run
side by side. All commands are run from the repo root (/home/vscode/repo).
Stop on the first failure unless the step is marked (best-effort).
Preconditions (Linux)
Run a quick check before doing anything else; if any fails, stop and report:
- Inside the devcontainer. Confirm with
cat /etc/os-release | head -2(expectUbuntuorAzure Linux) andcommand -v sfctl(must succeed). The host machine doesn't have SF orsfctlinstalled. - Onebox sibling container reachable.
sfctl cluster selectshould connect to the defaulthttp://onebox:19080(the sibling container's hostname). If it errors withconnection refused, the onebox container hasn't finished starting — wait 10 s and retry up to 3 times. - Working tree compiles.
cargo check -p samples_reflection -p samples_echomain -p samples_echomain_stateful— fail fast if there's a build error before invoking the full build.
Step 1 — Build everything via just
just drives cargo build and packages every sample into build/sf_apps/<app-name>/ (this is what sfctl application upload consumes).
justExpected outputs after success:
build/sf_apps/samples_reflection/(withApplicationManifest.xml,ServicePackage/, etc.)build/sf_apps/samples_echomain/build/sf_apps/samples_echomain_stateful/build/sf_apps/kvstore/(Windows only)
If any are missing, inspect the just log around the failing recipe. The root justfile defines what gets packaged.
Step 2 — Wait for the cluster to be healthy and provision apps
The repo's scripts/prepare_test_apps.sh does the entire wait-and-deploy loop with retries. Use it directly rather than re-implementing the logic:
bash ./scripts/prepare_test_apps.shThis script:
- Waits up to ~150 s for
sfctl cluster selectto succeed. - Waits for the cluster's aggregated health state to be
OkorWarning. - Sleeps 5 s for the ImageStore to stabilise.
- Uploads + provisions + creates
EchoApp(fabric:/EchoApp) andReflectionApp(fabric:/ReflectionApp) with retries. - Waits for both
EchoAppServiceandReflectionAppServiceto become resolvable.
If the script fails:
application uploadfailures usually mean the onebox container is still warming up or the ImageStore isn't ready — retry the script once.application createfailures withFABRIC_E_APPLICATION_TYPE_ALREADY_EXISTSmean a previous run left state behind. Run Step 4 — Cleanup first, then retry.service resolvefailures usually mean a placement constraint can't be satisfied — check the SF Explorer athttp://localhost:19080(port-forwarded by docker-compose).
Step 3 — Run tests
The integration tests use FabricClient::with_connection_strings(["localhost:19000"]) to reach the cluster. Inside the devcontainer this resolves to the onebox sibling container via the container runtime's DNS; the existing tests rely on this and don't need any extra wiring.
cargo test --all -- --nocaptureTwo recipes for narrower runs:
- Unit tests only (no cluster needed):
cargo test --all --lib -- --nocapture - One sample's integration tests:
cargo test -p samples_reflection -- --nocapture - A specific test name:
cargo test -p samples_reflection test_partition_info -- --nocapture --exact
If a test fails with FABRIC_E_APPLICATION_NOT_FOUND you skipped Step 2; if it fails with FabricError { code: -2147017735 } (timeout) the cluster is unhealthy — check sfctl cluster health and re-run the prepare step.
Step 4 — Cleanup (best-effort)
Run after a successful test pass to leave the cluster clean for the next iteration. Errors here are non-fatal.
# Per-app deletion. Skip silently if the app isn't registered.
sfctl application delete --application-id ReflectionApp 2>/dev/null || true
sfctl application unprovision --application-type-name ReflectionApp --application-type-version 0.0.1 2>/dev/null || true
sfctl application delete --application-id EchoApp 2>/dev/null || true
sfctl application unprovision --application-type-name EchoApp --application-type-version 0.0.1 2>/dev/null || trueIf state is irretrievably stuck, the onebox container needs to be
restarted from the host — the devcontainer cannot reach the host's
docker daemon. Ask the user to restart it from outside the
devcontainer (e.g., "reopen folder in container" from VS Code, which
rebuilds the containers; or docker restart <onebox-container-name>
from a host shell). Then re-run from Step 2.
Procedure (Windows)
Windows host setup where Service Fabric runtime + SDK are installed
locally and apps are provisioned via the ServiceFabric PowerShell
module (not sfctl). All commands are run from the repo root in a
PowerShell shell. Stop on the first failure unless the step is
marked (best-effort).
The CI equivalent is the build job in
.github/workflows/build.yaml
(runs-on: windows-latest).
Preconditions (Windows)
- Working tree compiles.
cargo check --all-targets— fail fast before the full build. CI also runscargo fmt --all -- --checkandcargo clippy -- -D warnings; mirror them locally if you want a CI-clean state. protocis onPATH. Required by the reflection sample's build script. CI installs it withtaiki-e/install-action@protoc; locally usewinget install protobufor any equivalent.justis onPATH(just --version). Install it withwinget install --id Casey.Just --exactif needed.
Skip the CI-only
Remove conflict dll pathsstep (deletesC:\Program Files\MySQL\...) and thecheck_sf_installed.ps1/check_cluster_online.ps1smoke checks — they exist to harden the GitHub-hosted runner image and are not needed locally.
Per-shell setup, not per-command.
Import-Module ServiceFabricandConnect-ServiceFabricClusteronly need to run once per PowerShell session — the module stays loaded and the cluster connection is cached on the runspace. The*_ctl.ps1scripts each callConnect-ServiceFabricClusterinternally, so for ad-hoc inspection (Get-ServiceFabricApplication, etc.) just reuse the existing connection. Do not repeatImport-ModuleorConnect-ServiceFabricClusterbetween commands in the same shell.
Step 1 — Build everything via just
Same as Linux — just drives cargo build and packages every
sample into build\sf_apps\<app-name>\.
justExpected outputs after success:
build\sf_apps\samples_reflection\build\sf_apps\samples_echomain\build\sf_apps\samples_echomain_stateful\build\sf_apps\kvstore\(Windows only)
Step 2 — Bring up the local 5-node cluster
Use onebox/windows/StartOnebox.ps1.
The script auto-elevates to Administrator via UAC. -Auto skips the
"existing cluster will be removed" prompt.
Powershell.exe -File .\onebox\windows\StartOnebox.ps1 -AutoAfter success: SF Explorer at http://localhost:19080/Explorer.
The script already waits for the cluster to be reachable and the
naming service to be ready, so a separate readiness wait is not
required for local runs.
Step 3 — Provision apps
The Linux prepare_test_apps.sh does not apply on Windows. Use the
per-sample PowerShell controllers, which mirror what CI runs:
# Lightweight smoke test for echomain (adds, resolves, echoes, removes).
.\tests\echo_script_test.ps1
# Long-lived deployments needed by `cargo test --all`.
.\scripts\reflection_ctl.ps1 -Action Add
.\scripts\echomain_ctl.ps1 -Action Add
# Optional — only needed if your tests touch these apps:
.\scripts\echomain_stateful_ctl.ps1 -Action Add
.\scripts\kvstore_ctl.ps1 -Action AddEach *_ctl.ps1 -Action Add does:
Connect-ServiceFabricCluster → Test-ServiceFabricApplicationPackage
→ Copy-ServiceFabricApplicationPackage → Register-ServiceFabricApplicationType
→ New-ServiceFabricApplication. Image-store path is MyApplicationV1
(or MyKvStoreApplicationV1 for kvstore), so back-to-back Adds of
two different apps will collide — Remove the previous one first or
they will overwrite each other's image-store entry.
If New-ServiceFabricApplication fails with
FABRIC_E_APPLICATION_TYPE_ALREADY_EXISTS, run the matching
-Action Remove then retry.
Step 4 — Run tests
cargo test --all -- --nocaptureSame narrowing recipes as Linux:
- Unit tests only:
cargo test --all --lib -- --nocapture - One sample:
cargo test -p samples_reflection -- --nocapture - Specific test:
cargo test -p samples_reflection test_partition_info -- --nocapture --exact
Tests connect to localhost:19000 via FabricClient.
Step 5 — Cleanup (best-effort)
Each controller's -Action Remove reverses its Add:
.\scripts\reflection_ctl.ps1 -Action Remove
.\scripts\echomain_ctl.ps1 -Action Remove
.\scripts\echomain_stateful_ctl.ps1 -Action Remove # if added
.\scripts\kvstore_ctl.ps1 -Action Remove # if addedTo stop the cluster while preserving data, or to fully tear it down:
Powershell.exe -File .\onebox\windows\StopOnebox.ps1 # stops FabricHostSvc only
Powershell.exe -File .\onebox\windows\StopOnebox.ps1 -CleanData -Auto # full removalA stopped cluster can be restarted with Start-Service FabricHostSvc
or by re-running StartOnebox.ps1.
What CI Does Differently
build-devcontainer job (Linux)
Runs Steps 1–4 in one shot via devcontainers/ci@v0.3 and adds:
- Disk-space prep (
/usr/local/lib/androidetc. removal). - Core-dump capture under
/tmp/artifacts/coredumps/. - Artifact upload of crashed binaries.
build job (Windows)
Runs the matrix (rust-min, rust-max) × windows-latest and adds:
cargo fmt --all -- --checkandcargo clippy -- -D warningsgates before the build.Remove conflict dll paths— deletesC:\Program Files\MySQL\MySQL Server 8.0\binbecause itslibprotobuf.dllis incompatible with Service Fabric and prevents the runtime from starting on the GitHub-hosted runner image. Not needed on a clean local box.check_sf_installed.ps1andcheck_cluster_online.ps1smoke checks — also CI-image hardening.
For local iteration both extra-step blocks are unnecessary. If the user is debugging a crash that only repros in CI, point them at the artifact upload step rather than re-running this skill locally.
Common Pitfalls
- A deployed sample is stale after editing
Cargo.toml. Rebuild and repackage it withjust build-sample-reflection, or runjustfor the full set. - (Linux)
sfctl: command not found. The host doesn't have it; you're outside the devcontainer. Start it via VS Code's "Reopen in Container" or rerun in the right shell. - (Linux)
http://onebox:19080unreachable from the repo container. The onebox container may have crashed. The devcontainer can't reach the host's docker daemon, so ask the user to check container status from a host shell (docker ps) and restart it there if needed — there is no auto-restart. - (Windows)
Connect-ServiceFabricClusterfails immediately afterStartOnebox.ps1. Re-run the connect; the SDK script already waits, but a freshly-restarted cluster occasionally needs a few extra seconds for the naming service. - (Windows)
New-ServiceFabricApplicationerrors withimage store path already exists. Two*_ctl.ps1scripts share theMyApplicationV1image-store path. Run-Action Removefor the previous app before adding the next, or accept that only one of them will be live. - (Windows)
*_ctl.ps1must be run from the repo root. The scripts use the relative pathbuild\sf_apps\<sample>— running from elsewhere failsTest-ServiceFabricApplicationPackage. - Tests pass locally but fail in CI. CI runs
u22,azl3, andwindows-latest; check whether the failure is platform-specific by reproducing in the matching environment.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

