14
14
from framework .properties import global_props
15
15
16
16
17
+ def setup_bind_mounts (tmp_path , n ):
18
+ """
19
+ Create bind mount points. The exact location of them
20
+ does not matter, they just need to exist.
21
+ """
22
+ mounts_paths = tmp_path / "mounts"
23
+ os .makedirs (mounts_paths )
24
+ for m in range (n ):
25
+ mount_path = f"{ mounts_paths } /mount{ m } "
26
+ os .makedirs (mount_path )
27
+ utils .check_output (f"mount --bind { mount_path } { mount_path } " )
28
+
29
+
30
+ def clean_up_mounts (tmp_path ):
31
+ """Cleanup mounts and jailer dirs"""
32
+ mounts_paths = tmp_path / "mounts"
33
+ for d in os .listdir (mounts_paths ):
34
+ utils .check_output (f"umount { mounts_paths } /{ d } " )
35
+
36
+
17
37
@pytest .mark .nonci
18
38
@pytest .mark .parametrize ("jailers" , [1 , 100 , 300 , 500 ])
19
39
@pytest .mark .parametrize ("mounts" , [0 , 100 , 300 , 500 ])
@@ -26,14 +46,7 @@ def test_jailer_startup(
26
46
27
47
jailer_binary = microvm_factory .jailer_binary_path
28
48
29
- # Create bind mount points. The exact location of them
30
- # does not matter, they just need to exist.
31
- mounts_paths = tmp_path / "mounts"
32
- os .makedirs (mounts_paths )
33
- for m in range (mounts ):
34
- mount_path = f"{ mounts_paths } /mount{ m } "
35
- os .makedirs (mount_path )
36
- utils .check_output (f"mount --bind { mount_path } { mount_path } " )
49
+ setup_bind_mounts (tmp_path , mounts )
37
50
38
51
metrics .set_dimensions (
39
52
{
@@ -79,9 +92,7 @@ def test_jailer_startup(
79
92
unit = "Microseconds" ,
80
93
)
81
94
82
- # Cleanup mounts and jailer dirs
83
- for d in os .listdir (mounts_paths ):
84
- utils .check_output (f"umount { mounts_paths } /{ d } " )
95
+ clean_up_mounts (tmp_path )
85
96
shutil .rmtree (DEFAULT_CHROOT_PATH )
86
97
87
98
@@ -98,14 +109,7 @@ def test_jailer_startup_parallel(
98
109
99
110
jailer_binary = microvm_factory .jailer_binary_path
100
111
101
- # Create bind mount points. The exact location of them
102
- # does not matter, they just need to exist.
103
- mounts_paths = tmp_path / "mounts"
104
- os .makedirs (mounts_paths )
105
- for m in range (mounts ):
106
- mount_path = f"{ mounts_paths } /mount{ m } "
107
- os .makedirs (mount_path )
108
- utils .check_output (f"mount --bind { mount_path } { mount_path } " )
112
+ setup_bind_mounts (tmp_path , mounts )
109
113
110
114
metrics .set_dimensions (
111
115
{
@@ -143,7 +147,5 @@ def test_jailer_startup_parallel(
143
147
unit = "Microseconds" ,
144
148
)
145
149
146
- # Cleanup mounts and jailer dirs
147
- for d in os .listdir (mounts_paths ):
148
- utils .check_output (f"umount { mounts_paths } /{ d } " )
150
+ clean_up_mounts (tmp_path )
149
151
shutil .rmtree (DEFAULT_CHROOT_PATH )
0 commit comments