From c1d9b464bf6249aa8ed6bc1a46142a9b09c2bf01 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 13 Mar 2024 23:31:02 +0000 Subject: [PATCH] clang-format --- test/core/xds/xds_client_test.cc | 471 +++++++++--------- test/cpp/end2end/xds/xds_core_end2end_test.cc | 49 +- 2 files changed, 243 insertions(+), 277 deletions(-) diff --git a/test/core/xds/xds_client_test.cc b/test/core/xds/xds_client_test.cc index cead75e113c..86af6ac76ef 100644 --- a/test/core/xds/xds_client_test.cc +++ b/test/core/xds/xds_client_test.cc @@ -605,8 +605,8 @@ class XdsClientTest : public ::testing::Test { absl::string_view resource_type, uint64_t num_resources_valid, uint64_t num_resources_invalid) override { - auto key = std::make_pair(std::string(xds_server), - std::string(resource_type)); + auto key = + std::make_pair(std::string(xds_server), std::string(resource_type)); if (num_resources_valid > 0) { resource_updates_valid_[key] += num_resources_valid; } @@ -1181,11 +1181,10 @@ TEST_F(XdsClientTest, SubscribeToMultipleResources) { EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre( - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), ::testing::Pair( ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, XdsFooResourceType::Get()->type_url(), @@ -1384,13 +1383,12 @@ TEST_F(XdsClientTest, ResourceValidationFailure) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); // Watcher should initially not see any resource reported. EXPECT_FALSE(watcher->HasEvent()); // XdsClient should have created an ADS stream. @@ -1428,13 +1426,12 @@ TEST_F(XdsClientTest, ResourceValidationFailure) { ::testing::Pair("default_xds_server", XdsFooResourceType::Get()->type_url()), 1))); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "nacked"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "nacked"), + 1))); // XdsClient should NACK the update. // Note that version_info is not populated in the request. request = WaitForRequest(stream.get()); @@ -1515,13 +1512,12 @@ TEST_F(XdsClientTest, ResourceValidationFailureMultipleResources) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); // XdsClient should have created an ADS stream. auto stream = WaitForAdsStream(); ASSERT_TRUE(stream != nullptr); @@ -1540,13 +1536,12 @@ TEST_F(XdsClientTest, ResourceValidationFailureMultipleResources) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 2))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 2))); // Client should send another request. request = WaitForRequest(stream.get()); ASSERT_TRUE(request.has_value()); @@ -1561,13 +1556,12 @@ TEST_F(XdsClientTest, ResourceValidationFailureMultipleResources) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 3))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 3))); // Client should send another request. request = WaitForRequest(stream.get()); ASSERT_TRUE(request.has_value()); @@ -1582,13 +1576,12 @@ TEST_F(XdsClientTest, ResourceValidationFailureMultipleResources) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 4))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 4))); // Client should send another request. request = WaitForRequest(stream.get()); ASSERT_TRUE(request.has_value()); @@ -1662,17 +1655,15 @@ TEST_F(XdsClientTest, ResourceValidationFailureMultipleResources) { GetResourceCounts(), ::testing::ElementsAre( // foo4 - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), // foo1 and foo3 - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "nacked"), - 2), + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "nacked"), + 2), // did not recognize response for foo2 ::testing::Pair( ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, @@ -1792,13 +1783,12 @@ TEST_F(XdsClientTest, ResourceValidationFailureForCachedResource) { ::testing::Pair("default_xds_server", XdsFooResourceType::Get()->type_url()), 1))); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "nacked_but_cached"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "nacked_but_cached"), + 1))); // XdsClient should NACK the update. // Note that version_info is set to the previous version in this request, // because there were no valid resources in it. @@ -1864,18 +1854,18 @@ TEST_F(XdsClientTest, WildcardCapableResponseWithEmptyResource) { EXPECT_EQ(resource->name, "wc1"); EXPECT_EQ(resource->value, 6); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 1))); - EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 1))); + EXPECT_THAT( + metrics_reporter_->resource_updates_valid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 1))); + EXPECT_THAT( + metrics_reporter_->resource_updates_invalid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 1))); EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre(::testing::Pair( @@ -1934,12 +1924,12 @@ TEST_F(XdsClientTest, ResourceDeletion) { EXPECT_EQ(resource->name, "wc1"); EXPECT_EQ(resource->value, 6); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 1))); + EXPECT_THAT( + metrics_reporter_->resource_updates_valid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 1))); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); EXPECT_THAT( @@ -1966,22 +1956,21 @@ TEST_F(XdsClientTest, ResourceDeletion) { // Watcher should see the does-not-exist event. EXPECT_TRUE(watcher->WaitForDoesNotExist(absl::Seconds(1))); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 1))); - EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), - ::testing::ElementsAre()); EXPECT_THAT( - GetResourceCounts(), + metrics_reporter_->resource_updates_valid(), ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq( - XdsClient::kOldStyleAuthority, - XdsWildcardCapableResourceType::Get()->type_url(), - "does_not_exist"), + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), 1))); + EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), + ::testing::ElementsAre()); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsWildcardCapableResourceType::Get()->type_url(), + "does_not_exist"), + 1))); // Start a new watcher for the same resource. It should immediately // receive the same does-not-exist notification. auto watcher2 = StartWildcardCapableWatch("wc1"); @@ -2010,12 +1999,12 @@ TEST_F(XdsClientTest, ResourceDeletion) { EXPECT_EQ(resource->name, "wc1"); EXPECT_EQ(resource->value, 7); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 2))); + EXPECT_THAT( + metrics_reporter_->resource_updates_valid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 2))); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); EXPECT_THAT( @@ -2070,12 +2059,12 @@ TEST_F(XdsClientTest, ResourceDeletionIgnoredWhenConfigured) { EXPECT_EQ(resource->name, "wc1"); EXPECT_EQ(resource->value, 6); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 1))); + EXPECT_THAT( + metrics_reporter_->resource_updates_valid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 1))); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); EXPECT_THAT( @@ -2103,12 +2092,12 @@ TEST_F(XdsClientTest, ResourceDeletionIgnoredWhenConfigured) { // deletion. EXPECT_TRUE(watcher->ExpectNoEvent(absl::Seconds(1))); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 1))); + EXPECT_THAT( + metrics_reporter_->resource_updates_valid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 1))); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); EXPECT_THAT( @@ -2149,12 +2138,12 @@ TEST_F(XdsClientTest, ResourceDeletionIgnoredWhenConfigured) { EXPECT_EQ(resource->name, "wc1"); EXPECT_EQ(resource->value, 7); // Check metric data. - EXPECT_THAT(metrics_reporter_->resource_updates_valid(), - ::testing::ElementsAre(::testing::Pair( - ::testing::Pair( - "default_xds_server", - XdsWildcardCapableResourceType::Get()->type_url()), - 2))); + EXPECT_THAT( + metrics_reporter_->resource_updates_valid(), + ::testing::ElementsAre(::testing::Pair( + ::testing::Pair("default_xds_server", + XdsWildcardCapableResourceType::Get()->type_url()), + 2))); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); EXPECT_THAT( @@ -2450,13 +2439,12 @@ TEST_F(XdsClientTest, ResourceDoesNotExistUponTimeout) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); // XdsClient should have created an ADS stream. auto stream = WaitForAdsStream(); ASSERT_TRUE(stream != nullptr); @@ -2476,13 +2464,12 @@ TEST_F(XdsClientTest, ResourceDoesNotExistUponTimeout) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "does_not_exist"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "does_not_exist"), + 1))); // Start a new watcher for the same resource. It should immediately // receive the same does-not-exist notification. auto watcher2 = StartFooWatch("foo1"); @@ -2546,13 +2533,12 @@ TEST_F(XdsClientTest, ResourceDoesNotExistAfterStreamRestart) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); // Watcher should initially not see any resource reported. EXPECT_FALSE(watcher->HasEvent()); // XdsClient should have created an ADS stream. @@ -2582,13 +2568,12 @@ TEST_F(XdsClientTest, ResourceDoesNotExistAfterStreamRestart) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); // XdsClient should create a new stream. stream = WaitForAdsStream(); ASSERT_TRUE(stream != nullptr); @@ -2608,13 +2593,12 @@ TEST_F(XdsClientTest, ResourceDoesNotExistAfterStreamRestart) { ::testing::ElementsAre()); EXPECT_THAT(metrics_reporter_->resource_updates_invalid(), ::testing::ElementsAre()); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "does_not_exist"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "does_not_exist"), + 1))); // Server now sends the requested resource. stream->SendMessageToClient( ResponseBuilder(XdsFooResourceType::Get()->type_url()) @@ -2680,13 +2664,12 @@ TEST_F(XdsClientTest, DoesNotExistTimerNotStartedUntilSendCompletes) { // timer should not be running while the channel is disconnected. EXPECT_TRUE(watcher->ExpectNoEvent(absl::Seconds(4))); // Check metric data. - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); // The ADS stream uses wait_for_ready inside the XdsTransport interface, // so when the channel connects, the already-started stream will proceed. stream->CompleteSendMessageFromClient(); @@ -2694,13 +2677,12 @@ TEST_F(XdsClientTest, DoesNotExistTimerNotStartedUntilSendCompletes) { // Watcher should see a does-not-exist event. EXPECT_TRUE(watcher->WaitForDoesNotExist(absl::Seconds(4))); // Check metric data. - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "does_not_exist"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "does_not_exist"), + 1))); // Now server sends a response. stream->SendMessageToClient( ResponseBuilder(XdsFooResourceType::Get()->type_url()) @@ -2803,11 +2785,10 @@ TEST_F(XdsClientTest, EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre( - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), ::testing::Pair( ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, XdsFooResourceType::Get()->type_url(), @@ -2824,22 +2805,19 @@ TEST_F(XdsClientTest, // complete. // Unsubscribe from foo1 and then re-subscribe to it. CancelFooWatch(watcher.get(), "foo1"); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre(::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); watcher = StartFooWatch("foo1"); - EXPECT_THAT( - GetResourceCounts(), - ::testing::ElementsAre( - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 2))); + EXPECT_THAT(GetResourceCounts(), + ::testing::ElementsAre(::testing::Pair( + ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), + "requested"), + 2))); // Now send a response from the server containing both foo1 and foo2. stream->SendMessageToClient( ResponseBuilder(XdsFooResourceType::Get()->type_url()) @@ -3163,16 +3141,14 @@ TEST_F(XdsClientTest, MultipleResourceTypes) { EXPECT_THAT( GetResourceCounts(), ::testing::UnorderedElementsAre( - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsBarResourceType::Get()->type_url(), - "acked"), - 1), - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1))); + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsBarResourceType::Get()->type_url(), "acked"), + 1), + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1))); // XdsClient should have sent an ACK message to the xDS server. request = WaitForRequest(stream.get()); ASSERT_TRUE(request.has_value()); @@ -3268,19 +3244,18 @@ TEST_F(XdsClientTest, Federation) { EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre( - ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), - ::testing::Pair( - ResourceCountLabelsEq(kAuthority, - XdsFooResourceType::Get()->type_url(), - "requested"), - 1))); - EXPECT_THAT(GetServerConnections(), ::testing::ElementsAre( - ::testing::Pair("default_xds_server", true), - ::testing::Pair(authority_server.server_uri(), true))); + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), + ::testing::Pair(ResourceCountLabelsEq( + kAuthority, XdsFooResourceType::Get()->type_url(), + "requested"), + 1))); + EXPECT_THAT(GetServerConnections(), + ::testing::ElementsAre( + ::testing::Pair("default_xds_server", true), + ::testing::Pair(authority_server.server_uri(), true))); // XdsClient will create a new stream to the server for this authority. auto stream2 = WaitForAdsStream(authority_server); ASSERT_TRUE(stream2 != nullptr); @@ -3322,19 +3297,18 @@ TEST_F(XdsClientTest, Federation) { EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre( + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), - ::testing::Pair( - ResourceCountLabelsEq(kAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), + ResourceCountLabelsEq( + kAuthority, XdsFooResourceType::Get()->type_url(), "acked"), 1))); - EXPECT_THAT(GetServerConnections(), ::testing::ElementsAre( - ::testing::Pair("default_xds_server", true), - ::testing::Pair(authority_server.server_uri(), true))); + EXPECT_THAT(GetServerConnections(), + ::testing::ElementsAre( + ::testing::Pair("default_xds_server", true), + ::testing::Pair(authority_server.server_uri(), true))); // XdsClient should have sent an ACK message to the xDS server. request = WaitForRequest(stream2.get()); ASSERT_TRUE(request.has_value()); @@ -3444,15 +3418,13 @@ TEST_F(XdsClientTest, FederationAuthorityDefaultsToTopLevelXdsServer) { EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre( + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), - ::testing::Pair( - ResourceCountLabelsEq(kAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), + ResourceCountLabelsEq( + kAuthority, XdsFooResourceType::Get()->type_url(), "acked"), 1))); EXPECT_THAT(GetServerConnections(), ::testing::ElementsAre(::testing::Pair( "default_xds_server", true))); @@ -3620,9 +3592,10 @@ TEST_F(XdsClientTest, FederationChannelFailureReportedToWatchers) { // Start a watch for the xdstp resource name. auto watcher2 = StartFooWatch(kXdstpResourceName); // Check metric data. - EXPECT_THAT(GetServerConnections(), ::testing::ElementsAre( - ::testing::Pair("default_xds_server", true), - ::testing::Pair(authority_server.server_uri(), true))); + EXPECT_THAT(GetServerConnections(), + ::testing::ElementsAre( + ::testing::Pair("default_xds_server", true), + ::testing::Pair(authority_server.server_uri(), true))); // Watcher should initially not see any resource reported. EXPECT_FALSE(watcher2->HasEvent()); // XdsClient will create a new stream to the server for this authority. @@ -3666,19 +3639,18 @@ TEST_F(XdsClientTest, FederationChannelFailureReportedToWatchers) { EXPECT_THAT( GetResourceCounts(), ::testing::ElementsAre( + ::testing::Pair(ResourceCountLabelsEq( + XdsClient::kOldStyleAuthority, + XdsFooResourceType::Get()->type_url(), "acked"), + 1), ::testing::Pair( - ResourceCountLabelsEq(XdsClient::kOldStyleAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), - 1), - ::testing::Pair( - ResourceCountLabelsEq(kAuthority, - XdsFooResourceType::Get()->type_url(), - "acked"), + ResourceCountLabelsEq( + kAuthority, XdsFooResourceType::Get()->type_url(), "acked"), 1))); - EXPECT_THAT(GetServerConnections(), ::testing::ElementsAre( - ::testing::Pair("default_xds_server", true), - ::testing::Pair(authority_server.server_uri(), true))); + EXPECT_THAT(GetServerConnections(), + ::testing::ElementsAre( + ::testing::Pair("default_xds_server", true), + ::testing::Pair(authority_server.server_uri(), true))); // XdsClient should have sent an ACK message to the xDS server. request = WaitForRequest(stream2.get()); ASSERT_TRUE(request.has_value()); @@ -3700,9 +3672,10 @@ TEST_F(XdsClientTest, FederationChannelFailureReportedToWatchers) { // The watcher for "foo1" should not see any error. EXPECT_FALSE(watcher->HasEvent()); // Check metric data. - EXPECT_THAT(GetServerConnections(), ::testing::ElementsAre( - ::testing::Pair("default_xds_server", true), - ::testing::Pair(authority_server.server_uri(), false))); + EXPECT_THAT(GetServerConnections(), + ::testing::ElementsAre( + ::testing::Pair("default_xds_server", true), + ::testing::Pair(authority_server.server_uri(), false))); // Cancel watch for "foo1". CancelFooWatch(watcher.get(), "foo1"); EXPECT_TRUE(stream->Orphaned()); diff --git a/test/cpp/end2end/xds/xds_core_end2end_test.cc b/test/cpp/end2end/xds/xds_core_end2end_test.cc index cc47ae662fb..adf02aaea8e 100644 --- a/test/cpp/end2end/xds/xds_core_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_core_end2end_test.cc @@ -1096,9 +1096,8 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(XdsMetricsTest, MetricDefinitionResourceUpdatesValid) { const auto* descriptor = - grpc_core::GlobalInstrumentsRegistryTestPeer:: - FindMetricDescriptorByName( - "grpc.xds_client.resource_updates_valid"); + grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName( + "grpc.xds_client.resource_updates_valid"); ASSERT_NE(descriptor, nullptr); EXPECT_EQ(descriptor->value_type, grpc_core::GlobalInstrumentsRegistry::ValueType::kUInt64); @@ -1115,9 +1114,8 @@ TEST_P(XdsMetricsTest, MetricDefinitionResourceUpdatesValid) { TEST_P(XdsMetricsTest, MetricDefinitionResourceUpdatesInvalid) { const auto* descriptor = - grpc_core::GlobalInstrumentsRegistryTestPeer:: - FindMetricDescriptorByName( - "grpc.xds_client.resource_updates_invalid"); + grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName( + "grpc.xds_client.resource_updates_invalid"); ASSERT_NE(descriptor, nullptr); EXPECT_EQ(descriptor->value_type, grpc_core::GlobalInstrumentsRegistry::ValueType::kUInt64); @@ -1134,9 +1132,8 @@ TEST_P(XdsMetricsTest, MetricDefinitionResourceUpdatesInvalid) { TEST_P(XdsMetricsTest, MetricDefinitionConnected) { const auto* descriptor = - grpc_core::GlobalInstrumentsRegistryTestPeer:: - FindMetricDescriptorByName( - "grpc.xds_client.connected"); + grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName( + "grpc.xds_client.connected"); ASSERT_NE(descriptor, nullptr); EXPECT_EQ(descriptor->value_type, grpc_core::GlobalInstrumentsRegistry::ValueType::kInt64); @@ -1153,9 +1150,8 @@ TEST_P(XdsMetricsTest, MetricDefinitionConnected) { TEST_P(XdsMetricsTest, MetricDefinitionResources) { const auto* descriptor = - grpc_core::GlobalInstrumentsRegistryTestPeer:: - FindMetricDescriptorByName( - "grpc.xds_client.resources"); + grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName( + "grpc.xds_client.resources"); ASSERT_NE(descriptor, nullptr); EXPECT_EQ(descriptor->value_type, grpc_core::GlobalInstrumentsRegistry::ValueType::kInt64); @@ -1165,10 +1161,10 @@ TEST_P(XdsMetricsTest, MetricDefinitionResources) { EXPECT_EQ(descriptor->enable_by_default, false); EXPECT_EQ(descriptor->name, "grpc.xds_client.resources"); EXPECT_EQ(descriptor->unit, "{resource}"); - EXPECT_THAT(descriptor->label_keys, - ::testing::ElementsAre("grpc.target", "grpc.xds.authority", - "grpc.xds.resource_type", - "grpc.xds.cache_state")); + EXPECT_THAT( + descriptor->label_keys, + ::testing::ElementsAre("grpc.target", "grpc.xds.authority", + "grpc.xds.resource_type", "grpc.xds.cache_state")); EXPECT_THAT(descriptor->optional_label_keys, ::testing::ElementsAre()); } @@ -1200,10 +1196,9 @@ TEST_P(XdsMetricsTest, MetricValues) { CheckRpcSendOk(DEBUG_LOCATION); stats_plugin_->TriggerCallbacks(); // Check client metrics. - EXPECT_THAT( - stats_plugin_->GetCallbackGaugeValue(kMetricConnected, - {kTarget, kXdsServer}, {}), - ::testing::Optional(1)); + EXPECT_THAT(stats_plugin_->GetCallbackGaugeValue(kMetricConnected, + {kTarget, kXdsServer}, {}), + ::testing::Optional(1)); for (absl::string_view type_url : {"envoy.config.listener.v3.Listener", "envoy.config.route.v3.RouteConfiguration", @@ -1217,16 +1212,14 @@ TEST_P(XdsMetricsTest, MetricValues) { stats_plugin_->GetCounterValue(kMetricResourceUpdatesInvalid, {kTarget, kXdsServer, type_url}, {}), ::testing::Optional(0)); - EXPECT_THAT( - stats_plugin_->GetCallbackGaugeValue( - kMetricResources, {kTarget, "#old", type_url, "acked"}, {}), - ::testing::Optional(1)); + EXPECT_THAT(stats_plugin_->GetCallbackGaugeValue( + kMetricResources, {kTarget, "#old", type_url, "acked"}, {}), + ::testing::Optional(1)); } // Check server metrics. - EXPECT_THAT( - stats_plugin_->GetCallbackGaugeValue(kMetricConnected, - {"#server", kXdsServer}, {}), - ::testing::Optional(1)); + EXPECT_THAT(stats_plugin_->GetCallbackGaugeValue(kMetricConnected, + {"#server", kXdsServer}, {}), + ::testing::Optional(1)); for (absl::string_view type_url : {"envoy.config.listener.v3.Listener", "envoy.config.route.v3.RouteConfiguration"}) {