Skip to content

Commit

Permalink
Backport of NET-7630 - Fix TXT record creation on node queries into r…
Browse files Browse the repository at this point in the history
…elease/1.18.x (#20500)

NET-7630 - Fix TXT record creation on node queries (#20483)

Co-authored-by: John Murret <[email protected]>
  • Loading branch information
hc-github-team-consul-core and jmurret authored Feb 6, 2024
1 parent d9bedd0 commit a118821
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 70 deletions.
30 changes: 20 additions & 10 deletions agent/dns_node_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/hashicorp/consul/testrpc"
)

// TODO (v2-dns): Failing on "lookup a non-existing node, we should receive a SOA"
// it is coming back empty.
func TestDNS_NodeLookup(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -117,13 +119,12 @@ func TestDNS_NodeLookup(t *testing.T) {
}
}

func TestDNS_CaseInsensitiveNodeLookup(t *testing.T) {
func TestDNS_NodeLookup_CaseInsensitive(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
}

t.Parallel()
for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -157,6 +158,8 @@ func TestDNS_CaseInsensitiveNodeLookup(t *testing.T) {
}
}

// TODO (v2-dns): NET-7632 - Fix node lookup when question name has a period in it.
// Answer is coming back empty
func TestDNS_NodeLookup_PeriodName(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -210,8 +213,7 @@ func TestDNS_NodeLookup_AAAA(t *testing.T) {
t.Skip("too slow for testing.Short")
}

t.Parallel()
for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -256,6 +258,11 @@ func TestDNS_NodeLookup_AAAA(t *testing.T) {
}
}

// TODO (v2-dns): NET-7631 - Implement external CNAME references
// Failing on answer assertion. some CNAMEs are not getting created
// and the record type on the AAAA record is incorrect.
// External services do not appear to be working properly here
// and in the service lookup tests.
func TestDNS_NodeLookup_CNAME(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -329,7 +336,7 @@ func TestDNS_NodeLookup_TXT(t *testing.T) {
t.Skip("too slow for testing.Short")
}

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -383,7 +390,7 @@ func TestDNS_NodeLookup_TXT_DontSuppress(t *testing.T) {
t.Skip("too slow for testing.Short")
}

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, `dns_config = { enable_additional_node_meta_txt = false } `+experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -437,7 +444,7 @@ func TestDNS_NodeLookup_ANY(t *testing.T) {
t.Skip("too slow for testing.Short")
}

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -486,7 +493,7 @@ func TestDNS_NodeLookup_ANY_DontSuppressTXT(t *testing.T) {
t.Skip("too slow for testing.Short")
}

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, `dns_config = { enable_additional_node_meta_txt = false } `+experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -535,7 +542,7 @@ func TestDNS_NodeLookup_A_SuppressTXT(t *testing.T) {
t.Skip("too slow for testing.Short")
}

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, `dns_config = { enable_additional_node_meta_txt = false } `+experimentsHCL)
defer a.Shutdown()
Expand Down Expand Up @@ -574,6 +581,9 @@ func TestDNS_NodeLookup_A_SuppressTXT(t *testing.T) {
}
}

// TODO (v2-dns): NET-7631 - Implement external CNAME references
// Failing on "Should have the CNAME record + a few A records" comment
// External services do not appear to be working properly here either.
func TestDNS_NodeLookup_TTL(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down
42 changes: 23 additions & 19 deletions agent/dns_service_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func TestDNS_ServiceLookupMultiAddrNoCNAME(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7640 - NS Record not populate on some invalid service / prepared query lookups.
func TestDNS_ServiceLookup(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -657,6 +657,7 @@ func TestDNS_ServiceLookupWithInternalServiceAddress(t *testing.T) {
}
}

// TODO (v2-dns): NET-7659 - Fix Ingress and Connect Service Lookups
func TestDNS_ConnectServiceLookup(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -710,6 +711,7 @@ func TestDNS_ConnectServiceLookup(t *testing.T) {
}
}

// TODO (v2-dns): NET-7659 - Fix Ingress and Connect Service Lookups
func TestDNS_IngressServiceLookup(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -1128,7 +1130,7 @@ func TestDNS_ExternalServiceToConsulCNAMENestedLookup(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7636 - Implement target having encoded IP address
func TestDNS_ServiceLookup_ServiceAddress_A(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -1230,7 +1232,7 @@ func TestDNS_ServiceLookup_ServiceAddress_A(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7636 - Implement target having encoded IP address
func TestDNS_AltDomain_ServiceLookup_ServiceAddress_A(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -1461,7 +1463,7 @@ func TestDNS_ServiceLookup_ServiceAddress_SRV(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7636 - Implement target having encoded IP address
func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -1563,7 +1565,7 @@ func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7636 - Implement target having encoded IP address
func TestDNS_AltDomain_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -1672,7 +1674,7 @@ func TestDNS_AltDomain_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7634 - Implement WAN translation
func TestDNS_ServiceLookup_WanTranslation(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -1889,8 +1891,7 @@ func TestDNS_ServiceLookup_WanTranslation(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
func TestDNS_CaseInsensitiveServiceLookup(t *testing.T) {
func TestDNS_ServiceLookup_CaseInsensitive(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
}
Expand Down Expand Up @@ -1992,7 +1993,7 @@ func TestDNS_CaseInsensitiveServiceLookup(t *testing.T) {
}
}

// TODO (v2-dns): this returns a response where the answer is an SOA record
// TODO (v2-dns): NET-7632 - Fix node and prepared query lookups when question name has a period in it
func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2073,7 +2074,7 @@ func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
}
}

// TODO (v2-dns): this returns a response where the answer is an SOA record
// TODO (v2-dns): NET-7632 - Fix node and prepared query lookups when question name has a period in it.
func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2273,7 +2274,7 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7641 - Service lookups not properly de-duping SRV records
func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2413,6 +2414,7 @@ func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) {
}
}

// TODO (v2-dns): NET-7637 - implementing health filtering
func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2577,6 +2579,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
}
}

// TODO (v2-dns): NET-7637 - implementing health filtering
func TestDNS_ServiceLookup_OnlyFailing(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2698,6 +2701,7 @@ func TestDNS_ServiceLookup_OnlyFailing(t *testing.T) {
}
}

// TODO (v2-dns): NET-7637 - implementing health filtering
func TestDNS_ServiceLookup_OnlyPassing(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2849,7 +2853,7 @@ func TestDNS_ServiceLookup_OnlyPassing(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7635 - Fix dns: overflowing header size in tests
func TestDNS_ServiceLookup_Randomize(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -2949,7 +2953,7 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7635 - Fix dns: overflowing header size in tests
func TestDNS_ServiceLookup_Truncate(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -3027,7 +3031,7 @@ func TestDNS_ServiceLookup_Truncate(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
// TODO (v2-dns): NET-7638 - Implemented truncated response
func TestDNS_ServiceLookup_LargeResponses(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -3321,6 +3325,7 @@ func checkDNSService(
}
}

// TODO (v2-dns): NET-7633 - implement answer limits.
func TestDNS_ServiceLookup_ARecordLimits(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -3407,6 +3412,7 @@ func TestDNS_ServiceLookup_ARecordLimits(t *testing.T) {
}
}

// TODO (v2-dns): NET-7633 - implement answer limits.
func TestDNS_ServiceLookup_AnswerLimits(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand Down Expand Up @@ -3482,7 +3488,6 @@ func TestDNS_ServiceLookup_AnswerLimits(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
func TestDNS_ServiceLookup_CNAME(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand All @@ -3497,7 +3502,7 @@ func TestDNS_ServiceLookup_CNAME(t *testing.T) {
})
defer recursor.Shutdown()

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, `
recursors = ["`+recursor.Addr+`"]
Expand Down Expand Up @@ -3588,7 +3593,6 @@ func TestDNS_ServiceLookup_CNAME(t *testing.T) {
}
}

// TODO (v2-dns): this requires a prepared query
func TestDNS_ServiceLookup_ServiceAddress_CNAME(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
Expand All @@ -3603,7 +3607,7 @@ func TestDNS_ServiceLookup_ServiceAddress_CNAME(t *testing.T) {
})
defer recursor.Shutdown()

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, `
recursors = ["`+recursor.Addr+`"]
Expand Down Expand Up @@ -4010,7 +4014,7 @@ func TestDNS_ServiceLookup_FilterACL(t *testing.T) {
}
`

for name, experimentsHCL := range getVersionHCL(false) {
for name, experimentsHCL := range getVersionHCL(true) {
t.Run(name, func(t *testing.T) {
a := NewTestAgent(t, hcl+experimentsHCL)
defer a.Shutdown()
Expand Down
Loading

0 comments on commit a118821

Please sign in to comment.