Skip to content

CI: run the unit tests on Windows (#971) - #973

Merged
scttfrdmn merged 7 commits into
mainfrom
fix/971
Oct 16, 2026
Merged

scttfrdmn merged 7 commits into
mainfrom
fix/971

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #971. Also fixes #997, #998 and #999, three real Windows bugs the new job found.

The job

test-windows (Test (Windows)) runs on windows-latest. It uses the same SHA-pinned actions/checkout / actions/setup-go and Go 1.26.9 as the other jobs, and runs scripts/windows-tests.sh, which is go test -short -count=1 over every root-module package except those in scripts/windows-test-skips.txt. The list is inverted on purpose: a new package is tested on Windows by default and has to be written down to escape. Each skip carries a reason and an issue.

Gates (windows_ci_test.go)

  • TestCIRunsUnitTestsOnWindows: a ci.yml job has a Windows runs-on and invokes the script at command position, so an echo that names it does not count, and nothing sets continue-on-error. The script runs go test -short over the discovered packages and reads the skip list.
  • TestWindowsCIJobHasNoAWS: no AWS credential or profile env var, and no secrets.*, at workflow, job or step level, and no configure-aws-credentials.
  • TestWindowsSkipListIsJustified: every skip cites #NNN and names a real package.
  • TestWindowsJobRunsWindowsOnlyTests: this is the anti-vacuity gate. It walks the root module and discovers _test.go files that build on windows but not on linux, by _windows filename suffix or by evaluating //go:build with go/build/constraint. It fails if it finds none, and fails if any of them sits in a skipped package. pkg/agent and cmd/spored may never be skipped. It currently finds pkg/agent/sys_windows_test.go and the new pkg/plugin/registry_windows_test.go.

I watched each gate fail against a compiling revert: runs-on: ubuntu-latest, run: echo scripts/windows-tests.sh, an AWS_ACCESS_KEY_ID: ${{ secrets.X }} step env, pkg/agent added to the skip list, an entry with no issue and a nonexistent package, go vet substituted for go test, and sys_windows_test.go removed. I also renamed that file to drop the _windows suffix, and it was still discovered through its //go:build windows line.

Real Windows bugs, fixed here

Test-only fixes

  • HOME alone does not move the home directory on Windows, where os.UserHomeDir reads USERPROFILE. Tests in cmd and pkg/config read the runner's real profile. A setTestHome helper sets both. On a developer's Windows machine those tests would have read their real ~/.spawn.
  • TestWriteOutputID wrote to a literal /tmp, which on Windows created C:\tmp. It now uses t.TempDir().
  • The DCV fake is a dcv.bat on Windows, found through PATHEXT, so the production exec path runs. The plugin env-passthrough steps use slash paths under sh. The platform path asserts compare in slash form. The service-upload test takes the OS's own not-found text.

Skipped on Windows, Linux-only by design (#1002)

These tests execute the Linux user-data, installer, pool-worker or task-flush shell, or assert POSIX mode bits. They are in pkg/agent (task-flush hook), arrayrec, cmd (pool worker loop, audit.log mode), launcher, sporedinstall (shell installer), taskpool and userdata (MPI block). Each skip message cites #1002.

Caveats

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/pipeline/data_handoff.go 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ux-only tests (#971)

Fixes #997 (plugin local paths), #998 (pipeline S3 key matching), #999
(snapshot raw-image Cleanup). Skips pkg/security (#1000) and
pkg/pluginruntime (#1001); Linux-only tests skip on Windows (#1002).
…ts (#971)

cmd/spored (real bug): buildStatusReport read uptime BEFORE the CPU/network
samples and "now" after them, so boot and billed time were late by the
sampling time — seconds on Windows, where each sample is a PowerShell
process (47s after launch reported 52s billed). And on the checkpoint path
(always on Windows, which publishes no compute clock) compute included the
status process's own run time, so it read "2s as of the last checkpoint"
with no checkpoint written. Clock readings now follow the samples, and an
unadopted clock reports exactly the checkpoint. The tests bound times by a
before/after window instead of assuming the report is instant; verified to
fail against the old code with a simulated 2.5s sampling delay.

pkg/agent: the /sys/class/net fixture used kernel-style names with ':',
which Windows rejects; the parser never reads them, so use '-'.

lambda/pipeline-orchestrator (part of the root module, no go.mod) and
pkg/taskproto: tests that execute Linux user-data / wrapper / flush hook
under bash are skipped on Windows (#1002).
@scttfrdmn
scttfrdmn merged commit be7112d into main Oct 16, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/971 branch October 16, 2026 17:47
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…1023's plugin order (#1007)

The sandboxed bootstrap tests execute the Linux user data under bash with
stubbed spored and su, which the Windows CI job (#973) cannot reproduce, so
they skip there as the other Linux-bootstrap execution tests do (#1002).
Rebased onto #1023/#1045, plugins.json is written before spored starts, so
the post-spored stop sits straight after the bootstrap body; the changelog
and the ordering test's comment now say so.

(#1007)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
… instant

Sampling in buildStatusReport takes seconds on Windows, so the 91-94s bound
flaked there (95s). Same window pattern as TestStatusReport_QueryCountsTheDaemonsRunningTime (#973). (#928)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
… instant

Sampling in buildStatusReport takes seconds on Windows, so the 91-94s bound
flaked there (95s). Same window pattern as TestStatusReport_QueryCountsTheDaemonsRunningTime (#973). (#928)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
… instant

Sampling in buildStatusReport takes seconds on Windows, so the 91-94s bound
flaked there (95s). Same window pattern as TestStatusReport_QueryCountsTheDaemonsRunningTime (#973). (#928)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…1023's plugin order (#1007)

The sandboxed bootstrap tests execute the Linux user data under bash with
stubbed spored and su, which the Windows CI job (#973) cannot reproduce, so
they skip there as the other Linux-bootstrap execution tests do (#1002).
Rebased onto #1023/#1045, plugins.json is written before spored starts, so
the post-spored stop sits straight after the bootstrap body; the changelog
and the ordering test's comment now say so.

(#1007)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…1021)

* Stop a Spot replacement from re-running the user's workload (#1007)

A replacement EC2 launches from a leaked persistent Spot request boots the
original's user data. The bootstrap started --command in the background
before spored, so the replacement re-ran the workload from the start, side
effects included, while spored was deciding to retire it.

New `spored is-spot-replacement` runs spotrequest.DetectReplacement and
exits 0 (replacement), 1 (not) or 2 (unknown). It retries an inconclusive
read every 5s for up to --timeout (60s), and not at all on an IAM refusal.

The Linux bootstrap calls it twice through spawn_is_spot_replacement:
inside the backgrounded --command subshell, ahead of the command, so it
never delays spored's start; and right after spored starts, where a
replacement exits the script. So storage, plugins, the container, custom
user data and the MPI, batch-queue and pool-worker scripts appended later
don't run either. Definite answers are cached in /run/spawn.

Only exit 0 skips. Unknown, a missing spored, an older spored without the
subcommand (cobra exits 1) and a timeout all run the workload, as before.
Holding would strand originals whenever EC2/IMDS is slow or a custom role
can't read tags; a replacement that gets past it is still retired by
spored and alarmed by the reaper.

The Windows bootstrap starts no workload (it runs no --command or user
data), so it has nothing to gate; a comment says what to do if it gains one.

Also adds TestRunDaemonStartsTheReplacementCheck, which fails if runDaemon
stops starting the #995 check (the gap #1008 noted), and a Detection.Err
field so the subcommand can tell an IAM refusal from a transient failure.

The bootstrap tests run the generated --command block and the post-spored
tail under bash with stubbed spored and su; each new test was watched
failing against a compiling revert.

(#1007)

* Run the post-spored replacement stop after the plugin declarations (#1007)

spored reads /etc/spawn/plugins.json once, at startup, and the bootstrap
writes it just after `systemctl start spored`. Putting the stop's EC2 round
trip between the two would have made spored miss the declarations on every
original instance. The stop now follows the plugins block; a gate keeps it
there. The existing race is filed as #1023.

(#1007)

* Name the original instance in spot_replacement_retired (#1007)

The notification comes from the replacement, whose instance id nobody
registered with spore-bot, so the bot's registration gate dropped every
DM and SMS for it. spored now also sends original_instance_id (via
Notifier.WithOriginalInstance), which spore-bot uses for this event alone.
Older bots ignore the unknown field.

(#1007)

* Skip the bash-run Spot replacement bootstrap tests on Windows; note #1023's plugin order (#1007)

The sandboxed bootstrap tests execute the Linux user data under bash with
stubbed spored and su, which the Windows CI job (#973) cannot reproduce, so
they skip there as the other Linux-bootstrap execution tests do (#1002).
Rebased onto #1023/#1045, plugins.json is written before spored starts, so
the post-spored stop sits straight after the bootstrap body; the changelog
and the ordering test's comment now say so.

(#1007)

* Use the repo's bare nosemgrep on the spot-replacement test harness (#1007)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
… instant

Sampling in buildStatusReport takes seconds on Windows, so the 91-94s bound
flaked there (95s). Same window pattern as TestStatusReport_QueryCountsTheDaemonsRunningTime (#973). (#928)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…; stop's TTL message (#928) (#947)

* Answer status for stopped instances from EC2, keep compute across stop/start, fix the TTL-pause message (#928)

- status: a non-running instance is rendered from EC2 data and tags (state,
  stopped since and why, TTL deadline, compute and cost so far, EBS accruing
  while stopped). No SSH or SSM. A running instance with no public IP uses SSM.
- pkg/sshtarget: every ssh/scp client starts through one guard that refuses
  empty, loopback and unspecified hosts (destination, -J, scp operands). A
  gate fails the build on any ssh/scp exec elsewhere, wrappers included.
- spored: durable compute checkpoint on the root volume, written every tick
  and first on shutdown. The compute-seconds tag flush is retried and
  logged. Each boot counts from kernel boot without double-counting a
  same-boot restart. A restarted instance's billed time excludes the stop.
- stop/hibernate/start: say the TTL deadline still applies (local time with
  UTC). start no longer overwrites spawn:ttl. Help text and docs-gen agree,
  and that agreement is gated.
- pkg/aws: InstanceInfo.StateReason (additive; api snapshot updated).

(#928)

* Test: measure the restarted-instance compute against a window, not an instant

Sampling in buildStatusReport takes seconds on Windows, so the 91-94s bound
flaked there (95s). Same window pattern as TestStatusReport_QueryCountsTheDaemonsRunningTime (#973). (#928)
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.

plugin: Windows local paths (C:\..., .\x.yaml) are treated as registry names CI has no Windows runner: windows-only tests are compiled but never run

1 participant