Do not fail (divide by zero) if terminal width is not set. Improved a bit the ACI e2e test, happy that it catches this error (this was going to break the log gRPC API)

This commit is contained in:
Guillaume Tardif 2020-07-10 13:00:41 +02:00
parent e6c115dc17
commit d21fd7b8cf
2 changed files with 10 additions and 2 deletions

View File

@ -280,6 +280,9 @@ func streamLogs(ctx context.Context, aciContext store.AciContext, containerGroup
}
func getBacktrackLines(lines []string, terminalWidth int) int {
if terminalWidth == 0 { // no terminal width has been set, do not divide by zero
return len(lines)
}
numLines := 0
for i := 0; i < len(lines)-1; i++ {
numLines++

View File

@ -117,13 +117,18 @@ func (s *E2eACISuite) TestACIRunSingleContainer() {
outChan := make(chan string)
go func() {
output, _ := ctx.Exec()
output, err := ctx.Exec()
// check the process is cancelled by the test, not another unexpected error
Expect(err.Error()).To(ContainSubstring("timed out"))
outChan <- output
}()
// Ensure logs -- follow is strated before we curl nginx
time.Sleep(5 * time.Second)
s.NewCommand("curl", nginxExposedURL+"/test").ExecOrDie()
// Give the `logs --follow` a little time to get logs of the curl call
time.Sleep(10 * time.Second)
time.Sleep(5 * time.Second)
// Trigger a timeout to make ctx.Exec exit
timeChan <- time.Now()