Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --test-payload option #243

Merged
merged 1 commit into from Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions flent/runners.py
Expand Up @@ -983,6 +983,7 @@ def check(self):
args.setdefault('send_size',
self.settings.SEND_SIZE[0]
if self.settings.SEND_SIZE else "")
args.setdefault('test_payload', self.settings.TEST_PAYLOAD)

if self.settings.SWAP_UPDOWN:
if self.test == 'TCP_STREAM':
Expand Down Expand Up @@ -1022,12 +1023,19 @@ def check(self):
netperf['-e'] = True

try:
# Sanity check; is /dev/urandom readable? If so, use it to
# If --test-payload option is specified, use data from that file
# else use the default value /dev/urandom.
fill_file = args['test_payload']
# Sanity check; is /dev/urandom or the custom file readable? If so, use it to
# pre-fill netperf's buffers
self.run_simple(['dd', 'if=/dev/urandom', 'of=/dev/null', 'bs=1', 'count=1'], errmsg="Err")
netperf['buffer'] = '-F /dev/urandom'
self.run_simple(['dd', 'if='+fill_file, 'of=/dev/null', 'bs=1', 'count=1'], errmsg="Err")
netperf['buffer'] = '-F '+fill_file
except RunnerCheckError:
netperf['buffer'] = ''
if(fill_file == '/dev/urandom'):
netperf['buffer'] = ''
else:
# If the custom file is not readable, fail noisily
raise RunnerCheckError("The specified test payload file does not exist or is not readable.")

if not self.remote_host:
# only cache values if we're not executing the checks on a
Expand Down
6 changes: 6 additions & 0 deletions flent/settings.py
Expand Up @@ -378,6 +378,12 @@ def __call__(self, parser, namespace, values, option_string=None):
"to decrease the socket buffer size. Can be specified multiple times, "
"with each value corresponding to a stream of a test.")

test_group.add_argument(
"--test-payload",
action="store", type=unicode, dest="TEST_PAYLOAD", default='/dev/urandom',
help="Path to file containing payload to pre-fill the netperf buffers with "
"defaults to randomised payload")

test_group.add_argument(
"--test-parameter",
action=Update, type=keyval, dest="TEST_PARAMETERS", metavar='key=value',
Expand Down
2 changes: 1 addition & 1 deletion flent/testenv.py
Expand Up @@ -57,7 +57,7 @@
# in the code below
STREAM_CONFIG_PARAM_NAMES = ['label', 'ping_label', 'marking',
'control_host', 'local_bind', 'cc_algo',
'udp_bandwidth', 'udp_pktsize', 'send_size']
'udp_bandwidth', 'udp_pktsize', 'send_size', 'test_payload']

# Mapping of test parameters that will be picked up from the global settings if
# they are not set
Expand Down