diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index a4320fad7..501b2f401 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -6,11 +6,14 @@ import ( "strings" "testing" + "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/providers" _ "github.com/StackExchange/dnscontrol/v4/providers/_all" ) func TestDNSProviders(t *testing.T) { + models.DefaultTTL = 600 // Avoid problems due to minimum TTLs + provider, domain, cfg := getProvider(t) if provider == nil { return @@ -223,10 +226,11 @@ func makeTests() []*TestGroup { testgroup("TTL", not("NETCUP"), // NETCUP does not support TTLs. not("LINODE"), // Linode does not support arbitrary TTLs: 666 and 1000 are both rounded up to 3600. - tc("Start", ttl(a("@", "8.8.8.8"), 900), ttl(a("www", "1.2.3.4"), 800), ttl(a("www", "5.6.7.8"), 700)), - tc("Change a ttl", ttl(a("@", "8.8.8.8"), 911), ttl(a("www", "1.2.3.4"), 800), ttl(a("www", "5.6.7.8"), 700)), - tc("Change single ttl in set", ttl(a("@", "8.8.8.8"), 911), ttl(a("www", "1.2.3.4"), 822), ttl(a("www", "5.6.7.8"), 700)), - tc("Change all ttls", ttl(a("@", "8.8.8.8"), 933), ttl(a("www", "2.2.2.2"), 933), ttl(a("www", "5.6.7.8"), 933)), + // NOTE: Many providers require all records in a recordset have the same TTL. Don't add tests that break that rule. + tc("Start ", ttl(a("@", "8.8.8.8"), 600), ttl(a("www", "1.2.3.4"), 600), ttl(a("www", "5.6.7.8"), 600)), + tc("Change a ttl ", ttl(a("@", "8.8.8.8"), 700), ttl(a("www", "1.2.3.4"), 600), ttl(a("www", "5.6.7.8"), 600)), + tc("Change others ", ttl(a("@", "8.8.8.8"), 700), ttl(a("www", "2.2.2.2"), 800), ttl(a("www", "5.6.7.8"), 800)), + tc("Change all ttls", ttl(a("@", "8.8.8.8"), 900), ttl(a("www", "2.2.2.2"), 900), ttl(a("www", "5.6.7.8"), 900)), ), // Narrative: Did you see that `not("NETCUP")` code? NETCUP just diff --git a/models/dns.go b/models/dns.go index 384aea4d7..8e0243fa0 100644 --- a/models/dns.go +++ b/models/dns.go @@ -8,7 +8,7 @@ import ( ) // DefaultTTL is applied to any DNS record without an explicit TTL. -const DefaultTTL = uint32(300) +var DefaultTTL = uint32(300) // DNSConfig describes the desired DNS configuration, usually loaded from dnsconfig.js. type DNSConfig struct { diff --git a/providers/route53/route53Provider.go b/providers/route53/route53Provider.go index a695d4954..b605efa04 100644 --- a/providers/route53/route53Provider.go +++ b/providers/route53/route53Provider.go @@ -442,7 +442,7 @@ func nativeToRecords(set r53Types.ResourceRecordSet, origin string) ([]*models.R if set.AliasTarget != nil { rc := &models.RecordConfig{ Type: "R53_ALIAS", - TTL: 300, + TTL: models.DefaultTTL, R53Alias: map[string]string{ "type": string(set.Type), "zone_id": aws.ToString(set.AliasTarget.HostedZoneId),