plugin/k8s_external: implement zone transfers (#4977)
Implement transfer for k8s_external. Notifies not supported. Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
parent
267ce8a820
commit
7263808fe1
17 changed files with 493 additions and 30 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin/kubernetes/object"
|
||||
"github.com/coredns/coredns/plugin/test"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
|
@ -170,3 +171,68 @@ func createExternalSvc(suffix int, client kubernetes.Interface, ip net.IP) {
|
|||
},
|
||||
}, meta.CreateOptions{})
|
||||
}
|
||||
|
||||
func TestServiceModified(t *testing.T) {
|
||||
var tests = []struct {
|
||||
oldSvc interface{}
|
||||
newSvc interface{}
|
||||
ichanged bool
|
||||
echanged bool
|
||||
}{
|
||||
{
|
||||
oldSvc: nil,
|
||||
newSvc: &object.Service{},
|
||||
ichanged: true,
|
||||
echanged: false,
|
||||
},
|
||||
{
|
||||
oldSvc: &object.Service{},
|
||||
newSvc: nil,
|
||||
ichanged: true,
|
||||
echanged: false,
|
||||
},
|
||||
{
|
||||
oldSvc: nil,
|
||||
newSvc: &object.Service{ExternalIPs: []string{"10.0.0.1"}},
|
||||
ichanged: true,
|
||||
echanged: true,
|
||||
},
|
||||
{
|
||||
oldSvc: &object.Service{ExternalIPs: []string{"10.0.0.1"}},
|
||||
newSvc: nil,
|
||||
ichanged: true,
|
||||
echanged: true,
|
||||
},
|
||||
{
|
||||
oldSvc: &object.Service{ExternalIPs: []string{"10.0.0.1"}},
|
||||
newSvc: &object.Service{ExternalIPs: []string{"10.0.0.2"}},
|
||||
ichanged: false,
|
||||
echanged: true,
|
||||
},
|
||||
{
|
||||
oldSvc: &object.Service{ExternalName: "10.0.0.1"},
|
||||
newSvc: &object.Service{ExternalName: "10.0.0.2"},
|
||||
ichanged: true,
|
||||
echanged: false,
|
||||
},
|
||||
{
|
||||
oldSvc: &object.Service{Ports: []api.ServicePort{{Name: "test1"}}},
|
||||
newSvc: &object.Service{Ports: []api.ServicePort{{Name: "test2"}}},
|
||||
ichanged: true,
|
||||
echanged: true,
|
||||
},
|
||||
{
|
||||
oldSvc: &object.Service{Ports: []api.ServicePort{{Name: "test1"}}},
|
||||
newSvc: &object.Service{Ports: []api.ServicePort{{Name: "test2"}, {Name: "test3"}}},
|
||||
ichanged: true,
|
||||
echanged: true,
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
ichanged, echanged := serviceModified(test.oldSvc, test.newSvc)
|
||||
if test.ichanged != ichanged || test.echanged != echanged {
|
||||
t.Errorf("Expected %v, %v for test %v. Got %v, %v", test.ichanged, test.echanged, i, ichanged, echanged)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue