dzbarsky / rules_itest

Bazel rules for integration testing services
MIT License
17 stars 6 forks source link

Resource allocation? #37

Open manuelnaranjo opened 1 day ago

manuelnaranjo commented 1 day ago

First of all let me say that the rationale behind this project is incredible! I've been watching at testcontainers for a while, and even though it's great from the developer perspective it's not so compelling from the management side. A nice feature of Bazel is the scheduler and the fact that you can rely on it doing a decent job to keep your resources utilized but not burned out, how does the rules deal with this? I think it doesn't at all, I don't see any tags like cpu= mem=, am I correct to assume that's the case? Has anyone tried to do this? I wouldn't mind see if I can manage some time for this, but before I jump I rather ask

dzbarsky commented 1 day ago

@manuelnaranjo My understanding is that resource allocation in Bazel works very different for local vs remote execution. I forget the details, but I think it has to do with execution_requirements for remote resource usage and tags for local usage for tests. For build actions, the rule author can use the resource_set API to try to guide Bazel.

Since this ruleset doesn't have any expensive build actions, I don't think there's much point in using resource_set, and you should be able to just use tags or execution_requirements to control resource usage.

It's totally possible that I'm missing something, could you help me understand what support you were thinking was needed from the rules?

manuelnaranjo commented 1 day ago

I'm thinking more along the lines the itest_service entries specify how much RAM and CPU is needed and then I service_test adds it all up. But I guess that's not possible

dzbarsky commented 12 hours ago

There's two challenges with that:

  1. I think the resources used by each service will be more so a property of the test itself than the service. For example a MySQL service might be mostly idle or it might be busy if you send it expensive queries in parallel
  2. Even if you could predict the usage, I'm not sure how to specify it in a way that will work for all execution modes

Do you want to try to prototype something in a fork and let me know how it works for you?

manuelnaranjo commented 5 hours ago

@dzbarsky fair point, I think you're right, I looked into the actions DefaultInfo and RunEnvironmentInfo and DefaultInfo and nothing allows to set that from inside the rule handler, I guess it's something I could help in documenting though, I would say CPU limits are not as bad as memory limits, let's say you want to use Cassandra or Elastic Search, this java services are very memory hungry and you don't want your resources to starve and end with kernel pagination or OOM