Skip to content

Commit b4c5a13

Browse files
piyushc01avamingli
authored andcommitted
Fixing if the time command has comma in the output (#17207)
Changes to fix gpcheckperf failure with an exception when sometime time command output has a comma separator instead of a dot. Steps to reproduce issue: $export LC_ALL=de_DE_utf8 $time sleep 1 real 0m1,021s user 0m0,001s sys 0m0,005s Fix: added check if comma present in the time output, replace it with a dot and continue parsing. Testing: Added unit tests to check the output of parseMultiDDResult() in case of comma and dot.
1 parent 0cea992 commit b4c5a13

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

gpMgmt/bin/gpcheckperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ def parseMultiDDResult(out):
443443
if o.find('real') >= 0:
444444
h = line[1:i]
445445
o = o.split()
446+
o[1] = o[1].replace(',', '.')
446447
m = re.search("(^\d+.\d+)", o[1])
447448
if m is None:
448449
sys.exit('[Error] expected %s to be a floating point number' % o[1])

gpMgmt/bin/gppylib/test/unit/test_unit_gpcheckperf.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,41 @@ def test_parseCommandLine_when_get_memory_succeeds(self, mock_get_memory):
6161
self.subject.parseCommandLine()
6262
self.assertEqual(self.subject.GV.opt['-S'], 246.0)
6363

64+
def test_parseMultiDDResult_when_output_regular(self):
65+
inputText = """[localhost] dd if=/dev/zero of=/tmp/gpcheckperf_gpadmin/ddfile count=131072 bs=32768
66+
[localhost] 131072+0 records in
67+
[localhost] 131072+0 records out
68+
[localhost] 4294967296 bytes transferred in 2.973025 secs (1444645536 bytes/sec)
69+
[localhost]
70+
[localhost] multidd total bytes 4294967296
71+
[localhost] real 3.65
72+
[localhost] user 0.18
73+
[localhost] sys 2.52
74+
"""
75+
actual_result = self.subject.parseMultiDDResult(inputText)
76+
(mbps, time, bytes) = actual_result["localhost"]
77+
exp_mbps, exp_time, exp_bytes = (1122.1917808219177, 3.65, 4294967296)
78+
self.assertEqual(mbps, exp_mbps)
79+
self.assertEqual(time, exp_time)
80+
self.assertEqual(bytes, exp_bytes)
81+
82+
def test_parseMultiDDResult_when_output_comma(self):
83+
inputText = """[localhost] dd if=/dev/zero of=/tmp/gpcheckperf_gpadmin/ddfile count=131072 bs=32768
84+
[localhost] 131072+0 records in
85+
[localhost] 131072+0 records out
86+
[localhost] 4294967296 bytes transferred in 2.973025 secs (1444645536 bytes/sec)
87+
[localhost]
88+
[localhost] multidd total bytes 4294967296
89+
[localhost] real 3,65
90+
[localhost] user 0,18
91+
[localhost] sys 2,52
92+
"""
93+
actual_result = self.subject.parseMultiDDResult(inputText)
94+
(mbps, time, bytes) = actual_result["localhost"]
95+
exp_mbps, exp_time, exp_bytes = (1122.1917808219177, 3.65, 4294967296)
96+
self.assertEqual(mbps, exp_mbps)
97+
self.assertEqual(time, exp_time)
98+
self.assertEqual(bytes, exp_bytes)
6499

65100
if __name__ == '__main__':
66101
run_tests()

0 commit comments

Comments
 (0)