@@ -256,6 +256,17 @@ func createRfc2136StubProviderWithStrategy(stub *rfc2136Stub, strategy string) (
256
256
return NewRfc2136Provider ([]string {"rfc2136-host1" , "rfc2136-host2" , "rfc2136-host3" }, 0 , nil , false , "key" , "secret" , "hmac-sha512" , true , & endpoint.DomainFilter {}, false , 300 * time .Second , false , false , "" , "" , "" , 50 , tlsConfig , strategy , stub )
257
257
}
258
258
259
+ func createRfc2136StubProviderWithBatchChangeSize (stub * rfc2136Stub , batchChangeSize int ) (provider.Provider , error ) {
260
+ tlsConfig := TLSConfig {
261
+ UseTLS : false ,
262
+ SkipTLSVerify : false ,
263
+ CAFilePath : "" ,
264
+ ClientCertFilePath : "" ,
265
+ ClientCertKeyFilePath : "" ,
266
+ }
267
+ return NewRfc2136Provider ([]string {"" }, 0 , nil , false , "key" , "secret" , "hmac-sha512" , true , & endpoint.DomainFilter {}, false , 300 * time .Second , false , false , "" , "" , "" , batchChangeSize , tlsConfig , "" , stub )
268
+ }
269
+
259
270
func extractUpdateSectionFromMessage (msg fmt.Stringer ) []string {
260
271
const searchPattern = "UPDATE SECTION:"
261
272
updateSectionOffset := strings .Index (msg .String (), searchPattern )
@@ -959,3 +970,44 @@ func TestRandomLoadBalancing(t *testing.T) {
959
970
960
971
assert .Greater (t , len (nameserverCounts ), 1 , "Expected multiple nameservers to be used in random strategy" )
961
972
}
973
+
974
+ // TestRfc2136ApplyChangesWithMultipleChunks tests Updates with multiple chunks
975
+ func TestRfc2136ApplyChangesWithMultipleChunks (t * testing.T ) {
976
+ stub := newStub ()
977
+
978
+ provider , err := createRfc2136StubProviderWithBatchChangeSize (stub , 2 )
979
+ assert .NoError (t , err )
980
+
981
+ var oldRecords []* endpoint.Endpoint
982
+ var newRecords []* endpoint.Endpoint
983
+
984
+ for i := 1 ; i <= 4 ; i ++ {
985
+ oldRecords = append (oldRecords , & endpoint.Endpoint {
986
+ DNSName : fmt .Sprintf ("%s%d%s" , "v" , i , ".foo.com" ),
987
+ RecordType : "A" ,
988
+ Targets : []string {fmt .Sprintf ("10.0.0.%d" , i )},
989
+ RecordTTL : endpoint .TTL (400 ),
990
+ })
991
+ newRecords = append (newRecords , & endpoint.Endpoint {
992
+ DNSName : fmt .Sprintf ("%s%d%s" , "v" , i , ".foo.com" ),
993
+ RecordType : "A" ,
994
+ Targets : []string {fmt .Sprintf ("10.0.1.%d" , i )},
995
+ RecordTTL : endpoint .TTL (400 ),
996
+ })
997
+ }
998
+
999
+ p := & plan.Changes {
1000
+ UpdateOld : oldRecords ,
1001
+ UpdateNew : newRecords ,
1002
+ }
1003
+
1004
+ err = provider .ApplyChanges (context .Background (), p )
1005
+ assert .NoError (t , err )
1006
+
1007
+ assert .Len (t , stub .updateMsgs , 4 )
1008
+
1009
+ assert .Contains (t , stub .updateMsgs [0 ].String (), "\n v1.foo.com.\t 0\t NONE\t A\t 10.0.0.1\n v1.foo.com.\t 400\t IN\t A\t 10.0.1.1\n " )
1010
+ assert .Contains (t , stub .updateMsgs [0 ].String (), "\n v2.foo.com.\t 0\t NONE\t A\t 10.0.0.2\n v2.foo.com.\t 400\t IN\t A\t 10.0.1.2\n " )
1011
+ assert .Contains (t , stub .updateMsgs [2 ].String (), "\n v3.foo.com.\t 0\t NONE\t A\t 10.0.0.3\n v3.foo.com.\t 400\t IN\t A\t 10.0.1.3\n " )
1012
+ assert .Contains (t , stub .updateMsgs [2 ].String (), "\n v4.foo.com.\t 0\t NONE\t A\t 10.0.0.4\n v4.foo.com.\t 400\t IN\t A\t 10.0.1.4\n " )
1013
+ }
0 commit comments