test/common/config/grpc_mux_impl_test.cc
// Validate behavior when multiple type URL watches are maintained and the stream is reset.
Validate behavior when multiple type URL watches are maintained and the stream is reset.
Validate behavior when multiple type URL watches are maintained and the stream is reset .
TEST_F(GrpcMuxImplTest, ResetStream) {
  Event::MockTimer* timer = nullptr;
  Event::TimerCb timer_cb;
  EXPECT_CALL(dispatcher_, createTimer_(_)).WillOnce(Invoke([&timer, &timer_cb](Event::TimerCb cb) {
    timer_cb = cb;
    EXPECT_EQ(nullptr, timer);
    timer = new Event::MockTimer();
    return timer;
  }));
  setup();
  InSequence s;
  auto foo_sub = grpc_mux_->subscribe("foo", {"x", "y"}, callbacks_);
  auto bar_sub = grpc_mux_->subscribe("bar", {}, callbacks_);
  auto baz_sub = grpc_mux_->subscribe("baz", {"z"}, callbacks_);
  EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
  expectSendMessage("foo", {"x", "y"}, "");
  expectSendMessage("bar", {}, "");
  expectSendMessage("baz", {"z"}, "");
  grpc_mux_->start();
  EXPECT_CALL(random_, random());
  ASSERT_TRUE(timer != nullptr); 
  EXPECT_CALL(*timer, enableTimer(_));
  grpc_mux_->onRemoteClose(Grpc::Status::GrpcStatus::Canceled, "");
  EXPECT_EQ(0, stats_.gauge("control_plane.connected_state").value());
  EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
  expectSendMessage("foo", {"x", "y"}, "");
  expectSendMessage("bar", {}, "");
  expectSendMessage("baz", {"z"}, "");
  timer_cb();
  expectSendMessage("baz", {}, "");
  expectSendMessage("foo", {}, "");
}
TEST_F ( GrpcMuxImplTest , ResetStream ) { Event :: MockTimer * timer = nullptr ; Event :: TimerCb timer_cb ; EXPECT_CALL ( dispatcher_ , createTimer_ ( _ ) ) . WillOnce ( Invoke ( [ & timer , & timer_cb ] ( Event :: TimerCb cb ) { timer_cb = cb ; EXPECT_EQ ( nullptr , timer ) ; timer = new Event :: MockTimer ( ) ; return timer ; } ) ) ; setup ( ) ; InSequence s ; auto foo_sub = grpc_mux_ -> subscribe ( " " , { " " , " " } , callbacks_ ) ; auto bar_sub = grpc_mux_ -> subscribe ( " " , { } , callbacks_ ) ; auto baz_sub = grpc_mux_ -> subscribe ( " " , { " " } , callbacks_ ) ; EXPECT_CALL ( * async_client_ , start ( _ , _ ) ) . WillOnce ( Return ( & async_stream_ ) ) ; expectSendMessage ( " " , { " " , " " } , " " ) ; expectSendMessage ( " " , { } , " " ) ; expectSendMessage ( " " , { " " } , " " ) ; grpc_mux_ -> start ( ) ; EXPECT_CALL ( random_ , random ( ) ) ; ASSERT_TRUE ( timer != nullptr ) ; EXPECT_CALL ( * timer , enableTimer ( _ ) ) ; grpc_mux_ -> onRemoteClose ( Grpc :: Status :: GrpcStatus :: Canceled , " " ) ; EXPECT_EQ ( 0 , stats_ . gauge ( " " ) . value ( ) ) ; EXPECT_CALL ( * async_client_ , start ( _ , _ ) ) . WillOnce ( Return ( & async_stream_ ) ) ; expectSendMessage ( " " , { " " , " " } , " " ) ; expectSendMessage ( " " , { } , " " ) ; expectSendMessage ( " " , { " " } , " " ) ; timer_cb ( ) ; expectSendMessage ( " " , { } , " " ) ; expectSendMessage ( " " , { } , " " ) ; }
Validate behavior when multiple type URL watches are maintained and the stream is reset.
Validate behavior when multiple type URL watches are maintained and the stream is reset .
// initialized from dispatcher mock.