Skip to content

Commit 4a4d55c

Browse files
committed
DAOS-19361 test: update ftest/cart to use self.log.info
Update ftest/cart tests to use self.log.info instead of print so logging goes to the log instead of stdout. Use register_cleanup instaed of a custom cleanup_processes Test-tag: cart Skip-unit-tests: true Skip-fault-injection-test: true Signed-off-by: Dalton Bohning <dalton.bohning@hpe.com>
1 parent fb2dd56 commit 4a4d55c

8 files changed

Lines changed: 75 additions & 94 deletions

File tree

src/tests/ftest/cart/ctl/ctl_five_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -27,7 +28,7 @@ def test_cart_ctl_five_node(self):
2728
srv_rtn = self.launch_cmd_bg(srvcmd)
2829
# pylint: disable=broad-except
2930
except Exception as error:
30-
self.print("Exception in launching server : {}".format(error))
31+
self.log.info("Exception in launching server : %s", error)
3132
self.fail("Test failed.\n")
3233

3334
# Verify the server is still running.

src/tests/ftest/cart/ctl/ctl_one_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -27,7 +28,7 @@ def test_cart_ctl_one_node(self):
2728
srv_rtn = self.launch_cmd_bg(srvcmd)
2829
# pylint: disable=broad-except
2930
except Exception as error:
30-
self.print("Exception in launching server : {}".format(error))
31+
self.log.info("Exception in launching server : %s", error)
3132
self.fail("Test failed.\n")
3233

3334
# Verify the server is still running.

src/tests/ftest/cart/iv/iv_one_node.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -88,18 +89,18 @@ class CartIvOneNodeTest(CartTest):
8889
def _verify_action(self, action):
8990
"""Verify the action."""
9091
if (('operation' not in action) or ('rank' not in action) or ('key' not in action)):
91-
self.print("Error happened during action check")
92+
self.log.info("Error happened during action check")
9293
raise ValueError(
9394
"Each action must contain an operation, rank, and key")
9495

9596
if len(action['key']) != 2:
96-
self.print("Error key should be tuple of (rank, idx)")
97+
self.log.info("Error key should be tuple of (rank, idx)")
9798
raise ValueError("key should be a tuple of (rank, idx)")
9899

99100
def _verify_fetch_operation(self, action):
100101
"""Verify the fetch operation."""
101102
if (('return_code' not in action) or ('expected_value' not in action)):
102-
self.print("Error: fetch operation was malformed")
103+
self.log.info("Error: fetch operation was malformed")
103104
raise ValueError("Fetch operation malformed")
104105

105106
def _iv_test_actions(self, cmd, actions):
@@ -135,7 +136,7 @@ def _iv_test_actions(self, cmd, actions):
135136
log_path)
136137
clicmd += command
137138

138-
self.print("\nClient cmd : %s\n" % clicmd)
139+
self.log.info("Client cmd : %s", clicmd)
139140
cli_rtn = subprocess.call(shlex.split(clicmd))
140141

141142
if cli_rtn != 0:
@@ -153,11 +154,11 @@ def _iv_test_actions(self, cmd, actions):
153154
# codecs.open(log_file, "w", "unicode").write('')
154155

155156
# DEBUGGING: dump contents of JSON file to screen
156-
with open(log_path, 'r') as file:
157-
print(file.read())
157+
with open(log_path, 'r', encoding='utf-8') as file:
158+
self.log.info(file.read())
158159

159160
# Read the result into test_result and remove the temp file
160-
with open(log_path, 'r') as log_file:
161+
with open(log_path, 'r', encoding='utf-8') as log_file:
161162
test_result = json.load(log_file)
162163

163164
os.close(log_fd)
@@ -197,7 +198,7 @@ def _iv_test_actions(self, cmd, actions):
197198

198199
clicmd += command
199200

200-
self.print("\nClient cmd : %s\n" % clicmd)
201+
self.log.info("Client cmd : %s", clicmd)
201202
cli_rtn = subprocess.call(shlex.split(clicmd))
202203

203204
if cli_rtn != 0:
@@ -214,7 +215,7 @@ def _iv_test_actions(self, cmd, actions):
214215
command = "{!s} -s '{!s}'".format(command, "none")
215216
clicmd += command
216217

217-
self.print("\nClient cmd : %s\n" % clicmd)
218+
self.log.info("Client cmd : %s", clicmd)
218219
cli_rtn = subprocess.call(shlex.split(clicmd))
219220

220221
if cli_rtn != 0:
@@ -234,7 +235,7 @@ def _iv_test_actions(self, cmd, actions):
234235
.format(command, 0)
235236
clicmd += command
236237

237-
self.print("\nClient cmd : %s\n" % clicmd)
238+
self.log.info("Client cmd : %s", clicmd)
238239
cli_rtn = subprocess.call(shlex.split(clicmd))
239240

240241
if cli_rtn != 0:
@@ -246,7 +247,7 @@ def _iv_test_actions(self, cmd, actions):
246247
command = " {!s} -o '{!s}' -r '{!s}' ".format(command, operation, rank)
247248
clicmd += command
248249

249-
self.print("\nClient cmd : %s\n" % clicmd)
250+
self.log.info("Client cmd : %s", clicmd)
250251
cli_rtn = subprocess.call(shlex.split(clicmd))
251252

252253
if cli_rtn != 0:
@@ -268,7 +269,7 @@ def test_cart_iv_one_node(self):
268269
srv_rtn = self.launch_cmd_bg(srvcmd)
269270
# pylint: disable=broad-except
270271
except Exception as error:
271-
self.print("Exception in launching server : {}".format(error))
272+
self.log.info("Exception in launching server : %s", error)
272273
self.fail("Test failed.\n")
273274

274275
# Verify the server is still running.
@@ -481,7 +482,7 @@ def test_cart_iv_one_node(self):
481482
except ValueError as exception:
482483
failed = True
483484
traceback.print_stack()
484-
self.print("TEST FAILED: %s" % str(exception))
485+
self.log.info("TEST FAILED: %s", exception)
485486

486487
# Shutdown Servers
487488

@@ -493,25 +494,25 @@ def test_cart_iv_one_node(self):
493494
# Request each server shut down gracefully
494495
for rank in reversed(list(range(1, int(srv_ppn) * num_servers))):
495496
clicmdt = clicmd + " -o shutdown -r " + str(rank)
496-
self.print("\nClient cmd : {}\n".format(clicmdt))
497+
self.log.info("Client cmd : %s", clicmdt)
497498
try:
498499
subprocess.call(shlex.split(clicmdt))
499500
# pylint: disable=broad-except
500501
except Exception as error:
501502
failed = True
502-
self.print("Exception in launching client : {}".format(error))
503+
self.log.info("Exception in launching client : %s", error)
503504

504505
time.sleep(1)
505506

506507
# Shutdown rank 0 separately
507508
clicmd += " -o shutdown -r 0"
508-
self.print("\nClient cmd : {}\n".format(clicmd))
509+
self.log.info("Client cmd : %s", clicmd)
509510
try:
510511
subprocess.call(shlex.split(clicmd))
511512
# pylint: disable=broad-except
512513
except Exception as error:
513514
failed = True
514-
self.print("Exception in launching client : {}".format(error))
515+
self.log.info("Exception in launching client : %s", error)
515516

516517
# wait for servers to finish shutting down
517518
time.sleep(2)

src/tests/ftest/cart/iv/iv_two_node.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -74,18 +75,18 @@ class CartIvTwoNodeTest(CartTest):
7475
def _verify_action(self, action):
7576
"""Verify the action."""
7677
if (('operation' not in action) or ('rank' not in action) or ('key' not in action)):
77-
self.print("Error happened during action check")
78+
self.log.info("Error happened during action check")
7879
raise ValueError(
7980
"Each action must contain an operation, rank, and key")
8081

8182
if len(action['key']) != 2:
82-
self.print("Error key should be tuple of (rank, idx)")
83+
self.log.info("Error key should be tuple of (rank, idx)")
8384
raise ValueError("key should be a tuple of (rank, idx)")
8485

8586
def _verify_fetch_operation(self, action):
8687
"""Verify fetch operation."""
8788
if (('return_code' not in action) or ('expected_value' not in action)):
88-
self.print("Error: fetch operation was malformed")
89+
self.log.info("Error: fetch operation was malformed")
8990
raise ValueError("Fetch operation malformed")
9091

9192
def _iv_test_actions(self, cmd, actions):
@@ -118,7 +119,7 @@ def _iv_test_actions(self, cmd, actions):
118119
log_path)
119120
clicmd += command
120121

121-
self.print("\nClient cmd : %s\n" % clicmd)
122+
self.log.info("Client cmd : %s", clicmd)
122123
cli_rtn = subprocess.call(shlex.split(clicmd))
123124

124125
if cli_rtn != 0:
@@ -161,7 +162,7 @@ def _iv_test_actions(self, cmd, actions):
161162
action['value'])
162163
clicmd += command
163164

164-
self.print("\nClient cmd : %s\n" % clicmd)
165+
self.log.info("Client cmd : %s", clicmd)
165166
cli_rtn = subprocess.call(shlex.split(clicmd))
166167

167168
if cli_rtn != 0:
@@ -174,7 +175,7 @@ def _iv_test_actions(self, cmd, actions):
174175
command, operation, rank, key_rank, key_idx)
175176
clicmd += command
176177

177-
self.print("\nClient cmd : %s\n" % clicmd)
178+
self.log.info("Client cmd : %s", clicmd)
178179
cli_rtn = subprocess.call(shlex.split(clicmd))
179180

180181
if cli_rtn != 0:
@@ -197,7 +198,7 @@ def test_cart_iv_two_node(self):
197198
srv_rtn = self.launch_cmd_bg(srvcmd)
198199
# pylint: disable=broad-except
199200
except Exception as error:
200-
self.print("Exception in launching server : {}".format(error))
201+
self.log.info("Exception in launching server : %s", error)
201202
self.fail("Test failed.\n")
202203

203204
# Verify the server is still running.
@@ -237,7 +238,7 @@ def test_cart_iv_two_node(self):
237238
self._iv_test_actions(clicmd, actions)
238239
except ValueError as exception:
239240
failed = True
240-
self.print("TEST FAILED: {}".format(exception))
241+
self.log.info("TEST FAILED: %s", exception)
241242

242243
# Shutdown Servers
243244
num_servers = 2
@@ -248,25 +249,25 @@ def test_cart_iv_two_node(self):
248249
# Request each server shut down gracefully
249250
for rank in reversed(list(range(1, int(srv_ppn) * num_servers))):
250251
clicmdt = clicmd + " -o shutdown -r " + str(rank)
251-
self.print("\nClient cmd : {}\n".format(clicmdt))
252+
self.log.info("Client cmd : %s", clicmdt)
252253
try:
253254
subprocess.call(shlex.split(clicmdt))
254255
# pylint: disable=broad-except
255256
except Exception as error:
256257
failed = True
257-
self.print("Exception in launching client : {}".format(error))
258+
self.log.info("Exception in launching client : %s", error)
258259

259260
time.sleep(1)
260261

261262
# Shutdown rank 0 separately
262263
clicmd += " -o shutdown -r 0"
263-
self.print("\nClient cmd : {}\n".format(clicmd))
264+
self.log.info("Client cmd : %s", clicmd)
264265
try:
265266
subprocess.call(shlex.split(clicmd))
266267
# pylint: disable=broad-except
267268
except Exception as error:
268269
failed = True
269-
self.print("Exception in launching client : {}".format(error))
270+
self.log.info("Exception in launching client : %s", error)
270271

271272
# Give some time for completion before forcing servers shut down
272273
time.sleep(2)

src/tests/ftest/cart/no_pmix/multictx_one_node.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -25,14 +26,14 @@ def test_cart_no_pmix(self):
2526
"""
2627
cmd = self.params.get("tst_bin", '/run/tests/*/')
2728

28-
self.print("\nTest cmd : {}\n".format(cmd))
29+
self.log.info("Test cmd : %s", cmd)
2930

3031
with subprocess.Popen([cmd], stdout=subprocess.PIPE) as proc:
3132

3233
rc = self.wait_process(proc, 30)
3334
if rc != 0:
34-
self.print("Error waiting for process.")
35-
self.print("returning {}".format(rc))
35+
self.log.info("Error waiting for process.")
36+
self.log.info("returning %s", rc)
3637
self.fail("Test failed.\n")
3738

38-
self.print("Finished waiting for {}".format(proc))
39+
self.log.info("Finished waiting for %s", proc)

src/tests/ftest/cart/rpc/swim_notification.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -29,7 +30,7 @@ def test_cart_rpc(self):
2930
srv_rtn = self.launch_cmd_bg(srvcmd)
3031
# pylint: disable=broad-except
3132
except Exception as error:
32-
self.print("Exception in launching server : {}".format(error))
33+
self.log.info("Exception in launching server : %s", error)
3334
self.fail("Test failed.\n")
3435

3536
# Verify the server is still running.
@@ -51,8 +52,6 @@ def test_cart_rpc(self):
5152

5253
# Verify the server(s) exited gracefully
5354
if not self.check_files(glob_pat, count=3, retries=4):
54-
self.print("Didn't find completion file(s): '{}'. "
55-
"This indicates not all CaRT binaries exited "
56-
"gracefully. "
57-
"Marking test pass while DAOS-7892 remains "
58-
"unresolved.\n".format(glob_pat))
55+
self.log.info("Didn't find completion file(s): '%s'.", glob_pat)
56+
self.log.info("This indicates not all CaRT binaries exited gracefully.")
57+
self.log.info("Marking test pass while DAOS-7892 remains unresolved.")

src/tests/ftest/cart/selftest/selftest_three_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'''
22
(C) Copyright 2018-2023 Intel Corporation.
3+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
45
SPDX-License-Identifier: BSD-2-Clause-Patent
56
'''
@@ -27,7 +28,7 @@ def test_cart_selftest_three_node(self):
2728
srv_rtn = self.launch_cmd_bg(srvcmd)
2829
# pylint: disable=broad-except
2930
except Exception as error:
30-
self.print("Exception in launching server : {}".format(error))
31+
self.log.info("Exception in launching server : %s", error)
3132
self.fail("Test failed.\n")
3233

3334
# Verify the server is still running.

0 commit comments

Comments
 (0)