goconvey icon indicating copy to clipboard operation
goconvey copied to clipboard

fix(web): fix nondeterministic tests

Open srabraham opened this issue 1 year ago • 1 comments

These integration tests were very flaky before. Running them repeatedly, e.g. by while true; do go test -count=1 ./web/server/watch; done, would lead to different errors each time on assertions about watcher results outputs.

I traced this back to integration.go's Watcher.Listen(). This function is designed to loop forever, each time looking for changes in the local filesystem, then responding if it does find changes. It's all really janky, to be honest. The problem here was that the tests were very sensitive to when input commands came in. If the recipient got two commands quickly, then you'd have the two commands processed before a scan could happen (in the select's default case). With this change, the select will always do a scan after each command is run, and it also won't sleep unnecessarily while a command is arriving.

This required an update to one test, because this caused it to run scan twice more, which is innocuous and fine.

I think this code is used for filewatching for the test web UI, and I confirmed locally that it still works.

srabraham avatar Feb 13 '24 17:02 srabraham

FYI @riannucci. This makes it so that go test ./... totally passes for me, which is awesome

srabraham avatar Feb 13 '24 18:02 srabraham

LG w/ question re: test

riannucci avatar Mar 04 '24 19:03 riannucci