|
|
|
@ -252,24 +252,26 @@ class XdsClientTest : public ::testing::Test { |
|
|
|
|
return !queue_.empty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
absl::optional<ResourceStruct> WaitForNextResource( |
|
|
|
|
std::shared_ptr<const ResourceStruct> WaitForNextResource( |
|
|
|
|
absl::Duration timeout = absl::Seconds(1), |
|
|
|
|
SourceLocation location = SourceLocation()) { |
|
|
|
|
MutexLock lock(&mu_); |
|
|
|
|
if (!WaitForEventLocked(timeout)) return absl::nullopt; |
|
|
|
|
if (!WaitForEventLocked(timeout)) return nullptr; |
|
|
|
|
Event& event = queue_.front(); |
|
|
|
|
if (!absl::holds_alternative<ResourceStruct>(event)) { |
|
|
|
|
if (!absl::holds_alternative<std::shared_ptr<const ResourceStruct>>( |
|
|
|
|
event)) { |
|
|
|
|
EXPECT_TRUE(false) |
|
|
|
|
<< "got unexpected event " |
|
|
|
|
<< (absl::holds_alternative<absl::Status>(event) |
|
|
|
|
? "error" |
|
|
|
|
: "does-not-exist") |
|
|
|
|
<< " at " << location.file() << ":" << location.line(); |
|
|
|
|
return absl::nullopt; |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
ResourceStruct foo = std::move(absl::get<ResourceStruct>(event)); |
|
|
|
|
auto foo = |
|
|
|
|
std::move(absl::get<std::shared_ptr<const ResourceStruct>>(event)); |
|
|
|
|
queue_.pop_front(); |
|
|
|
|
return std::move(foo); |
|
|
|
|
return foo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
absl::optional<absl::Status> WaitForNextError( |
|
|
|
@ -281,7 +283,8 @@ class XdsClientTest : public ::testing::Test { |
|
|
|
|
if (!absl::holds_alternative<absl::Status>(event)) { |
|
|
|
|
EXPECT_TRUE(false) |
|
|
|
|
<< "got unexpected event " |
|
|
|
|
<< (absl::holds_alternative<ResourceStruct>(event) |
|
|
|
|
<< (absl::holds_alternative< |
|
|
|
|
std::shared_ptr<const ResourceStruct>>(event) |
|
|
|
|
? "resource" |
|
|
|
|
: "does-not-exist") |
|
|
|
|
<< " at " << location.file() << ":" << location.line(); |
|
|
|
@ -300,8 +303,8 @@ class XdsClientTest : public ::testing::Test { |
|
|
|
|
if (!absl::holds_alternative<DoesNotExist>(event)) { |
|
|
|
|
EXPECT_TRUE(false) |
|
|
|
|
<< "got unexpected event " |
|
|
|
|
<< (absl::holds_alternative<ResourceStruct>(event) ? "resource" |
|
|
|
|
: "error") |
|
|
|
|
<< (absl::holds_alternative<absl::Status>(event) ? "error" |
|
|
|
|
: "resource") |
|
|
|
|
<< " at " << location.file() << ":" << location.line(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -311,9 +314,11 @@ class XdsClientTest : public ::testing::Test { |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
struct DoesNotExist {}; |
|
|
|
|
using Event = absl::variant<ResourceStruct, absl::Status, DoesNotExist>; |
|
|
|
|
using Event = absl::variant<std::shared_ptr<const ResourceStruct>, |
|
|
|
|
absl::Status, DoesNotExist>; |
|
|
|
|
|
|
|
|
|
void OnResourceChanged(ResourceStruct foo) override { |
|
|
|
|
void OnResourceChanged( |
|
|
|
|
std::shared_ptr<const ResourceStruct> foo) override { |
|
|
|
|
MutexLock lock(&mu_); |
|
|
|
|
queue_.push_back(std::move(foo)); |
|
|
|
|
cv_.Signal(); |
|
|
|
@ -758,7 +763,7 @@ TEST_F(XdsClientTest, BasicWatch) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -799,7 +804,7 @@ TEST_F(XdsClientTest, UpdateFromServer) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -818,7 +823,7 @@ TEST_F(XdsClientTest, UpdateFromServer) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 9); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -859,7 +864,7 @@ TEST_F(XdsClientTest, MultipleWatchersForSameResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -874,7 +879,7 @@ TEST_F(XdsClientTest, MultipleWatchersForSameResource) { |
|
|
|
|
// This watcher should get an immediate notification, because the
|
|
|
|
|
// resource is already cached.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// Server should not have seen another request from the client.
|
|
|
|
@ -888,11 +893,11 @@ TEST_F(XdsClientTest, MultipleWatchersForSameResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should deliver the response to both watchers.
|
|
|
|
|
resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 9); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 9); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -937,7 +942,7 @@ TEST_F(XdsClientTest, SubscribeToMultipleResources) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -965,7 +970,7 @@ TEST_F(XdsClientTest, SubscribeToMultipleResources) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo2"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1014,7 +1019,7 @@ TEST_F(XdsClientTest, UpdateContainsOnlyChangedResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1042,7 +1047,7 @@ TEST_F(XdsClientTest, UpdateContainsOnlyChangedResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo2"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1061,7 +1066,7 @@ TEST_F(XdsClientTest, UpdateContainsOnlyChangedResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 9); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1149,11 +1154,11 @@ TEST_F(XdsClientTest, ResourceValidationFailure) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should deliver the response to both watchers.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 9); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 9); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1258,7 +1263,7 @@ TEST_F(XdsClientTest, ResourceValidationFailureMultipleResources) { |
|
|
|
|
EXPECT_FALSE(watcher2->HasEvent()); |
|
|
|
|
// It will delivery a valid resource update for foo4.
|
|
|
|
|
auto resource = watcher4->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo4"); |
|
|
|
|
EXPECT_EQ(resource->value, 5); |
|
|
|
|
// XdsClient should NACK the update.
|
|
|
|
@ -1321,7 +1326,7 @@ TEST_F(XdsClientTest, ResourceValidationFailureForCachedResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1371,7 +1376,7 @@ TEST_F(XdsClientTest, ResourceValidationFailureForCachedResource) { |
|
|
|
|
// another option is to send the errors even for newly started watchers.
|
|
|
|
|
auto watcher2 = StartFooWatch("foo1"); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// Cancel watches.
|
|
|
|
@ -1408,7 +1413,7 @@ TEST_F(XdsClientTest, WildcardCapableResponseWithEmptyResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient will delivery a valid resource update for wc1.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should NACK the update.
|
|
|
|
@ -1458,7 +1463,7 @@ TEST_F(XdsClientTest, ResourceDeletion) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1497,11 +1502,11 @@ TEST_F(XdsClientTest, ResourceDeletion) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watchers.
|
|
|
|
|
resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1545,7 +1550,7 @@ TEST_F(XdsClientTest, ResourceDeletionIgnoredWhenConfigured) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1569,7 +1574,7 @@ TEST_F(XdsClientTest, ResourceDeletionIgnoredWhenConfigured) { |
|
|
|
|
// receive the cached resource.
|
|
|
|
|
auto watcher2 = StartWildcardCapableWatch("wc1"); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1588,11 +1593,11 @@ TEST_F(XdsClientTest, ResourceDeletionIgnoredWhenConfigured) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watchers.
|
|
|
|
|
resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "wc1"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1634,7 +1639,7 @@ TEST_F(XdsClientTest, StreamClosedByServer) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1668,7 +1673,7 @@ TEST_F(XdsClientTest, StreamClosedByServer) { |
|
|
|
|
// resource.
|
|
|
|
|
auto watcher2 = StartFooWatch("foo1"); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// Server now sends the requested resource.
|
|
|
|
@ -1741,7 +1746,7 @@ TEST_F(XdsClientTest, StreamClosedByServerWithoutSeeingResponse) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// Watcher gets the resource.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient sends an ACK.
|
|
|
|
@ -1816,11 +1821,11 @@ TEST_F(XdsClientTest, ConnectionFails) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watchers.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1870,11 +1875,11 @@ TEST_F(XdsClientTest, ResourceDoesNotExistUponTimeout) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watchers.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -1942,7 +1947,7 @@ TEST_F(XdsClientTest, ResourceDoesNotExistAfterStreamRestart) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// The resource is delivered to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient sends an ACK.
|
|
|
|
@ -1998,7 +2003,7 @@ TEST_F(XdsClientTest, DoesNotExistTimerNotStartedUntilSendCompletes) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2051,7 +2056,7 @@ TEST_F(XdsClientTest, |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watchers.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2090,12 +2095,12 @@ TEST_F(XdsClientTest, |
|
|
|
|
// has not changed, since the previous value was removed from the
|
|
|
|
|
// cache when we unsubscribed.
|
|
|
|
|
resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// For foo2, the watcher should receive notification for the new resource.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo2"); |
|
|
|
|
EXPECT_EQ(resource->value, 7); |
|
|
|
|
// Now we finally tell XdsClient that its previous send_message op is
|
|
|
|
@ -2147,7 +2152,7 @@ TEST_F(XdsClientTest, DoNotSendDoesNotExistForCachedResource) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2225,7 +2230,7 @@ TEST_F(XdsClientTest, ResourceWrappedInResourceMessage) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2266,7 +2271,7 @@ TEST_F(XdsClientTest, MultipleResourceTypes) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2296,7 +2301,7 @@ TEST_F(XdsClientTest, MultipleResourceTypes) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource2 = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource2.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource2->name, "bar1"); |
|
|
|
|
EXPECT_EQ(resource2->value, "whee"); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2353,7 +2358,7 @@ TEST_F(XdsClientTest, Federation) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2389,7 +2394,7 @@ TEST_F(XdsClientTest, Federation) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, kXdstpResourceName); |
|
|
|
|
EXPECT_EQ(resource->value, 3); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2439,7 +2444,7 @@ TEST_F(XdsClientTest, FederationAuthorityDefaultsToTopLevelXdsServer) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2471,7 +2476,7 @@ TEST_F(XdsClientTest, FederationAuthorityDefaultsToTopLevelXdsServer) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, kXdstpResourceName); |
|
|
|
|
EXPECT_EQ(resource->value, 3); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2560,7 +2565,7 @@ TEST_F(XdsClientTest, FederationDisabledWithNewStyleName) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, kXdstpResourceName); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2609,7 +2614,7 @@ TEST_F(XdsClientTest, FederationChannelFailureReportedToWatchers) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
auto resource = watcher->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, "foo1"); |
|
|
|
|
EXPECT_EQ(resource->value, 6); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
@ -2645,7 +2650,7 @@ TEST_F(XdsClientTest, FederationChannelFailureReportedToWatchers) { |
|
|
|
|
.Serialize()); |
|
|
|
|
// XdsClient should have delivered the response to the watcher.
|
|
|
|
|
resource = watcher2->WaitForNextResource(); |
|
|
|
|
ASSERT_TRUE(resource.has_value()); |
|
|
|
|
ASSERT_NE(resource, nullptr); |
|
|
|
|
EXPECT_EQ(resource->name, kXdstpResourceName); |
|
|
|
|
EXPECT_EQ(resource->value, 3); |
|
|
|
|
// XdsClient should have sent an ACK message to the xDS server.
|
|
|
|
|