Adds twiddling of the real state store in snapshot tests.

This commit is contained in:
James Phillips 2015-10-09 09:26:20 -07:00
parent 4ec5013811
commit 92e48b87bf

View file

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