Skip to content

Commit bdb0d60

Browse files
authored
Merge pull request #122 from jweite-amazon/fix-occasional-e2e-html-read-failures
Fix intermittent e2e deploy test failures where empty string returned as the test html
2 parents 1b99d23 + b6b56f8 commit bdb0d60

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/e2e/common.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"os"
2525
"path/filepath"
2626
"strings"
27+
"time"
2728

2829
apierrors "k8s.io/apimachinery/pkg/api/errors"
2930

@@ -187,9 +188,22 @@ func DeployAppToWorkloadClusterAndWaitForDeploymentReady(ctx context.Context, wo
187188

188189
func DownloadFromAppInWorkloadCluster(ctx context.Context, workloadKubeconfigPath string, appName string, port int, path string) (string, error) {
189190
runArgs := []string{
190-
"-i", "--restart=Never", "dummy", "--image=dockerqa/curl:ubuntu-trusty", "--command", "--", "curl", "--silent", fmt.Sprintf("%s:%d%s", appName, port, path),
191+
// Required by below: container name is runArg zero.
192+
"dummy", "-i", "--restart=Never", "--image=dockerqa/curl:ubuntu-trusty", "--command", "--", "curl", "--silent", "--show-error", fmt.Sprintf("%s:%d%s", appName, port, path),
191193
}
192-
return KubectlExec(ctx, "run", workloadKubeconfigPath, runArgs...)
194+
var result, err = KubectlExec(ctx, "run", workloadKubeconfigPath, runArgs...)
195+
if err != nil {
196+
return result, err
197+
}
198+
if result == "" {
199+
// A single retry to accommodate occasional cases where an empty string is returned, ostensibly
200+
// because the service isn't fully ready. Subsequent requests have always worked.
201+
fmt.Println("Retrying html download")
202+
time.Sleep(5 * time.Second)
203+
runArgs[0] = "dummy2" // Assumed: container name is runArg zero.
204+
result, err = KubectlExec(ctx, "run", workloadKubeconfigPath, runArgs...)
205+
}
206+
return result, err
193207
}
194208

195209
type cloudConfig struct {

0 commit comments

Comments
 (0)