-
Notifications
You must be signed in to change notification settings - Fork 5.5k
test: deflaking */LoadStatsIntegrationTest.LocalityWeighted/* #7225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8bca37a
test: deflaking */LoadStatsIntegrationTest.LocalityWeighted/*
alyssawilk b7a1ac2
fixups
alyssawilk 91c51c7
reviewer comments
alyssawilk b787680
Merge branch 'master' into flake
alyssawilk e366120
reviewer comments
alyssawilk 460a278
Merge branch 'master' into flake
alyssawilk d7ca29e
reviewer comments
alyssawilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,15 +191,13 @@ class LoadStatsIntegrationTest : public testing::TestWithParam<Network::Address: | |
| upstream_locality_stats->set_total_successful_requests( | ||
| upstream_locality_stats->total_successful_requests() + | ||
| local_upstream_locality_stats.total_successful_requests()); | ||
| upstream_locality_stats->set_total_requests_in_progress( | ||
| upstream_locality_stats->total_requests_in_progress() + | ||
| local_upstream_locality_stats.total_requests_in_progress()); | ||
| upstream_locality_stats->set_total_error_requests( | ||
| upstream_locality_stats->total_error_requests() + | ||
| local_upstream_locality_stats.total_error_requests()); | ||
| upstream_locality_stats->set_total_issued_requests( | ||
| upstream_locality_stats->total_issued_requests() + | ||
| local_upstream_locality_stats.total_issued_requests()); | ||
| // Unlike most stats, current requests in progress replaces old requests in progress. | ||
| break; | ||
| } | ||
| } | ||
|
|
@@ -208,6 +206,25 @@ class LoadStatsIntegrationTest : public testing::TestWithParam<Network::Address: | |
| upstream_locality_stats->CopyFrom(local_upstream_locality_stats); | ||
| } | ||
| } | ||
|
|
||
| // Unfortunately because we don't issue an update when total_requests_in_progress goes from | ||
| // non-zero to zero, we have to go through and zero it out for any locality stats we didn't see. | ||
| for (int i = 0; i < cluster_stats->upstream_locality_stats_size(); ++i) { | ||
| auto upstream_locality_stats = cluster_stats->mutable_upstream_locality_stats(i); | ||
| bool found = false; | ||
| for (int j = 0; j < local_cluster_stats.upstream_locality_stats_size(); ++j) { | ||
| auto& local_upstream_locality_stats = local_cluster_stats.upstream_locality_stats(j); | ||
| if (TestUtility::protoEqual(upstream_locality_stats->locality(), | ||
| local_upstream_locality_stats.locality()) && | ||
| upstream_locality_stats->priority() == local_upstream_locality_stats.priority()) { | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!found) { | ||
| upstream_locality_stats->set_total_requests_in_progress(0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void waitForLoadStatsRequest( | ||
|
|
@@ -257,7 +274,7 @@ class LoadStatsIntegrationTest : public testing::TestWithParam<Network::Address: | |
| EXPECT_EQ("application/grpc", | ||
| loadstats_stream_->headers().ContentType()->value().getStringView()); | ||
| } while (!TestUtility::assertRepeatedPtrFieldEqual(expected_cluster_stats, | ||
| loadstats_request.cluster_stats())); | ||
| loadstats_request.cluster_stats(), true)); | ||
| } | ||
|
|
||
| void waitForUpstreamResponse(uint32_t endpoint_index, uint32_t response_code = 200) { | ||
|
|
@@ -461,22 +478,16 @@ TEST_P(LoadStatsIntegrationTest, LocalityWeighted) { | |
| initialize(); | ||
|
|
||
| // Debug logs for #6874 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comment? |
||
| std::cerr << "Waiting for load stats stream." << std::endl; | ||
| waitForLoadStatsStream(); | ||
| std::cerr << "Waiting for load stats request." << std::endl; | ||
| waitForLoadStatsRequest({}); | ||
|
|
||
| std::cerr << "Done waiting." << std::endl; | ||
| loadstats_stream_->startGrpcStream(); | ||
| std::cerr << "Starting response." << std::endl; | ||
| requestLoadStatsResponse({"cluster_0"}); | ||
| std::cerr << "Updating assignments." << std::endl; | ||
|
|
||
| // Simple 33%/67% split between dragon/winter localities. | ||
| // Even though there are more endpoints in the dragon locality, the winter locality gets the | ||
| // expected weighting in the WRR locality schedule. | ||
| updateClusterLoadAssignment({{0}, 2}, {{1, 2}, 1}, {}, {}); | ||
| std::cerr << "Sending traffic." << std::endl; | ||
|
|
||
| sendAndReceiveUpstream(0); | ||
| sendAndReceiveUpstream(1); | ||
|
|
@@ -486,10 +497,8 @@ TEST_P(LoadStatsIntegrationTest, LocalityWeighted) { | |
| sendAndReceiveUpstream(0); | ||
|
|
||
| // Verify we get the expect request distribution. | ||
| std::cerr << "Waiting for load stats request 2." << std::endl; | ||
| waitForLoadStatsRequest( | ||
| {localityStats("winter", 4, 0, 0, 4), localityStats("dragon", 2, 0, 0, 2)}); | ||
| std::cerr << "Done waiting." << std::endl; | ||
|
|
||
| EXPECT_EQ(1, test_server_->counter("load_reporter.requests")->value()); | ||
| // On slow machines, more than one load stats response may be pushed while we are simulating load. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,30 +265,59 @@ class TestUtility { | |
| * | ||
| * @param lhs RepeatedPtrField on LHS. | ||
| * @param rhs RepeatedPtrField on RHS. | ||
| * @param ignore_repeated_field_ordering if ordering should be ignored. Note if true this turns | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name here doesn't match the paramter name |
||
| * comparison into an N^2 operation. | ||
| * @return bool indicating whether the RepeatedPtrField are equal. TestUtility::protoEqual() is | ||
| * used for individual element testing. | ||
| */ | ||
| template <class ProtoType> | ||
| template <typename ProtoType> | ||
| static bool repeatedPtrFieldEqual(const Protobuf::RepeatedPtrField<ProtoType>& lhs, | ||
| const Protobuf::RepeatedPtrField<ProtoType>& rhs) { | ||
| const Protobuf::RepeatedPtrField<ProtoType>& rhs, | ||
| bool ignore_ordering = false) { | ||
| if (lhs.size() != rhs.size()) { | ||
| return false; | ||
| } | ||
|
|
||
| for (int i = 0; i < lhs.size(); ++i) { | ||
| if (!TestUtility::protoEqual(lhs[i], rhs[i], /*ignore_repeated_field_ordering=*/false)) { | ||
| if (!ignore_ordering) { | ||
| for (int i = 0; i < lhs.size(); ++i) { | ||
| if (!TestUtility::protoEqual(lhs[i], rhs[i], /*ignore_ordering=*/false)) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| typedef std::list<std::unique_ptr<const Protobuf::Message>> ProtoList; | ||
| // Iterate through using protoEqual as ignore_ordering is true, and fields | ||
| // in the sub-protos may also be out of order. | ||
| ProtoList lhs_list = | ||
| RepeatedPtrUtil::convertToConstMessagePtrContainer<ProtoType, ProtoList>(lhs); | ||
| ProtoList rhs_list = | ||
| RepeatedPtrUtil::convertToConstMessagePtrContainer<ProtoType, ProtoList>(rhs); | ||
| while (!lhs_list.empty()) { | ||
| bool found = false; | ||
| for (auto it = rhs_list.begin(); it != rhs_list.end(); ++it) { | ||
| if (TestUtility::protoEqual(*lhs_list.front(), **it, | ||
| /*ignore_ordering=*/true)) { | ||
| lhs_list.pop_front(); | ||
| rhs_list.erase(it); | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!found) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| template <class ProtoType> | ||
| static AssertionResult | ||
| assertRepeatedPtrFieldEqual(const Protobuf::RepeatedPtrField<ProtoType>& lhs, | ||
| const Protobuf::RepeatedPtrField<ProtoType>& rhs) { | ||
| if (!repeatedPtrFieldEqual(lhs, rhs)) { | ||
| const Protobuf::RepeatedPtrField<ProtoType>& rhs, | ||
| bool ignore_ordering = false) { | ||
| if (!repeatedPtrFieldEqual(lhs, rhs, ignore_ordering)) { | ||
| return AssertionFailure() << RepeatedPtrUtil::debugString(lhs) << " does not match " | ||
| << RepeatedPtrUtil::debugString(rhs); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename the variable now that it's not always a vector?