mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	the current update frequency for the refresh loop in the route 53 plugin is hard-coded to 1 minute. aws rate-limits the number of api requests so less frequent record refreshes can help when reaching those limits depending upon your individual scenarios. this pull adds a configuration option to the route53 plugin to adjust the refresh frequency. thanks for getting my last pull released so quickly. this is the last local change that i have been running and would love to get it contributed back to the project. Signed-off-by: Matt Kulka <mkulka@parchment.com>
		
			
				
	
	
		
			81 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package route53
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/aws/aws-sdk-go/aws/credentials"
 | 
						|
	"github.com/aws/aws-sdk-go/service/route53/route53iface"
 | 
						|
	"github.com/caddyserver/caddy"
 | 
						|
)
 | 
						|
 | 
						|
func TestSetupRoute53(t *testing.T) {
 | 
						|
	f := func(credential *credentials.Credentials) route53iface.Route53API {
 | 
						|
		return fakeRoute53{}
 | 
						|
	}
 | 
						|
 | 
						|
	tests := []struct {
 | 
						|
		body          string
 | 
						|
		expectedError bool
 | 
						|
	}{
 | 
						|
		{`route53`, false},
 | 
						|
		{`route53 :`, true},
 | 
						|
		{`route53 example.org:12345678`, false},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
    aws_access_key
 | 
						|
}`, true},
 | 
						|
		{`route53 example.org:12345678 { }`, false},
 | 
						|
 | 
						|
		{`route53 example.org:12345678 { }`, false},
 | 
						|
		{`route53 example.org:12345678 { wat
 | 
						|
}`, true},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
    aws_access_key ACCESS_KEY_ID SEKRIT_ACCESS_KEY
 | 
						|
}`, false},
 | 
						|
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
    fallthrough
 | 
						|
}`, false},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
		credentials
 | 
						|
	}`, true},
 | 
						|
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
		credentials default
 | 
						|
	}`, false},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
		credentials default credentials
 | 
						|
	}`, false},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
		credentials default credentials extra-arg
 | 
						|
	}`, true},
 | 
						|
		{`route53 example.org:12345678 example.org:12345678 {
 | 
						|
	}`, true},
 | 
						|
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
	refresh 90
 | 
						|
}`, false},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
	refresh 5m
 | 
						|
}`, false},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
	refresh
 | 
						|
}`, true},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
	refresh foo
 | 
						|
}`, true},
 | 
						|
		{`route53 example.org:12345678 {
 | 
						|
	refresh -1m
 | 
						|
}`, true},
 | 
						|
 | 
						|
		{`route53 example.org {
 | 
						|
	}`, true},
 | 
						|
	}
 | 
						|
 | 
						|
	for _, test := range tests {
 | 
						|
		c := caddy.NewTestController("dns", test.body)
 | 
						|
		if err := setup(c, f); (err == nil) == test.expectedError {
 | 
						|
			t.Errorf("Unexpected errors: %v", err)
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |