expose Endpoints API for a Sandbox
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
7cefc36f02
commit
7a76968485
3 changed files with 21 additions and 0 deletions
|
@ -1221,6 +1221,10 @@ func (f *fakeSandbox) ResolveIP(ip string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (f *fakeSandbox) Endpoints() []libnetwork.Endpoint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestExternalKey(t *testing.T) {
|
||||
externalKeyTest(t, false)
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ type Sandbox interface {
|
|||
// ResolveIP returns the service name for the passed in IP. IP is in reverse dotted
|
||||
// notation; the format used for DNS PTR records
|
||||
ResolveIP(name string) string
|
||||
// Endpoints returns all the endpoints connected to the sandbox
|
||||
Endpoints() []Endpoint
|
||||
}
|
||||
|
||||
// SandboxOption is an option setter function type used to pass various options to
|
||||
|
@ -347,6 +349,17 @@ func (sb *sandbox) setupResolutionFiles() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sb *sandbox) Endpoints() []Endpoint {
|
||||
sb.Lock()
|
||||
defer sb.Unlock()
|
||||
|
||||
endpoints := make([]Endpoint, len(sb.endpoints))
|
||||
for i, ep := range sb.endpoints {
|
||||
endpoints[i] = ep
|
||||
}
|
||||
return endpoints
|
||||
}
|
||||
|
||||
func (sb *sandbox) getConnectedEndpoints() []*endpoint {
|
||||
sb.Lock()
|
||||
defer sb.Unlock()
|
||||
|
|
|
@ -119,6 +119,10 @@ func TestSandboxAddMultiPrio(t *testing.T) {
|
|||
t.Fatal("Expected ep3 to be at the top of the heap. But did not find ep3 at the top of the heap")
|
||||
}
|
||||
|
||||
if len(sbx.Endpoints()) != 3 {
|
||||
t.Fatal("Expected 3 endpoints to be connected to the sandbox.")
|
||||
}
|
||||
|
||||
if err := ep3.Leave(sbx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue