···1616 "time"
17171818 "github.com/acarl005/stripansi"
1919+ "github.com/cenkalti/backoff/v5"
1920 "github.com/stretchr/testify/require"
2021 "stream.place/streamplace/pkg/gstinit"
2122)
···103104 os.Exit(m.Run())
104105}
105106107107+// Often the GC is instance, but sometimes it takes a while. So, we retry a few times
108108+// with exponential backoff, giving the GC more time to do its thing.
106109func getLeakCount(t *testing.T) int {
110110+ ticker := backoff.NewTicker(backoff.NewExponentialBackOff())
111111+ defer ticker.Stop()
112112+ var leaks int
113113+ for i := 0; i < 10; i++ {
114114+ leaks = getLeakCountInner(t)
115115+ if leaks == 0 {
116116+ return leaks
117117+ }
118118+ if i < 9 {
119119+ <-ticker.C
120120+ }
121121+ }
122122+ return leaks
123123+}
124124+125125+func getLeakCountInner(t *testing.T) int {
107126 if os.Getenv(IgnoreLeaks) != "" {
108127 return 0
109128 }
···116135117136 // we want CI to be extra reliable here and a little slower is okay
118137 flushes := 2
119119- if os.Getenv("CI") != "" {
120120- flushes = 5
121121- }
122138123139 for range flushes {
124140 ch := make(chan struct{})
···143159 <-ch
144160 }()
145161 }
146146-147147- time.Sleep(time.Duration(flushes) * time.Second)
148162149163 err = process.Signal(os.Signal(syscall.SIGUSR1))
150164 require.NoError(t, err)