Skip to content

Commit

Permalink
Wait for E2E Job Pod log stream to be over before finishing E2E tests (
Browse files Browse the repository at this point in the history
…elastic#3377)

I think there are cases (eg. OCP) where streaming the E2E Pod logs is
slower than others. In such case, we may end up in a situation where, at
the end of the E2E tests, we haven't retrieved the full go test log.
Which then makes the job fail in CI since test logs cannot be parsed and
transformed to XML.

This commit solves it by waiting for the streamStatus chan to report
something (either err or nil), before returning from the
`monitorTestJob` function.
  • Loading branch information
sebgl authored and David Kowalski committed Jul 16, 2020
1 parent e69914e commit 470dc1a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/e2e/cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,12 @@ func (h *helper) monitorTestJob(client *kubernetes.Clientset) error {
}
}
case corev1.PodSucceeded:
log.Info("Tests completed successfully", "name", newPod.Name)
log.Info("Test Job succeeded, waiting for log stream to be over", "name", newPod.Name)
streamErr := <-streamStatus
if streamErr != nil {
log.Error(streamErr, "Stream failure")
err = streamErr
}
cancelFunc()
case corev1.PodFailed:
log.Info("Pod is in failed state", "name", newPod.Name)
Expand Down Expand Up @@ -484,14 +489,12 @@ func (h *helper) streamTestJobOutput(streamStatus chan<- error, client *kubernet

writer := io.MultiWriter(outputs...)
var buffer [logBufferSize]byte
if _, err := io.CopyBuffer(writer, stream, buffer[:]); err != nil {
if err == io.EOF {
log.Info("Log stream ended")
return
}

if _, err := io.CopyBuffer(writer, stream, buffer[:]); err != nil && err != io.EOF {
streamStatus <- err
return
}
log.Info("Log stream ended")
streamStatus <- nil
}

func (h *helper) kubectlApplyTemplate(templatePath string, templateParam interface{}) (string, error) {
Expand Down

0 comments on commit 470dc1a

Please sign in to comment.