(snapshotter: Snapshotter, now: datetime)
| 75 | |
| 76 | |
| 77 | def test_get_system_info(snapshotter: Snapshotter, now: datetime) -> None: |
| 78 | system_status = SystemStatus( |
| 79 | snapshotter, |
| 80 | max_snapshot_age=timedelta(minutes=1), |
| 81 | cpu_overload_threshold=0.5, |
| 82 | memory_overload_threshold=0.5, |
| 83 | event_loop_overload_threshold=0.5, |
| 84 | client_overload_threshold=0.5, |
| 85 | ) |
| 86 | |
| 87 | # Add CPU snapshots |
| 88 | system_status._snapshotter._cpu_snapshots = Snapshotter._get_sorted_list_by_created_at( |
| 89 | [ |
| 90 | CpuSnapshot(used_ratio=0.6, max_used_ratio=0.75, created_at=now - timedelta(minutes=3)), |
| 91 | CpuSnapshot(used_ratio=0.7, max_used_ratio=0.75, created_at=now - timedelta(minutes=2)), |
| 92 | CpuSnapshot(used_ratio=0.8, max_used_ratio=0.75, created_at=now - timedelta(minutes=1)), |
| 93 | CpuSnapshot(used_ratio=0.9, max_used_ratio=0.75, created_at=now), |
| 94 | ] |
| 95 | ) |
| 96 | |
| 97 | # Add memory snapshots |
| 98 | system_status._snapshotter._memory_snapshots = Snapshotter._get_sorted_list_by_created_at( |
| 99 | [ |
| 100 | MemorySnapshot( |
| 101 | current_size=ByteSize.from_gb(4), |
| 102 | max_memory_size=ByteSize.from_gb(12), |
| 103 | max_used_memory_ratio=0.8, |
| 104 | created_at=now - timedelta(seconds=90), |
| 105 | system_wide_used_size=None, |
| 106 | system_wide_memory_size=None, |
| 107 | ), |
| 108 | MemorySnapshot( |
| 109 | current_size=ByteSize.from_gb(7), |
| 110 | max_memory_size=ByteSize.from_gb(8), |
| 111 | max_used_memory_ratio=0.8, |
| 112 | created_at=now - timedelta(seconds=60), |
| 113 | system_wide_used_size=None, |
| 114 | system_wide_memory_size=None, |
| 115 | ), |
| 116 | MemorySnapshot( |
| 117 | current_size=ByteSize.from_gb(28), |
| 118 | max_memory_size=ByteSize.from_gb(30), |
| 119 | max_used_memory_ratio=0.8, |
| 120 | created_at=now - timedelta(seconds=30), |
| 121 | system_wide_used_size=None, |
| 122 | system_wide_memory_size=None, |
| 123 | ), |
| 124 | MemorySnapshot( |
| 125 | current_size=ByteSize.from_gb(48), |
| 126 | max_memory_size=ByteSize.from_gb(60), |
| 127 | max_used_memory_ratio=0.8, |
| 128 | created_at=now, |
| 129 | system_wide_used_size=None, |
| 130 | system_wide_memory_size=None, |
| 131 | ), |
| 132 | ] |
| 133 | ) |
| 134 |
nothing calls this directly
no test coverage detected