Somehow I missed it when it was first announced, so only
recently did I discover the exciting testing/synctest experiment 
available in go1.24.

If you are a fan of repeatable, deterministic tests
for tricky concurrent code... you should really check 
out synctest.

My RPC package tests go 10x faster with the fake time
of synctest in place. Niiice.

Here is the post in case you missed it the first time
around like I did. https://go.dev/blog/synctest
And the docs, https://pkg.go.dev/testing/synctest

Caveats: one limitation of synctest is that it is kind of tricky to test 
network
code with it, because you aren't allowed to
talk to a "real" network. OS calls create
non-determinism. So you need a mocked or simulated
network, entirely in memory, using only channels,
for example.

I happened to need a network simulator myself for
testing my Raft implementation under partitions,
server power failures, reboots, etc... You know,
the general chaos that fault tolerant algorithms are
made for. Lacking a better alternative, I wrote one. 
If you dismissed synctest before because you didn't have a network
simulator... happy birthday. Gosimnet implements net.Conn
and can crash, reboot, and partition servers.
It's probably got bugs, I'd consider it alpha quality,
but those can be fixed.

https://github.com/glycerine/gosimnet

Enjoy.

Jason

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/5ca5ece6-2e40-448f-846e-a894fc8e56aan%40googlegroups.com.

Reply via email to