|
|
@@ -499,6 +499,15 @@ func TestStoreWatchCreate(t *testing.T) {
|
|
|
assert.Nil(t, e, "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store doesn't see hidden key creations.
|
|
|
+func TestStoreWatchCreateWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+ w, _ := s.Watch("/_foo", false, false, 0)
|
|
|
+ s.Create("/_foo", false, "bar", false, Permanent)
|
|
|
+ e := nbselect(w.EventChan)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch for recursive key creation.
|
|
|
func TestStoreWatchRecursiveCreate(t *testing.T) {
|
|
|
s := newStore()
|
|
|
@@ -509,6 +518,15 @@ func TestStoreWatchRecursiveCreate(t *testing.T) {
|
|
|
assert.Equal(t, e.Node.Key, "/foo/bar", "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store can watch for recursive key creation.
|
|
|
+func TestStoreWatchRecursiveCreateWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+ w, _ := s.Watch("/foo", true, false, 0)
|
|
|
+ s.Create("/foo/_bar", false, "baz", false, Permanent)
|
|
|
+ e := nbselect(w.EventChan)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch for key updates.
|
|
|
func TestStoreWatchUpdate(t *testing.T) {
|
|
|
s := newStore()
|
|
|
@@ -520,6 +538,16 @@ func TestStoreWatchUpdate(t *testing.T) {
|
|
|
assert.Equal(t, e.Node.Key, "/foo", "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store doesn't see hidden key updates.
|
|
|
+func TestStoreWatchUpdateWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+ s.Create("/_foo", false, "bar", false, Permanent)
|
|
|
+ w, _ := s.Watch("/_foo", false, false, 0)
|
|
|
+ s.Update("/_foo", "baz", Permanent)
|
|
|
+ e := nbselect(w.EventChan)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch for recursive key updates.
|
|
|
func TestStoreWatchRecursiveUpdate(t *testing.T) {
|
|
|
s := newStore()
|
|
|
@@ -531,6 +559,16 @@ func TestStoreWatchRecursiveUpdate(t *testing.T) {
|
|
|
assert.Equal(t, e.Node.Key, "/foo/bar", "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store doesn't get recursive key updates for hidden keys.
|
|
|
+func TestStoreWatchRecursiveUpdateWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+ s.Create("/foo/_bar", false, "baz", false, Permanent)
|
|
|
+ w, _ := s.Watch("/foo", true, false, 0)
|
|
|
+ s.Update("/foo/_bar", "baz", Permanent)
|
|
|
+ e := nbselect(w.EventChan)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch for key deletions.
|
|
|
func TestStoreWatchDelete(t *testing.T) {
|
|
|
s := newStore()
|
|
|
@@ -542,6 +580,16 @@ func TestStoreWatchDelete(t *testing.T) {
|
|
|
assert.Equal(t, e.Node.Key, "/foo", "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store doesn't see hidden key deletions.
|
|
|
+func TestStoreWatchDeleteWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+ s.Create("/_foo", false, "bar", false, Permanent)
|
|
|
+ w, _ := s.Watch("/foo", false, false, 0)
|
|
|
+ s.Delete("/_foo", false, false)
|
|
|
+ e := nbselect(w.EventChan)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch for recursive key deletions.
|
|
|
func TestStoreWatchRecursiveDelete(t *testing.T) {
|
|
|
s := newStore()
|
|
|
@@ -553,6 +601,16 @@ func TestStoreWatchRecursiveDelete(t *testing.T) {
|
|
|
assert.Equal(t, e.Node.Key, "/foo/bar", "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store can watch for recursive key deletions.
|
|
|
+func TestStoreWatchRecursiveDeleteWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+ s.Create("/foo/_bar", false, "baz", false, Permanent)
|
|
|
+ w, _ := s.Watch("/foo", true, false, 0)
|
|
|
+ s.Delete("/foo/_bar", false, false)
|
|
|
+ e := nbselect(w.EventChan)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch for CAS updates.
|
|
|
func TestStoreWatchCompareAndSwap(t *testing.T) {
|
|
|
s := newStore()
|
|
|
@@ -602,6 +660,32 @@ func TestStoreWatchExpire(t *testing.T) {
|
|
|
assert.Equal(t, e.Node.Key, "/foofoo", "")
|
|
|
}
|
|
|
|
|
|
+// Ensure that the store doesn't see expirations of hidden keys.
|
|
|
+func TestStoreWatchExpireWithHiddenKey(t *testing.T) {
|
|
|
+ s := newStore()
|
|
|
+
|
|
|
+ stopChan := make(chan bool)
|
|
|
+ defer func() {
|
|
|
+ stopChan <- true
|
|
|
+ }()
|
|
|
+ go mockSyncService(s.DeleteExpiredKeys, stopChan)
|
|
|
+
|
|
|
+ s.Create("/_foo", false, "bar", false, time.Now().Add(500*time.Millisecond))
|
|
|
+ s.Create("/foofoo", false, "barbarbar", false, time.Now().Add(1000*time.Millisecond))
|
|
|
+
|
|
|
+ w, _ := s.Watch("/", true, false, 0)
|
|
|
+ c := w.EventChan
|
|
|
+ e := nbselect(c)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+ time.Sleep(600 * time.Millisecond)
|
|
|
+ e = nbselect(c)
|
|
|
+ assert.Nil(t, e, "")
|
|
|
+ time.Sleep(600 * time.Millisecond)
|
|
|
+ e = nbselect(c)
|
|
|
+ assert.Equal(t, e.Action, "expire", "")
|
|
|
+ assert.Equal(t, e.Node.Key, "/foofoo", "")
|
|
|
+}
|
|
|
+
|
|
|
// Ensure that the store can watch in streaming mode.
|
|
|
func TestStoreWatchStream(t *testing.T) {
|
|
|
s := newStore()
|