Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions cmd/firefly.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ func run() error {
case <-orchestratorCtx.Done():
log.L(ctx).Infof("Restarting due to configuration change")
o.WaitStop()
// Re-read the configuration
config.Reset()
if err := config.ReadConfig(cfgFile); err != nil {
cancelCtx()
return err
}
case err := <-errChan:
cancelCtx()
return err
Expand Down
26 changes: 26 additions & 0 deletions cmd/firefly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@ func TestExecOkRestartThenExit(t *testing.T) {
assert.EqualError(t, err, "second run")
}

func TestExecOkRestartConfigProblem(t *testing.T) {
o := &orchestratormocks.Orchestrator{}
tmpDir, err := os.MkdirTemp(os.TempDir(), "ut")
assert.NoError(t, err)
defer os.RemoveAll(tmpDir)
o.On("IsPreInit").Return(false)
var orContext context.Context
init := o.On("Init", mock.Anything, mock.Anything, mock.Anything).Return(nil)
init.RunFn = func(a mock.Arguments) {
orContext = a[0].(context.Context)
cancelOrContext := a[1].(context.CancelFunc)
cancelOrContext()
}
o.On("Start").Return(nil)
o.On("WaitStop").Run(func(args mock.Arguments) {
<-orContext.Done()
os.Chdir(tmpDir) // this will mean we fail to read the config
})
_utOrchestrator = o
defer func() { _utOrchestrator = nil }()

os.Chdir(configDir)
err = Execute()
assert.Regexp(t, "Config File.*Not Found", err)
}

func TestAPIServerError(t *testing.T) {
o := &orchestratormocks.Orchestrator{}
o.On("Init", mock.Anything, mock.Anything).Return(nil)
Expand Down