Skip to content

Update googletest to 1.15.2 #36699

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

Closed
wants to merge 36 commits into from
Closed

Conversation

asedeno
Copy link
Contributor

@asedeno asedeno commented Oct 18, 2024

Fix #35540

This picks up nearly four years of changes in googletest.

googletest has updated to abseil flags1.

The most notable difference is that unrecognized flags result in a flag parsing error,
and are not returned to the user though a modified argc/argv, unless they appear
after the positional argument delimiter ("--").

For example, to pass a non-Abseil flag, you would have to do
./mytest --gtest_color=false -- --myflag=myvalue

After this upgrade, to set Envoy's CLI arguments in tests requires passing them after --.
For example,

bazel test //test/common/common:logger_test --test_arg="--" --test_arg="-l trace"

Per googletest documentation2, it is strongly recommended that death tests
have names ending in DeathTest rather than simply Test.

Some death tests behave better when run in a threadsafe manner3.
This is a trade-off that costs speed. The flag has been set in tests where it made a difference.

When building with bazel and abseil, googletest uses re24. The switch to re2 means
that . does not match newline by default. This prefixes regex that need it with (?s)
to change that behavior5.

Risk Level: low — test only
Testing: Updates

Footnotes

  1. https://github.com/google/googletest/commit/25dcdc7e8bfac8967f20fb2c0a628f5cf442188d

  2. https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-naming

  3. https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-styles

  4. https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-styles

  5. https://github.com/google/re2/wiki/syntax#flags

Signed-off-by: Alejandro R. Sedeño <[email protected]>
google/googletest@25dcdc7

"""
The most notable difference is that unrecognized flags result
in a flag parsing error, and are not returned to the user though
a modified argc/argv, unless they appear after the positional
argument delimiter ("--").

For example, to pass a non-Abseil flag, you would have to do
./mytest --gtest_color=false -- --myflag=myvalue
"""

Signed-off-by: Alejandro R. Sedeño <[email protected]>
Signed-off-by: Alejandro R. Sedeño <[email protected]>
Per googletest documentation[^1], it is strongly recommended that
death tests have names ending in `DeathTest` rather than simply
`Test`. This makes those changes.

Some death tests behave better when run in a threadsafe
manner[^2]. This is a trade-off that costs speed. The flag has been
set in tests where it made a difference.

[^1]: https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-naming
[^2]: https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-styles

Signed-off-by: Alejandro R. Sedeño <[email protected]>
When building with bazel and abseil, googletest uses re2[^1]. The
switch to re2 means that `.` does not match newline by default. This
prefixes regex that need it with `(?s)` to change that behavior[^2].

[^1]: https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-styles
[^2]: https://github.com/google/re2/wiki/syntax#flags

Signed-off-by: Alejandro R. Sedeño <[email protected]>
googletest has switched from custom-rolled heterogeneous comparator
functors to C++ standard ones (e.g., `std::equal_to<>`). The version
of clang we're currently using in docker finds two equally good
`operator==` overloads here, in which a cast for one operand or the
other is necessary, and having not found one unambiguously better
operator, fails to build. This has been resolved in newer versions of
clang.

Since the relevant `operator==` already does its own dynamic casting,
drop the `WhenDynamicCastTo<>` from this one `EXPECT_CALL` so it'll
build again.

Signed-off-by: Alejandro R. Sedeño <[email protected]>
This moves setting `--gmock_default_mock_behavior=2` to the head of
`args`, which makes sense in light of the googletest/absel flag
changes. This ensures that this googletest flag appears before any
`--` separating googletest flags from envoy/test flags.

Signed-off-by: Alejandro R. Sedeño <[email protected]>
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #36699 was opened by asedeno.

see: more, trace.

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Oct 18, 2024
Copy link

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @mattklein123

🐱

Caused by: #36699 was opened by asedeno.

see: more, trace.

@asedeno
Copy link
Contributor Author

asedeno commented Oct 18, 2024

cc: @phlax @adisuissa @yanavlasov
x-ref #33219

Copy link
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pursuing this!
I cannot recall which CI test was problematic, but I hope we can get this solved in this PR.

@@ -4769,7 +4769,8 @@ class AllowForceFail : public Api::OsSysCallsImpl {
bool fail_ = false;
};

TEST_P(ProtocolIntegrationTest, HandleUpstreamSocketCreationFail) {
TEST_P(ProtocolIntegrationDeathTest, HandleUpstreamSocketCreationFail) {
GTEST_FLAG_SET(death_test_style, "threadsafe");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed here (and in some of the other tests)? I thought it is set once in the test_runner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not go digging into why. All I can tell you is that anywhere I set it explicitly, the tests failed without it.

Signed-off-by: Alejandro R. Sedeño <[email protected]>
Signed-off-by: Alejandro R. Sedeño <[email protected]>
…ntiation into #ifdef

Signed-off-by: Alejandro R. Sedeño <[email protected]>
pulling in the fake @fuchsia_sdk from googletest left it not marked
for test only, which made the envoy CI deps check fail. Stripping it
out is a very small and simple patch, so let's do that instead.

Signed-off-by: Alejandro R. Sedeño <[email protected]>
@asedeno
Copy link
Contributor Author

asedeno commented Oct 19, 2024

Fun. Coverage tests are failing because the disk is full. From df-post:

Filesystem      Size  Used Avail Use% Mounted on                                                                                     
/dev/root        73G   73G   16M 100% /                                                                                                            
tmpfs           7.9G  172K  7.9G   1% /dev/shm                                                                                                     
tmpfs           3.2G  1.1M  3.2G   1% /run                                                                                                         
tmpfs           5.0M     0  5.0M   0% /run/lock                                                                                                    
/dev/sdb15      105M  6.1M   99M   6% /boot/efi                                                                                                    
/dev/sda1        74G  4.1G   66G   6% /mnt                                                                                                         
tmpfs           1.6G   12K  1.6G   1% /run/user/1001                                                                                               

@asedeno
Copy link
Contributor Author

asedeno commented Oct 19, 2024

clang and gcc are being killed building some targets. We can iterate and keep bumping up the rbe_pools for targets one by one, but I don't like it.

@phlax
Copy link
Member

phlax commented Oct 21, 2024

Fun. Coverage tests are failing because the disk is full

hmm - i added the diskspace-hack (ie delete some of the default installed cruft before running) so i would have hoped this didnt happen - lmc again ...

clang and gcc are being killed building some targets. We can iterate and keep bumping up the rbe_pools for targets one by one, but I don't like it.

i have some tooling to identify which jobs need more mem by profiling a complete run with everything running on max mem workers, but tbh, with most of the problematic tasks already identified, doing what you are doing is probably more reliable and less time consuming

@phlax
Copy link
Member

phlax commented Oct 21, 2024

so diskspace hack is running and frees up a fair amount of space but evidently not enough

Disk space before cruft removal
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        73G   58G   16G  80% /
tmpfs           7.9G  172K  7.9G   1% /dev/shm
tmpfs           3.2G  1.1M  3.2G   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda15      105M  6.1M   99M   6% /boot/efi
/dev/sdb1        74G  4.1G   66G   6% /mnt
tmpfs           1.6G   12K  1.6G   1% /run/user/1001
Removing: /opt/hostedtoolcache ...
Removing: /usr/local/lib/android ...
Removing: /usr/local/.ghcup ...
Disk after cruft removal
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        73G   36G   37G  50% /
tmpfs           7.9G  172K  7.9G   1% /dev/shm
tmpfs           3.2G  1.1M  3.2G   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda15      105M  6.1M   99M   6% /boot/efi
/dev/sdb1        74G  4.1G   66G   6% /mnt
tmpfs           1.6G   12K  1.6G   1% /run/user/1001

i guess we just need to rm -rf even more paths to free space - i can raise a PR for that now

@asedeno
Copy link
Contributor Author

asedeno commented Oct 22, 2024

In the last Mobile/ASAN run, //test/common:internal_engine_test failed to compile and it's already set to run on 4core.

@@ -18,6 +18,7 @@ envoy_cc_test(
envoy_cc_test(
name = "internal_engine_test",
srcs = ["internal_engine_test.cc"],
rbe_pool = "2core",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mobile CI doesnt use these pools

for ref here are the mobile pools:

https://envoy.cluster.engflow.com/restatus

and the envoy ones:

https://mordenite.cluster.engflow.com/restatus

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also mobile is not set up to use rbe_pool so it will either break stuff or at best be ignored

it is, however, OOMing

ERROR: /source/mobile/test/common/BUILD:18:14: Compiling test/common/internal_engine_test.cc failed: (Killed): clang-14 failed: error executing command (from target //test/common:internal_engine_test) 

which means there is a bigger issue in terms of mobile workers and resources - probably you will need to raise this on the related channel

@asedeno
Copy link
Contributor Author

asedeno commented Nov 11, 2024

Still OOMing. Waiting on further resources.

@@ -31,6 +31,7 @@ envoy_extension_cc_test(
"platform_bridge_filter_integration_test.cc",
],
extension_names = ["envoy.filters.http.platform_bridge"],
rbe_pool = "6gig",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont work out of the box - what it actually needs to be is:

exec_properties = {"Pool": "6gig"}

probably it makes sense to set up a macro - so that you can set it as rbe_pool - see eg

exec_properties = exec_properties | select({
repository + "//bazel:engflow_rbe": {"Pool": rbe_pool} if rbe_pool else {},
"//conditions:default": {},
})

Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 15, 2024
Copy link

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps Approval required for changes to Envoy's external dependencies stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Newer release available com_google_googletest: v1.15.2 (current: a4ab0ab)
4 participants