@@ -495,6 +495,69 @@ async def test_nacos_update_without_runtime_key_preserves_instance_mirrors():
495495 assert rock_config .runtime .instance_registry_mirrors == ["keep.example.com/ns" ]
496496
497497
498+ # ===== Nacos hot-reload for max_allowed_spec =====
499+
500+
501+ @pytest .mark .asyncio
502+ async def test_nacos_update_loads_max_allowed_spec ():
503+ rock_config = RockConfig ()
504+ rock_config .nacos_provider = MagicMock ()
505+ rock_config .nacos_provider .get_config = AsyncMock (
506+ return_value = {
507+ "runtime" : {
508+ "max_allowed_spec" : {
509+ "cpus" : 32 ,
510+ "memory" : "128g" ,
511+ "disk" : "512g" ,
512+ },
513+ },
514+ }
515+ )
516+
517+ await rock_config .update ()
518+
519+ assert rock_config .runtime .max_allowed_spec .cpus == 32
520+ assert rock_config .runtime .max_allowed_spec .memory == "128g"
521+ assert rock_config .runtime .max_allowed_spec .disk == "512g"
522+
523+
524+ @pytest .mark .asyncio
525+ async def test_nacos_max_allowed_spec_partial_update_preserves_yaml_values ():
526+ rock_config = RockConfig (
527+ runtime = RuntimeConfig (
528+ max_allowed_spec = {
529+ "cpus" : 8 ,
530+ "memory" : "32g" ,
531+ "disk" : "128g" ,
532+ }
533+ )
534+ )
535+ rock_config .nacos_provider = MagicMock ()
536+ rock_config .nacos_provider .get_config = AsyncMock (
537+ return_value = {"runtime" : {"max_allowed_spec" : {"cpus" : 12 }}}
538+ )
539+
540+ await rock_config .update ()
541+
542+ assert rock_config .runtime .max_allowed_spec .cpus == 12
543+ assert rock_config .runtime .max_allowed_spec .memory == "32g"
544+ assert rock_config .runtime .max_allowed_spec .disk == "128g"
545+
546+
547+ @pytest .mark .asyncio
548+ async def test_nacos_without_max_allowed_spec_preserves_existing_limit ():
549+ rock_config = RockConfig ()
550+ rock_config .runtime .max_allowed_spec .cpus = 10
551+ rock_config .nacos_provider = MagicMock ()
552+ rock_config .nacos_provider .get_config = AsyncMock (
553+ return_value = {"runtime" : {"instance_registry_mirrors" : ["reg.example.com/ns" ]}}
554+ )
555+
556+ await rock_config .update ()
557+
558+ assert rock_config .runtime .max_allowed_spec .cpus == 10
559+
560+
498561# ===== _resolve_k8s_template_includes =====
499562
500563
0 commit comments