plugin/test: fix TXT record comparison logic for multi-string vs multi-record scenarios #7413
+43
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a subtle but important bug in the
testplugin of CoreDNS where TXT record assertions failed to correctly distinguish between:The result was inaccurate test validations — either false positives or failures — especially in cases where long TXT records were involved.
Problem Description
In DNS, a single TXT record may be split into multiple substrings due to the 255-byte limit. For example:
This is one TXT record, not two.
The
testplugin previously compared TXT records using raw[]stringslices fromdns.TXT.Txt, like:This caused incorrect results when:
len(Txt) > 1), andSolution
The comparison logic has been updated to:
strings.Join(...)Example Fix:
Additional Changes
plugin/test/testdata/txtrecordsplit.testRunTestFileintestdata_test.goto enable isolated testinggo fmtandgolangci-lintwith no issuesImpact
This improves the reliability of the
testplugin when verifying TXT records, especially in cases involving long or split TXT strings. It ensures future plugin development or zone file testing behaves consistently with DNS standards.Related Issue
Fixes #7404