Beefs up node and service watch tests for multi-table triggers.

This commit is contained in:
James Phillips 2015-10-08 23:45:43 -07:00
parent bde2495a14
commit 87bb81ba4c
1 changed files with 27 additions and 0 deletions

View File

@ -669,6 +669,21 @@ func TestStateStore_Node_Watches(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
}) })
// Check that a delete of a node + service + check triggers all three
// tables in one shot.
testRegisterNode(t, s, 4, "node1")
testRegisterService(t, s, 5, "node1", "service1")
testRegisterCheck(t, s, 6, "node1", "service1", "check3", structs.HealthPassing)
verifyWatch(t, s.GetTableWatch("nodes"), func() {
verifyWatch(t, s.GetTableWatch("services"), func() {
verifyWatch(t, s.GetTableWatch("checks"), func() {
if err := s.DeleteNode(7, "node1"); err != nil {
t.Fatalf("err: %s", err)
}
})
})
})
} }
func TestStateStore_EnsureService(t *testing.T) { func TestStateStore_EnsureService(t *testing.T) {
@ -906,6 +921,18 @@ func TestStateStore_Service_Watches(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
}) })
// Check that a delete of a service + check triggers both tables in one
// shot.
testRegisterService(t, s, 4, "node1", "service1")
testRegisterCheck(t, s, 5, "node1", "service1", "check3", structs.HealthPassing)
verifyWatch(t, s.GetTableWatch("services"), func() {
verifyWatch(t, s.GetTableWatch("checks"), func() {
if err := s.DeleteService(6, "node1", "service1"); err != nil {
t.Fatalf("err: %s", err)
}
})
})
} }
func TestStateStore_EnsureCheck(t *testing.T) { func TestStateStore_EnsureCheck(t *testing.T) {