Skip to content

Commit eae88e9

Browse files
committed
#45, wrapup
1 parent 301fc3b commit eae88e9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

content/posts/meetup-45-wrapup.md

+21
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,26 @@ coverage reports is: [gocovsh](https://github.com/orlangure/gocovsh).
7575

7676
### Go scheduler overlay
7777

78+
We took another view on testing, through the lens of [timestone](https://github.com/Metamogul/timestone),
7879

80+
> a library to create deterministic and easy-to-understand unit tests for time-dependent, concurrent go code.
81+
82+
It requires modification of existing code (replace go routine invocations with
83+
timestone), but after that, tests can be run in either with the system
84+
scheduler, i.e. [using
85+
goroutines](https://github.com/Metamogul/timestone/blob/7411decd9b3e1e28ef539e2bbb0ebb67b9e059d7/system/scheduler.go#L20-L29)
86+
or a [simulation
87+
scheduler](https://github.com/Metamogul/timestone/blob/7411decd9b3e1e28ef539e2bbb0ebb67b9e059d7/simulation/scheduler.go#L149-L155),
88+
that gives the caller control over the process execution.
89+
90+
By default, Go programs can exhibit non-determinism in a few places, among others in:
91+
92+
* randomized work stealing in the [scheduler](https://github.com/golang/go/blob/8e714281e441f93d2865adb3c5a507fd161314e9/src/runtime/proc.go#L7198)
93+
* randomized map [iteration](https://github.com/golang/go/blob/8b0ac33da8574b74ba50ad727b59fa8679d93e4b/src/internal/runtime/maps/map.go#L141-L142)
94+
* randomized[select clause](https://github.com/golang/go/blob/8e714281e441f93d2865adb3c5a507fd161314e9/src/runtime/select.go#L181)
95+
96+
With [timestone](https://github.com/Metamogul/timestone), it is possible to get
97+
around the scheduling randomness, when this interferes with test results. Check
98+
out some of the examples included in the library, here:
99+
[timestone/examples](https://github.com/Metamogul/timestone/tree/main/examples)
79100

0 commit comments

Comments
 (0)