Review feedback
This commit is contained in:
1 parent
a7e0f03647
commit
d55c68c248
2 files changed
+9
-13
No files matched your search
+2
-2
@@ -131,9 +131,9 @@ func (alloc *Allocator) cancelOpsFor(ops *[]operation, ident string) bool {
|
|||||||
found = true
|
found = true
|
||||||
op.Cancel()
|
op.Cancel()
|
||||||
*ops = append((*ops)[:i], (*ops)[i+1:]...)
|
*ops = append((*ops)[:i], (*ops)[i+1:]...)
|
||||||
continue
|
} else {
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-11
@@ -229,7 +229,6 @@ func TestCancel(t *testing.T) {
|
|||||||
doneChan <- ok == nil
|
doneChan <- ok == nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
AssertNothingSent(t, doneChan)
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
AssertNothingSent(t, doneChan)
|
AssertNothingSent(t, doneChan)
|
||||||
|
|
||||||
@@ -247,30 +246,27 @@ func TestCancelOnDied(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
router := gossip.NewTestRouter(0.0)
|
router := gossip.NewTestRouter(0.0)
|
||||||
|
|
||||||
alloc1, subnet := makeAllocator("01:00:00:02:00:00", CIDR, 2)
|
alloc1, subnet := makeAllocator("01:00:00:02:00:00", CIDR, 2)
|
||||||
alloc1.SetInterfaces(router.Connect(alloc1.ourName, alloc1))
|
alloc1.SetInterfaces(router.Connect(alloc1.ourName, alloc1))
|
||||||
|
|
||||||
alloc1.Start()
|
alloc1.Start()
|
||||||
|
|
||||||
doneChan := make(chan bool)
|
doneChan := make(chan bool)
|
||||||
go func() {
|
f := func() {
|
||||||
_, ok := alloc1.Allocate(container1, subnet, nil)
|
_, ok := alloc1.Allocate(container1, subnet, nil)
|
||||||
doneChan <- ok == nil
|
doneChan <- ok == nil
|
||||||
}()
|
}
|
||||||
|
|
||||||
// Do another allocation in parallel, to check that is handled correctly
|
// Attempt two allocations in parallel, to check that this is handled correctly
|
||||||
go func() {
|
go f()
|
||||||
_, ok := alloc1.Allocate(container1, subnet, nil)
|
go f()
|
||||||
doneChan <- ok == nil
|
|
||||||
}()
|
|
||||||
|
|
||||||
AssertNothingSent(t, doneChan)
|
// Nothing should happen, because we declared the quorum as 2
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
AssertNothingSent(t, doneChan)
|
AssertNothingSent(t, doneChan)
|
||||||
|
|
||||||
alloc1.ContainerDied(container1)
|
alloc1.ContainerDied(container1)
|
||||||
|
|
||||||
|
// Check that the two allocations both exit with an error
|
||||||
if <-doneChan || <-doneChan {
|
if <-doneChan || <-doneChan {
|
||||||
require.FailNow(t, "Error: got result from Allocate")
|
require.FailNow(t, "Error: got result from Allocate")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user