@@ -76,12 +76,12 @@ var _ = Describe("CertWatcher", func() {
7676 Expect (err ).ToNot (HaveOccurred ())
7777 })
7878
79- startWatcher := func () (done <- chan struct {}) {
79+ startWatcher := func (interval time. Duration ) (done <- chan struct {}) {
8080 doneCh := make (chan struct {})
8181 go func () {
8282 defer GinkgoRecover ()
8383 defer close (doneCh )
84- Expect (watcher .WithWatchInterval (time . Second ).Start (ctx )).To (Succeed ())
84+ Expect (watcher .WithWatchInterval (interval ).Start (ctx )).To (Succeed ())
8585 }()
8686 // wait till we read first cert
8787 Eventually (func () error {
@@ -92,14 +92,16 @@ var _ = Describe("CertWatcher", func() {
9292 }
9393
9494 It ("should read the initial cert/key" , func () {
95- doneCh := startWatcher ()
95+ // This test verifies the initial read succeeded. So interval doesn't matter.
96+ doneCh := startWatcher (10 * time .Second )
9697
9798 ctxCancel ()
9899 Eventually (doneCh , "4s" ).Should (BeClosed ())
99100 })
100101
101102 It ("should reload currentCert when changed" , func () {
102- doneCh := startWatcher ()
103+ // This test verifies fsnotify detects the cert change. So interval doesn't matter.
104+ doneCh := startWatcher (10 * time .Second )
103105 called := atomic.Int64 {}
104106 watcher .RegisterCallback (func (crt tls.Certificate ) {
105107 called .Add (1 )
@@ -123,7 +125,8 @@ var _ = Describe("CertWatcher", func() {
123125 })
124126
125127 It ("should reload currentCert when changed with rename" , func () {
126- doneCh := startWatcher ()
128+ // This test verifies fsnotify detects the cert change. So interval doesn't matter.
129+ doneCh := startWatcher (10 * time .Second )
127130 called := atomic.Int64 {}
128131 watcher .RegisterCallback (func (crt tls.Certificate ) {
129132 called .Add (1 )
@@ -153,7 +156,8 @@ var _ = Describe("CertWatcher", func() {
153156 })
154157
155158 It ("should reload currentCert after move out" , func () {
156- doneCh := startWatcher ()
159+ // This test verifies poll works, so we'll use 1s as interval (fsnotify doesn't detect this change).
160+ doneCh := startWatcher (1 * time .Second )
157161 called := atomic.Int64 {}
158162 watcher .RegisterCallback (func (crt tls.Certificate ) {
159163 called .Add (1 )
@@ -189,7 +193,8 @@ var _ = Describe("CertWatcher", func() {
189193 })
190194
191195 It ("should get updated on successful certificate read" , func () {
192- doneCh := startWatcher ()
196+ // This test verifies fsnotify, so interval doesn't matter.
197+ doneCh := startWatcher (10 * time .Second )
193198
194199 Eventually (func () error {
195200 readCertificateTotalAfter := testutil .ToFloat64 (metrics .ReadCertificateTotal )
@@ -204,7 +209,8 @@ var _ = Describe("CertWatcher", func() {
204209 })
205210
206211 It ("should get updated on read certificate errors" , func () {
207- doneCh := startWatcher ()
212+ // This test works with fsnotify, so interval doesn't matter.
213+ doneCh := startWatcher (10 * time .Second )
208214
209215 Eventually (func () error {
210216 readCertificateTotalAfter := testutil .ToFloat64 (metrics .ReadCertificateTotal )
0 commit comments