test/common/config/grpc_mux_impl_test.cc
//  Verifies that a messsage with no resources is accepted.
Verifies that a messsage with no resources is accepted.
Verifies that a messsage with no resources is accepted .
TEST_F(GrpcMuxImplTest, UnwatchedTypeAcceptsEmptyResources) {
  setup();
  EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
  const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
  grpc_mux_->start();
  {
    expectSendMessage(type_url, {"y"}, "");
    auto temp_sub = grpc_mux_->subscribe(type_url, {"y"}, callbacks_);
    expectSendMessage(type_url, {}, "");
  }
  std::unique_ptr<envoy::api::v2::DiscoveryResponse> response(
      new envoy::api::v2::DiscoveryResponse());
  response->set_nonce("bar");
  response->set_version_info("1");
  response->set_type_url(type_url);
  grpc_mux_->onReceiveMessage(std::move(response));
  expectSendMessage(type_url, {"x"}, "1", "bar");
  auto sub = grpc_mux_->subscribe(type_url, {"x"}, callbacks_);
  expectSendMessage(type_url, {}, "1", "bar");
}
TEST_F ( GrpcMuxImplTest , UnwatchedTypeAcceptsEmptyResources ) { setup ( ) ; EXPECT_CALL ( * async_client_ , start ( _ , _ ) ) . WillOnce ( Return ( & async_stream_ ) ) ; const std :: string & type_url = Config :: TypeUrl :: get ( ) . ClusterLoadAssignment ; grpc_mux_ -> start ( ) ; { expectSendMessage ( type_url , { " " } , " " ) ; auto temp_sub = grpc_mux_ -> subscribe ( type_url , { " " } , callbacks_ ) ; expectSendMessage ( type_url , { } , " " ) ; } std :: unique_ptr < envoy :: api :: v2 :: DiscoveryResponse > response ( new envoy :: api :: v2 :: DiscoveryResponse ( ) ) ; response -> set_nonce ( " " ) ; response -> set_version_info ( " " ) ; response -> set_type_url ( type_url ) ; grpc_mux_ -> onReceiveMessage ( std :: move ( response ) ) ; expectSendMessage ( type_url , { " " } , " " , " " ) ; auto sub = grpc_mux_ -> subscribe ( type_url , { " " } , callbacks_ ) ; expectSendMessage ( type_url , { } , " " , " " ) ; }
Verifies that a messsage with no resources is accepted.
Verifies that a messsage with no resources is accepted .
// subscribe and unsubscribe to simulate a cluster added and removed // simulate the server sending empty CLA message to notify envoy that the CLA was removed. // This contains zero resources. No discovery request should be sent. // when we add the new subscription version should be 1 and nonce should be bar // simulate a new cluster x is added. add CLA subscription for it.