Skip to content

router: use new config_impl_test_lib instead of synthetic build target#6871

Merged
lizan merged 4 commits intoenvoyproxy:masterfrom
fcfort:config_impl_test
May 13, 2019
Merged

router: use new config_impl_test_lib instead of synthetic build target#6871
lizan merged 4 commits intoenvoyproxy:masterfrom
fcfort:config_impl_test

Conversation

@fcfort
Copy link
Copy Markdown
Contributor

@fcfort fcfort commented May 9, 2019

Signed-off-by: Frank Fort ffort@google.com

Description: The build target //test/common/router:config_impl_test_static was relying upon the _lib target that is created by the envoy_cc_test in envoy_build_system.bzl. This target should not be relied upon since it is an implementation detail of the Envoy build system rather than a public build target that we want to allow dependencies upon.

This PR restricts the visibility of these synthetic targets to only the code coverage tools and renames them to end with _lib_INTERNAL_ONLY instead. See #6725 for where we started using these synthetic targets in our BUILD files.

This PR also hides the envoy_cc_test_infrastructure_library build macro by renaming it to _envoy_cc_test_infrastructure_library as per https://docs.bazel.build/versions/master/build-ref.html#load. This macro was not being used outside of envoy_build_system.bzl.

Note this does not break coverage builds since coverage pulls in the synthetic targets via the coverage_test_lib tag, see generated_coverage_BUILD.txt for the generated coverage BUILD file.

Risk Level: Low
Testing: Ran bazel test //test/common/.... and ran test/run_envoy_bazel_coverage.sh.
Docs Changes: N/A
Release Notes: N/A

@fcfort
Copy link
Copy Markdown
Contributor Author

fcfort commented May 9, 2019

@lizan @htuch

@fcfort
Copy link
Copy Markdown
Contributor Author

fcfort commented May 9, 2019

Looks like there was somewhere else relying upon these _lib targets that I missed, let me take a look.

Signed-off-by: Frank Fort <ffort@google.com>
@lizan
Copy link
Copy Markdown
Member

lizan commented May 9, 2019

I'm not very thrilled with this approach though not a strong opinion, this is the issue how Google internal envoy_build_system.bzl is implemented. Also I'm worrying about other repository that may depends on the test libs. We didn't guard them with bazel visibility or document it so I don't think it is really an implementation details which we should hide.

The alternative would be either:

  • Fix your internal envoy_build_system.bzl
  • Exposing linkstatic in envoy_cc_test.

@htuch thoughts?

@lizan lizan requested a review from htuch May 9, 2019 20:01
@lizan lizan self-assigned this May 9, 2019
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

@lizan good points, I think though that anyone relying on this behavior is probably sophisticated enough to fix when this merges. @fcfort can you fix the visibility as well, so that we can prevent folks forming these dependencies?
/wait

…rgets

Signed-off-by: Frank Fort <ffort@google.com>
@fcfort
Copy link
Copy Markdown
Contributor Author

fcfort commented May 10, 2019

@lizan good points, I think though that anyone relying on this behavior is probably sophisticated enough to fix when this merges. @fcfort can you fix the visibility as well, so that we can prevent folks forming these dependencies?

Done, see updated PR description. Basically:

This PR restrict the visibility of these synthetic targets to only the code coverage tools and renames them to end with _lib_INTERNAL_ONLY instead. See #6725 for where we started using these synthetic targets in our BUILD files.

This PR also hides the envoy_cc_test_infrastructure_library build macro by renaming it to _envoy_cc_test_infrastructure_library as per https://docs.bazel.build/versions/master/build-ref.html#load. This macro was not being used outside of envoy_build_system.bzl.

@fcfort
Copy link
Copy Markdown
Contributor Author

fcfort commented May 10, 2019

As an aside it may be worth fixing some our uses of envoy_cc_test_library. By default it declares all targets as //visibility:public which will hamper refactoring efforts.

@fcfort
Copy link
Copy Markdown
Contributor Author

fcfort commented May 10, 2019

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #6871 (comment) was created by @fcfort.

see: more, trace.

lizan
lizan previously approved these changes May 10, 2019
data = data,
external_deps = external_deps,
deps = deps,
deps = deps + [repository + "//test/test_common:printers_includes"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why this change? What do we gain by replacing envoy_cc_test_library?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We cannot continue to use envoy_cc_test_library here since it declares all targets created with it as //visibility:public, which means we cannot restrict the visibility of the _lib_internal_only targets to @envoy//test/coverage:__pkg__.

tags = test_lib_tags,
copts = copts,
# Restrict only to the code coverage tools.
visibility = ["@envoy//test/coverage:__pkg__"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you verify that the fuzzers targets needed at https://github.com/google/oss-fuzz/blob/master/projects/envoy/build.sh#L62 still build? I.e. the _driverless variants of each fuzz target. This isn't caught by CI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Verified that bazel build $(bazel query 'filter("_driverless", kind(".* rule", //...))') progresses to the linking stage (despite encountering a library error there) and that bazel build $(bazel query 'filter("_corpus$", kind(".* rule", //...))') finishes successfully.

Signed-off-by: Frank Fort <ffort@google.com>
@lizan lizan merged commit eaa2cb5 into envoyproxy:master May 13, 2019
@fcfort fcfort deleted the config_impl_test branch May 13, 2019 19:58
htuch pushed a commit that referenced this pull request May 16, 2019
This PR makes all macros used solely within envoy_build_system.bzl as private by prefixing the macro name with an _ as per https://docs.bazel.build/versions/master/build-ref.html#load. For more background, see #6871 where Envoy's build macro envoy_cc_test_infrastructure_library was made private.

We should strive to restrict visibility of our build macros where possible so that we don't create dependencies on the internal details of our build system where we do not intend to.

Risk Level: Low
Testing: Ran bazel test //test/common/... //test/exe/...

Signed-off-by: Frank Fort <ffort@google.com>
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.

3 participants