mirror of
https://github.com/coder/coder.git
synced 2025-07-23 21:32:07 +00:00
test(cli): fix TestServer flake due to DNS lookup (#10390)
This commit is contained in:
committed by
GitHub
parent
7732ac475a
commit
eac155aec2
@ -1206,6 +1206,14 @@ func WriteConfigMW(cfg *codersdk.DeploymentValues) clibase.MiddlewareFunc {
|
||||
// isLocalURL returns true if the hostname of the provided URL appears to
|
||||
// resolve to a loopback address.
|
||||
func IsLocalURL(ctx context.Context, u *url.URL) (bool, error) {
|
||||
// In tests, we commonly use "example.com" or "google.com", which
|
||||
// are not loopback, so avoid the DNS lookup to avoid flakes.
|
||||
if flag.Lookup("test.v") != nil {
|
||||
if u.Hostname() == "example.com" || u.Hostname() == "google.com" {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
resolver := &net.Resolver{}
|
||||
ips, err := resolver.LookupIPAddr(ctx, u.Hostname())
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user