···16 "time"
1718 "github.com/acarl005/stripansi"
019 "github.com/stretchr/testify/require"
20 "stream.place/streamplace/pkg/gstinit"
21)
···103 os.Exit(m.Run())
104}
10500106func getLeakCount(t *testing.T) int {
0000000000000000107 if os.Getenv(IgnoreLeaks) != "" {
108 return 0
109 }
···116117 // we want CI to be extra reliable here and a little slower is okay
118 flushes := 2
119- if os.Getenv("CI") != "" {
120- flushes = 5
121- }
122123 for range flushes {
124 ch := make(chan struct{})
···143 <-ch
144 }()
145 }
146-147- time.Sleep(time.Duration(flushes) * time.Second)
148149 err = process.Signal(os.Signal(syscall.SIGUSR1))
150 require.NoError(t, err)
···16 "time"
1718 "github.com/acarl005/stripansi"
19+ "github.com/cenkalti/backoff/v5"
20 "github.com/stretchr/testify/require"
21 "stream.place/streamplace/pkg/gstinit"
22)
···104 os.Exit(m.Run())
105}
106107+// Often the GC is instance, but sometimes it takes a while. So, we retry a few times
108+// with exponential backoff, giving the GC more time to do its thing.
109func getLeakCount(t *testing.T) int {
110+ ticker := backoff.NewTicker(backoff.NewExponentialBackOff())
111+ defer ticker.Stop()
112+ var leaks int
113+ for i := 0; i < 10; i++ {
114+ leaks = getLeakCountInner(t)
115+ if leaks == 0 {
116+ return leaks
117+ }
118+ if i < 9 {
119+ <-ticker.C
120+ }
121+ }
122+ return leaks
123+}
124+125+func getLeakCountInner(t *testing.T) int {
126 if os.Getenv(IgnoreLeaks) != "" {
127 return 0
128 }
···135136 // we want CI to be extra reliable here and a little slower is okay
137 flushes := 2
000138139 for range flushes {
140 ch := make(chan struct{})
···159 <-ch
160 }()
161 }
00162163 err = process.Signal(os.Signal(syscall.SIGUSR1))
164 require.NoError(t, err)