Why does my Bazel test report failure when all individual tests are passing?

Viewed 1869

When running my unit test (gtest) through Bazel, I'm seeing a failure reported. However, the logs indicate that my test is running successfully and passing.

Other tests in my project are passing and the only difference between the deviant test and the others is that the deviant test is multithreaded.

I've run the test binary found in bazel-bin by itself and it passes and returns successfully.

Bazel version:

Build label: 0.26.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue May 28 08:35:14 2019 (1559032514)
Build timestamp: 1559032514
Build timestamp as int: 1559032514

The relevant block in my BUILD file:

cc_test(
  name = "DBControllerIntegration",
  srcs = ["dbcontroller_integration_test.cc"],
  deps = [
    "//src:db_ctl_lib",
    "//test/mocks:sstable_mock_lib",
    "@boost//:filesystem",
    "@com_google_protobuf//:protobuf",
    "@glog//:glog",
    "@googletest//:gtest_main",
  ],
  copts = ["-std=c++17"],
)

Bazel test failure output:

>> bazel test //test:DBControllerIntegration --test_output=errors
INFO: Invocation ID: ccca8fa7-27a5-4c8c-badf-3f342934e4e5
INFO: Analysed target //test:DBControllerIntegration (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
FAIL: //test:DBControllerIntegration (see /home/tallen/.cache/bazel/_bazel_tallen/f087948e065d612174d90a43a5740198/execroot/diodb/bazel-out/k8-dbg/testlogs/test/DBControllerIntegration/test.log)
INFO: From Testing //test:DBControllerIntegration:
==================== Test output for //test:DBControllerIntegration:
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DBControllerIntegrationTest
[ RUN      ] DBControllerIntegrationTest.Basic

... <omitting my application's logs> ...

[       OK ] DBControllerIntegrationTest.Basic (4000 ms)
[----------] 1 test from DBControllerIntegrationTest (4000 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (4001 ms total)
[  PASSED  ] 1 test.
================================================================================
Target //test:DBControllerIntegration up-to-date:
  bazel-bin/test/DBControllerIntegration
INFO: Elapsed time: 4.706s, Critical Path: 4.57s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//test:DBControllerIntegration                                           FAILED in 4.6s
  /home/tallen/.cache/bazel/_bazel_tallen/f087948e065d612174d90a43a5740198/execroot/diodb/bazel-out/k8-dbg/testlogs/test/DBControllerIntegration/test.log

INFO: Build completed, 1 test FAILED, 2 total actions

Running the test binary by itself:

>> ./bazel-bin/test/DBControllerIntegration
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DBControllerIntegrationTest
[ RUN      ] DBControllerIntegrationTest.Basic

... <omitting my application's logs> ...

[       OK ] DBControllerIntegrationTest.Basic (4001 ms)
[----------] 1 test from DBControllerIntegrationTest (4001 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (4001 ms total)
[  PASSED  ] 1 test.

I would expect the Bazel test result to be reported as passing since the actual test is passing, but I'm seeing the test as failed.

1 Answers

This was resolved when gracefully terminating all threads spawned by my project.

Related