Skip to content
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

Remove include of gtest_prod.h #152

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

autopear
Copy link
Contributor

Currently we use flare's fiber in our project, which cannot include any googletest headers in the production environment. IMO, release headers should not include gtest. To test against certain private/protected class members, you can add some test-specific APIs to access these members. Similar methods can be applied to other components like hbase and rpc.

@0x804d8000
Copy link
Collaborator

I'm not sure this is my preferred way to address the issue.

My concern is that exposing these internal methods, albeit with a TEST prefix, makes public interfaces ugly. Especially with auto-completion enabled, IDE will list them out regardless of their prefix.

If linking against gtest is a concern, maybe we can instead provide our own gtest_prod.h in flare/testing and include it in headers you're modifying instead. That header is simple enough for us to roll our own.

@autopear
Copy link
Contributor Author

I think you proposed method is better. However, I'm not sure how this is possible in bazel/blade. You need to add come build time option to enable include of the actual gtest_prod.h or the customized one with empty defines for FRIEND_TEST, and linking against gtest_prod.

@0x804d8000
Copy link
Collaborator

Guess I wasn't clear about my proposal.

What I meant was to always use flare/testing/gtest_prod.h. We can implement our own FRIEND_TEST in this new header, and get rid of gtest's header altogether.

This should be relatively easy to do, as FRIEND_TEST is just a macro expanding to friend class.

@autopear autopear force-pushed the rm_gtest_from_prod branch 2 times, most recently from acee433 to e63b55a Compare May 28, 2024 04:14
@autopear autopear changed the title Remove include of gtest from maybe_owning.h and metrics.h Remove include of gtest_prod.h May 28, 2024
Copy link
Collaborator

@0x804d8000 0x804d8000 left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply, been busy these days..

I've commented inline.

Bazel build is also failing due to missing bazel target for test_prod.h. (Previously bazel build failed too, but not for the same reason. It was mostly a environment issue. I'm trying to fix it in #153 )

flare/base/internal/test_prod.h Outdated Show resolved Hide resolved
flare/net/hbase/hbase_controller_common.h Outdated Show resolved Hide resolved
flare/net/hbase/hbase_server_protocol.h Outdated Show resolved Hide resolved
flare/rpc/internal/stream_call_gate.h Outdated Show resolved Hide resolved
flare/rpc/protocol/protobuf/rpc_channel.h Outdated Show resolved Hide resolved
flare/rpc/protocol/protobuf/rpc_client_controller.h Outdated Show resolved Hide resolved
flare/rpc/protocol/protobuf/service.h Outdated Show resolved Hide resolved
flare/rpc/server.h Outdated Show resolved Hide resolved
flare/rpc/tracing/tracing_ops.h Outdated Show resolved Hide resolved
flare/base/internal/test_prod.h Show resolved Hide resolved
@0x804d8000
Copy link
Collaborator

0x804d8000 commented Jun 1, 2024

I've merged aforementioned PR. You can now pull changes from master to verify that your changes pass all CIs.

Thanks for the contribution 🙏.


A few tests aren't stable and fail under high load, which does happen in GitHub runners, they can be safely ignored.

@autopear
Copy link
Contributor Author

autopear commented Jun 4, 2024

All comments are addressed. However, I'm not sure why some tests are failing. Can you take a look?

@0x804d8000
Copy link
Collaborator

Some load-sensitivity tests, though I didn't expect them to fail so frequently.

I retried them and now all of them passed.

Merged, thanks!

@0x804d8000 0x804d8000 merged commit 16ae3fa into Tencent:master Jun 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants