@@ -77,12 +77,12 @@ var _ = Describe("CertWatcher", func() {
77
77
Expect (err ).ToNot (HaveOccurred ())
78
78
})
79
79
80
- startWatcher := func () (done <- chan struct {}) {
80
+ startWatcher := func (interval time. Duration ) (done <- chan struct {}) {
81
81
doneCh := make (chan struct {})
82
82
go func () {
83
83
defer GinkgoRecover ()
84
84
defer close (doneCh )
85
- Expect (watcher .WithWatchInterval (time . Second ).Start (ctx )).To (Succeed ())
85
+ Expect (watcher .WithWatchInterval (interval ).Start (ctx )).To (Succeed ())
86
86
}()
87
87
// wait till we read first cert
88
88
Eventually (func () error {
@@ -93,14 +93,16 @@ var _ = Describe("CertWatcher", func() {
93
93
}
94
94
95
95
It ("should read the initial cert/key" , func () {
96
- doneCh := startWatcher ()
96
+ // This test verifies the initial read succeeded. So interval doesn't matter.
97
+ doneCh := startWatcher (10 * time .Second )
97
98
98
99
ctxCancel ()
99
100
Eventually (doneCh , "4s" ).Should (BeClosed ())
100
101
})
101
102
102
103
It ("should reload currentCert when changed" , func () {
103
- doneCh := startWatcher ()
104
+ // This test verifies fsnotify detects the cert change. So interval doesn't matter.
105
+ doneCh := startWatcher (10 * time .Second )
104
106
called := atomic.Int64 {}
105
107
watcher .RegisterCallback (func (crt tls.Certificate ) {
106
108
called .Add (1 )
@@ -124,7 +126,8 @@ var _ = Describe("CertWatcher", func() {
124
126
})
125
127
126
128
It ("should reload currentCert when changed with rename" , func () {
127
- doneCh := startWatcher ()
129
+ // This test verifies fsnotify detects the cert change. So interval doesn't matter.
130
+ doneCh := startWatcher (10 * time .Second )
128
131
called := atomic.Int64 {}
129
132
watcher .RegisterCallback (func (crt tls.Certificate ) {
130
133
called .Add (1 )
@@ -154,7 +157,8 @@ var _ = Describe("CertWatcher", func() {
154
157
})
155
158
156
159
It ("should reload currentCert after move out" , func () {
157
- doneCh := startWatcher ()
160
+ // This test verifies poll works, so we'll use 1s as interval (fsnotify doesn't detect this change).
161
+ doneCh := startWatcher (1 * time .Second )
158
162
called := atomic.Int64 {}
159
163
watcher .RegisterCallback (func (crt tls.Certificate ) {
160
164
called .Add (1 )
@@ -190,7 +194,8 @@ var _ = Describe("CertWatcher", func() {
190
194
})
191
195
192
196
It ("should get updated on successful certificate read" , func () {
193
- doneCh := startWatcher ()
197
+ // This test verifies fsnotify, so interval doesn't matter.
198
+ doneCh := startWatcher (10 * time .Second )
194
199
195
200
Eventually (func () error {
196
201
readCertificateTotalAfter := testutil .ToFloat64 (metrics .ReadCertificateTotal )
@@ -205,7 +210,8 @@ var _ = Describe("CertWatcher", func() {
205
210
})
206
211
207
212
It ("should get updated on read certificate errors" , func () {
208
- doneCh := startWatcher ()
213
+ // This test works with fsnotify, so interval doesn't matter.
214
+ doneCh := startWatcher (10 * time .Second )
209
215
210
216
Eventually (func () error {
211
217
readCertificateTotalAfter := testutil .ToFloat64 (metrics .ReadCertificateTotal )
0 commit comments