parent
c8fb66f8cc
commit
6ed88fab74
13 changed files with 380 additions and 291 deletions
|
@ -379,15 +379,15 @@ func TestServeDNS(t *testing.T) {
|
|||
|
||||
type APIConnServeTest struct{}
|
||||
|
||||
func (APIConnServeTest) HasSynced() bool { return true }
|
||||
func (APIConnServeTest) Run() { return }
|
||||
func (APIConnServeTest) Stop() error { return nil }
|
||||
func (APIConnServeTest) EpIndexReverse(string) *object.Endpoints { return nil }
|
||||
func (APIConnServeTest) SvcIndexReverse(string) *object.Service { return nil }
|
||||
func (APIConnServeTest) Modified() int64 { return time.Now().Unix() }
|
||||
func (APIConnServeTest) SetWatchChan(watch.Chan) {}
|
||||
func (APIConnServeTest) Watch(string) error { return nil }
|
||||
func (APIConnServeTest) StopWatching(string) {}
|
||||
func (APIConnServeTest) HasSynced() bool { return true }
|
||||
func (APIConnServeTest) Run() { return }
|
||||
func (APIConnServeTest) Stop() error { return nil }
|
||||
func (APIConnServeTest) EpIndexReverse(string) []*object.Endpoints { return nil }
|
||||
func (APIConnServeTest) SvcIndexReverse(string) []*object.Service { return nil }
|
||||
func (APIConnServeTest) Modified() int64 { return time.Now().Unix() }
|
||||
func (APIConnServeTest) SetWatchChan(watch.Chan) {}
|
||||
func (APIConnServeTest) Watch(string) error { return nil }
|
||||
func (APIConnServeTest) StopWatching(string) {}
|
||||
|
||||
func (APIConnServeTest) PodIndex(string) []*object.Pod {
|
||||
a := []*object.Pod{
|
||||
|
@ -396,90 +396,103 @@ func (APIConnServeTest) PodIndex(string) []*object.Pod {
|
|||
return a
|
||||
}
|
||||
|
||||
var svcIndex = map[string]*object.Service{
|
||||
"testns/svc1": {
|
||||
Name: "svc1",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "10.0.0.1",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
var svcIndex = map[string][]*object.Service{
|
||||
"svc1.testns": {
|
||||
{
|
||||
Name: "svc1",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "10.0.0.1",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
},
|
||||
},
|
||||
},
|
||||
"testns/svcempty": {
|
||||
Name: "svcempty",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "10.0.0.1",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
"svcempty.testns": {
|
||||
{
|
||||
Name: "svcempty",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "10.0.0.1",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
},
|
||||
},
|
||||
},
|
||||
"testns/svc6": {
|
||||
Name: "svc6",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "1234:abcd::1",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
"svc6.testns": {
|
||||
{
|
||||
Name: "svc6",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "1234:abcd::1",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
},
|
||||
},
|
||||
},
|
||||
"testns/hdls1": {
|
||||
Name: "hdls1",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: api.ClusterIPNone,
|
||||
},
|
||||
"testns/external": {
|
||||
|
||||
Name: "external",
|
||||
Namespace: "testns",
|
||||
ExternalName: "ext.interwebs.test",
|
||||
Type: api.ServiceTypeExternalName,
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
"hdls1.testns": {
|
||||
{
|
||||
Name: "hdls1",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: api.ClusterIPNone,
|
||||
},
|
||||
},
|
||||
"testns/external-to-service": {
|
||||
Name: "external-to-service",
|
||||
Namespace: "testns",
|
||||
ExternalName: "svc1.testns.svc.cluster.local.",
|
||||
Type: api.ServiceTypeExternalName,
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
"external.testns": {
|
||||
{
|
||||
Name: "external",
|
||||
Namespace: "testns",
|
||||
ExternalName: "ext.interwebs.test",
|
||||
Type: api.ServiceTypeExternalName,
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
},
|
||||
},
|
||||
},
|
||||
"testns/hdlsprtls": {
|
||||
Name: "hdlsprtls",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: api.ClusterIPNone,
|
||||
"external-to-service.testns": {
|
||||
{
|
||||
Name: "external-to-service",
|
||||
Namespace: "testns",
|
||||
ExternalName: "svc1.testns.svc.cluster.local.",
|
||||
Type: api.ServiceTypeExternalName,
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
},
|
||||
},
|
||||
},
|
||||
"unexposedns/svc1": {
|
||||
Name: "svc1",
|
||||
Namespace: "unexposedns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "10.0.0.2",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
"hdlsprtls.testns": {
|
||||
{
|
||||
Name: "hdlsprtls",
|
||||
Namespace: "testns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: api.ClusterIPNone,
|
||||
},
|
||||
},
|
||||
"svc1.unexposedns": {
|
||||
{
|
||||
Name: "svc1",
|
||||
Namespace: "unexposedns",
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
ClusterIP: "10.0.0.2",
|
||||
Ports: []api.ServicePort{
|
||||
{Name: "http", Protocol: "tcp", Port: 80},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func (APIConnServeTest) SvcIndex(s string) *object.Service {
|
||||
return svcIndex[s]
|
||||
}
|
||||
func (APIConnServeTest) SvcIndex(s string) []*object.Service { return svcIndex[s] }
|
||||
|
||||
func (APIConnServeTest) ServiceList() []*object.Service {
|
||||
var svcs []*object.Service
|
||||
for _, svc := range svcIndex {
|
||||
svcs = append(svcs, svc)
|
||||
svcs = append(svcs, svc...)
|
||||
}
|
||||
return svcs
|
||||
}
|
||||
|
||||
var epsIndex = map[string]*object.Endpoints{
|
||||
"testns/svc1": {
|
||||
var epsIndex = map[string][]*object.Endpoints{
|
||||
"svc1.testns": {{
|
||||
Subsets: []object.EndpointSubset{
|
||||
{
|
||||
Addresses: []object.EndpointAddress{
|
||||
|
@ -492,8 +505,8 @@ var epsIndex = map[string]*object.Endpoints{
|
|||
},
|
||||
Name: "svc1",
|
||||
Namespace: "testns",
|
||||
},
|
||||
"testns/svcempty": {
|
||||
}},
|
||||
"svcempty.testns": {{
|
||||
Subsets: []object.EndpointSubset{
|
||||
{
|
||||
Addresses: nil,
|
||||
|
@ -504,8 +517,8 @@ var epsIndex = map[string]*object.Endpoints{
|
|||
},
|
||||
Name: "svcempty",
|
||||
Namespace: "testns",
|
||||
},
|
||||
"testns/hdls1": {
|
||||
}},
|
||||
"hdls1.testns": {{
|
||||
Subsets: []object.EndpointSubset{
|
||||
{
|
||||
Addresses: []object.EndpointAddress{
|
||||
|
@ -523,8 +536,8 @@ var epsIndex = map[string]*object.Endpoints{
|
|||
},
|
||||
Name: "hdls1",
|
||||
Namespace: "testns",
|
||||
},
|
||||
"testns/hdlsprtls": {
|
||||
}},
|
||||
"hdlsprtls.testns": {{
|
||||
Subsets: []object.EndpointSubset{
|
||||
{
|
||||
Addresses: []object.EndpointAddress{
|
||||
|
@ -535,17 +548,17 @@ var epsIndex = map[string]*object.Endpoints{
|
|||
},
|
||||
Name: "hdlsprtls",
|
||||
Namespace: "testns",
|
||||
},
|
||||
}},
|
||||
}
|
||||
|
||||
func (APIConnServeTest) EpIndex(s string) *object.Endpoints {
|
||||
func (APIConnServeTest) EpIndex(s string) []*object.Endpoints {
|
||||
return epsIndex[s]
|
||||
}
|
||||
|
||||
func (APIConnServeTest) EndpointsList() []*object.Endpoints {
|
||||
var eps []*object.Endpoints
|
||||
for _, ep := range epsIndex {
|
||||
eps = append(eps, ep)
|
||||
eps = append(eps, ep...)
|
||||
}
|
||||
return eps
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue