From 3da0424c0b26221920fde06de841665fd45480b7 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 10:22:28 -0500 Subject: [PATCH 01/10] bug(IGNORE): issue/3227 IGNORE() deletes ignored records on some platforms --- integrationTest/integration_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 5bb42e15c7..f382f8049d 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -2351,11 +2351,29 @@ func makeTests() []*TestGroup { a("testdefined", "9.9.9.9"), ignore("testignore", "", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("testignore", "8.8.8.8"), + a("testdefined", "9.9.9.9"), + ).ExpectNoChanges(), + + tc("Verify nothing changed", + a("testignore", "8.8.8.8"), + a("testdefined", "9.9.9.9"), + ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("testignore", "8.8.8.8"), + a("testdefined", "9.9.9.9"), + ).ExpectNoChanges(), + tc("ignore with change", //a("testignore", "8.8.8.8"), a("testdefined", "2.2.2.2"), ignore("testignore", "", ""), ), + tc("VERIFY PREVIOUS", + a("testignore", "8.8.8.8"), + a("testdefined", "9.9.9.9"), + ).ExpectNoChanges(), ), // OVH features From 0bc434fb7c76ea470d87e55f493d414711f3f3cf Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 10:36:00 -0500 Subject: [PATCH 02/10] fix test --- integrationTest/integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index f382f8049d..e69f8d9a97 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -2372,7 +2372,7 @@ func makeTests() []*TestGroup { ), tc("VERIFY PREVIOUS", a("testignore", "8.8.8.8"), - a("testdefined", "9.9.9.9"), + a("testdefined", "2.2.2.2"), ).ExpectNoChanges(), ), From c5f278c26eb5c430bf726d818a3de6d7cbb69512 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 11:25:27 -0500 Subject: [PATCH 03/10] record changed records --- pkg/diff2/diff2.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/diff2/diff2.go b/pkg/diff2/diff2.go index ddfb7b6500..51a41b7d56 100644 --- a/pkg/diff2/diff2.go +++ b/pkg/diff2/diff2.go @@ -231,6 +231,8 @@ func byHelper(fn func(cc *CompareConfig) (ChangeList, int), existing models.Reco // Regroup existing/desiredd for easy comparison: cc := NewCompareConfig(dc.Name, existing, desired, compFunc) + dc.Records = desired + // Analyze and generate the instructions: instructions, actualChangeCount := fn(cc) From 051ea45cdb238dae0732f769b1fad4057827efd8 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 12:29:23 -0500 Subject: [PATCH 04/10] fix bug --- pkg/diff2/diff2.go | 45 ++++++++++++++----- providers/autodns/autoDnsProvider.go | 6 ++- providers/bind/bindProvider.go | 8 ++-- .../mythicbeasts/mythicbeastsProvider.go | 5 ++- .../realtimeregisterProvider.go | 7 +-- providers/sakuracloud/records.go | 3 +- 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/pkg/diff2/diff2.go b/pkg/diff2/diff2.go index 51a41b7d56..83ff999f65 100644 --- a/pkg/diff2/diff2.go +++ b/pkg/diff2/diff2.go @@ -205,19 +205,37 @@ func ByRecord(existing models.Records, dc *models.DomainConfig, compFunc Compara // } // // Example providers include: BIND, AUTODNS -func ByZone(existing models.Records, dc *models.DomainConfig, compFunc ComparableFunc) ([]string, bool, int, error) { - // Only return the messages. The caller has the list of records needed to build the new zone. - instructions, actualChangeCount, err := byHelper(analyzeByRecord, existing, dc, compFunc) - return justMsgs(instructions), actualChangeCount > 0, actualChangeCount, err +func ByZone(existing models.Records, dc *models.DomainConfig, compFunc ComparableFunc) (ByResults, error) { + // Only return the messages and a list of records needed to build the new zone. + result, err := byHelperStruct(analyzeByRecord, existing, dc, compFunc) + result.Msgs = justMsgs(result.Instructions) + return result, err } -// +// ByResults is the results of ByZone() and perhaps someday all the By*() functions. +// It is partially populated by // byHelperStruct() and partially by the By*() +// functions that use it. +type ByResults struct { + // Fields filled in by byHelperStruct(): + Instructions ChangeList // Instructions to turn existing into desired. + ActualChangeCount int // Number of actual changes, not including REPORTs. + HasChanges bool // True if there are any changes. + DesiredPlus models.Records // Desired + foreign + ignored + // Fields filled in by ByZone(): + Msgs []string // Just the messages from the instructions. +} -// byHelper does 90% of the work for the By*() calls. +// byHelper is like byHelperStruct but has a signature that is compatible with legacy code. +// Deprecated: Use byHelperStruct instead. func byHelper(fn func(cc *CompareConfig) (ChangeList, int), existing models.Records, dc *models.DomainConfig, compFunc ComparableFunc) (ChangeList, int, error) { + result, err := byHelperStruct(fn, existing, dc, compFunc) + return result.Instructions, result.ActualChangeCount, err +} +// byHelperStruct does 90% of the work for the By*() calls. +func byHelperStruct(fn func(cc *CompareConfig) (ChangeList, int), existing models.Records, dc *models.DomainConfig, compFunc ComparableFunc) (ByResults, error) { // Process NO_PURGE/ENSURE_ABSENT and IGNORE*(). - desired, msgs, err := handsoff( + desiredPlus, msgs, err := handsoff( dc.Name, existing, dc.Records, dc.EnsureAbsent, dc.Unmanaged, @@ -225,13 +243,11 @@ func byHelper(fn func(cc *CompareConfig) (ChangeList, int), existing models.Reco dc.KeepUnknown, ) if err != nil { - return nil, 0, err + return ByResults{}, err } // Regroup existing/desiredd for easy comparison: - cc := NewCompareConfig(dc.Name, existing, desired, compFunc) - - dc.Records = desired + cc := NewCompareConfig(dc.Name, existing, desiredPlus, compFunc) // Analyze and generate the instructions: instructions, actualChangeCount := fn(cc) @@ -247,5 +263,10 @@ func byHelper(fn func(cc *CompareConfig) (ChangeList, int), existing models.Reco instructions = append([]Change{chg}, instructions...) } - return instructions, actualChangeCount, nil + return ByResults{ + Instructions: instructions, + ActualChangeCount: actualChangeCount, + HasChanges: actualChangeCount > 0, + DesiredPlus: desiredPlus, + }, nil } diff --git a/providers/autodns/autoDnsProvider.go b/providers/autodns/autoDnsProvider.go index e0fc8a30c1..87795e0915 100644 --- a/providers/autodns/autoDnsProvider.go +++ b/providers/autodns/autoDnsProvider.go @@ -77,16 +77,18 @@ func (api *autoDNSProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, e var corrections []*models.Correction - msgs, changed, actualChangeCount, err := diff2.ByZone(existingRecords, dc, nil) + result, err := diff2.ByZone(existingRecords, dc, nil) if err != nil { return nil, 0, err } + msgs, changed, actualChangeCount := result.Msgs, result.HasChanges, result.ActualChangeCount + if changed { msgs = append(msgs, "Zone update for "+domain) msg := strings.Join(msgs, "\n") - nameServers, zoneTTL, resourceRecords := recordsToNative(dc.Records) + nameServers, zoneTTL, resourceRecords := recordsToNative(result.DesiredPlus) corrections = append(corrections, &models.Correction{ diff --git a/providers/bind/bindProvider.go b/providers/bind/bindProvider.go index 68b83b4265..0c853f95bd 100644 --- a/providers/bind/bindProvider.go +++ b/providers/bind/bindProvider.go @@ -211,7 +211,7 @@ func ParseZoneContents(content string, zoneName string, zonefileName string) (mo return foundRecords, nil } -func (n *bindProvider) EnsureZoneExists(_ string) error { +func (c *bindProvider) EnsureZoneExists(_ string) error { return nil } @@ -247,12 +247,12 @@ func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundR } var msgs []string - var err error var actualChangeCount int - msgs, changes, actualChangeCount, err = diff2.ByZone(foundRecords, dc, nil) + result, err := diff2.ByZone(foundRecords, dc, nil) if err != nil { return nil, 0, err } + msgs, changes, actualChangeCount = result.Msgs, result.HasChanges, result.ActualChangeCount if !changes { return nil, 0, nil } @@ -299,7 +299,7 @@ func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundR // Beware that if there are any fake types, then they will // be commented out on write, but we don't reverse that when // reading, so there will be a diff on every invocation. - err = prettyzone.WriteZoneFileRC(zf, dc.Records, dc.Name, 0, comments) + err = prettyzone.WriteZoneFileRC(zf, result.DesiredPlus, dc.Name, 0, comments) if err != nil { return fmt.Errorf("failed WriteZoneFile: %w", err) diff --git a/providers/mythicbeasts/mythicbeastsProvider.go b/providers/mythicbeasts/mythicbeastsProvider.go index 517a8ceb01..a386f24500 100644 --- a/providers/mythicbeasts/mythicbeastsProvider.go +++ b/providers/mythicbeasts/mythicbeastsProvider.go @@ -115,10 +115,11 @@ func zoneFileToRecords(r io.Reader, origin string) (models.Records, error) { // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (n *mythicBeastsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) ([]*models.Correction, int, error) { - msgs, changes, actualChangeCount, err := diff2.ByZone(actual, dc, nil) + result, err := diff2.ByZone(actual, dc, nil) if err != nil { return nil, 0, err } + msgs, changes, actualChangeCount := result.Msgs, result.HasChanges, result.ActualChangeCount var corrections []*models.Correction if changes { @@ -127,7 +128,7 @@ func (n *mythicBeastsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig Msg: strings.Join(msgs, "\n"), F: func() error { var b strings.Builder - for _, record := range dc.Records { + for _, record := range result.DesiredPlus { switch rr := record.ToRR().(type) { case *dns.SSHFP: // "Hex strings [for SSHFP] must be in lower-case", per Mythic Beasts API docs. diff --git a/providers/realtimeregister/realtimeregisterProvider.go b/providers/realtimeregister/realtimeregisterProvider.go index fb433fa313..47d9a4c4d4 100644 --- a/providers/realtimeregister/realtimeregisterProvider.go +++ b/providers/realtimeregister/realtimeregisterProvider.go @@ -107,10 +107,11 @@ func (api *realtimeregisterAPI) GetZoneRecords(domain string, meta map[string]st } func (api *realtimeregisterAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, existing models.Records) ([]*models.Correction, int, error) { - msgs, changes, actualChangeCount, err := diff2.ByZone(existing, dc, nil) + result, err := diff2.ByZone(existing, dc, nil) if err != nil { return nil, 0, err } + msgs, changes, actualChangeCount := result.Msgs, result.HasChanges, result.ActualChangeCount var corrections []*models.Correction @@ -149,8 +150,8 @@ func (api *realtimeregisterAPI) GetZoneRecordsCorrections(dc *models.DomainConfi &models.Correction{ Msg: strings.Join(msgs, "\n"), F: func() error { - records := make([]Record, len(dc.Records)) - for i, r := range dc.Records { + records := make([]Record, len(result.DesiredPlus)) + for i, r := range result.DesiredPlus { records[i] = toRecord(r) } zone := &Zone{Records: records, Dnssec: dnssec} diff --git a/providers/sakuracloud/records.go b/providers/sakuracloud/records.go index 126fb34e32..f029f22e24 100644 --- a/providers/sakuracloud/records.go +++ b/providers/sakuracloud/records.go @@ -65,10 +65,11 @@ func (s *sakuracloudProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, } } - msgs, changes, actualChangeCount, err := diff2.ByZone(existing, dc, nil) + result, err := diff2.ByZone(existing, dc, nil) if err != nil { return nil, 0, err } + msgs, changes, actualChangeCount := result.Msgs, result.HasChanges, result.ActualChangeCount if !changes { return nil, actualChangeCount, nil } From 552bb7636a6bbaf7fbc00987d0e47ed9b9d53b55 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 12:36:25 -0500 Subject: [PATCH 05/10] fix_sak --- pkg/diff2/diff2.go | 4 ++-- providers/sakuracloud/records.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/diff2/diff2.go b/pkg/diff2/diff2.go index 83ff999f65..4c94adddaa 100644 --- a/pkg/diff2/diff2.go +++ b/pkg/diff2/diff2.go @@ -195,13 +195,13 @@ func ByRecord(existing models.Records, dc *models.DomainConfig, compFunc Compara // // Example usage: // -// msgs, changes, err := diff2.ByZone(foundRecords, dc, nil) +// result, err := diff2.ByZone(foundRecords, dc, nil) // if err != nil { // return nil, err // } // if changes { // // Generate a "correction" that uploads the entire zone. -// // (dc.Records are the new records for the zone). +// // (result.DesiredPlus are the new records for the zone). // } // // Example providers include: BIND, AUTODNS diff --git a/providers/sakuracloud/records.go b/providers/sakuracloud/records.go index f029f22e24..d29c642b75 100644 --- a/providers/sakuracloud/records.go +++ b/providers/sakuracloud/records.go @@ -79,8 +79,8 @@ func (s *sakuracloudProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, &models.Correction{ Msg: msg, F: func() error { - drs := make([]domainRecord, 0, len(dc.Records)) - for _, rc := range dc.Records { + drs := make([]domainRecord, 0, len(result.DesiredPlus)) + for _, rc := range result.DesiredPlus { drs = append(drs, toNative(rc)) } return s.api.UpdateZone(dc.Name, drs) From 7bfee0bc72106fd767e67f7f4b43249a2ee6c9eb Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 13:41:22 -0500 Subject: [PATCH 06/10] Add VERIFY PREVIOUS to all integration tests --- integrationTest/integration_test.go | 182 +++++++++++++++++++++++++++- 1 file changed, 181 insertions(+), 1 deletion(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index e69f8d9a97..c21cab5f83 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -2093,6 +2093,14 @@ func makeTests() []*TestGroup { a("bar", "5.5.5.5"), cname("mail", "ghs.googlehosted.com."), ), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label", // NB(tlim): This ignores 1 record of a recordSet. This should // fail for diff2.ByRecordSet() providers if diff2 is not @@ -2104,6 +2112,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("foo", "", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label,type", //a("foo", "1.2.3.4"), //a("foo", "2.3.4.5"), @@ -2112,6 +2128,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("foo", "A", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label,type,target", //a("foo", "1.2.3.4"), a("foo", "2.3.4.5"), @@ -2120,6 +2144,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("foo", "A", "1.2.3.4"), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore type", //a("foo", "1.2.3.4"), //a("foo", "2.3.4.5"), @@ -2128,6 +2160,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "A", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore type,target", a("foo", "1.2.3.4"), //a("foo", "2.3.4.5"), @@ -2136,6 +2176,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "A", "2.3.4.5"), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore target", a("foo", "1.2.3.4"), //a("foo", "2.3.4.5"), @@ -2144,6 +2192,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "", "2.3.4.5"), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + // // Many types: tc("ignore manytypes", @@ -2154,7 +2210,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "A,TXT", ""), ).ExpectNoChanges(), - // + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + // Target with wildcard: tc("ignore label,type,target=*", a("foo", "1.2.3.4"), @@ -2164,6 +2227,13 @@ func makeTests() []*TestGroup { //cname("mail", "ghs.googlehosted.com."), ignore("", "CNAME", "*.googlehosted.com."), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo", "1.2.3.4"), + a("foo", "2.3.4.5"), + txt("foo", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), ), // Same as "main" but with an apex ("@") record. @@ -2175,6 +2245,7 @@ func makeTests() []*TestGroup { a("bar", "5.5.5.5"), cname("mail", "ghs.googlehosted.com."), ), + tc("ignore label", // NB(tlim): This ignores 1 record of a recordSet. This should // fail for diff2.ByRecordSet() providers if diff2 is not @@ -2190,6 +2261,14 @@ func makeTests() []*TestGroup { // that providers injects into zones are treated like input // from dnsconfig.js. ).ExpectNoChanges().UnsafeIgnore(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label,type", //a("@", "1.2.3.4"), //a("@", "2.3.4.5"), @@ -2198,6 +2277,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("@", "A", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label,type,target", //a("@", "1.2.3.4"), a("@", "2.3.4.5"), @@ -2209,6 +2296,14 @@ func makeTests() []*TestGroup { // that providers injects into zones are treated like input // from dnsconfig.js. ).ExpectNoChanges().UnsafeIgnore(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore type", //a("@", "1.2.3.4"), //a("@", "2.3.4.5"), @@ -2217,6 +2312,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "A", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore type,target", a("@", "1.2.3.4"), //a("@", "2.3.4.5"), @@ -2225,6 +2328,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "A", "2.3.4.5"), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore target", a("@", "1.2.3.4"), //a("@", "2.3.4.5"), @@ -2233,6 +2344,14 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "", "2.3.4.5"), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + // Many types: tc("ignore manytypes", //a("@", "1.2.3.4"), @@ -2242,6 +2361,13 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ignore("", "A,TXT", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("@", "1.2.3.4"), + a("@", "2.3.4.5"), + txt("@", "simple"), + a("bar", "5.5.5.5"), + cname("mail", "ghs.googlehosted.com."), + ).ExpectNoChanges(), ), // IGNORE with unsafe notation @@ -2260,6 +2386,13 @@ func makeTests() []*TestGroup { a("@", "2.2.2.2"), ignore("foo", "TXT", ""), ).ExpectNoChanges().UnsafeIgnore(), + tc("VERIFY PREVIOUS", + txt("foo", "simple"), + a("foo", "1.2.3.4"), + txt("@", "asimple"), + a("@", "2.2.2.2"), + ).ExpectNoChanges(), + tc("ignore label=apex", txt("foo", "simple"), a("foo", "1.2.3.4"), @@ -2267,6 +2400,12 @@ func makeTests() []*TestGroup { a("@", "2.2.2.2"), ignore("@", "TXT", ""), ).ExpectNoChanges().UnsafeIgnore(), + tc("VERIFY PREVIOUS", + txt("foo", "simple"), + a("foo", "1.2.3.4"), + txt("@", "asimple"), + a("@", "2.2.2.2"), + ).ExpectNoChanges(), ), // IGNORE with wildcards @@ -2279,6 +2418,14 @@ func makeTests() []*TestGroup { a("bar.bat", "5.5.5.5"), cname("mail.bat", "ghs.googlehosted.com."), ), + tc("VERIFY PREVIOUS", + a("foo.bat", "1.2.3.4"), + a("foo.bat", "2.3.4.5"), + txt("foo.bat", "simple"), + a("bar.bat", "5.5.5.5"), + cname("mail.bat", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label=foo.*", //a("foo.bat", "1.2.3.4"), //a("foo.bat", "2.3.4.5"), @@ -2287,6 +2434,14 @@ func makeTests() []*TestGroup { cname("mail.bat", "ghs.googlehosted.com."), ignore("foo.*", "", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo.bat", "1.2.3.4"), + a("foo.bat", "2.3.4.5"), + txt("foo.bat", "simple"), + a("bar.bat", "5.5.5.5"), + cname("mail.bat", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore label=foo.bat,type", //a("foo.bat", "1.2.3.4"), //a("foo.bat", "2.3.4.5"), @@ -2295,6 +2450,14 @@ func makeTests() []*TestGroup { cname("mail.bat", "ghs.googlehosted.com."), ignore("*.bat", "A", ""), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo.bat", "1.2.3.4"), + a("foo.bat", "2.3.4.5"), + txt("foo.bat", "simple"), + a("bar.bat", "5.5.5.5"), + cname("mail.bat", "ghs.googlehosted.com."), + ).ExpectNoChanges(), + tc("ignore target=*.domain", a("foo.bat", "1.2.3.4"), a("foo.bat", "2.3.4.5"), @@ -2303,6 +2466,13 @@ func makeTests() []*TestGroup { //cname("mail.bat", "ghs.googlehosted.com."), ignore("", "", "*.googlehosted.com."), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + a("foo.bat", "1.2.3.4"), + a("foo.bat", "2.3.4.5"), + txt("foo.bat", "simple"), + a("bar.bat", "5.5.5.5"), + cname("mail.bat", "ghs.googlehosted.com."), + ).ExpectNoChanges(), ), // IGNORE repro bug reports @@ -2316,6 +2486,10 @@ func makeTests() []*TestGroup { tc("Add a new record - ignoring test.foo.com.", ignoreTarget("**.acm-validations.aws.", "CNAME"), ).ExpectNoChanges(), + tc("VERIFY PREVIOUS", + cname("foo", "redact1.acm-validations.aws."), + cname("bar", "redact2.acm-validations.aws."), + ).ExpectNoChanges(), ), // https://github.com/StackExchange/dnscontrol/issues/2822 @@ -2338,6 +2512,12 @@ func makeTests() []*TestGroup { ignore("dyndns-city1", "A,AAAA", ""), ignore("dyndns-city2", "A,AAAA", ""), ).ExpectNoChanges().UnsafeIgnore(), + tc("VERIFY PREVIOUS", + a("dyndns-city1", "91.42.1.1"), + a("dyndns-city2", "91.42.1.2"), + aaaa("dyndns-city1", "2003:dd:d7ff::fe71:ce77"), + aaaa("dyndns-city2", "2003:dd:d7ff::fe71:ce78"), + ).ExpectNoChanges(), ), // https://github.com/StackExchange/dnscontrol/issues/3227 From d7739e8fb9400eb96782ef4ce5375ded6b053d44 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 15:37:43 -0500 Subject: [PATCH 07/10] mooore tests --- integrationTest/integration_test.go | 146 +++++++++++++++++++++++----- 1 file changed, 119 insertions(+), 27 deletions(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index c21cab5f83..0d9e670e14 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -2093,13 +2093,6 @@ func makeTests() []*TestGroup { a("bar", "5.5.5.5"), cname("mail", "ghs.googlehosted.com."), ), - tc("VERIFY PREVIOUS", - a("foo", "1.2.3.4"), - a("foo", "2.3.4.5"), - txt("foo", "simple"), - a("bar", "5.5.5.5"), - cname("mail", "ghs.googlehosted.com."), - ).ExpectNoChanges(), tc("ignore label", // NB(tlim): This ignores 1 record of a recordSet. This should @@ -2200,7 +2193,6 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ).ExpectNoChanges(), - // // Many types: tc("ignore manytypes", //a("foo", "1.2.3.4"), @@ -2246,7 +2238,7 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ), - tc("ignore label", + tc("apex label", // NB(tlim): This ignores 1 record of a recordSet. This should // fail for diff2.ByRecordSet() providers if diff2 is not // implemented correctly. @@ -2269,7 +2261,7 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ).ExpectNoChanges(), - tc("ignore label,type", + tc("apex label,type", //a("@", "1.2.3.4"), //a("@", "2.3.4.5"), txt("@", "simple"), @@ -2285,7 +2277,7 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ).ExpectNoChanges(), - tc("ignore label,type,target", + tc("apex label,type,target", //a("@", "1.2.3.4"), a("@", "2.3.4.5"), txt("@", "simple"), @@ -2304,7 +2296,7 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ).ExpectNoChanges(), - tc("ignore type", + tc("apex type", //a("@", "1.2.3.4"), //a("@", "2.3.4.5"), txt("@", "simple"), @@ -2320,7 +2312,7 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ).ExpectNoChanges(), - tc("ignore type,target", + tc("apex type,target", a("@", "1.2.3.4"), //a("@", "2.3.4.5"), txt("@", "simple"), @@ -2336,7 +2328,7 @@ func makeTests() []*TestGroup { cname("mail", "ghs.googlehosted.com."), ).ExpectNoChanges(), - tc("ignore target", + tc("apex target", a("@", "1.2.3.4"), //a("@", "2.3.4.5"), txt("@", "simple"), @@ -2353,7 +2345,7 @@ func makeTests() []*TestGroup { ).ExpectNoChanges(), // Many types: - tc("ignore manytypes", + tc("apex manytypes", //a("@", "1.2.3.4"), //a("@", "2.3.4.5"), //txt("@", "simple"), @@ -2372,19 +2364,20 @@ func makeTests() []*TestGroup { // IGNORE with unsafe notation - testgroup("IGNORE cross", + testgroup("IGNORE unsafe", tc("Create some records", txt("foo", "simple"), a("foo", "1.2.3.4"), txt("@", "asimple"), a("@", "2.2.2.2"), ), - tc("ignore label=apex", + + tc("ignore unsafe apex", txt("foo", "simple"), a("foo", "1.2.3.4"), txt("@", "asimple"), a("@", "2.2.2.2"), - ignore("foo", "TXT", ""), + ignore("@", "", ""), ).ExpectNoChanges().UnsafeIgnore(), tc("VERIFY PREVIOUS", txt("foo", "simple"), @@ -2393,12 +2386,12 @@ func makeTests() []*TestGroup { a("@", "2.2.2.2"), ).ExpectNoChanges(), - tc("ignore label=apex", + tc("ignore unsafe label", txt("foo", "simple"), a("foo", "1.2.3.4"), txt("@", "asimple"), a("@", "2.2.2.2"), - ignore("@", "TXT", ""), + ignore("foo", "", ""), ).ExpectNoChanges().UnsafeIgnore(), tc("VERIFY PREVIOUS", txt("foo", "simple"), @@ -2418,13 +2411,6 @@ func makeTests() []*TestGroup { a("bar.bat", "5.5.5.5"), cname("mail.bat", "ghs.googlehosted.com."), ), - tc("VERIFY PREVIOUS", - a("foo.bat", "1.2.3.4"), - a("foo.bat", "2.3.4.5"), - txt("foo.bat", "simple"), - a("bar.bat", "5.5.5.5"), - cname("mail.bat", "ghs.googlehosted.com."), - ).ExpectNoChanges(), tc("ignore label=foo.*", //a("foo.bat", "1.2.3.4"), @@ -2475,6 +2461,112 @@ func makeTests() []*TestGroup { ).ExpectNoChanges(), ), + // IGNORE with changes + testgroup("IGNORE with modify", + tc("Create some records", + a("foo", "1.1.1.1"), + a("foo", "10.10.10.10"), + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ), + + // ByZone: Change (anywhere) + tc("IGNORE change ByZone", + ignore("zzz", "A", ""), + a("foo", "1.1.1.1"), + a("foo", "11.11.11.11"), // CHANGE + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + //a("zzz", "3.3.3.3"), + //a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ), + tc("VERIFY PREVIOUS", + a("foo", "1.1.1.1"), + a("foo", "11.11.11.11"), + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ).ExpectNoChanges(), + + // ByLabel: Change within a (name) while we ignore the rest + tc("IGNORE change ByLabel", + ignore("foo", "MX", ""), + a("foo", "1.1.1.1"), + a("foo", "12.12.12.12"), // CHANGE + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + //mx("foo", 10, "aspmx.l.google.com."), + //mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ), + tc("VERIFY PREVIOUS", + a("foo", "1.1.1.1"), + a("foo", "12.12.12.12"), + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ).ExpectNoChanges(), + + // ByRecordSet: Change within a (name+type) while we ignore the rest + tc("IGNORE change ByRecordSet", + ignore("foo", "MX,AAAA", ""), + a("foo", "1.1.1.1"), + a("foo", "13.13.13.13"), // CHANGE + //aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + //mx("foo", 10, "aspmx.l.google.com."), + //mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ), + tc("VERIFY PREVIOUS", + a("foo", "1.1.1.1"), + a("foo", "13.13.13.13"), + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ).ExpectNoChanges(), + + // Change within a (name+type+data) ("ByRecord") + tc("IGNORE change ByRecord", + ignore("foo", "A", "1.1.1.1"), + //a("foo", "1.1.1.1"), + a("foo", "14.14.14.14"), + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ), + tc("VERIFY PREVIOUS", + a("foo", "1.1.1.1"), + a("foo", "14.14.14.14"), + aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), + mx("foo", 10, "aspmx.l.google.com."), + mx("foo", 20, "alt1.aspmx.l.google.com"), + a("zzz", "3.3.3.3"), + a("zzz", "4.4.4.4"), + aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), + ).ExpectNoChanges(), + ), + // IGNORE repro bug reports // https://github.com/StackExchange/dnscontrol/issues/2285 From c9c72a34d8d9cb8e9c5bd8b40139d6dacc61a3f5 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 16:04:40 -0500 Subject: [PATCH 08/10] empty From e5d5a2ff763d663d9ef08c1f21e6cc77eee312fe Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 17:55:45 -0500 Subject: [PATCH 09/10] fix MX record --- integrationTest/integration_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 0d9e670e14..82cec9e26e 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -2463,12 +2463,13 @@ func makeTests() []*TestGroup { // IGNORE with changes testgroup("IGNORE with modify", + //not("TRANSIP"), // IGNORE_with_modifyjjj tc("Create some records", a("foo", "1.1.1.1"), a("foo", "10.10.10.10"), aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), a("zzz", "3.3.3.3"), a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), @@ -2481,7 +2482,7 @@ func makeTests() []*TestGroup { a("foo", "11.11.11.11"), // CHANGE aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), //a("zzz", "3.3.3.3"), //a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), @@ -2491,7 +2492,7 @@ func makeTests() []*TestGroup { a("foo", "11.11.11.11"), aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), a("zzz", "3.3.3.3"), a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), @@ -2514,7 +2515,7 @@ func makeTests() []*TestGroup { a("foo", "12.12.12.12"), aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), a("zzz", "3.3.3.3"), a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), @@ -2537,7 +2538,7 @@ func makeTests() []*TestGroup { a("foo", "13.13.13.13"), aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), a("zzz", "3.3.3.3"), a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), @@ -2550,7 +2551,7 @@ func makeTests() []*TestGroup { a("foo", "14.14.14.14"), aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), a("zzz", "3.3.3.3"), a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), @@ -2560,7 +2561,7 @@ func makeTests() []*TestGroup { a("foo", "14.14.14.14"), aaaa("foo", "2003:dd:d7ff::fe71:aaaa"), mx("foo", 10, "aspmx.l.google.com."), - mx("foo", 20, "alt1.aspmx.l.google.com"), + mx("foo", 20, "alt1.aspmx.l.google.com."), a("zzz", "3.3.3.3"), a("zzz", "4.4.4.4"), aaaa("zzz", "2003:dd:d7ff::fe71:cccc"), From e7498ff43d43b5ef80bfdba10cf9ad16d35d7aba Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 18 Dec 2024 17:56:15 -0500 Subject: [PATCH 10/10] fixup! --- integrationTest/integration_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 82cec9e26e..8272b95f3e 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -2463,7 +2463,6 @@ func makeTests() []*TestGroup { // IGNORE with changes testgroup("IGNORE with modify", - //not("TRANSIP"), // IGNORE_with_modifyjjj tc("Create some records", a("foo", "1.1.1.1"), a("foo", "10.10.10.10"),