From bf66ac9e173ceff534562c29dbfb23b955bcb274 Mon Sep 17 00:00:00 2001 From: xenolf Date: Sun, 14 Feb 2016 00:55:03 +0100 Subject: [PATCH] Resolve issue where the route53 tests would take 30secs to complete. The default AWS HTTP client retries three times with a deadline of 10 seconds in order to fetch metadata from EC2. Replaced the default HTTP client with one that does not retry and has a low timeout. --- acme/dns_challenge_route53_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/acme/dns_challenge_route53_test.go b/acme/dns_challenge_route53_test.go index 20eb008b..e57fdaa7 100644 --- a/acme/dns_challenge_route53_test.go +++ b/acme/dns_challenge_route53_test.go @@ -1,8 +1,10 @@ package acme import ( + "net/http" "os" "testing" + "time" "github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/route53" @@ -116,9 +118,18 @@ func TestNewDNSProviderRoute53MissingAuthErr(t *testing.T) { os.Setenv("AWS_SECRET_ACCESS_KEY", "") os.Setenv("AWS_CREDENTIAL_FILE", "") // in case test machine has this variable set os.Setenv("HOME", "/") // in case test machine has ~/.aws/credentials + + // The default AWS HTTP client retries three times with a deadline of 10 seconds. + // Replace the default HTTP client with one that does not retry and has a low timeout. + awsClient := aws.RetryingClient + aws.RetryingClient = &http.Client{Timeout: time.Millisecond} + _, err := NewDNSProviderRoute53("", "", "us-east-1") assert.EqualError(t, err, "No valid AWS authentication found") restoreRoute53Env() + + // restore default AWS HTTP client + aws.RetryingClient = awsClient } func TestNewDNSProviderRoute53InvalidRegionErr(t *testing.T) {