@@ -49,6 +49,14 @@ services:
49
49
tmpfs:
50
50
- "/run:rw,size=1gb"
51
51
read_only: true
52
+ ulimits:
53
+ rss: 65535
54
+ nofile:
55
+ soft: 2000
56
+ hard: 4000
57
+ nice:
58
+ soft: 300
59
+ hard: 500
52
60
mysql:
53
61
image: mysql
54
62
labels:
@@ -418,6 +426,19 @@ func verifyConvertToContainerConfigOutput(t *testing.T, expected types.ServiceCo
418
426
assert .Empty (t , actual .PortMappings )
419
427
}
420
428
429
+ if len (expected .Ulimits ) > 0 {
430
+ assert .Equal (t , len (expected .Ulimits ), len (actual .Ulimits ), "Expected number of Ulimits to match" )
431
+
432
+ for _ , lim := range actual .Ulimits {
433
+ matchingServUlimit := expected .Ulimits [* lim .Name ]
434
+
435
+ assert .NotNil (t , matchingServUlimit , "Expected ContainerConfig ulimit to have corresponding serviceConfig ulimit" )
436
+ verifyUlimit (t , * matchingServUlimit , * lim )
437
+ }
438
+ } else {
439
+ assert .Empty (t , actual .Ulimits )
440
+ }
441
+
421
442
if len (expected .Volumes ) > 0 {
422
443
for i , vol := range expected .Volumes {
423
444
if vol .Type == "volume" {
@@ -437,6 +458,20 @@ func verifyConvertToContainerConfigOutput(t *testing.T, expected types.ServiceCo
437
458
}
438
459
}
439
460
461
+ func verifyUlimit (t * testing.T , servUlimit types.UlimitsConfig , containerUlimit ecs.Ulimit ) {
462
+ var soft int64
463
+ var hard int64
464
+ if servUlimit .Single > 0 {
465
+ soft = int64 (servUlimit .Single )
466
+ hard = int64 (servUlimit .Single )
467
+ } else {
468
+ soft = int64 (servUlimit .Soft )
469
+ hard = int64 (servUlimit .Hard )
470
+ }
471
+ assert .Equal (t , soft , * containerUlimit .SoftLimit , "Expected soft limit to match" )
472
+ assert .Equal (t , hard , * containerUlimit .HardLimit , "Expected hard limit to match" )
473
+ }
474
+
440
475
func verifyMountPoint (t * testing.T , servVolume types.ServiceVolumeConfig , mountPoint ecs.MountPoint ) {
441
476
if servVolume .Source == "" {
442
477
assert .True (t , strings .HasPrefix (* mountPoint .SourceVolume , "volume-" ), "Expected volume Source to being with 'volume-'" )
0 commit comments