mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 05:36:27 +08:00
Merge branch 'ttl_fix' into bytemain-refactor/change-min-ttl
This commit is contained in:
commit
2cdbda7861
5 changed files with 14 additions and 7 deletions
|
|
@ -433,7 +433,7 @@ func loc(name string, d1 uint8, m1 uint8, s1 float32, ns string,
|
||||||
func makeRec(name, target, typ string) *models.RecordConfig {
|
func makeRec(name, target, typ string) *models.RecordConfig {
|
||||||
r := &models.RecordConfig{
|
r := &models.RecordConfig{
|
||||||
Type: typ,
|
Type: typ,
|
||||||
TTL: 600,
|
TTL: models.DefaultTTL,
|
||||||
}
|
}
|
||||||
SetLabel(r, name, "**current-domain**.")
|
SetLabel(r, name, "**current-domain**.")
|
||||||
r.MustSetTarget(target)
|
r.MustSetTarget(target)
|
||||||
|
|
@ -570,6 +570,7 @@ func testgroup(desc string, items ...interface{}) *TestGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tc(desc string, recs ...*models.RecordConfig) *TestCase {
|
func tc(desc string, recs ...*models.RecordConfig) *TestCase {
|
||||||
|
desc = strings.TrimSpace(desc)
|
||||||
var records []*models.RecordConfig
|
var records []*models.RecordConfig
|
||||||
var unmanagedItems []*models.UnmanagedConfig
|
var unmanagedItems []*models.UnmanagedConfig
|
||||||
for _, r := range recs {
|
for _, r := range recs {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/StackExchange/dnscontrol/v4/models"
|
||||||
"github.com/StackExchange/dnscontrol/v4/pkg/credsfile"
|
"github.com/StackExchange/dnscontrol/v4/pkg/credsfile"
|
||||||
"github.com/StackExchange/dnscontrol/v4/providers"
|
"github.com/StackExchange/dnscontrol/v4/providers"
|
||||||
"github.com/StackExchange/dnscontrol/v4/providers/cloudflare"
|
"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, `, `) + ` }`)
|
metadata = []byte(`{ ` + strings.Join(items, `, `) + ` }`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if profileType == "ALIDNS" {
|
||||||
|
models.DefaultTTL = 600
|
||||||
|
}
|
||||||
|
|
||||||
provider, err := providers.CreateDNSProvider(profileType, cfg, metadata)
|
provider, err := providers.CreateDNSProvider(profileType, cfg, metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
||||||
|
|
@ -223,10 +223,11 @@ func makeTests() []*TestGroup {
|
||||||
testgroup("TTL",
|
testgroup("TTL",
|
||||||
not("NETCUP"), // NETCUP does not support TTLs.
|
not("NETCUP"), // NETCUP does not support TTLs.
|
||||||
not("LINODE"), // Linode does not support arbitrary TTLs: 666 and 1000 are both rounded up to 3600.
|
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")),
|
// NOTE: Many providers require all records in a recordset have the same TTL. Don't add tests that break that rule.
|
||||||
tc("Change a ttl", ttl(a("@", "8.8.8.8"), 1000), a("www", "1.2.3.4"), a("www", "5.6.7.8")),
|
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 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 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 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)),
|
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
|
// Narrative: Did you see that `not("NETCUP")` code? NETCUP just
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultTTL is applied to any DNS record without an explicit TTL.
|
// 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.
|
// DNSConfig describes the desired DNS configuration, usually loaded from dnsconfig.js.
|
||||||
type DNSConfig struct {
|
type DNSConfig struct {
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,7 @@ func nativeToRecords(set r53Types.ResourceRecordSet, origin string) ([]*models.R
|
||||||
if set.AliasTarget != nil {
|
if set.AliasTarget != nil {
|
||||||
rc := &models.RecordConfig{
|
rc := &models.RecordConfig{
|
||||||
Type: "R53_ALIAS",
|
Type: "R53_ALIAS",
|
||||||
TTL: 300,
|
TTL: models.DefaultTTL,
|
||||||
R53Alias: map[string]string{
|
R53Alias: map[string]string{
|
||||||
"type": string(set.Type),
|
"type": string(set.Type),
|
||||||
"zone_id": aws.ToString(set.AliasTarget.HostedZoneId),
|
"zone_id": aws.ToString(set.AliasTarget.HostedZoneId),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue