2021-05-25 19:48:54 -04:00
|
|
|
// +build linux
|
|
|
|
|
2015-05-08 02:57:40 -04:00
|
|
|
package bridge
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-04-05 20:24:47 -04:00
|
|
|
"github.com/docker/docker/libnetwork/types"
|
2015-05-08 02:57:40 -04:00
|
|
|
)
|
|
|
|
|
2015-05-20 16:28:46 -04:00
|
|
|
func getPorts() []types.TransportPort {
|
|
|
|
return []types.TransportPort{
|
2016-02-12 08:07:00 -05:00
|
|
|
{Proto: types.TCP, Port: uint16(5000)},
|
|
|
|
{Proto: types.UDP, Port: uint16(400)},
|
|
|
|
{Proto: types.TCP, Port: uint16(600)},
|
2015-05-08 02:57:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLinkNew(t *testing.T) {
|
|
|
|
ports := getPorts()
|
|
|
|
|
|
|
|
link := newLink("172.0.17.3", "172.0.17.2", ports, "docker0")
|
|
|
|
|
|
|
|
if link == nil {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
if link.parentIP != "172.0.17.3" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
if link.childIP != "172.0.17.2" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
for i, p := range link.ports {
|
|
|
|
if p != ports[i] {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if link.bridge != "docker0" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|