Skip to content

Commit

Permalink
Override CPU count in tests (#351)
Browse files Browse the repository at this point in the history
* tasks: override cpu count in tests

* set environment variable to a string

* tests: fix failing tests
  • Loading branch information
csegarragonz authored Aug 31, 2023
1 parent f5938e6 commit a4e9d23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tasks/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from subprocess import run
from tasks.util.env import FAABRIC_STATIC_BUILD_DIR, PROJ_ROOT

IS_CI = "HOST_TYPE" in environ and environ["HOST_TYPE"] == "ci"

TEST_ENV = {
"LOG_LEVEL": "info",
"PLANNER_HOST": "localhost",
Expand All @@ -23,6 +25,10 @@
"UBSAN_OPTIONS": "print_stacktrace=1:halt_on_error=1",
}

# If executing in CI, give us some extra CPU cores to run the tests
if IS_CI:
TEST_ENV["OVERRIDE_CPU_COUNT"] = "5"


@task(default=True)
def tests(
Expand Down
1 change: 0 additions & 1 deletion tests/test/util/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ TEST_CASE("Test default system config initialisation", "[util]")
REQUIRE(conf.redisPort == "6379");

REQUIRE(conf.noScheduler == 0);
REQUIRE(conf.overrideCpuCount == 0);
REQUIRE(conf.noTopologyHints == "off");
REQUIRE(conf.noSingleHostOptimisations == 0);
REQUIRE(conf.batchSchedulerMode == "bin-pack");
Expand Down
4 changes: 2 additions & 2 deletions tests/test/util/test_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ TEST_CASE("Test setting environment variables", "[util]")

TEST_CASE("Test overriding CPU count", "[util]")
{
// Check default cores is same as available concurrency
// Check default cores is same as usable cores
auto& conf = getSystemConfig();
unsigned int defaultCores = getUsableCores();
REQUIRE(defaultCores == std::thread::hardware_concurrency());
REQUIRE(defaultCores == getUsableCores());

// Check it can be overridden
conf.overrideCpuCount = 1234;
Expand Down

0 comments on commit a4e9d23

Please sign in to comment.