Add retries for dns in tcp e2e test (#5283)
This commit is contained in:
parent
5cf7018b6d
commit
760f40e45c
1 changed files with 26 additions and 1 deletions
|
@ -22,12 +22,14 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||||
)
|
)
|
||||||
|
@ -170,7 +172,30 @@ var _ = framework.IngressNginxDescribe("[TCP] tcp-services", func() {
|
||||||
return d.DialContext(ctx, "tcp", fmt.Sprintf("%v:5353", ip))
|
return d.DialContext(ctx, "tcp", fmt.Sprintf("%v:5353", ip))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ips, err := resolver.LookupHost(context.Background(), "google-public-dns-b.google.com")
|
|
||||||
|
// add retries to LookupHost to avoid random e2e errors
|
||||||
|
retry := wait.Backoff{
|
||||||
|
Steps: 10,
|
||||||
|
Duration: 2 * time.Second,
|
||||||
|
Factor: 0.8,
|
||||||
|
Jitter: 0.2,
|
||||||
|
}
|
||||||
|
|
||||||
|
var ips []string
|
||||||
|
var retryErr error
|
||||||
|
err = wait.ExponentialBackoff(retry, func() (bool, error) {
|
||||||
|
ips, retryErr = resolver.LookupHost(context.Background(), "google-public-dns-b.google.com")
|
||||||
|
if retryErr == nil {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err == wait.ErrWaitTimeout {
|
||||||
|
err = retryErr
|
||||||
|
}
|
||||||
|
|
||||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error from DNS resolver")
|
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error from DNS resolver")
|
||||||
assert.Contains(ginkgo.GinkgoT(), ips, "8.8.4.4")
|
assert.Contains(ginkgo.GinkgoT(), ips, "8.8.4.4")
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue