Skip to content

Commit

Permalink
selftests: tc-testing: move back to per test ns setup
Browse files Browse the repository at this point in the history
Surprisingly in kernel configs with most of the debug knobs turned on,
pre-allocating the test resources makes tdc run much slower overall than
when allocating resources on a per test basis.

As these knobs are used in kselftests in downstream CIs, let's go back
to the old way of doing things to avoid kselftests timeouts.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-lkp/[email protected]
Signed-off-by: Pedro Tammela <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Acked-by: Jamal Hadi Salim <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
tammela authored and kuba-moo committed Nov 21, 2023
1 parent 025de7b commit 50a5988
Showing 1 changed file with 25 additions and 43 deletions.
68 changes: 25 additions & 43 deletions tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,6 @@
netlink = False
print("!!! Consider installing pyroute2 !!!")

def prepare_suite(obj, test):
original = obj.args.NAMES

if 'skip' in test and test['skip'] == 'yes':
return

if 'nsPlugin' not in test['plugins']:
return

shadow = {}
shadow['IP'] = original['IP']
shadow['TC'] = original['TC']
shadow['NS'] = '{}-{}'.format(original['NS'], test['random'])
shadow['DEV0'] = '{}id{}'.format(original['DEV0'], test['id'])
shadow['DEV1'] = '{}id{}'.format(original['DEV1'], test['id'])
shadow['DUMMY'] = '{}id{}'.format(original['DUMMY'], test['id'])
shadow['DEV2'] = original['DEV2']
obj.args.NAMES = shadow

if netlink == True:
obj._nl_ns_create()
else:
obj._ns_create()

# Make sure the netns is visible in the fs
while True:
obj._proc_check()
try:
ns = obj.args.NAMES['NS']
f = open('/run/netns/{}'.format(ns))
f.close()
break
except:
time.sleep(0.1)
continue

obj.args.NAMES = original

class SubPlugin(TdcPlugin):
def __init__(self):
self.sub_class = 'ns/SubPlugin'
Expand All @@ -65,19 +27,39 @@ def pre_suite(self, testcount, testlist):

super().pre_suite(testcount, testlist)

print("Setting up namespaces and devices...")
def prepare_test(self, test):
if 'skip' in test and test['skip'] == 'yes':
return

with Pool(self.args.mp) as p:
it = zip(cycle([self]), testlist)
p.starmap(prepare_suite, it)
if 'nsPlugin' not in test['plugins']:
return

def pre_case(self, caseinfo, test_skip):
if netlink == True:
self._nl_ns_create()
else:
self._ns_create()

# Make sure the netns is visible in the fs
while True:
self._proc_check()
try:
ns = self.args.NAMES['NS']
f = open('/run/netns/{}'.format(ns))
f.close()
break
except:
time.sleep(0.1)
continue

def pre_case(self, test, test_skip):
if self.args.verbose:
print('{}.pre_case'.format(self.sub_class))

if test_skip:
return

self.prepare_test(test)

def post_case(self):
if self.args.verbose:
print('{}.post_case'.format(self.sub_class))
Expand Down

0 comments on commit 50a5988

Please sign in to comment.