Skip to content

Commit 9388628

Browse files
authored
PYTHON-5275 Fix handlig of FIPS build (#2266)
1 parent bc2cc1e commit 9388628

File tree

6 files changed

+12
-4
lines changed

6 files changed

+12
-4
lines changed

.evergreen/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ functions:
6767
binary: bash
6868
working_dir: "src"
6969
include_expansions_in_env: [VERSION, TOPOLOGY, AUTH, SSL, ORCHESTRATION_FILE, PYTHON_BINARY, PYTHON_VERSION,
70-
STORAGE_ENGINE, REQUIRE_API_VERSION, DRIVERS_TOOLS, TEST_CRYPT_SHARED, AUTH_AWS, LOAD_BALANCER, LOCAL_ATLAS]
70+
STORAGE_ENGINE, REQUIRE_API_VERSION, DRIVERS_TOOLS, TEST_CRYPT_SHARED, AUTH_AWS, LOAD_BALANCER, LOCAL_ATLAS, NO_EXT]
7171
args: [.evergreen/just.sh, run-server, "${TEST_NAME}"]
7272
- command: expansions.update
7373
params:
@@ -89,7 +89,7 @@ functions:
8989
include_expansions_in_env: [AUTH, SSL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
9090
AWS_SESSION_TOKEN, COVERAGE, PYTHON_BINARY, LIBMONGOCRYPT_URL, MONGODB_URI, PYTHON_VERSION,
9191
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION, DEBUG_LOG,
92-
ORCHESTRATION_FILE, OCSP_SERVER_TYPE, VERSION]
92+
ORCHESTRATION_FILE, OCSP_SERVER_TYPE, VERSION, REQUIRE_FIPS]
9393
binary: bash
9494
working_dir: "src"
9595
args: [.evergreen/just.sh, setup-tests, "${TEST_NAME}", "${SUB_TEST_NAME}"]

.evergreen/generated_configs/variants.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ buildvariants:
1818
batchtime: 10080
1919
expansions:
2020
NO_EXT: "1"
21+
REQUIRE_FIPS: "1"
2122
- name: other-hosts-rhel8-zseries
2223
tasks:
2324
- name: .6.0 .standalone !.sync_async

.evergreen/scripts/generate_config.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,12 @@ def create_alternative_hosts_variants():
800800
)
801801
)
802802

803-
expansions = dict()
804-
handle_c_ext(C_EXTS[0], expansions)
805803
for host_name in OTHER_HOSTS:
804+
expansions = dict()
805+
handle_c_ext(C_EXTS[0], expansions)
806806
host = HOSTS[host_name]
807+
if "fips" in host_name.lower():
808+
expansions["REQUIRE_FIPS"] = "1"
807809
tags = [".6.0 .standalone !.sync_async"]
808810
if host_name == "Amazon2023":
809811
tags = [f".latest !.sync_async {t}" for t in SUB_TASKS]

.evergreen/scripts/setup_tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"DEBUG_LOG",
3434
"PYTHON_BINARY",
3535
"PYTHON_VERSION",
36+
"REQUIRE_FIPS",
3637
]
3738

3839
# Map the test name to test extra.

test/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ def fips_enabled(self):
389389
self._fips_enabled = True
390390
except (subprocess.SubprocessError, FileNotFoundError):
391391
self._fips_enabled = False
392+
if os.environ.get("REQUIRE_FIPS") and not self._fips_enabled:
393+
raise RuntimeError("Expected FIPS to be enabled")
392394
return self._fips_enabled
393395

394396
def check_auth_type(self, auth_type):

test/asynchronous/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ def fips_enabled(self):
391391
self._fips_enabled = True
392392
except (subprocess.SubprocessError, FileNotFoundError):
393393
self._fips_enabled = False
394+
if os.environ.get("REQUIRE_FIPS") and not self._fips_enabled:
395+
raise RuntimeError("Expected FIPS to be enabled")
394396
return self._fips_enabled
395397

396398
def check_auth_type(self, auth_type):

0 commit comments

Comments
 (0)