diff --git a/integrationTest/helpers_integration_test.go b/integrationTest/helpers_integration_test.go index 0b29bcf43..348193efb 100644 --- a/integrationTest/helpers_integration_test.go +++ b/integrationTest/helpers_integration_test.go @@ -433,7 +433,7 @@ func loc(name string, d1 uint8, m1 uint8, s1 float32, ns string, func makeRec(name, target, typ string) *models.RecordConfig { r := &models.RecordConfig{ Type: typ, - TTL: 600, + TTL: models.DefaultTTL, } SetLabel(r, name, "**current-domain**.") r.MustSetTarget(target) @@ -570,6 +570,7 @@ func testgroup(desc string, items ...interface{}) *TestGroup { } func tc(desc string, recs ...*models.RecordConfig) *TestCase { + desc = strings.TrimSpace(desc) var records []*models.RecordConfig var unmanagedItems []*models.UnmanagedConfig for _, r := range recs { diff --git a/integrationTest/helpers_test.go b/integrationTest/helpers_test.go index 3c174b716..d18640684 100644 --- a/integrationTest/helpers_test.go +++ b/integrationTest/helpers_test.go @@ -9,6 +9,7 @@ import ( "strings" "testing" + "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/credsfile" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/StackExchange/dnscontrol/v4/providers/cloudflare" @@ -117,6 +118,10 @@ func getProvider(t *testing.T) (providers.DNSServiceProvider, string, map[string metadata = []byte(`{ ` + strings.Join(items, `, `) + ` }`) } + if profileType == "ALIDNS" { + models.DefaultTTL = 600 + } + provider, err := providers.CreateDNSProvider(profileType, cfg, metadata) if err != nil { t.Fatal(err) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 6f999cdfc..ec01e0a49 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -223,10 +223,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"), 666), a("www", "1.2.3.4"), a("www", "5.6.7.8")), - tc("Change a ttl", ttl(a("@", "8.8.8.8"), 1000), a("www", "1.2.3.4"), a("www", "5.6.7.8")), - tc("Change single target from set", ttl(a("@", "8.8.8.8"), 1000), a("www", "2.2.2.2"), a("www", "5.6.7.8")), - tc("Change all ttls", ttl(a("@", "8.8.8.8"), 900), ttl(a("www", "2.2.2.2"), 800), ttl(a("www", "5.6.7.8"), 700)), + // 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),