|
1 |
| -// Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 1 | +// Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | //
|
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"). You may
|
4 | 4 | // not use this file except in compliance with the License. A copy of the
|
@@ -227,57 +227,6 @@ func TestDockerHostConfigRawConfig(t *testing.T) {
|
227 | 227 | assertSetStructFieldsEqual(t, expectedOutput, *config)
|
228 | 228 | }
|
229 | 229 |
|
230 |
| -func TestDockerHostConfigRawConfigMerging(t *testing.T) { |
231 |
| - // Use a struct that will marshal to the actual message we expect; not |
232 |
| - // docker.HostConfig which will include a lot of zero values. |
233 |
| - rawHostConfigInput := struct { |
234 |
| - Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"` |
235 |
| - SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"` |
236 |
| - }{ |
237 |
| - Privileged: true, |
238 |
| - SecurityOpt: []string{"foo", "bar"}, |
239 |
| - } |
240 |
| - |
241 |
| - rawHostConfig, err := json.Marshal(&rawHostConfigInput) |
242 |
| - if err != nil { |
243 |
| - t.Fatal(err) |
244 |
| - } |
245 |
| - |
246 |
| - testTask := &Task{ |
247 |
| - Arn: "arn:aws:ecs:us-east-1:012345678910:task/c09f0188-7f87-4b0f-bfc3-16296622b6fe", |
248 |
| - Family: "myFamily", |
249 |
| - Version: "1", |
250 |
| - Containers: []*Container{ |
251 |
| - { |
252 |
| - Name: "c1", |
253 |
| - Image: "image", |
254 |
| - CPU: 50, |
255 |
| - Memory: 100, |
256 |
| - VolumesFrom: []VolumeFrom{{SourceContainer: "c2"}}, |
257 |
| - DockerConfig: DockerConfig{ |
258 |
| - HostConfig: strptr(string(rawHostConfig)), |
259 |
| - }, |
260 |
| - }, |
261 |
| - { |
262 |
| - Name: "c2", |
263 |
| - }, |
264 |
| - }, |
265 |
| - } |
266 |
| - |
267 |
| - hostConfig, configErr := testTask.DockerHostConfig(testTask.Containers[0], dockerMap(testTask), defaultDockerClientAPIVersion) |
268 |
| - assert.Nil(t, configErr) |
269 |
| - |
270 |
| - expected := docker.HostConfig{ |
271 |
| - Privileged: true, |
272 |
| - SecurityOpt: []string{"foo", "bar"}, |
273 |
| - VolumesFrom: []string{"dockername-c2"}, |
274 |
| - MemorySwappiness: memorySwappinessDefault, |
275 |
| - CPUPercent: minimumCPUPercent, |
276 |
| - } |
277 |
| - |
278 |
| - assertSetStructFieldsEqual(t, expected, *hostConfig) |
279 |
| -} |
280 |
| - |
281 | 230 | func TestDockerHostConfigPauseContainer(t *testing.T) {
|
282 | 231 | testTask := &Task{
|
283 | 232 | ENI: &ENI{
|
@@ -1282,52 +1231,6 @@ func TestApplyExecutionRoleLogsAuthFailNoCredentialsForTask(t *testing.T) {
|
1282 | 1231 | assert.Error(t, err)
|
1283 | 1232 | }
|
1284 | 1233 |
|
1285 |
| -// TestSetConfigHostconfigBasedOnAPIVersion tests the docker hostconfig was correctly set// based on the docker client version |
1286 |
| -func TestSetConfigHostconfigBasedOnAPIVersion(t *testing.T) { |
1287 |
| - memoryMiB := 500 |
1288 |
| - testTask := &Task{ |
1289 |
| - Containers: []*Container{ |
1290 |
| - { |
1291 |
| - Name: "c1", |
1292 |
| - CPU: uint(10), |
1293 |
| - Memory: uint(memoryMiB), |
1294 |
| - }, |
1295 |
| - }, |
1296 |
| - } |
1297 |
| - |
1298 |
| - hostconfig, err := testTask.DockerHostConfig(testTask.Containers[0], dockerMap(testTask), defaultDockerClientAPIVersion) |
1299 |
| - assert.Nil(t, err) |
1300 |
| - |
1301 |
| - config, cerr := testTask.DockerConfig(testTask.Containers[0], defaultDockerClientAPIVersion) |
1302 |
| - assert.Nil(t, cerr) |
1303 |
| - |
1304 |
| - assert.Equal(t, int64(memoryMiB*1024*1024), config.Memory) |
1305 |
| - if runtime.GOOS == "windows" { |
1306 |
| - assert.Equal(t, int64(minimumCPUPercent), hostconfig.CPUPercent) |
1307 |
| - } else { |
1308 |
| - assert.Equal(t, int64(10), config.CPUShares) |
1309 |
| - } |
1310 |
| - assert.Empty(t, hostconfig.CPUShares) |
1311 |
| - assert.Empty(t, hostconfig.Memory) |
1312 |
| - |
1313 |
| - hostconfig, err = testTask.DockerHostConfig(testTask.Containers[0], dockerMap(testTask), dockerclient.Version_1_18) |
1314 |
| - assert.Nil(t, err) |
1315 |
| - |
1316 |
| - config, cerr = testTask.DockerConfig(testTask.Containers[0], dockerclient.Version_1_18) |
1317 |
| - assert.Nil(t, err) |
1318 |
| - assert.Equal(t, int64(memoryMiB*1024*1024), hostconfig.Memory) |
1319 |
| - if runtime.GOOS == "windows" { |
1320 |
| - // cpushares is set to zero on windows |
1321 |
| - assert.Empty(t, hostconfig.CPUShares) |
1322 |
| - assert.Equal(t, int64(minimumCPUPercent), hostconfig.CPUPercent) |
1323 |
| - } else { |
1324 |
| - assert.Equal(t, int64(10), hostconfig.CPUShares) |
1325 |
| - } |
1326 |
| - |
1327 |
| - assert.Empty(t, config.CPUShares) |
1328 |
| - assert.Empty(t, config.Memory) |
1329 |
| -} |
1330 |
| - |
1331 | 1234 | // TestSetMinimumMemoryLimit ensures that we set the correct minimum memory limit when the limit is too low
|
1332 | 1235 | func TestSetMinimumMemoryLimit(t *testing.T) {
|
1333 | 1236 | testTask := &Task{
|
|
0 commit comments