ci: fix for Bazel issues seen in PR #5767#5868
ci: fix for Bazel issues seen in PR #5767#5868htuch merged 5 commits intoenvoyproxy:masterfrom mpwarres:debug-experimental-remap-main-repo
Conversation
Signed-off-by: Michael Warres <mpw@google.com>
Signed-off-by: Michael Warres <mpw@google.com>
|
/retest |
|
🔨 rebuilding |
|
/retest I'm surprised at the ASAN errors, they are consistent across tests, but seem to indicate some file I/O issue. |
|
🔨 rebuilding |
| @@ -1,12 +1,12 @@ | |||
| workspace(name = "envoy") | |||
| workspace(name = "envoy_filter_example") | |||
There was a problem hiding this comment.
The ASAN/TSAN test failures are real, CI run ASAN/TSAN from envoy-filter-example though our test setup depends on TEST_WORKSPACE env. Before this change it is identical so wasn't a problem though now it is.
There was a problem hiding this comment.
Addressed by splitting into separate 'bazel test' invocations, so the @envoy//... tests are run with TEST_WORKSPACE=envoy, while the @envoy-filter-example//... tests are run with TEST_WORKSPACE=envoy-filter-example. All CI tests pass now.
@lizan PTAL again, thanks!
Needed to pick up #5850.
Run tests defined in envoy workspace in one bazel test invocation, and tests defined in envoy-filter-example workspace in a separate bazel test invocation, done from $ENVOY_FILTER_EXAMPLE_SRCDIR. This is so that the $TEST_WORKSPACE environment variable, which plays a role in locating test runtime file dependencies, will be set properly for each grouping of tests. Signed-off-by: Michael Warres <mpw@google.com>
|
/retest |
|
🔨 rebuilding |
…ffic tapping. Signed-off-by: Michael Warres <mpw@google.com>
| echo "bazel ASAN/UBSAN debug build with tests" | ||
| echo "Building and testing envoy tests..." | ||
| cd "${ENVOY_SRCDIR}" | ||
| bazel_with_collection test ${BAZEL_TEST_OPTIONS} -c dbg --config=clang-asan //test/... |
There was a problem hiding this comment.
How come we can't build/test @envoy directly anymore? I get that we're in a different workspace etc, but don't see why we should be able to use these paths.
There was a problem hiding this comment.
It's a combination of a few things:
-
bazeltest automatically sets the TEST_WORKSPACE environment variable to the local repository's workspace name.- Without this PR, when
bazel testis run from $ENVOY_FILTER_EXAMPLE_SRCDIR, TEST_WORKSPACE would evaluate to "envoy", since that was the workspace name set by WORKSPACE.filter.example. - With this PR, when
bazel testis run from $ENVOY_FILTER_EXAMPLE_SRCDIR, TEST_WORKSPACE evaluates to "envoy_filter_example".
- Without this PR, when
-
TEST_WORKSPACE affects TEST_RUNDIR. Here's where envoy/test/main.cc sets TEST_RUNDIR to $TEST_SRCDIR/$TEST_WORKSPACE. And TEST_RUNDIR is how Envoy::TestEnvironment finds test input data: TestEnvironment::runfilesPath() just appends the path it is given to TEST_RUNDIR.
-
Empirically, bazel places runfiles for build targets in $TEST_SRCDIR/<workspace-name>, where <workspace-name> is the name of the (maybe external) workspace containing the build target. With this PR, prior to the latest changes that split
bazel testinvocations, runfiles for @envoy tests were in $TEST_SRCDIR/envoy, whilebazel testinvoked from $ENVOY_FILTER_EXAMPLE_SRCDIR was setting TEST_RUNDIR to $TEST_SRCDIR/envoy_filter_example and looking for them there.
Splitting the bazel test invocations ensures that TEST_WORKSPACE is always the same as the <workspace-name> in which the runfiles for tests can be found. This issue didn't arise before, since we used the same workspace name "envoy" in both cases.
There was a problem hiding this comment.
This seems to be masking an underlying issue in how we or Bazel are setting up the rundir path for tests. Shouldn't we be able to bazel test @foo//:bar for some external repository?
There was a problem hiding this comment.
Here is a very basic, self-contained repro that illustrates the behavior: https://gist.github.com/mpwarres/b83539d17f92d63d9c25794a84a734ab
@dkelmer / @dslomov, is this supposed to work, or is running a test with runfiles that belongs to external dependency A from some other workspace B not a supported use case?
@htuch I'm not sure how else to address the Bazel behavior within the confines of this PR, any suggestions welcome. In some sense the Bazel behavior was masked even prior to this PR, by virtue of the external dependency having the same name as the workspace using it.
There was a problem hiding this comment.
@htuch from a repository consuming envoy as deps (e.g. envoy-filter-example, istio/proxy), bazel test @envoy//test/... will fail some of tests depending on TEST_WORKSPACE, I think it is a separate issue which we should address, but should not block on this PR.
htuch
left a comment
There was a problem hiding this comment.
@mpwarres if you can file this repro as an issue at https://github.com/bazelbuild/bazel/issues (and CC me), happy to merge this PR for now. Thanks!
|
Sure thing, filed as bazelbuild/bazel#7399 . Thanks for the review! |
|
I'm not quite sure it is bazel issue though, seems like we shouldn't use TEST_WORKSPACE but hardcode |
|
@lizan what if someone sets up Envoy with a different WORKSPACE and chosen name? I guess the Bazel issue is "what are the best practices for referring to your runfiles?". |
|
+1 to what @htuch said. I updated the repro at https://gist.github.com/mpwarres/b83539d17f92d63d9c25794a84a734ab to illustrate both @lizan's workaround (which does work, so long as the workspace name matches), as well as the failure if the workspace name assumed by the test code doesn't match the name assigned to the external dependency by the importing workspace. |
Proposed fix for issues seen in envoyproxy#5767 Update envoy/ci/WORKSPACE.filter.example, which is used in CI tests (see setup [here](https://github.com/envoyproxy/envoy/blob/f2511a39cf2c4fe392d5499e854c39f262712100/ci/build_setup.sh#L92)), to more closely match current envoy-filter-example [WORKSPACE](https://github.com/envoyproxy/envoy-filter-example/blob/master/WORKSPACE) file. In particular, remove the dual use of "envoy" as both the name of envoy-filter-example workspace as well as the envoy local_repository, and load //bazel:repositories.bzl and //bazel:cc_configure.bzl using fully qualified target names, which removes the need to [set --package_path](https://github.com/envoyproxy/envoy/blob/f2511a39cf2c4fe392d5499e854c39f262712100/ci/build_setup.sh#L63) in ci/build_setup.sh. Risk Level: low: errors should result in CI failure Testing: existing CI tests Signed-off-by: Michael Warres <mpw@google.com> Signed-off-by: Fred Douglas <fredlas@google.com>
Description:
Proposed fix for issues seen in #5767
Update envoy/ci/WORKSPACE.filter.example, which is used in CI tests (see setup here), to more closely match current envoy-filter-example WORKSPACE file. In particular, remove the dual use of "envoy" as both the name of envoy-filter-example workspace as well as the envoy local_repository, and load //bazel:repositories.bzl and //bazel:cc_configure.bzl using fully qualified target names, which removes the need to set --package_path in ci/build_setup.sh.
Risk Level: low: errors should result in CI failure
Testing: existing CI tests
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]
Signed-off-by: Michael Warres mpw@google.com