@@ -25,7 +25,7 @@ def get_minimal_container():
2525 }
2626
2727
28- class TestContainerToArgs (unittest .TestCase ):
28+ class TestContainerToArgs (unittest .IsolatedAsyncioTestCase ):
2929 async def test_minimal (self ):
3030 c = create_compose_mock ()
3131
@@ -66,3 +66,67 @@ async def test_runtime(self):
6666 "busybox" ,
6767 ],
6868 )
69+
70+ async def test_sysctl_list (self ):
71+ c = create_compose_mock ()
72+
73+ cnt = get_minimal_container ()
74+ cnt ["sysctls" ] = [
75+ "net.core.somaxconn=1024" ,
76+ "net.ipv4.tcp_syncookies=0" ,
77+ ]
78+
79+ args = await container_to_args (c , cnt )
80+ self .assertEqual (
81+ args ,
82+ [
83+ "--name=project_name_service_name1" ,
84+ "-d" ,
85+ "--net" ,
86+ "" ,
87+ "--network-alias" ,
88+ "service_name" ,
89+ "--sysctl" ,
90+ "net.core.somaxconn=1024" ,
91+ "--sysctl" ,
92+ "net.ipv4.tcp_syncookies=0" ,
93+ "busybox" ,
94+ ],
95+ )
96+
97+ async def test_sysctl_map (self ):
98+ c = create_compose_mock ()
99+
100+ cnt = get_minimal_container ()
101+ cnt ["sysctls" ] = {
102+ "net.core.somaxconn" : 1024 ,
103+ "net.ipv4.tcp_syncookies" : 0 ,
104+ }
105+
106+ args = await container_to_args (c , cnt )
107+ self .assertEqual (
108+ args ,
109+ [
110+ "--name=project_name_service_name1" ,
111+ "-d" ,
112+ "--net" ,
113+ "" ,
114+ "--network-alias" ,
115+ "service_name" ,
116+ "--sysctl" ,
117+ "net.core.somaxconn=1024" ,
118+ "--sysctl" ,
119+ "net.ipv4.tcp_syncookies=0" ,
120+ "busybox" ,
121+ ],
122+ )
123+
124+ async def test_sysctl_wrong_type (self ):
125+ c = create_compose_mock ()
126+ cnt = get_minimal_container ()
127+
128+ # check whether wrong types are correctly rejected
129+ for wrong_type in [True , 0 , 0.0 , "wrong" , ()]:
130+ with self .assertRaises (TypeError ):
131+ cnt ["sysctls" ] = wrong_type
132+ await container_to_args (c , cnt )
0 commit comments