MCPcopy Create free account
hub / github.com/pace/bricks / testRunBlocksAfterShutdown

Function testRunBlocksAfterShutdown

pkg/routine/routine_test.go:87–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func testRunBlocksAfterShutdown(t *testing.T) {
88 var endOfTest sync.WaitGroup
89 endOfTest.Add(1)
90
91 // start routine that gets canceled by the shutdown
92 routineCtx := make(chan context.Context)
93 routine.Run(context.Background(), func(ctx context.Context) {
94 routineCtx <- ctx
95 endOfTest.Wait()
96 })
97
98 // kill this process
99 err := syscall.Kill(syscall.Getpid(), syscall.SIGINT)
100 require.NoError(t, err)
101
102 // wait until the routine gets canceled because of the shutdown
103 <-(<-routineCtx).Done()
104
105 // start routine
106 done := make(chan struct{})
107 go func() {
108 waitForRun(context.Background(), nil)
109 done <- struct{}{}
110 }()
111 select {
112 case <-done:
113 t.Fatal("routine started after shutdown")
114 case <-time.After(10 * time.Millisecond):
115 // good
116 }
117}
118
119func TestRun_cancelsContextsOnSIGINT(t *testing.T) {
120 t.Skip("test not working properly in docker, skipping")

Callers

nothing calls this directly

Calls 5

RunFunction · 0.92
waitForRunFunction · 0.85
WaitMethod · 0.80
FatalMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…