Browse Source

consul: Test tombstone creation

pull/577/head
Armon Dadgar 10 years ago
parent
commit
089b7655ca
  1. 6
      consul/state_store.go
  2. 23
      consul/state_store_test.go

6
consul/state_store.go

@ -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)

23
consul/state_store_test.go

@ -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():

Loading…
Cancel
Save