mirror of https://github.com/docker/docker-py.git
Test port lookup with protocols
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
This commit is contained in:
parent
35714c46b1
commit
7143cf02ab
|
@ -1083,11 +1083,17 @@ class PortTest(BaseAPIIntegrationTest):
|
|||
|
||||
port_bindings = {
|
||||
'1111': ('127.0.0.1', '4567'),
|
||||
'2222': ('127.0.0.1', '4568')
|
||||
'2222': ('127.0.0.1', '4568'),
|
||||
'3333/udp': ('127.0.0.1', '4569'),
|
||||
}
|
||||
ports = [
|
||||
1111,
|
||||
2222,
|
||||
(3333, 'udp'),
|
||||
]
|
||||
|
||||
container = self.client.create_container(
|
||||
BUSYBOX, ['sleep', '60'], ports=list(port_bindings.keys()),
|
||||
BUSYBOX, ['sleep', '60'], ports=ports,
|
||||
host_config=self.client.create_host_config(
|
||||
port_bindings=port_bindings, network_mode='bridge'
|
||||
)
|
||||
|
@ -1098,13 +1104,15 @@ class PortTest(BaseAPIIntegrationTest):
|
|||
|
||||
# Call the port function on each biding and compare expected vs actual
|
||||
for port in port_bindings:
|
||||
port, _, protocol = port.partition('/')
|
||||
actual_bindings = self.client.port(container, port)
|
||||
port_binding = actual_bindings.pop()
|
||||
|
||||
ip, host_port = port_binding['HostIp'], port_binding['HostPort']
|
||||
|
||||
assert ip == port_bindings[port][0]
|
||||
assert host_port == port_bindings[port][1]
|
||||
port_binding = port if not protocol else port + "/" + protocol
|
||||
assert ip == port_bindings[port_binding][0]
|
||||
assert host_port == port_bindings[port_binding][1]
|
||||
|
||||
self.client.kill(id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue