Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Applying Go 1.25's testing goodies to an existi...

Avatar for Adrian Cole Adrian Cole
September 18, 2025
5

Applying Go 1.25's testing goodies to an existing codebase

Fun chat about synctest mostly at the golang meetup in Sydney Sep 18 2025!

https://www.meetup.com/golang-syd/events/310950764/?eventOrigin=group_upcoming_events

Avatar for Adrian Cole

Adrian Cole

September 18, 2025
Tweet

Transcript

  1. Open Source history includes.. Observability: OpenZipkin, OpenTelemetry, OpenInference (GenAI obs)

    Usability: wazero (golang for wasm), func-e (easy start for envoy) Portability: Netflix Denominator (DNS clouds), jclouds (compute + storage) github.com/codefromthecrypt linkedin.com/in/adrianfcole @adrianfcole linkedin.com/in/adrianfcole • principal engineer at • focused on the genai dev -> prod transition
  2. Some recent Go testing goodies • Go 1.23: Enhanced range

    over function (handy, though not just for tests) • Go 1.24: testing.B.Loop() and my favorite t.Context(), and go vet • Go 1.25: testing/synctest for determinism and AllocsPerRun improvement You and the ecosystem: tools like testcontainers-go and our improved skill and practice!
  3. World without synctest (or workarounds) • Operations that deal with

    time.Sleep take wall time to complete • Testing goroutines ends up needing sync.Waitgroup or blocking practice • Race conditions and things like context cancelation code is hard to reach
  4. Synctest and bubbles Synthetic Time: Clock advances when system reaches

    stable state Deterministic Scheduling: Predictable goroutine execution order State Detection: "Durably blocked" means blocked on channels, select, or sleep Network I/O operations cannot span bubble boundaries Goroutine creation must occur within bubble context
  5. How limiting is this durably blocked thing? Real network connections

    break synctest bubbles. Goroutines blocked on actual network I/O are not durably blocked in synctest terms, which means: 1. synctest.Wait() won't work - it can't detect when all goroutines are properly blocked 2. Time won't advance - the bubble can't become idle 3. Tests become unreliable - mixing real network with synthetic time creates race conditions
  6. Tread carefully! httptest smartly has a Client() function This allows

    it to cleanup resources Your code may not like being handed a client!
  7. Summary advise • Go 1.25 makes things better.. again: Tests

    I showed were real stories • Don’t forget the old good: t.Setenv t.Context etc keep doing it! • Be mindful of where your code goes: Using lighter abstractions makes testing easier • synctest may require you to tinker: Sometimes the refactoring was needed anyway • This is all new: don’t trust your LLM’s knowledge.. Feed it synctest docs!
  8. Code discussed is real and Go! Join the fun! linkedin.com/in/adrianfcole

    Envoy AI Gateway - LLM and (soon) MCP gateway https://github.com/envoyproxy/ai-gateway Connect - browser and gRPC compatible APIs https://github.com/connectrpc/connect-go func-e - fetches and runs Envoy as a subprocess https://github.com/tetratelabs/func-e https://pkg.go.dev/testing/synctest@master