]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tests-999: add a random directory to mount path
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 22 May 2023 11:27:54 +0000 (11:27 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 22 May 2023 21:46:41 +0000 (15:46 -0600)
Currently, the mount path is static/hard coded and sometimes there might
be corners cases where the mount path directories are not deleted
completely, or there might be two instances of CI running at the same
time. Let's introduce an additional directory to the mount path, that's
generated randomly, so that every run is unique and doesn't interfere
with each other.

-----------------------------------------------------------------
Test Results:
        Run Date:                          May 22 11:27:45
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                          Time (sec)
        ----------------------------------------
        setup                               0.00
        999-stress-cgroup_init.py           1.36
        teardown                            0.00
        ----------------------------------------
        Total Run Time                      1.36

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/999-stress-cgroup_init.py

index e157fb77ef1df088ce34c332537dd0d59f1a0142..611d53599cdf391b8cdbc1cbf115c55c5a89b405 100755 (executable)
@@ -11,16 +11,19 @@ from libcgroup import Cgroup
 from run import Run
 import consts
 import ftests
+import random
+import string
 import sys
 import os
 
 MNT_COUNT = 101
 MNT_POINT = '/tmp/999stress/'
 DIR_PREFIX = 'name'
+RANDOM_DIR = ''.join(random.choices(string.ascii_letters, k=5))
 
 
 def cgroup_path(count):
-    return MNT_POINT + DIR_PREFIX + str(count)
+    return MNT_POINT + RANDOM_DIR + '/' + DIR_PREFIX + str(count)
 
 
 def prereqs(config):
@@ -31,6 +34,7 @@ def setup(config):
     cmd = ['sudo', 'mkdir']
 
     cmd.append(MNT_POINT)
+    cmd.append(MNT_POINT + RANDOM_DIR)
 
     for count in range(MNT_COUNT):
         cmd.append(cgroup_path(count))
@@ -73,6 +77,7 @@ def teardown(config):
     for count in range(MNT_COUNT):
         cmd.append(cgroup_path(count))
 
+    cmd.append(MNT_POINT + RANDOM_DIR)
     cmd.append(MNT_POINT)
 
     # execute rmdir top-level top-level/sub-directory* at once.