Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nfregistration/nf_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ var (
keepAliveTimerMutex sync.Mutex
registerCtxMutex sync.Mutex
afterFunc = time.AfterFunc
retryTime = 10 * time.Second
)

const (
defaultHeartbeatTimer int32 = 60
retryTime = 10 * time.Second
)

// StartNfRegistrationService starts the registration service. If the new config is empty, the NF
Expand Down
5 changes: 5 additions & 0 deletions nfregistration/nf_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,17 @@ func TestNfRegistrationService_WhenEmptyConfig_ThenContinuesListeningForUpdates(

func TestNfRegistrationService_ConfigChanged_RetryIfRegisterNFFails(t *testing.T) {
originalSendRegisterNFInstance := consumer.SendRegisterNFInstance
originalRetryTime := retryTime
retryTime = 20 * time.Millisecond
ch := make(chan []models.PlmnId, 1)
cancel, done := startRegistrationServiceForTest(t, ch)
defer func() {
cancel()
<-done
consumer.SendRegisterNFInstance = originalSendRegisterNFInstance
registerCtxMutex.Lock()
retryTime = originalRetryTime
registerCtxMutex.Unlock()
withKeepAliveTimerLock(func() {
stopKeepAliveTimer()
})
Expand Down
9 changes: 6 additions & 3 deletions polling/nf_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import (
"github.com/omec-project/openapi/v2/models"
)

const (
var (
initialPollingInterval = 5 * time.Second
pollingMaxBackoff = 40 * time.Second
pollingBackoffFactor = 2
pollingPath = "/nfconfig/plmn"
)

const (
pollingBackoffFactor = 2
pollingPath = "/nfconfig/plmn"
)

type nfConfigPoller struct {
Expand Down
6 changes: 6 additions & 0 deletions polling/nf_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func startPollingServiceForTest(t *testing.T, ch chan<- []models.PlmnId) (contex

func TestStartPollingService_Success(t *testing.T) {
originalFetchPlmnConfig := fetchPlmnConfig
originalInterval := initialPollingInterval
initialPollingInterval = 20 * time.Millisecond

expectedConfig := []models.PlmnId{{Mcc: "001", Mnc: "01"}}
fetchPlmnConfig = func(poller *nfConfigPoller, pollingEndpoint string) ([]models.PlmnId, error) {
Expand All @@ -50,6 +52,7 @@ func TestStartPollingService_Success(t *testing.T) {
cancel()
<-done
fetchPlmnConfig = originalFetchPlmnConfig
initialPollingInterval = originalInterval
}()

time.Sleep(initialPollingInterval)
Expand All @@ -66,6 +69,8 @@ func TestStartPollingService_Success(t *testing.T) {

func TestStartPollingService_RetryAfterFailure(t *testing.T) {
originalFetchPlmnConfig := fetchPlmnConfig
originalInterval := initialPollingInterval
initialPollingInterval = 20 * time.Millisecond
Comment thread
gab-arrobo marked this conversation as resolved.

var callCount atomic.Int32
fetchPlmnConfig = func(poller *nfConfigPoller, pollingEndpoint string) ([]models.PlmnId, error) {
Expand All @@ -76,6 +81,7 @@ func TestStartPollingService_RetryAfterFailure(t *testing.T) {
cancel, done := startPollingServiceForTest(t, plmnChan)
defer func() {
fetchPlmnConfig = originalFetchPlmnConfig
initialPollingInterval = originalInterval
}()
Comment thread
gab-arrobo marked this conversation as resolved.

time.Sleep(4 * initialPollingInterval)
Expand Down
Loading