Rework push reservation w/ datastore

- At Handle creation, first check if an instance of the
  the respective object is already present in the datastore.
- Handle sequence must be saved only if commit
  to datastore is succesfull
- Caller (ipam) needs to manage the retry

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch
2015-06-17 16:49:21 -07:00
parent 0020b76d39
commit bca6ec2e64
4 changed files with 129 additions and 8 deletions
+52
View File
@@ -87,6 +87,58 @@ func TestSequenceEqual(t *testing.T) {
}
}
func TestSequenceCopy(t *testing.T) {
s := &Sequence{
Block: 0x0,
Count: 8,
Next: &Sequence{
Block: 0x0,
Count: 8,
Next: &Sequence{
Block: 0x0,
Count: 0,
Next: &Sequence{
Block: 0x0,
Count: 0,
Next: &Sequence{
Block: 0x0,
Count: 2,
Next: &Sequence{
Block: 0x0,
Count: 1,
Next: &Sequence{
Block: 0x0,
Count: 1,
Next: &Sequence{
Block: 0x0,
Count: 2,
Next: &Sequence{
Block: 0x1,
Count: 1,
Next: &Sequence{
Block: 0x0,
Count: 2,
Next: nil,
},
},
},
},
},
},
},
},
},
}
n := s.GetCopy()
if !s.Equal(n) {
t.Fatalf("copy of s failed")
}
if n == s {
t.Fatalf("not true copy of s")
}
}
func TestGetFirstAvailable(t *testing.T) {
input := []struct {
mask *Sequence