MCPcopy
hub / github.com/etcd-io/etcd / TestWatchRequestProgress

Function TestWatchRequestProgress

tests/integration/clientv3/watch_test.go:611–677  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

609}
610
611func TestWatchRequestProgress(t *testing.T) {
612 if integration2.ThroughProxy {
613 t.Skipf("grpc-proxy does not support WatchProgress yet")
614 }
615 testCases := []struct {
616 name string
617 watchers []string
618 }{
619 {"0-watcher", []string{}},
620 {"1-watcher", []string{"/"}},
621 {"2-watcher", []string{"/", "/"}},
622 }
623
624 for _, c := range testCases {
625 t.Run(c.name, func(t *testing.T) {
626 integration2.BeforeTest(t)
627
628 watchTimeout := 3 * time.Second
629
630 clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 3})
631 defer clus.Terminate(t)
632
633 wc := clus.RandClient()
634
635 var watchChans []clientv3.WatchChan
636
637 for _, prefix := range c.watchers {
638 watchChans = append(watchChans, wc.Watch(context.Background(), prefix, clientv3.WithPrefix()))
639 }
640
641 _, err := wc.Put(context.Background(), "/a", "1")
642 require.NoError(t, err)
643
644 for _, rch := range watchChans {
645 select {
646 case resp := <-rch: // wait for notification
647 if len(resp.Events) != 1 {
648 t.Fatalf("resp.Events expected 1, got %d", len(resp.Events))
649 }
650 case <-time.After(watchTimeout):
651 t.Fatalf("watch response expected in %v, but timed out", watchTimeout)
652 }
653 }
654
655 // put a value not being watched to increment revision
656 _, err = wc.Put(context.Background(), "x", "1")
657 require.NoError(t, err)
658
659 require.NoError(t, wc.RequestProgress(context.Background()))
660
661 // verify all watch channels receive a progress notify
662 for _, rch := range watchChans {
663 select {
664 case resp := <-rch:
665 if !resp.IsProgressNotify() {
666 t.Fatalf("expected resp.IsProgressNotify() == true")
667 }
668 if resp.Header.Revision != 3 {

Callers

nothing calls this directly

Calls 11

TerminateMethod · 0.95
RandClientMethod · 0.95
WithPrefixMethod · 0.80
IsProgressNotifyMethod · 0.80
RunMethod · 0.65
BeforeTestMethod · 0.65
NewClusterMethod · 0.65
WatchMethod · 0.65
PutMethod · 0.65
FatalfMethod · 0.65
RequestProgressMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…