From 147962d10191ab2c54b1f96b0c300694d57dbcad Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 8 Jun 2015 12:03:06 +0100 Subject: [PATCH] Clarify some unit test operations --- ipam/allocator_test.go | 4 ++-- ipam/http_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ipam/allocator_test.go b/ipam/allocator_test.go index d8473c0d..ccf1043a 100644 --- a/ipam/allocator_test.go +++ b/ipam/allocator_test.go @@ -38,13 +38,13 @@ func TestAllocFree(t *testing.T) { _, cidr2, _ := address.ParseCIDR(subnet2) alloc.claimRingForTesting() - addr1, _ := alloc.Allocate(container1, cidr1, nil) + addr1, err := alloc.Allocate(container1, cidr1, nil) + wt.AssertNoErr(t, err) wt.AssertEqualString(t, addr1.String(), testAddr1, "address") addr2, err := alloc.Allocate(container1, cidr2, nil) wt.AssertNoErr(t, err) wt.AssertEqualString(t, addr2.String(), testAddr2, "address") - CheckAllExpectedMessagesSent(alloc) // Ask for another address for a different container and check it's different addr1b, _ := alloc.Allocate(container2, cidr1, nil) diff --git a/ipam/http_test.go b/ipam/http_test.go index 68578bf9..bdf48277 100644 --- a/ipam/http_test.go +++ b/ipam/http_test.go @@ -74,22 +74,22 @@ func TestHttp(t *testing.T) { container2 = "baddf00d" container3 = "b01df00d" universe = "10.0.0.0/8" - testAddr1 = "10.0.3.9/29" testCIDR1 = "10.0.3.8/29" testCIDR2 = "10.2.0.0/16" + testAddr1 = "10.0.3.9/29" testAddr2 = "10.2.0.1/16" ) alloc, subnet := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", universe, 1) port := listenHTTP(alloc, subnet) - alloc.claimRingForTesting() + + // Allocate an address in each subnet, and check we got what we expected cidr1a := HTTPPost(t, allocURL(port, testCIDR1, containerID)) wt.AssertEqualString(t, cidr1a, testAddr1, "address") - cidr2a := HTTPPost(t, allocURL(port, testCIDR2, containerID)) wt.AssertEqualString(t, cidr2a, testAddr2, "address") - + // Now, make the same requests again to check the operation is idempotent check := HTTPGet(t, allocURL(port, testCIDR1, containerID)) wt.AssertEqualString(t, check, cidr1a, "address") check = HTTPGet(t, allocURL(port, testCIDR2, containerID)) @@ -101,7 +101,7 @@ func TestHttp(t *testing.T) { cidr2b := HTTPPost(t, allocURL(port, testCIDR2, container2)) wt.AssertFalse(t, cidr2b == testAddr2, "address") - // Now free the first container, and we should get it back when we ask + // Now free the first container, and we should get its addresses back when we ask doHTTP("DELETE", identURL(port, containerID)) cidr1c := HTTPPost(t, allocURL(port, testCIDR1, container3))