@@ -777,17 +777,15 @@ class XdsClientTest : public ::testing::Test {
777777
778778 // Sets transport_factory_ and initializes xds_client_ with the
779779 // specified bootstrap config.
780- void InitXdsClient(
781- FakeXdsBootstrap::Builder bootstrap_builder = FakeXdsBootstrap::Builder(),
782- Duration resource_request_timeout = Duration::Seconds(15)) {
780+ void InitXdsClient(FakeXdsBootstrap::Builder bootstrap_builder =
781+ FakeXdsBootstrap::Builder()) {
783782 transport_factory_ = MakeRefCounted<FakeXdsTransportFactory>(
784783 []() { FAIL() << "Multiple concurrent reads"; }, event_engine_);
785784 auto metrics_reporter = std::make_unique<MetricsReporter>(event_engine_);
786785 metrics_reporter_ = metrics_reporter.get();
787786 xds_client_ = MakeRefCounted<XdsClient>(
788787 bootstrap_builder.Build(), transport_factory_, event_engine_,
789- std::move(metrics_reporter), "foo agent", "foo version",
790- resource_request_timeout * grpc_test_slowdown_factor());
788+ std::move(metrics_reporter), "foo agent", "foo version");
791789 }
792790
793791 // Starts and cancels a watch for a Foo resource.
@@ -2438,9 +2436,7 @@ TEST_F(XdsClientTest, StreamClosedByServerWithoutSeeingResponse) {
24382436}
24392437
24402438TEST_F(XdsClientTest, ConnectionFails) {
2441- // Lower resources-does-not-exist timeout, to make sure that we're not
2442- // triggering that here.
2443- InitXdsClient(FakeXdsBootstrap::Builder(), Duration::Seconds(3));
2439+ InitXdsClient();
24442440 // Tell transport to let us manually trigger completion of the
24452441 // send_message ops to XdsClient.
24462442 transport_factory_->SetAutoCompleteMessagesFromClient(false);
@@ -2639,7 +2635,7 @@ TEST_F(XdsClientTest, ConnectionFailsWithCachedResource) {
26392635}
26402636
26412637TEST_F(XdsClientTest, ResourceDoesNotExistUponTimeout) {
2642- InitXdsClient(FakeXdsBootstrap::Builder(), Duration::Seconds(1) );
2638+ InitXdsClient();
26432639 // Start a watch for "foo1".
26442640 auto watcher = StartFooWatch("foo1");
26452641 // Watcher should initially not see any resource reported.
@@ -2725,8 +2721,7 @@ TEST_F(XdsClientTest, ResourceDoesNotExistUponTimeout) {
27252721}
27262722
27272723TEST_F(XdsClientTest, ResourceDoesNotExistAfterStreamRestart) {
2728- // Lower resources-does-not-exist timeout so test finishes faster.
2729- InitXdsClient(FakeXdsBootstrap::Builder(), Duration::Seconds(3));
2724+ InitXdsClient();
27302725 // Metrics should initially be empty.
27312726 EXPECT_THAT(metrics_reporter_->resource_updates_valid(),
27322727 ::testing::ElementsAre());
@@ -2840,9 +2835,7 @@ TEST_F(XdsClientTest, ResourceDoesNotExistAfterStreamRestart) {
28402835}
28412836
28422837TEST_F(XdsClientTest, DoesNotExistTimerNotStartedUntilSendCompletes) {
2843- // Lower resources-does-not-exist timeout, to make sure that we're not
2844- // triggering that here.
2845- InitXdsClient(FakeXdsBootstrap::Builder(), Duration::Seconds(3));
2838+ InitXdsClient();
28462839 // Tell transport to let us manually trigger completion of the
28472840 // send_message ops to XdsClient.
28482841 transport_factory_->SetAutoCompleteMessagesFromClient(false);
@@ -2925,7 +2918,7 @@ TEST_F(XdsClientTest, DoesNotExistTimerNotStartedUntilSendCompletes) {
29252918// update containing that resource.
29262919TEST_F(XdsClientTest,
29272920 ResourceDoesNotExistUnsubscribeAndResubscribeWhileSendMessagePending) {
2928- InitXdsClient(FakeXdsBootstrap::Builder(), Duration::Seconds(1) );
2921+ InitXdsClient();
29292922 // Tell transport to let us manually trigger completion of the
29302923 // send_message ops to XdsClient.
29312924 transport_factory_->SetAutoCompleteMessagesFromClient(false);
@@ -3074,9 +3067,7 @@ TEST_F(XdsClientTest,
30743067}
30753068
30763069TEST_F(XdsClientTest, DoNotSendDoesNotExistForCachedResource) {
3077- // Lower resources-does-not-exist timeout, to make sure that we're not
3078- // triggering that here.
3079- InitXdsClient(FakeXdsBootstrap::Builder(), Duration::Seconds(3));
3070+ InitXdsClient();
30803071 // Start a watch for "foo1".
30813072 auto watcher = StartFooWatch("foo1");
30823073 // Watcher should initially not see any resource reported.
@@ -3358,7 +3349,48 @@ TEST_F(XdsClientTest, MultipleResourceTypes) {
33583349 CheckRequest(*request, XdsFooResourceType::Get()->type_url(),
33593350 /*version_info=*/"1", /*response_nonce=*/"A",
33603351 /*error_detail=*/absl::OkStatus(), /*resource_names=*/{});
3361- // Now cancel watch for "bar1".
3352+ // Server sends an empty response for the resource type.
3353+ // (The server doesn't need to do this, but it may.)
3354+ stream->SendMessageToClient(
3355+ ResponseBuilder(XdsFooResourceType::Get()->type_url())
3356+ .set_version_info("1")
3357+ .set_nonce("C")
3358+ .Serialize());
3359+ // Client should ACK.
3360+ request = WaitForRequest(stream.get());
3361+ ASSERT_TRUE(request.has_value());
3362+ CheckRequest(*request, XdsFooResourceType::Get()->type_url(),
3363+ /*version_info=*/"1", /*response_nonce=*/"C",
3364+ /*error_detail=*/absl::OkStatus(), /*resource_names=*/{});
3365+ // Now subscribe to foo2.
3366+ watcher = StartFooWatch("foo2");
3367+ // Client sends a subscription request, which retains the nonce and
3368+ // version seen previously.
3369+ request = WaitForRequest(stream.get());
3370+ ASSERT_TRUE(request.has_value());
3371+ CheckRequest(*request, XdsFooResourceType::Get()->type_url(),
3372+ /*version_info=*/"1", /*response_nonce=*/"C",
3373+ /*error_detail=*/absl::OkStatus(), /*resource_names=*/{"foo2"});
3374+ // Server sends foo2.
3375+ stream->SendMessageToClient(
3376+ ResponseBuilder(XdsFooResourceType::Get()->type_url())
3377+ .set_version_info("1")
3378+ .set_nonce("D")
3379+ .AddFooResource(XdsFooResource("foo2", 8))
3380+ .Serialize());
3381+ // Watcher receives the resource.
3382+ resource = watcher->WaitForNextResource();
3383+ ASSERT_NE(resource, nullptr);
3384+ EXPECT_EQ(resource->name, "foo2");
3385+ EXPECT_EQ(resource->value, 8);
3386+ // Client ACKs.
3387+ request = WaitForRequest(stream.get());
3388+ ASSERT_TRUE(request.has_value());
3389+ CheckRequest(*request, XdsFooResourceType::Get()->type_url(),
3390+ /*version_info=*/"1", /*response_nonce=*/"D",
3391+ /*error_detail=*/absl::OkStatus(), /*resource_names=*/{"foo2"});
3392+ // Cancel watches.
3393+ CancelFooWatch(watcher.get(), "foo2", /*delay_unsubscription=*/true);
33623394 CancelBarWatch(watcher2.get(), "bar1");
33633395 EXPECT_TRUE(stream->IsOrphaned());
33643396}
0 commit comments