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
@@ -112,13 +123,7 @@ def test_jailer_startup_parallel(
112
123
113
124
jailer_binary = microvm_factory .jailer_binary_path
114
125
115
- # Create bind mount points. The exact location of them
116
- # does not matter, they just need to exist.
117
- mounts_paths = tmp_path / "mounts"
118
- for m in range (mounts ):
119
- mount_path = f"{ mounts_paths } /mount{ m } "
120
- os .makedirs (mount_path )
121
- utils .check_output (f"mount --bind { mount_path } { mount_path } " )
126
+ setup_bind_mounts (tmp_path , mounts )
122
127
123
128
metrics .set_dimensions (
124
129
{
@@ -156,7 +161,5 @@ def test_jailer_startup_parallel(
156
161
unit = "Microseconds" ,
157
162
)
158
163
159
- # Cleanup mounts and jailer dirs
160
- for d in os .listdir (mounts_paths ):
161
- utils .check_output (f"umount { mounts_paths } /{ d } " )
164
+ clean_up_mounts (tmp_path )
162
165
shutil .rmtree (DEFAULT_CHROOT_PATH )
0 commit comments