From 6b7cfc9e95af8510abc801a02cda7879e4f82518 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 1 Apr 2014 07:27:34 +0000 Subject: [PATCH] Update test to reallocate port Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- .../portallocator/portallocator_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runtime/networkdriver/portallocator/portallocator_test.go b/runtime/networkdriver/portallocator/portallocator_test.go index 8b4062c37c..5a4765ddd4 100644 --- a/runtime/networkdriver/portallocator/portallocator_test.go +++ b/runtime/networkdriver/portallocator/portallocator_test.go @@ -118,6 +118,19 @@ func TestAllocateAllPorts(t *testing.T) { if err != nil { t.Fatal(err) } + + // release a port in the middle and ensure we get another tcp port + port := BeginPortRange + 5 + if err := ReleasePort(defaultIP, "tcp", port); err != nil { + t.Fatal(err) + } + newPort, err := RequestPort(defaultIP, "tcp", 0) + if err != nil { + t.Fatal(err) + } + if newPort != port { + t.Fatalf("Expected port %d got %d", port, newPort) + } } func BenchmarkAllocatePorts(b *testing.B) {