Get the owned ranges for test purposes via the actor loop, so we don't set off the race detector
This commit is contained in:
1 parent
71ec252298
commit
09a6c2eda0
2 files changed
+11
-3
No files matched your search
@@ -597,7 +597,7 @@ func TestSpaceRequest(t *testing.T) {
|
||||
// free it again so the donation splits the range neatly
|
||||
err = alloc1.Free(container1, addr)
|
||||
require.Nil(t, err, "")
|
||||
require.Equal(t, cidrRanges(universe), alloc1.ring.OwnedRanges(), "")
|
||||
require.Equal(t, cidrRanges(universe), alloc1.OwnedRanges(), "")
|
||||
|
||||
// Start a new peer
|
||||
alloc2, _ := makeAllocator("02:00:00:02:00:00", universe, 2)
|
||||
@@ -607,8 +607,8 @@ func TestSpaceRequest(t *testing.T) {
|
||||
alloc2.Allocate(container2, subnet, returnFalse)
|
||||
|
||||
// Test whether the universe has been split into two equal halves (GH #2009)
|
||||
require.Equal(t, cidrRanges("10.32.0.0/13"), alloc1.ring.OwnedRanges(), "")
|
||||
require.Equal(t, cidrRanges("10.40.0.0/13"), alloc2.ring.OwnedRanges(), "")
|
||||
require.Equal(t, cidrRanges("10.32.0.0/13"), alloc1.OwnedRanges(), "")
|
||||
require.Equal(t, cidrRanges("10.40.0.0/13"), alloc2.OwnedRanges(), "")
|
||||
}
|
||||
|
||||
func cidrRanges(s string) []address.Range {
|
||||
|
||||
@@ -175,6 +175,14 @@ func (alloc *Allocator) NumFreeAddresses(r address.Range) address.Count {
|
||||
return <-resultChan
|
||||
}
|
||||
|
||||
func (alloc *Allocator) OwnedRanges() (result []address.Range) {
|
||||
resultChan := make(chan []address.Range)
|
||||
alloc.actionChan <- func() {
|
||||
resultChan <- alloc.ring.OwnedRanges()
|
||||
}
|
||||
return <-resultChan
|
||||
}
|
||||
|
||||
// Check whether or not something was sent on a channel
|
||||
func AssertSent(t *testing.T, ch <-chan bool) {
|
||||
timeout := time.After(10 * time.Second)
|
||||
|
||||
Reference in new issue
Block a user