Skip to content

Commit 50a5988

Browse files
tammelakuba-moo
authored andcommitted
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: kernel test robot <oliver.sang@intel.com> Closes: https://lore.kernel.org/oe-lkp/202311161129.3b45ed53-oliver.sang@intel.com Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Reviewed-by: Simon Horman <horms@kernel.org> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Link: https://lore.kernel.org/r/20231117171208.2066136-3-pctammela@mojatatu.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 025de7b commit 50a5988

File tree

1 file changed

+25
-43
lines changed
  • tools/testing/selftests/tc-testing/plugin-lib

1 file changed

+25
-43
lines changed

tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,6 @@
1717
netlink = False
1818
print("!!! Consider installing pyroute2 !!!")
1919

20-
def prepare_suite(obj, test):
21-
original = obj.args.NAMES
22-
23-
if 'skip' in test and test['skip'] == 'yes':
24-
return
25-
26-
if 'nsPlugin' not in test['plugins']:
27-
return
28-
29-
shadow = {}
30-
shadow['IP'] = original['IP']
31-
shadow['TC'] = original['TC']
32-
shadow['NS'] = '{}-{}'.format(original['NS'], test['random'])
33-
shadow['DEV0'] = '{}id{}'.format(original['DEV0'], test['id'])
34-
shadow['DEV1'] = '{}id{}'.format(original['DEV1'], test['id'])
35-
shadow['DUMMY'] = '{}id{}'.format(original['DUMMY'], test['id'])
36-
shadow['DEV2'] = original['DEV2']
37-
obj.args.NAMES = shadow
38-
39-
if netlink == True:
40-
obj._nl_ns_create()
41-
else:
42-
obj._ns_create()
43-
44-
# Make sure the netns is visible in the fs
45-
while True:
46-
obj._proc_check()
47-
try:
48-
ns = obj.args.NAMES['NS']
49-
f = open('/run/netns/{}'.format(ns))
50-
f.close()
51-
break
52-
except:
53-
time.sleep(0.1)
54-
continue
55-
56-
obj.args.NAMES = original
57-
5820
class SubPlugin(TdcPlugin):
5921
def __init__(self):
6022
self.sub_class = 'ns/SubPlugin'
@@ -65,19 +27,39 @@ def pre_suite(self, testcount, testlist):
6527

6628
super().pre_suite(testcount, testlist)
6729

68-
print("Setting up namespaces and devices...")
30+
def prepare_test(self, test):
31+
if 'skip' in test and test['skip'] == 'yes':
32+
return
6933

70-
with Pool(self.args.mp) as p:
71-
it = zip(cycle([self]), testlist)
72-
p.starmap(prepare_suite, it)
34+
if 'nsPlugin' not in test['plugins']:
35+
return
7336

74-
def pre_case(self, caseinfo, test_skip):
37+
if netlink == True:
38+
self._nl_ns_create()
39+
else:
40+
self._ns_create()
41+
42+
# Make sure the netns is visible in the fs
43+
while True:
44+
self._proc_check()
45+
try:
46+
ns = self.args.NAMES['NS']
47+
f = open('/run/netns/{}'.format(ns))
48+
f.close()
49+
break
50+
except:
51+
time.sleep(0.1)
52+
continue
53+
54+
def pre_case(self, test, test_skip):
7555
if self.args.verbose:
7656
print('{}.pre_case'.format(self.sub_class))
7757

7858
if test_skip:
7959
return
8060

61+
self.prepare_test(test)
62+
8163
def post_case(self):
8264
if self.args.verbose:
8365
print('{}.post_case'.format(self.sub_class))

0 commit comments

Comments
 (0)