@@ -15,6 +15,7 @@ import (
15
15
16
16
"github.com/hashicorp/boundary/internal/cmd/base"
17
17
"github.com/hashicorp/boundary/internal/cmd/config"
18
+ "github.com/hashicorp/boundary/internal/daemon/worker/common"
18
19
"github.com/hashicorp/boundary/internal/daemon/worker/session"
19
20
"github.com/hashicorp/boundary/internal/db"
20
21
"github.com/hashicorp/boundary/internal/event"
@@ -223,6 +224,98 @@ func TestWorkerNew(t *testing.T) {
223
224
}
224
225
}
225
226
227
+ func TestWorkerReload (t * testing.T ) {
228
+ t .Run ("default config is the same as the reload config" , func (t * testing.T ) {
229
+ require , assert := require .New (t ), assert .New (t )
230
+ cfg := & Config {
231
+ Server : & base.Server {
232
+ Logger : hclog .Default (),
233
+ Eventer : & event.Eventer {},
234
+ Listeners : []* base.ServerListener {
235
+ {Config : & listenerutil.ListenerConfig {Purpose : []string {"api" }}},
236
+ {Config : & listenerutil.ListenerConfig {Purpose : []string {"proxy" }}},
237
+ {Config : & listenerutil.ListenerConfig {Purpose : []string {"cluster" }}},
238
+ },
239
+ },
240
+ RawConfig : & config.Config {
241
+ SharedConfig : & configutil.SharedConfig {DisableMlock : true },
242
+ Worker : & config.Worker {},
243
+ },
244
+ }
245
+ w , err := New (context .Background (), cfg )
246
+ require .NoError (err )
247
+
248
+ assert .Equal (int64 (server .DefaultLiveness ), w .successfulRoutingInfoGracePeriod .Load ())
249
+ assert .Equal (int64 (server .DefaultLiveness ), w .successfulSessionInfoGracePeriod .Load ())
250
+ assert .Equal (int64 (server .DefaultLiveness ), session .CloseCallTimeout .Load ())
251
+
252
+ assert .Equal (int64 (common .DefaultRoutingInfoTimeout ), w .routingInfoCallTimeoutDuration .Load ())
253
+ assert .Equal (int64 (common .DefaultStatisticsTimeout ), w .statisticsCallTimeoutDuration .Load ())
254
+ assert .Equal (int64 (common .DefaultSessionInfoTimeout ), w .sessionInfoCallTimeoutDuration .Load ())
255
+
256
+ assert .Equal (int64 (server .DefaultLiveness ), w .getDownstreamWorkersTimeoutDuration .Load ())
257
+
258
+ w .Reload (context .Background (), cfg .RawConfig )
259
+
260
+ assert .Equal (int64 (server .DefaultLiveness ), w .successfulRoutingInfoGracePeriod .Load ())
261
+ assert .Equal (int64 (server .DefaultLiveness ), w .successfulSessionInfoGracePeriod .Load ())
262
+ assert .Equal (int64 (server .DefaultLiveness ), session .CloseCallTimeout .Load ())
263
+
264
+ assert .Equal (int64 (common .DefaultRoutingInfoTimeout ), w .routingInfoCallTimeoutDuration .Load ())
265
+ assert .Equal (int64 (common .DefaultStatisticsTimeout ), w .statisticsCallTimeoutDuration .Load ())
266
+ assert .Equal (int64 (common .DefaultSessionInfoTimeout ), w .sessionInfoCallTimeoutDuration .Load ())
267
+
268
+ assert .Equal (int64 (server .DefaultLiveness ), w .getDownstreamWorkersTimeoutDuration .Load ())
269
+ })
270
+
271
+ t .Run ("new config is the same as the reload config" , func (t * testing.T ) {
272
+ require , assert := require .New (t ), assert .New (t )
273
+ cfg := & Config {
274
+ Server : & base.Server {
275
+ Logger : hclog .Default (),
276
+ Eventer : & event.Eventer {},
277
+ Listeners : []* base.ServerListener {
278
+ {Config : & listenerutil.ListenerConfig {Purpose : []string {"api" }}},
279
+ {Config : & listenerutil.ListenerConfig {Purpose : []string {"proxy" }}},
280
+ {Config : & listenerutil.ListenerConfig {Purpose : []string {"cluster" }}},
281
+ },
282
+ },
283
+ RawConfig : & config.Config {
284
+ SharedConfig : & configutil.SharedConfig {DisableMlock : true },
285
+ Worker : & config.Worker {
286
+ SuccessfulControllerRPCGracePeriodDuration : 5 * time .Second ,
287
+ ControllerRPCCallTimeoutDuration : 10 * time .Second ,
288
+ GetDownstreamWorkersTimeoutDuration : 20 * time .Second ,
289
+ },
290
+ },
291
+ }
292
+ w , err := New (context .Background (), cfg )
293
+ require .NoError (err )
294
+
295
+ assert .Equal (int64 (5 * time .Second ), w .successfulRoutingInfoGracePeriod .Load ())
296
+ assert .Equal (int64 (5 * time .Second ), w .successfulSessionInfoGracePeriod .Load ())
297
+ assert .Equal (w .successfulRoutingInfoGracePeriod .Load (), session .CloseCallTimeout .Load ())
298
+
299
+ assert .Equal (int64 (10 * time .Second ), w .routingInfoCallTimeoutDuration .Load ())
300
+ assert .Equal (int64 (10 * time .Second ), w .statisticsCallTimeoutDuration .Load ())
301
+ assert .Equal (int64 (10 * time .Second ), w .sessionInfoCallTimeoutDuration .Load ())
302
+
303
+ assert .Equal (int64 (20 * time .Second ), w .getDownstreamWorkersTimeoutDuration .Load ())
304
+
305
+ w .Reload (context .Background (), cfg .RawConfig )
306
+
307
+ assert .Equal (int64 (5 * time .Second ), w .successfulRoutingInfoGracePeriod .Load ())
308
+ assert .Equal (int64 (5 * time .Second ), w .successfulSessionInfoGracePeriod .Load ())
309
+ assert .Equal (w .successfulRoutingInfoGracePeriod .Load (), session .CloseCallTimeout .Load ())
310
+
311
+ assert .Equal (int64 (10 * time .Second ), w .routingInfoCallTimeoutDuration .Load ())
312
+ assert .Equal (int64 (10 * time .Second ), w .statisticsCallTimeoutDuration .Load ())
313
+ assert .Equal (int64 (10 * time .Second ), w .sessionInfoCallTimeoutDuration .Load ())
314
+
315
+ assert .Equal (int64 (20 * time .Second ), w .getDownstreamWorkersTimeoutDuration .Load ())
316
+ })
317
+ }
318
+
226
319
func TestSetupWorkerAuthStorage (t * testing.T ) {
227
320
ctx := context .Background ()
228
321
0 commit comments