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 ( " \n Client 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 ( " \n Client 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 ( " \n Client 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 ( " \n Client 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 ( " \n Client 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 ( " \n Client 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 ( " \n Client 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 )
0 commit comments