Browse Source

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)

Guillaume Tardif 5 years ago
parent
commit
d21fd7b8cf
2 changed files with 10 additions and 2 deletions
  1. 3 0
      azure/aci.go
  2. 7 2
      tests/aci-e2e/e2e-aci_test.go

+ 3 - 0
azure/aci.go

@@ -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++

+ 7 - 2
tests/aci-e2e/e2e-aci_test.go

@@ -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()