@@ -503,3 +503,93 @@ async def test_addon_new_device_no_haos(
503503 await install_addon_ssh .stop ()
504504 assert coresys .resolution .issues == []
505505 assert coresys .resolution .suggestions == []
506+
507+
508+ async def test_ulimits_integration (
509+ coresys : CoreSys ,
510+ install_addon_ssh : Addon ,
511+ ):
512+ """Test ulimits integration with Docker addon."""
513+ docker_addon = DockerAddon (coresys , install_addon_ssh )
514+
515+ # Test default case (no ulimits, no realtime)
516+ assert docker_addon .ulimits is None
517+
518+ # Test with realtime enabled (should have built-in ulimits)
519+ install_addon_ssh .data ["realtime" ] = True
520+ ulimits = docker_addon .ulimits
521+ assert ulimits is not None
522+ assert len (ulimits ) == 2
523+ # Check for rtprio limit
524+ rtprio_limit = next ((u for u in ulimits if u .name == "rtprio" ), None )
525+ assert rtprio_limit is not None
526+ assert rtprio_limit .soft == 90
527+ assert rtprio_limit .hard == 99
528+ # Check for memlock limit
529+ memlock_limit = next ((u for u in ulimits if u .name == "memlock" ), None )
530+ assert memlock_limit is not None
531+ assert memlock_limit .soft == 128 * 1024 * 1024
532+ assert memlock_limit .hard == 128 * 1024 * 1024
533+
534+ # Test with configurable ulimits (simple format)
535+ install_addon_ssh .data ["realtime" ] = False
536+ install_addon_ssh .data ["ulimits" ] = {"nofile" : 65535 , "nproc" : 32768 }
537+ ulimits = docker_addon .ulimits
538+ assert ulimits is not None
539+ assert len (ulimits ) == 2
540+
541+ nofile_limit = next ((u for u in ulimits if u .name == "nofile" ), None )
542+ assert nofile_limit is not None
543+ assert nofile_limit .soft == 65535
544+ assert nofile_limit .hard == 65535
545+
546+ nproc_limit = next ((u for u in ulimits if u .name == "nproc" ), None )
547+ assert nproc_limit is not None
548+ assert nproc_limit .soft == 32768
549+ assert nproc_limit .hard == 32768
550+
551+ # Test with configurable ulimits (detailed format)
552+ install_addon_ssh .data ["ulimits" ] = {
553+ "nofile" : {"soft" : 20000 , "hard" : 40000 },
554+ "memlock" : {"soft" : 67108864 , "hard" : 134217728 },
555+ }
556+ ulimits = docker_addon .ulimits
557+ assert ulimits is not None
558+ assert len (ulimits ) == 2
559+
560+ nofile_limit = next ((u for u in ulimits if u .name == "nofile" ), None )
561+ assert nofile_limit is not None
562+ assert nofile_limit .soft == 20000
563+ assert nofile_limit .hard == 40000
564+
565+ memlock_limit = next ((u for u in ulimits if u .name == "memlock" ), None )
566+ assert memlock_limit is not None
567+ assert memlock_limit .soft == 67108864
568+ assert memlock_limit .hard == 134217728
569+
570+ # Test mixed format and realtime (realtime + custom ulimits)
571+ install_addon_ssh .data ["realtime" ] = True
572+ install_addon_ssh .data ["ulimits" ] = {
573+ "nofile" : 65535 ,
574+ "core" : {"soft" : 0 , "hard" : 0 }, # Disable core dumps
575+ }
576+ ulimits = docker_addon .ulimits
577+ assert ulimits is not None
578+ assert (
579+ len (ulimits ) == 4
580+ ) # rtprio, memlock (from realtime) + nofile, core (from config)
581+
582+ # Check realtime limits still present
583+ rtprio_limit = next ((u for u in ulimits if u .name == "rtprio" ), None )
584+ assert rtprio_limit is not None
585+
586+ # Check custom limits added
587+ nofile_limit = next ((u for u in ulimits if u .name == "nofile" ), None )
588+ assert nofile_limit is not None
589+ assert nofile_limit .soft == 65535
590+ assert nofile_limit .hard == 65535
591+
592+ core_limit = next ((u for u in ulimits if u .name == "core" ), None )
593+ assert core_limit is not None
594+ assert core_limit .soft == 0
595+ assert core_limit .hard == 0
0 commit comments