consul: Test tombstone creation

This commit is contained in:
Armon Dadgar 2014-12-18 14:48:43 -08:00
parent f9d322f346
commit bba573dfbc
2 changed files with 29 additions and 0 deletions

View File

@ -296,6 +296,12 @@ func (s *StateStore) initialize() error {
Unique: true,
Fields: []string{"Key"},
},
"id_prefix": &MDBIndex{
Virtual: true,
RealIndex: "id",
Fields: []string{"Key"},
IdxFunc: DefaultIndexPrefixFunc,
},
},
Decoder: func(buf []byte) interface{} {
out := new(structs.DirEntry)

View File

@ -1444,6 +1444,15 @@ func TestKVSDelete(t *testing.T) {
t.Fatalf("bad: %v", d)
}
// Check tombstone exists
_, res, err := store.tombstoneTable.Get("id", "/foo")
if err != nil {
t.Fatalf("err: %v", err)
}
if res == nil || res[0].(*structs.DirEntry).ModifyIndex != 1020 {
t.Fatalf("bad: %#v", d)
}
// Check that we get a delete
select {
case idx := <-gc.ExpireCh():
@ -1801,6 +1810,20 @@ func TestKVSDeleteTree(t *testing.T) {
t.Fatalf("bad: %v", ents)
}
// Check tombstones exists
_, res, err := store.tombstoneTable.Get("id_prefix", "/web")
if err != nil {
t.Fatalf("err: %v", err)
}
if len(res) != 3 {
t.Fatalf("bad: %#v", d)
}
for _, r := range res {
if r.(*structs.DirEntry).ModifyIndex != 1010 {
t.Fatalf("bad: %#v", r)
}
}
// Check that we get a delete
select {
case idx := <-gc.ExpireCh():