Skip to content

test(cloud-service): run the suite on Windows - #107

Open
DeryFerd wants to merge 1 commit into
DuskBotAI:mainfrom
DeryFerd:fix/cloud-service-tests-windows
Open

DeryFerd wants to merge 1 commit into
DuskBotAI:mainfrom
DeryFerd:fix/cloud-service-tests-windows

Conversation

@DeryFerd

Copy link
Copy Markdown
Contributor

What and why

Two tests in the cloud-service suite cannot pass on Windows, and both of them are the test harness rather than the service.

apps/cloud-service/src/recheck.test.ts spawns a child process to prove the data-directory lock refuses a second writer. The child's specifier was built with join(process.cwd(), "apps/dashboard/server/data-dir-lock.ts"), which on Windows is D:\...\data-dir-lock.ts. import() rejects that, so the child died before printing anything and the assertion looking for REFUSED DataDirLockedError read an empty string. The child now gets a pathToFileURL(...).href specifier.

apps/cloud-service/src/home-update.test.ts has a describe block that runs the real control script on the machine. The fixture stubs root commands as shell scripts, runs the script through execFileSync("bash", ...) with a POSIX PATH, presents docker as a unix socket at a path so the script's [ -S ] test finds it, and builds its package tarball with the system tar. None of that holds on Windows: bash is not found once PATH is replaced with the POSIX directories, a unix socket cannot be bound at a filesystem path, and GNU tar reads a C:\... argument as a remote host. Faking those away would mean rewriting the fixture around a second platform, so the block is now describe.skipIf(process.platform === "win32"). That is the convention the repo already uses in its platform-specific tests, and docs/development.md asks for it directly: POSIX-only calls need a gated Windows equivalent rather than a silent failure.

How it was checked

Before, on Windows: pnpm exec vitest run apps/cloud-service/src/home-update.test.ts gave 4 failed and 9 passed, two of the failures timing out at the 40 s Windows limit because the docker stand-in's listen() never settled, and two with tar (child): Cannot connect to C: resolve failed. pnpm exec vitest run apps/cloud-service/src/recheck.test.ts gave 1 failed with expected '' to contain 'REFUSED DataDirLockedError'.

After: pnpm exec vitest run apps/cloud-service/src/home-update.test.ts apps/cloud-service/src/recheck.test.ts gives 23 passed, 4 skipped and 0 failed. The skipped four are the whole omb-home on the machine block; the other nine tests in that file still run, and nothing in the block changes on Linux or macOS. pnpm exec oxlint --deny-warnings over the two files reports no warnings and no errors.

The guard tests around this pass as well: scripts/testing/host-e2e.test.ts (the rule that flags tests skipped on Linux, which this skip is not), scripts/testing/comment-history.test.ts, scripts/testing/file-size-ratchet.test.ts and scripts/testing/verification-docs.test.ts.

  • New behaviour has a test
  • No secrets, personal data or local paths in the diff

Notes for reviewers

I left the two seeded power simulations in apps/cloud-service/src/power/ alone. On a loaded Windows laptop they end with Error: Test timed out in 40000ms (they run for 58 to 186 seconds against the doubled Windows timeout), and a TZ=UTC run failed them the same way, so that is capacity on my machine rather than anything portable. They are worth a separate look if the Windows shard sees them too.

Based on upstream main at 289ccb24. No rebase was needed.

Two of these tests could not pass there. The lock test built the child's
import specifier from a Windows path, which import() rejects, so the child
printed nothing and the refusal it checks never appeared: the specifier is a
file URL now. The omb-home describe runs the real control script under bash
with a POSIX PATH, shell stubs, a unix socket at a path and the system tar, so
it is POSIX only and is skipped on Windows like the other platform-specific
tests here.
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.

1 participant