[SERVER-79137] Add a single unit test to bazel PoC Created: 19/Jul/23  Updated: 28/Nov/23  Resolved: 16/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Alex Neben Assignee: Zack Winter
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Development Platform
Backwards Compatibility: Fully Compatible
Participants:

 Description   

We should demonstrate that bazel is able to run a unit test. This will make sure static initializers work. We should try to convert "unit test test" to confirm it is working. This ticket will be completed when we are able to run this binary outside of bazel.

This work should be completed on daniel.moody@mongodb.com 's PoC branch . There is also prior art for how to build server as part of the work on this branch. I think you will need to do work to combine the two branches because you will most likely need some third_parties built with bazel.



 Comments   
Comment by Zack Winter [ 16/Nov/23 ]

Closing this out since we now have a bazel unit test running in CI (this is a real mongodb unit test, just not using the unit test framework).

Created SERVER-83364 to track the work of supporting the MongoDB unit test framework in phase 2 since we cannot do this until we've made bazel required.

Comment by Githook User [ 08/Nov/23 ]

Author:

{'name': 'Zack Winter', 'email': 'zack.winter@mongodb.com', 'username': 'zackwintermdb'}

Message: SERVER-79137 Add evergreen target to exercise 'bazel run'
Branch: master
https://github.com/mongodb/mongo/commit/1f820ec1a41a07107b0ce500a8c47d0cfebf67ce

Comment by Zack Winter [ 06/Nov/23 ]

I don't know if we can really call this done. Technically visibility_test1 is a test but it doesn't depend on the mongodb unit test framework. After the previous PR, this target is now fully runnable via "bazel run" and "bazel test", but it's not much more than a hello world program.

That being said, I don't think we want to add in all of the dependencies for the unit test framework in phase 1. I looked through what files it would touch and it seems like certain dependencies of the unit test framework are fairly regularly updated. Since we don't want to port over commonly modified targets, I'd like to defer this to phase 2 when we can fully deprecate the scons version of these targets.

We can use this target to test out linking, which should get us what we need for phase 1.

Comment by Alex Neben [ 05/Nov/23 ]

The intent of this ticket was for a user to be able to run a unit test. Can this be run after this merge? My reading was that it just builds?

Comment by Githook User [ 04/Nov/23 ]

Author:

{'name': 'Zack Winter', 'email': 'zack.winter@mongodb.com', 'username': 'zackwintermdb'}

Message: SERVER-79137 convert visibility_test1 to build in bazel
Branch: master
https://github.com/mongodb/mongo/commit/03c8f50ee8a8a6e94f3144ed6d1d55da3bb4d1ea

Comment by Steve Gross [ 04/Aug/23 ]

I've explored making a unit test buildable here. However, it's not feasible... yet! Bazel is quite strict about #include directives, so I can't really build a unit test without first ensuring the Bazel-buildability of the test's dependencies. This includes #include-based dependencies.

I still plan to do this as part of phase 1, but I need a bit more time. In particular, I need to adapt a minimum set of libraries to be Bazel-buildable, and then build a test that depends on those libraries.

Comment by Alex Neben [ 21/Jul/23 ]

"base_test" seems to be a top level test which can be found here

Comment by Alex Neben [ 21/Jul/23 ]

I am not totally sure. Maybe base_test?

Comment by Steve Gross [ 20/Jul/23 ]

Note to self: to easily view how daniel.moody@mongodb.com's changes work, use this link

Generated at Thu Feb 08 06:40:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.