13
13
from framework .properties import global_props
14
14
15
15
16
+ def setup_bind_mounts (tmp_path , n ):
17
+ """
18
+ Create bind mount points. The exact location of them
19
+ does not matter, they just need to exist.
20
+ """
21
+ mounts_paths = tmp_path / "mounts"
22
+ os .makedirs (mounts_paths )
23
+ for m in range (n ):
24
+ mount_path = f"{ mounts_paths } /mount{ m } "
25
+ os .makedirs (mount_path )
26
+ subprocess .run (
27
+ ["mount" , "--bind" , f"{ mount_path } " , f"{ mount_path } " ], check = True
28
+ )
29
+
30
+
31
+ def clean_up_mounts (tmp_path ):
32
+ """Cleanup mounts and jailer dirs"""
33
+ mounts_paths = tmp_path / "mounts"
34
+ for d in os .listdir (mounts_paths ):
35
+ subprocess .run (["umount" , f"{ mounts_paths } /{ d } " ], check = True )
36
+
37
+
16
38
@pytest .mark .nonci
17
39
@pytest .mark .parametrize ("jailers" , [1 , 100 , 300 , 500 ])
18
40
@pytest .mark .parametrize ("mounts" , [0 , 100 , 300 , 500 ])
@@ -25,16 +47,7 @@ def test_jailer_startup(
25
47
26
48
jailer_binary = microvm_factory .jailer_binary_path
27
49
28
- # Create bind mount points. The exact location of them
29
- # does not matter, they just need to exist.
30
- mounts_paths = tmp_path / "mounts"
31
- os .makedirs (mounts_paths )
32
- for m in range (mounts ):
33
- mount_path = f"{ mounts_paths } /mount{ m } "
34
- os .makedirs (mount_path )
35
- subprocess .run (
36
- ["mount" , "--bind" , f"{ mount_path } " , f"{ mount_path } " ], check = True
37
- )
50
+ setup_bind_mounts (tmp_path , mounts )
38
51
39
52
metrics .set_dimensions (
40
53
{
@@ -80,9 +93,7 @@ def test_jailer_startup(
80
93
unit = "Microseconds" ,
81
94
)
82
95
83
- # Cleanup mounts and jailer dirs
84
- for d in os .listdir (mounts_paths ):
85
- subprocess .run (["umount" , f"{ mounts_paths } /{ d } " ], check = True )
96
+ clean_up_mounts (tmp_path )
86
97
shutil .rmtree (DEFAULT_CHROOT_PATH )
87
98
88
99
@@ -113,16 +124,7 @@ def test_jailer_startup_parallel(
113
124
114
125
jailer_binary = microvm_factory .jailer_binary_path
115
126
116
- # Create bind mount points. The exact location of them
117
- # does not matter, they just need to exist.
118
- mounts_paths = tmp_path / "mounts"
119
- os .makedirs (mounts_paths )
120
- for m in range (mounts ):
121
- mount_path = f"{ mounts_paths } /mount{ m } "
122
- os .makedirs (mount_path )
123
- subprocess .run (
124
- ["mount" , "--bind" , f"{ mount_path } " , f"{ mount_path } " ], check = True
125
- )
127
+ setup_bind_mounts (tmp_path , mounts )
126
128
127
129
metrics .set_dimensions (
128
130
{
@@ -160,7 +162,5 @@ def test_jailer_startup_parallel(
160
162
unit = "Microseconds" ,
161
163
)
162
164
163
- # Cleanup mounts and jailer dirs
164
- for d in os .listdir (mounts_paths ):
165
- subprocess .run (["umount" , f"{ mounts_paths } /{ d } " ], check = True )
165
+ clean_up_mounts (tmp_path )
166
166
shutil .rmtree (DEFAULT_CHROOT_PATH )
0 commit comments