mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #9297 from jpbetz/automated-cherry-pick-of-#9281-origin-release-3.2
Automated cherry pick of #9281
This commit is contained in:
commit
b5abfe1858
@ -188,7 +188,7 @@ func (s *watchableStore) Restore(b backend.Backend) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for wa := range s.synced.watchers {
|
for wa := range s.synced.watchers {
|
||||||
s.unsynced.watchers.add(wa)
|
s.unsynced.add(wa)
|
||||||
}
|
}
|
||||||
s.synced = newWatcherGroup()
|
s.synced = newWatcherGroup()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -295,6 +295,8 @@ func TestWatchFutureRev(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWatchRestore(t *testing.T) {
|
func TestWatchRestore(t *testing.T) {
|
||||||
|
test := func(delay time.Duration) func(t *testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
b, tmpPath := backend.NewDefaultTmpBackend()
|
b, tmpPath := backend.NewDefaultTmpBackend()
|
||||||
s := newWatchableStore(b, &lease.FakeLessor{}, nil)
|
s := newWatchableStore(b, &lease.FakeLessor{}, nil)
|
||||||
defer cleanup(s, b, tmpPath)
|
defer cleanup(s, b, tmpPath)
|
||||||
@ -310,6 +312,8 @@ func TestWatchRestore(t *testing.T) {
|
|||||||
w := newStore.NewWatchStream()
|
w := newStore.NewWatchStream()
|
||||||
w.Watch(testKey, nil, rev-1)
|
w.Watch(testKey, nil, rev-1)
|
||||||
|
|
||||||
|
time.Sleep(delay)
|
||||||
|
|
||||||
newStore.Restore(b)
|
newStore.Restore(b)
|
||||||
select {
|
select {
|
||||||
case resp := <-w.Chan():
|
case resp := <-w.Chan():
|
||||||
@ -326,6 +330,11 @@ func TestWatchRestore(t *testing.T) {
|
|||||||
t.Fatal("failed to receive event in 1 second.")
|
t.Fatal("failed to receive event in 1 second.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("Normal", test(0))
|
||||||
|
t.Run("RunSyncWatchLoopBeforeRestore", test(time.Millisecond*120)) // longer than default waitDuration
|
||||||
|
}
|
||||||
|
|
||||||
// TestWatchBatchUnsynced tests batching on unsynced watchers
|
// TestWatchBatchUnsynced tests batching on unsynced watchers
|
||||||
func TestWatchBatchUnsynced(t *testing.T) {
|
func TestWatchBatchUnsynced(t *testing.T) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user