forked from TrueCloudLab/lego
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.
This commit is contained in:
parent
01ac49f59a
commit
bf66ac9e17
1 changed files with 11 additions and 0 deletions
|
@ -1,8 +1,10 @@
|
||||||
package acme
|
package acme
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/goamz/aws"
|
"github.com/mitchellh/goamz/aws"
|
||||||
"github.com/mitchellh/goamz/route53"
|
"github.com/mitchellh/goamz/route53"
|
||||||
|
@ -116,9 +118,18 @@ func TestNewDNSProviderRoute53MissingAuthErr(t *testing.T) {
|
||||||
os.Setenv("AWS_SECRET_ACCESS_KEY", "")
|
os.Setenv("AWS_SECRET_ACCESS_KEY", "")
|
||||||
os.Setenv("AWS_CREDENTIAL_FILE", "") // in case test machine has this variable set
|
os.Setenv("AWS_CREDENTIAL_FILE", "") // in case test machine has this variable set
|
||||||
os.Setenv("HOME", "/") // in case test machine has ~/.aws/credentials
|
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")
|
_, err := NewDNSProviderRoute53("", "", "us-east-1")
|
||||||
assert.EqualError(t, err, "No valid AWS authentication found")
|
assert.EqualError(t, err, "No valid AWS authentication found")
|
||||||
restoreRoute53Env()
|
restoreRoute53Env()
|
||||||
|
|
||||||
|
// restore default AWS HTTP client
|
||||||
|
aws.RetryingClient = awsClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewDNSProviderRoute53InvalidRegionErr(t *testing.T) {
|
func TestNewDNSProviderRoute53InvalidRegionErr(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue