Skip to content

Commit

Permalink
[Akshat] Exit with non-zero status code on proc execution submission …
Browse files Browse the repository at this point in the history
…and streaming logs errors
  • Loading branch information
Tasdik Rahman committed Dec 17, 2018
1 parent 44846f4 commit 9d0ea9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/execution/executioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ func NewCmd(printer io.Printer, proctorDClient daemon.Client, osExitFunc func(in

executedProcName, err := proctorDClient.ExecuteProc(procName, procArgs)
if err != nil {
osExitFunc(1)
printer.Println("Error submitting proc for execution", color.FgRed)
return
}

printer.Println("Proc submitted for execution. \nStreaming logs:", color.FgGreen)
err = proctorDClient.StreamProcLogs(executedProcName)
if err != nil {
osExitFunc(1)
printer.Println("Error Streaming Logs", color.FgRed)
return
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/execution/executioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ func (s *ExecutionCmdTestSuite) TestExecutionCmdForProctorDExecutionFailure() {

s.mockPrinter.On("Println", "Error submitting proc for execution", color.FgRed).Once()

s.testExecutionCmd.Run(&cobra.Command{}, args)
osExitFunc := func(exitCode int) {
assert.Equal(s.T(), 1, exitCode)
}
testExecutionCmdOSExit := NewCmd(s.mockPrinter, s.mockProctorDClient, osExitFunc)
testExecutionCmdOSExit.Run(&cobra.Command{}, args)

s.mockProctorDClient.AssertExpectations(s.T())
s.mockPrinter.AssertExpectations(s.T())
Expand All @@ -142,7 +146,11 @@ func (s *ExecutionCmdTestSuite) TestExecutionCmdForProctorDLogStreamingFailure()
s.mockProctorDClient.On("StreamProcLogs", "executed-proc-name").Return(errors.New("error")).Once()
s.mockPrinter.On("Println", "Error Streaming Logs", color.FgRed).Once()

s.testExecutionCmd.Run(&cobra.Command{}, args)
osExitFunc := func(exitCode int) {
assert.Equal(s.T(), 1, exitCode)
}
testExecutionCmdOSExit := NewCmd(s.mockPrinter, s.mockProctorDClient, osExitFunc)
testExecutionCmdOSExit.Run(&cobra.Command{}, args)

s.mockProctorDClient.AssertExpectations(s.T())
s.mockPrinter.AssertExpectations(s.T())
Expand Down

0 comments on commit 9d0ea9d

Please sign in to comment.