Skip to content

test: fire interrupt tests from an event, not a sleep - #278

Closed
noahkhomer18 wants to merge 1 commit into
TMHSDigital:mainfrom
noahkhomer18:test/260-interrupt-events
Closed

noahkhomer18 wants to merge 1 commit into
TMHSDigital:mainfrom
noahkhomer18:test/260-interrupt-events

Conversation

@noahkhomer18

Copy link
Copy Markdown

Closes #260.

Both interrupt tests decided when to interrupt with a fixed wall-clock sleep, so a slow or loaded runner could finish the scan before the signal landed. That is the flake class this repo has been clearing out.

Interrupts now fire from an interruptWriter that triggers on the Nth stdout line, so the signal lands while the scan is genuinely running.

  • main_e2e_test.go: TestE2EResume fires os.Interrupt after the 3rd result line, replacing the 1s sleep.
  • main_signal_unix_test.go: TestE2ESIGTERMExits143 fires SIGTERM after the 1st result line, replacing the 200ms sleep.

Acceptance criterion met: no time.Sleep decides when the interrupt fires in either file.

$ grep -n time.Sleep main_e2e_test.go main_signal_unix_test.go
(no matches)
$ go test -run TestE2EResume -count=20 .
ok  github.com/TMHSDigital/subenum  43.395s
$ go test ./...
19 ok, 0 FAIL

One honest note: main_signal_unix_test.go carries a //go:build unix tag, so on this Windows machine I could not execute that test. It was changed by reading it and mirrors the pattern proven in TestE2EResume; CI on Linux will be the first real run of it.

Both interrupt tests decided when to interrupt with a fixed wall-clock sleep. A
slow or loaded runner could finish the scan first, which is the flake class this
repo has been clearing out.

Interrupts now fire from an interruptWriter that triggers on the Nth stdout line,
so the signal lands while the scan is genuinely running. No time.Sleep decides
the interrupt in either file.

Closes TMHSDigital#260
@noahkhomer18

Copy link
Copy Markdown
Author

Closing this: 536c4b6 on main already fixes #260, and it landed after I branched. Same approach (interrupt on a result line instead of a wall-clock sleep) and the same two files, so this PR is redundant rather than conflicting.

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.

Interrupt tests rely on wall-clock sleeps

1 participant