File tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -85,11 +85,7 @@ class VmExecution:
8585
8686 @property
8787 def is_running (self ) -> bool :
88- return (
89- bool (self .times .starting_at and not self .times .stopping_at )
90- if not self .persistent
91- else self .systemd_manager .is_service_active (self .controller_service )
92- )
88+ return bool (self .times .starting_at and not self .times .stopping_at )
9389
9490 @property
9591 def is_stopping (self ) -> bool :
Original file line number Diff line number Diff line change @@ -87,8 +87,8 @@ def get_machine_properties() -> MachineProperties:
8787 cpu_info = cpuinfo .get_cpu_info () # Slow
8888 return MachineProperties (
8989 cpu = CpuProperties (
90- architecture = cpu_info [ "raw_arch_string" ] ,
91- vendor = cpu_info ["vendor_id " ],
90+ architecture = cpu_info . get ( "raw_arch_string" , cpu_info . get ( "arch_string_raw" )) ,
91+ vendor = cpu_info ["vendor_id_raw " ],
9292 ),
9393 )
9494
Original file line number Diff line number Diff line change @@ -239,8 +239,9 @@ async def load_persistent_executions(self):
239239 persistent = saved_execution .persistent ,
240240 )
241241
242- if execution .is_running :
243- # TODO: Improve the way that we re-create running execution
242+ if await self .systemd_manager .is_service_active (
243+ execution .controller_service
244+ ): # TODO: Improve the way that we re-create running execution
244245 await execution .prepare ()
245246 if self .network :
246247 vm_type = VmType .from_message_content (execution .message )
Original file line number Diff line number Diff line change @@ -24,3 +24,16 @@ async def test_allocation_fails_on_invalid_item_hash(aiohttp_client):
2424 "type" : "value_error.unknownhash" ,
2525 },
2626 ]
27+
28+
29+ @pytest .mark .asyncio
30+ async def test_system_usage (aiohttp_client ):
31+ """Test that the allocation endpoint fails when an invalid item_hash is provided."""
32+ client = await aiohttp_client (app )
33+ settings .ALLOCATION_TOKEN_HASH = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" # = "test"
34+ response : web .Response = await client .get ("/about/usage/system" )
35+ assert response .status == 200
36+ # check if it is valid json
37+ resp = await response .json ()
38+ assert "cpu" in resp
39+ assert resp ["cpu" ]["count" ] > 0
You can’t perform that action at this time.
0 commit comments