Skip to content

Commit

Permalink
Make the 900 number lower in this test (#1176)
Browse files Browse the repository at this point in the history
Original PR doesn't make clear why this is 900-now assuming we want to
cross the 14 bit length boundary.

Up to 900 creates a super large (>2^16) message. Not sure why that needs
testing.

Also remove the packs at lower sizes.

Signed-off-by: Miek Gieben <[email protected]>
  • Loading branch information
miekg authored Oct 16, 2020
1 parent 3b0ffe4 commit 95dddd3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion length_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,19 @@ func TestMsgCompressLengthLargeRecordsWithPaddingPermutation(t *testing.T) {
}

func TestMsgCompressLengthLargeRecordsAllValues(t *testing.T) {
// we want to cross the 14 (16384) bit boundary here, so we build it up to just below and go slightly over.
msg := new(Msg)
msg.Compress = true
msg.SetQuestion("redis.service.consul.", TypeSRV)
for i := 0; i < 900; i++ {
for i := 0; i < 170; i++ {
target := fmt.Sprintf("host-redis-%d-%d.test.acme.com.node.dc1.consul.", i/256, i%256)
msg.Answer = append(msg.Answer, &SRV{Hdr: RR_Header{Name: "redis.service.consul.", Class: 1, Rrtype: TypeSRV, Ttl: 0x3c}, Port: 0x4c57, Target: target})
msg.Extra = append(msg.Extra, &CNAME{Hdr: RR_Header{Name: target, Class: ClassINET, Rrtype: TypeCNAME, Ttl: 0x3c}, Target: fmt.Sprintf("fx.168.%d.%d.", i/256, i%256)})
}
// msg.Len() == 15458
// msg.Len() == 16470 at 180

for i := 170; i < 181; i++ {
target := fmt.Sprintf("host-redis-%d-%d.test.acme.com.node.dc1.consul.", i/256, i%256)
msg.Answer = append(msg.Answer, &SRV{Hdr: RR_Header{Name: "redis.service.consul.", Class: 1, Rrtype: TypeSRV, Ttl: 0x3c}, Port: 0x4c57, Target: target})
msg.Extra = append(msg.Extra, &CNAME{Hdr: RR_Header{Name: target, Class: ClassINET, Rrtype: TypeCNAME, Ttl: 0x3c}, Target: fmt.Sprintf("fx.168.%d.%d.", i/256, i%256)})
Expand Down

0 comments on commit 95dddd3

Please sign in to comment.