Skip to content

Commit

Permalink
ns: Fix test config
Browse files Browse the repository at this point in the history
  • Loading branch information
halimi committed Nov 20, 2024
1 parent 8b9e2ec commit b1b06a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
18 changes: 18 additions & 0 deletions pkg/networkserver/internal/test/shared/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,21 @@ func NewRedisScheduledDownlinkMatcher(ctx context.Context) (ScheduledDownlinkMat
cl.Close()
}
}

// NewRedisMACSettingsProfileRegistry initialize a new test Redis for MAC Settings Profile Registry.
func NewRedisMACSettingsProfileRegistry(ctx context.Context) (MACSettingsProfileRegistry, func()) {
tb := test.MustTBFromContext(ctx)
cl, flush := test.NewRedis(ctx, append(redisNamespace[:], "mac-settings-profile")...)
reg := &redis.MACSettingsProfileRegistry{
Redis: cl,
LockTTL: test.Delay << 10,
}
if err := reg.Init(ctx); err != nil {
tb.Fatalf("Failed to initialize Redis MAC Settings Profile Registry: %s", test.FormatError(err))
}
return reg,
func() {
flush()
cl.Close()
}
}
18 changes: 13 additions & 5 deletions pkg/networkserver/networkserver_util_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ var (
EvtScheduleJoinAcceptSuccess = evtScheduleJoinAcceptSuccess
EvtUpdateEndDevice = evtUpdateEndDevice

NewDeviceRegistry func(context.Context) (DeviceRegistry, func())
NewApplicationUplinkQueue func(context.Context) (ApplicationUplinkQueue, func())
NewDownlinkTaskQueue func(context.Context) (DownlinkTaskQueue, func())
NewUplinkDeduplicator func(context.Context) (UplinkDeduplicator, func())
NewScheduledDownlinkMatcher func(context.Context) (ScheduledDownlinkMatcher, func())
NewDeviceRegistry func(context.Context) (DeviceRegistry, func())
NewApplicationUplinkQueue func(context.Context) (ApplicationUplinkQueue, func())
NewDownlinkTaskQueue func(context.Context) (DownlinkTaskQueue, func())
NewUplinkDeduplicator func(context.Context) (UplinkDeduplicator, func())
NewScheduledDownlinkMatcher func(context.Context) (ScheduledDownlinkMatcher, func())
NewMACSettingsProfileRegistry func(context.Context) (MACSettingsProfileRegistry, func())
)

type DownlinkPath = downlinkPath
Expand Down Expand Up @@ -2103,6 +2104,13 @@ func StartTest(ctx context.Context, conf TestConfig) (*NetworkServer, context.Co
}
conf.NetworkServer.ScheduledDownlinkMatcher = v
}
if conf.NetworkServer.MACSettingsProfileRegistry == nil {
v, closeFn := NewMACSettingsProfileRegistry(ctx)
if closeFn != nil {
closeFuncs = append(closeFuncs, closeFn)
}
conf.NetworkServer.MACSettingsProfileRegistry = v
}

ns := test.Must(New(
componenttest.NewComponent(tb, &conf.Component, cmpOpts...),
Expand Down
1 change: 1 addition & 0 deletions pkg/networkserver/networkserver_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ func init() {
NewDownlinkTaskQueue = NewRedisDownlinkTaskQueue
NewUplinkDeduplicator = NewRedisUplinkDeduplicator
NewScheduledDownlinkMatcher = NewRedisScheduledDownlinkMatcher
NewMACSettingsProfileRegistry = NewRedisMACSettingsProfileRegistry
}

0 comments on commit b1b06a1

Please sign in to comment.