@@ -41,96 +41,92 @@ def test_create_container_args(self):
41
41
)
42
42
}
43
43
44
- create_kwargs = _create_container_args (dict (
45
- image = 'alpine' ,
46
- command = 'echo hello world' ,
47
- blkio_weight_device = [{'Path' : 'foo' , 'Weight' : 3 }],
48
- blkio_weight = 2 ,
49
- cap_add = ['foo' ],
50
- cap_drop = ['bar' ],
51
- cgroup_parent = 'foobar' ,
52
- cgroupns = 'host' ,
53
- cpu_period = 1 ,
54
- cpu_quota = 2 ,
55
- cpu_shares = 5 ,
56
- cpuset_cpus = '0-3' ,
57
- detach = False ,
58
- device_read_bps = [{'Path' : 'foo' , 'Rate' : 3 }],
59
- device_read_iops = [{'Path' : 'foo' , 'Rate' : 3 }],
60
- device_write_bps = [{'Path' : 'foo' , 'Rate' : 3 }],
61
- device_write_iops = [{'Path' : 'foo' , 'Rate' : 3 }],
62
- devices = ['/dev/sda:/dev/xvda:rwm' ],
63
- dns = ['8.8.8.8' ],
64
- domainname = 'example.com' ,
65
- dns_opt = ['foo' ],
66
- dns_search = ['example.com' ],
67
- entrypoint = '/bin/sh' ,
68
- environment = {'FOO' : 'BAR' },
69
- extra_hosts = {'foo' : '1.2.3.4' },
70
- group_add = ['blah' ],
71
- ipc_mode = 'foo' ,
72
- kernel_memory = 123 ,
73
- labels = {'key' : 'value' },
74
- links = {'foo' : 'bar' },
75
- log_config = {'Type' : 'json-file' , 'Config' : {}},
76
- lxc_conf = {'foo' : 'bar' },
77
- healthcheck = {'test' : 'true' },
78
- hostname = 'somehost' ,
79
- mac_address = 'abc123' ,
80
- mem_limit = 123 ,
81
- mem_reservation = 123 ,
82
- mem_swappiness = 2 ,
83
- memswap_limit = 456 ,
84
- name = 'somename' ,
85
- network_disabled = False ,
86
- network = 'foo' ,
87
- networking_config = networking_config ,
88
- oom_kill_disable = True ,
89
- oom_score_adj = 5 ,
90
- pid_mode = 'host' ,
91
- pids_limit = 500 ,
92
- platform = 'linux' ,
93
- ports = {
94
- 1111 : 4567 ,
95
- 2222 : None
96
- },
97
- privileged = True ,
98
- publish_all_ports = True ,
99
- read_only = True ,
100
- restart_policy = {'Name' : 'always' },
101
- security_opt = ['blah' ],
102
- shm_size = 123 ,
103
- stdin_open = True ,
104
- stop_signal = 9 ,
105
- sysctls = {'foo' : 'bar' },
106
- tmpfs = {'/blah' : '' },
107
- tty = True ,
108
- ulimits = [{"Name" : "nofile" , "Soft" : 1024 , "Hard" : 2048 }],
109
- user = 'bob' ,
110
- userns_mode = 'host' ,
111
- uts_mode = 'host' ,
112
- version = DEFAULT_DOCKER_API_VERSION ,
113
- volume_driver = 'some_driver' ,
114
- volumes = [
44
+ create_kwargs = _create_container_args ({
45
+ 'image' : 'alpine' ,
46
+ 'command' : 'echo hello world' ,
47
+ 'blkio_weight_device' : [{'Path' : 'foo' , 'Weight' : 3 }],
48
+ 'blkio_weight' : 2 ,
49
+ 'cap_add' : ['foo' ],
50
+ 'cap_drop' : ['bar' ],
51
+ 'cgroup_parent' : 'foobar' ,
52
+ 'cgroupns' : 'host' ,
53
+ 'cpu_period' : 1 ,
54
+ 'cpu_quota' : 2 ,
55
+ 'cpu_shares' : 5 ,
56
+ 'cpuset_cpus' : '0-3' ,
57
+ 'detach' : False ,
58
+ 'device_read_bps' : [{'Path' : 'foo' , 'Rate' : 3 }],
59
+ 'device_read_iops' : [{'Path' : 'foo' , 'Rate' : 3 }],
60
+ 'device_write_bps' : [{'Path' : 'foo' , 'Rate' : 3 }],
61
+ 'device_write_iops' : [{'Path' : 'foo' , 'Rate' : 3 }],
62
+ 'devices' : ['/dev/sda:/dev/xvda:rwm' ],
63
+ 'dns' : ['8.8.8.8' ],
64
+ 'domainname' : 'example.com' ,
65
+ 'dns_opt' : ['foo' ],
66
+ 'dns_search' : ['example.com' ],
67
+ 'entrypoint' : '/bin/sh' ,
68
+ 'environment' : {'FOO' : 'BAR' },
69
+ 'extra_hosts' : {'foo' : '1.2.3.4' },
70
+ 'group_add' : ['blah' ],
71
+ 'ipc_mode' : 'foo' ,
72
+ 'kernel_memory' : 123 ,
73
+ 'labels' : {'key' : 'value' },
74
+ 'links' : {'foo' : 'bar' },
75
+ 'log_config' : {'Type' : 'json-file' , 'Config' : {}},
76
+ 'lxc_conf' : {'foo' : 'bar' },
77
+ 'healthcheck' : {'test' : 'true' },
78
+ 'hostname' : 'somehost' ,
79
+ 'mac_address' : 'abc123' ,
80
+ 'mem_limit' : 123 ,
81
+ 'mem_reservation' : 123 ,
82
+ 'mem_swappiness' : 2 ,
83
+ 'memswap_limit' : 456 ,
84
+ 'name' : 'somename' ,
85
+ 'network_disabled' : False ,
86
+ 'network' : 'foo' ,
87
+ 'networking_config' : networking_config ,
88
+ 'oom_kill_disable' : True ,
89
+ 'oom_score_adj' : 5 ,
90
+ 'pid_mode' : 'host' ,
91
+ 'pids_limit' : 500 ,
92
+ 'platform' : 'linux' ,
93
+ 'ports' : {1111 : 4567 , 2222 : None },
94
+ 'privileged' : True ,
95
+ 'publish_all_ports' : True ,
96
+ 'read_only' : True ,
97
+ 'restart_policy' : {'Name' : 'always' },
98
+ 'security_opt' : ['blah' ],
99
+ 'shm_size' : 123 ,
100
+ 'stdin_open' : True ,
101
+ 'stop_signal' : 9 ,
102
+ 'sysctls' : {'foo' : 'bar' },
103
+ 'tmpfs' : {'/blah' : '' },
104
+ 'tty' : True ,
105
+ 'ulimits' : [{"Name" : "nofile" , "Soft" : 1024 , "Hard" : 2048 }],
106
+ 'user' : 'bob' ,
107
+ 'userns_mode' : 'host' ,
108
+ 'uts_mode' : 'host' ,
109
+ 'version' : DEFAULT_DOCKER_API_VERSION ,
110
+ 'volume_driver' : 'some_driver' , 'volumes' : [
115
111
'/home/user1/:/mnt/vol2' ,
116
112
'/var/www:/mnt/vol1:ro' ,
117
113
'volumename:/mnt/vol3r' ,
118
114
'/volumewithnohostpath' ,
119
115
'/anothervolumewithnohostpath:ro' ,
120
116
'C:\\ windows\\ path:D:\\ hello\\ world:rw'
121
117
],
122
- volumes_from = ['container' ],
123
- working_dir = ' /code'
124
- ) )
118
+ ' volumes_from' : ['container' ],
119
+ ' working_dir' : ' /code',
120
+ } )
125
121
126
- expected = dict (
127
- image = 'alpine' ,
128
- command = 'echo hello world' ,
129
- domainname = 'example.com' ,
130
- detach = False ,
131
- entrypoint = '/bin/sh' ,
132
- environment = {'FOO' : 'BAR' },
133
- host_config = {
122
+ expected = {
123
+ ' image' : 'alpine' ,
124
+ ' command' : 'echo hello world' ,
125
+ ' domainname' : 'example.com' ,
126
+ ' detach' : False ,
127
+ ' entrypoint' : '/bin/sh' ,
128
+ ' environment' : {'FOO' : 'BAR' },
129
+ ' host_config' : {
134
130
'Binds' : [
135
131
'/home/user1/:/mnt/vol2' ,
136
132
'/var/www:/mnt/vol1:ro' ,
@@ -153,9 +149,13 @@ def test_create_container_args(self):
153
149
'CpuQuota' : 2 ,
154
150
'CpuShares' : 5 ,
155
151
'CpusetCpus' : '0-3' ,
156
- 'Devices' : [{'PathOnHost' : '/dev/sda' ,
157
- 'CgroupPermissions' : 'rwm' ,
158
- 'PathInContainer' : '/dev/xvda' }],
152
+ 'Devices' : [
153
+ {
154
+ 'PathOnHost' : '/dev/sda' ,
155
+ 'CgroupPermissions' : 'rwm' ,
156
+ 'PathInContainer' : '/dev/xvda' ,
157
+ },
158
+ ],
159
159
'Dns' : ['8.8.8.8' ],
160
160
'DnsOptions' : ['foo' ],
161
161
'DnsSearch' : ['example.com' ],
@@ -187,37 +187,44 @@ def test_create_container_args(self):
187
187
'ShmSize' : 123 ,
188
188
'Sysctls' : {'foo' : 'bar' },
189
189
'Tmpfs' : {'/blah' : '' },
190
- 'Ulimits' : [{"Name" : "nofile" , "Soft" : 1024 , "Hard" : 2048 }],
190
+ 'Ulimits' : [
191
+ {"Name" : "nofile" , "Soft" : 1024 , "Hard" : 2048 },
192
+ ],
191
193
'UsernsMode' : 'host' ,
192
194
'UTSMode' : 'host' ,
193
195
'VolumeDriver' : 'some_driver' ,
194
196
'VolumesFrom' : ['container' ],
195
197
},
196
- healthcheck = {'test' : 'true' },
197
- hostname = 'somehost' ,
198
- labels = {'key' : 'value' },
199
- mac_address = 'abc123' ,
200
- name = 'somename' ,
201
- network_disabled = False ,
202
- networking_config = {'EndpointsConfig' : {
203
- 'foo' : {'Aliases' : ['test' ], 'DriverOpts' : {'key1' : 'a' }}}
198
+ 'healthcheck' : {'test' : 'true' },
199
+ 'hostname' : 'somehost' ,
200
+ 'labels' : {'key' : 'value' },
201
+ 'mac_address' : 'abc123' ,
202
+ 'name' : 'somename' ,
203
+ 'network_disabled' : False ,
204
+ 'networking_config' : {
205
+ 'EndpointsConfig' : {
206
+ 'foo' : {
207
+ 'Aliases' : ['test' ],
208
+ 'DriverOpts' : {'key1' : 'a' },
209
+ },
210
+ }
204
211
},
205
- platform = 'linux' ,
206
- ports = [('1111' , 'tcp' ), ('2222' , 'tcp' )],
207
- stdin_open = True ,
208
- stop_signal = 9 ,
209
- tty = True ,
210
- user = 'bob' ,
211
- volumes = [
212
+ ' platform' : 'linux' ,
213
+ ' ports' : [('1111' , 'tcp' ), ('2222' , 'tcp' )],
214
+ ' stdin_open' : True ,
215
+ ' stop_signal' : 9 ,
216
+ ' tty' : True ,
217
+ ' user' : 'bob' ,
218
+ ' volumes' : [
212
219
'/mnt/vol2' ,
213
220
'/mnt/vol1' ,
214
221
'/mnt/vol3r' ,
215
222
'/volumewithnohostpath' ,
216
223
'/anothervolumewithnohostpath' ,
217
224
'D:\\ hello\\ world'
218
225
],
219
- working_dir = ' /code'
220
- )
226
+ ' working_dir' : ' /code',
227
+ }
221
228
222
229
assert create_kwargs == expected
223
230
0 commit comments