Skip to content

Commit 957a7e8

Browse files
piyushc01avamingli
authored andcommitted
gpcheckperf: incorporating parity changes from 6X PR
Parity changes from 6X PR: https://github.com/greenplum-db/gpdb/pull/15192 Changes are as follows: 1. Controlling verbosity of gpssh() function through verbose parameter 2. Updating gpssh calls with verbose parameter 3. Removing non-required checks in print*Results() 4. Removing regex removal for b' and \r characters when getting hostname as it is fixed in gpssh. 5. Re-structured test cases for gpcheckperf
1 parent b6f0fc2 commit 957a7e8

2 files changed

Lines changed: 70 additions & 61 deletions

File tree

gpMgmt/bin/gpcheckperf

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def strcmd(cmd):
8282
return reduce(lambda x, y: x + ' ' + y, map(lambda x: x.find(' ') > 0 and "'" + x + "'" or x, cmd))
8383

8484

85-
def gpssh(cmd, call_verbose=True):
85+
def gpssh(cmd, verbose):
8686
c = ['%s/bin/gpssh' % GPHOME]
87-
if GV.opt['-V'] and call_verbose:
87+
if verbose:
8888
c.append('-v')
8989
if GV.opt['-f']:
9090
c.append('-f')
@@ -326,13 +326,13 @@ def runTeardown():
326326
for d in GV.opt['-d']:
327327
dirs = '%s %s/gpcheckperf_$USER' % (dirs, d)
328328
try:
329-
gpssh('rm -rf ' + dirs)
329+
gpssh('rm -rf ' + dirs, GV.opt['-V'])
330330
except:
331331
pass
332332

333333
try:
334334
if GV.opt['--net']:
335-
gpssh(killall(GV.opt['--netserver']))
335+
gpssh(killall(GV.opt['--netserver']), GV.opt['-V'])
336336
except:
337337
pass
338338

@@ -349,7 +349,7 @@ def runSetup():
349349
# Verify python3 is accessible
350350
if GV.opt['-v']:
351351
print('[Info] verify python3 interpreter exists')
352-
(ok, out) = gpssh('python3 -c print')
352+
(ok, out) = gpssh('python3 -c print', GV.opt['-V'])
353353
if not ok:
354354
if not GV.opt['-v']:
355355
print(out)
@@ -364,7 +364,7 @@ def runSetup():
364364
dirs = '%s %s/gpcheckperf_$USER' % (dirs, d)
365365

366366
cmd = 'rm -rf %s ; mkdir -p %s' % (dirs, dirs)
367-
(ok, out) = gpssh(cmd)
367+
(ok, out) = gpssh(cmd, GV.opt['-V'])
368368
if not ok:
369369
print('failed gpssh: %s' % out)
370370
sys.exit("[Error] unable to make gpcheckperf directory. \n"
@@ -402,7 +402,7 @@ def copyExecOver(fname):
402402
sys.exit('[Error] command failed: gpsync %s =:%s with output: %s' % (path, target, out))
403403

404404
# chmod +x file
405-
(ok, out) = gpssh('chmod a+rx %s' % target)
405+
(ok, out) = gpssh('chmod a+rx %s' % target, GV.opt['-V'])
406406
if not ok:
407407
sys.exit('[Error] command failed: chmod a+rx %s with output: %s' % (target, out))
408408

@@ -458,7 +458,7 @@ def runDiskWriteTest(multidd):
458458
cmd = cmd + (' -B %d' % GV.opt['-B'])
459459
if GV.opt['-S']:
460460
cmd = cmd + (' -S %d' % GV.opt['-S'])
461-
(ok, out) = gpssh(cmd)
461+
(ok, out) = gpssh(cmd, GV.opt['-V'])
462462
if not ok:
463463
sys.exit('[Error] command failed: %s with output: %s' % (cmd, out))
464464
return parseMultiDDResult(out)
@@ -477,7 +477,7 @@ def runDiskReadTest(multidd):
477477
cmd = cmd + (' -B %d' % GV.opt['-B'])
478478
if GV.opt['-S']:
479479
cmd = cmd + (' -S %d' % GV.opt['-S'])
480-
(ok, out) = gpssh(cmd)
480+
(ok, out) = gpssh(cmd, GV.opt['-V'])
481481
if not ok:
482482
sys.exit('[Error] command failed: %s with output: %s' % (cmd, out))
483483
return parseMultiDDResult(out)
@@ -490,7 +490,7 @@ def runStreamTest():
490490
print('--------------------')
491491

492492
cmd = copyExecOver('stream')
493-
(ok, out) = gpssh(cmd)
493+
(ok, out) = gpssh(cmd, GV.opt['-V'])
494494
if not ok:
495495
sys.exit('[Error] command failed: %s with output: %s' % (cmd, out))
496496
out = io.StringIO(out)
@@ -512,9 +512,9 @@ def startNetServer():
512512
for i in range(5):
513513
if i > 0:
514514
print('[Warning] retrying with port %d' % port)
515-
(ok, out) = gpssh(killall(GV.opt['--netserver']))
515+
(ok, out) = gpssh(killall(GV.opt['--netserver']), GV.opt['-V'])
516516

517-
(ok, out) = gpssh('%s -p %d > /dev/null 2>&1' % (rmtPath, port))
517+
(ok, out) = gpssh('%s -p %d > /dev/null 2>&1' % (rmtPath, port), GV.opt['-V'])
518518
if ok:
519519
return port
520520

@@ -745,8 +745,15 @@ def get_host_map(hostlist):
745745
seglist = dict() # segment list
746746
uniqhosts = dict() # unique host list
747747

748-
# get list of hostnames
749-
# disabling verbose mode for gpssh as it is adding extra lines of output
748+
'''
749+
Get hostnames using non-verbose mode since verbose output makes parsing difficult with extra lines as show:
750+
Using delaybeforesend 0.05 and prompt_validation_timeout 1.0
751+
[Reset ...]
752+
[INFO] login sdw2
753+
[sdw2] sdw2
754+
[INFO] completed successfully
755+
[Cleanup...]
756+
'''
750757
rc, out = gpssh('hostname', False)
751758

752759
if not rc:
@@ -760,9 +767,6 @@ def get_host_map(hostlist):
760767
# get unique hostname list
761768
for line in out.splitlines():
762769
seg, host = line.translate(str.maketrans('','','[]')).split()
763-
# removing \r and b coming in the output of the command in hostname
764-
host = host.replace('\\r\'', '')
765-
host = host.replace('b\'', '')
766770
uniqhosts[host] = seg
767771

768772
# get list of segments associated with each host (can't use gpssh since it de-dupes hosts)
@@ -771,7 +775,7 @@ def get_host_map(hostlist):
771775

772776
proc = None
773777
try:
774-
if GV.opt['-v'] or GV.opt['-V']:
778+
if GV.opt['-v']:
775779
print('[Info]', strcmd(cmd))
776780
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
777781
out = proc.stdout.read(-1)
@@ -824,8 +828,6 @@ def runNetPerfTestMatrix():
824828

825829

826830
def printMatrixResult(result, seglist):
827-
if not result:
828-
return
829831
print('Full matrix netperf bandwidth test')
830832

831833
# sum up Rx/Tx rate for each host
@@ -882,8 +884,6 @@ def printMatrixResult(result, seglist):
882884

883885

884886
def printNetResult(result):
885-
if not result:
886-
return
887887
print('Netperf bisection bandwidth test')
888888
for h in result:
889889
print('%s -> %s = %f' % (h[0], h[1], h[6]))
@@ -915,8 +915,6 @@ def printNetResult(result):
915915

916916

917917
def printResult(title, result):
918-
if not result:
919-
return
920918
totTime = 0
921919
totBytes = 0
922920
totMBPS = 0

gpMgmt/test/behave/mgmt_utils/gpcheckperf.feature

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,59 @@ Feature: Tests for gpcheckperf
1717
And gpcheckperf should not print "NOTICE: -t is deprecated " to stdout
1818

1919
@concourse_cluster
20-
Scenario: gpcheckperf runs tests by passing hostfile in super verbose mode
20+
Scenario Outline: gpcheckperf run <test_type> test by passing hostfile in regular mode
2121
Given the database is running
22-
And create a gpcheckperf input host file
23-
When the user runs "gpcheckperf -f /tmp/hostfile1 -r M -d /data/gpdata/ --duration=3m -V"
22+
And create a gpcheckperf input host file
23+
When the user runs "gpcheckperf -f /tmp/hostfile1 -r <cmd_param> -d /data/gpdata/ --duration=10s"
2424
Then gpcheckperf should return a return code of 0
25-
And gpcheckperf should print "Full matrix netperf bandwidth test" to stdout
26-
And gpcheckperf should not print "IndexError: list index out of range" to stdout
25+
And gpcheckperf should print "-- NETPERF TEST" to stdout
26+
And gpcheckperf should print "<print_message>" to stdout
27+
And gpcheckperf should print "Summary:" to stdout
28+
And gpcheckperf should print "sum =" to stdout
29+
And gpcheckperf should print "min =" to stdout
30+
And gpcheckperf should print "max =" to stdout
31+
And gpcheckperf should print "avg =" to stdout
32+
And gpcheckperf should print "median =" to stdout
2733

28-
@concourse_cluster
29-
Scenario: gpcheckperf runs tests by passing hostfile in verbose mode
30-
Given the database is running
31-
And create a gpcheckperf input host file
32-
When the user runs "gpcheckperf -f /tmp/hostfile1 -r M -d /data/gpdata/ --duration=3m -v"
33-
Then gpcheckperf should return a return code of 0
34-
And gpcheckperf should print "Full matrix netperf bandwidth test" to stdout
35-
And gpcheckperf should not print "IndexError: list index out of range" to stdout
34+
Examples:
35+
| test_type | cmd_param | print_message |
36+
| network | N | Netperf bisection bandwidth test |
37+
| matrix | M | Full matrix netperf bandwidth test |
3638

37-
@concourse_cluster
38-
Scenario: gpcheckperf runs tests by passing hostfile in regular mode
39-
Given the database is running
40-
And create a gpcheckperf input host file
41-
When the user runs "gpcheckperf -f /tmp/hostfile1 -r M -d /data/gpdata/ --duration=3m"
42-
Then gpcheckperf should return a return code of 0
43-
And gpcheckperf should print "Full matrix netperf bandwidth test" to stdout
44-
And gpcheckperf should not print "IndexError: list index out of range" to stdout
39+
@concourse_cluster
40+
Scenario Outline: gpcheckperf runs <test_type> test with hostfile in <verbosity> mode
41+
Given the database is running
42+
And create a gpcheckperf input host file
43+
When the user runs "gpcheckperf -f /tmp/hostfile1 -r <cmd_param> -d /data/gpdata/ --duration=10s <verbose_flag>"
44+
Then gpcheckperf should return a return code of 0
45+
And gpcheckperf should print "-- NETPERF TEST" to stdout
46+
And gpcheckperf should print "<print_message>" to stdout
47+
And gpcheckperf should print "making gpcheckperf directory on all hosts ..." to stdout
48+
And gpcheckperf should print "[Info].*gpssh <gpssh_param> .*hostfile1 .*gpnetbenchClient." to stdout
49+
And gpcheckperf should print "[Info].*gpssh <gpssh_param> .*hostfile1 .*gpnetbenchServer." to stdout
50+
And gpcheckperf should print "== RESULT*" to stdout
51+
And gpcheckperf should print "Summary:" to stdout
52+
And gpcheckperf should print "TEARDOWN" to stdout
53+
54+
Examples:
55+
| test_type | verbosity | cmd_param | verbose_flag | gpssh_param | print_message |
56+
| network | verbose | N | -v | -f | Netperf bisection bandwidth test |
57+
| network | extra verbose | N | -V | -v -f | Netperf bisection bandwidth test |
58+
| matrix | verbose | M | -v | -f | Full matrix netperf bandwidth test |
59+
| matrix | extra verbose | M | -V | -v -f | Full matrix netperf bandwidth test |
4560

4661
@concourse_cluster
47-
Scenario: gpcheckperf does not throws typeerror when run with single host
48-
Given the database is running
49-
And create a gpcheckperf input host file
50-
When the user runs "gpcheckperf -h sdw1 -r M -d /data/gpdata/ --duration=3m"
51-
Then gpcheckperf should return a return code of 0
52-
And gpcheckperf should print "single host only - abandon netperf test" to stdout
53-
And gpcheckperf should not print "TypeError:" to stdout
62+
Scenario Outline: running gpcheckperf single host <test_name> test case
63+
Given the database is running
64+
And create a gpcheckperf input host file
65+
When the user runs "gpcheckperf -h cdw -r <cmd_param> -d /data/gpdata/ --duration=10s -v"
66+
Then gpcheckperf should return a return code of 0
67+
And gpcheckperf should print "-- NETPERF TEST" to stdout
68+
And gpcheckperf should print "single host only - abandon netperf test" to stdout
69+
And gpcheckperf should print "TEARDOWN" to stdout
5470

55-
Scenario: gpcheckperf runs with -S option and prints a warning message
56-
Given the database is running
57-
When the user runs "gpcheckperf -h localhost -r d -d /tmp -S 1GB"
58-
Then gpcheckperf should return a return code of 0
59-
And gpcheckperf should print "\[Warning] Using 1073741824 bytes for disk performance test. This might take some time" to stdout
71+
Examples:
72+
| test_name | cmd_param|
73+
| matrix test | M |
74+
| network test| N |
6075

61-
Scenario: gpcheckperf errors out when invalid value is passed to the -S option
62-
Given the database is running
63-
When the user runs "gpcheckperf -h localhost -r d -d /tmp -S abc"
64-
Then gpcheckperf should return a return code of 1

0 commit comments

Comments
 (0)