Browse Source

Adds twiddling of the real state store in snapshot tests.

pull/1291/head
James Phillips 9 years ago
parent
commit
c791f2a709
  1. 36
      consul/state/state_store_test.go

36
consul/state/state_store_test.go

@ -623,6 +623,9 @@ func TestStateStore_Node_Snapshot(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
testRegisterNode(t, s, 3, "node3")
// Verify the snapshot.
if idx := snap.LastIndex(); idx != 2 {
t.Fatalf("bad index: %d", idx)
@ -879,6 +882,9 @@ func TestStateStore_Service_Snapshot(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
testRegisterService(t, s, 5, "node2", "service3")
// Verify the snapshot.
if idx := snap.LastIndex(); idx != 4 {
t.Fatalf("bad index: %d", idx)
@ -1302,6 +1308,9 @@ func TestStateStore_Check_Snapshot(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
testRegisterCheck(t, s, 6, "node2", "service2", "check4", structs.HealthPassing)
// Verify the snapshot.
if idx := snap.LastIndex(); idx != 5 {
t.Fatalf("bad index: %d", idx)
@ -2547,6 +2556,11 @@ func TestStateStore_KVS_Snapshot_Restore(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
if err := s.KVSSet(8, &structs.DirEntry{Key: "aaa", Value: []byte("nope")}); err != nil {
t.Fatalf("err: %s", err)
}
// Verify the snapshot.
if idx := snap.LastIndex(); idx != 7 {
t.Fatalf("bad index: %d", idx)
@ -2736,6 +2750,18 @@ func TestStateStore_Tombstone_Snapshot_Restore(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
if err := s.ReapTombstones(2); err != nil {
t.Fatalf("err: %s", err)
}
idx, _, err := s.KVSList("foo/bar")
if err != nil {
t.Fatalf("err: %s", err)
}
if idx != 0 {
t.Fatalf("bad index: %d", idx)
}
// Verify the snapshot.
dump, err := snap.TombstoneDump()
if err != nil {
@ -3092,6 +3118,11 @@ func TestStateStore_Session_Snapshot_Restore(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
if err := s.SessionDestroy(8, "session1"); err != nil {
t.Fatalf("err: %s", err)
}
// Verify the snapshot.
if idx := snap.LastIndex(); idx != 7 {
t.Fatalf("bad index: %d", idx)
@ -3723,6 +3754,11 @@ func TestStateStore_ACL_Snapshot_Restore(t *testing.T) {
snap := s.Snapshot()
defer snap.Close()
// Alter the real state store.
if err := s.ACLDelete(3, "acl1"); err != nil {
t.Fatalf("err: %s", err)
}
// Verify the snapshot.
if idx := snap.LastIndex(); idx != 2 {
t.Fatalf("bad index: %d", idx)

Loading…
Cancel
Save