Commit 50a5988a authored by Pedro Tammela's avatar Pedro Tammela Committed by Jakub Kicinski

selftests: tc-testing: move back to per test ns setup

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: default avatarkernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202311161129.3b45ed53-oliver.sang@intel.comSigned-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Link: https://lore.kernel.org/r/20231117171208.2066136-3-pctammela@mojatatu.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 025de7b6
...@@ -17,35 +17,33 @@ except ImportError: ...@@ -17,35 +17,33 @@ except ImportError:
netlink = False netlink = False
print("!!! Consider installing pyroute2 !!!") print("!!! Consider installing pyroute2 !!!")
def prepare_suite(obj, test): class SubPlugin(TdcPlugin):
original = obj.args.NAMES def __init__(self):
self.sub_class = 'ns/SubPlugin'
super().__init__()
def pre_suite(self, testcount, testlist):
from itertools import cycle
super().pre_suite(testcount, testlist)
def prepare_test(self, test):
if 'skip' in test and test['skip'] == 'yes': if 'skip' in test and test['skip'] == 'yes':
return return
if 'nsPlugin' not in test['plugins']: if 'nsPlugin' not in test['plugins']:
return 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: if netlink == True:
obj._nl_ns_create() self._nl_ns_create()
else: else:
obj._ns_create() self._ns_create()
# Make sure the netns is visible in the fs # Make sure the netns is visible in the fs
while True: while True:
obj._proc_check() self._proc_check()
try: try:
ns = obj.args.NAMES['NS'] ns = self.args.NAMES['NS']
f = open('/run/netns/{}'.format(ns)) f = open('/run/netns/{}'.format(ns))
f.close() f.close()
break break
...@@ -53,31 +51,15 @@ def prepare_suite(obj, test): ...@@ -53,31 +51,15 @@ def prepare_suite(obj, test):
time.sleep(0.1) time.sleep(0.1)
continue continue
obj.args.NAMES = original def pre_case(self, test, test_skip):
class SubPlugin(TdcPlugin):
def __init__(self):
self.sub_class = 'ns/SubPlugin'
super().__init__()
def pre_suite(self, testcount, testlist):
from itertools import cycle
super().pre_suite(testcount, testlist)
print("Setting up namespaces and devices...")
with Pool(self.args.mp) as p:
it = zip(cycle([self]), testlist)
p.starmap(prepare_suite, it)
def pre_case(self, caseinfo, test_skip):
if self.args.verbose: if self.args.verbose:
print('{}.pre_case'.format(self.sub_class)) print('{}.pre_case'.format(self.sub_class))
if test_skip: if test_skip:
return return
self.prepare_test(test)
def post_case(self): def post_case(self):
if self.args.verbose: if self.args.verbose:
print('{}.post_case'.format(self.sub_class)) print('{}.post_case'.format(self.sub_class))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment