16 lines
1 KiB
Python
16 lines
1 KiB
Python
#!/usr/bin/env python3
|
|
import importlib.util, unittest
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
spec=importlib.util.spec_from_file_location("scheduler",ROOT/"server-tools/persona-compute-pool/scheduler.py")
|
|
M=importlib.util.module_from_spec(spec); assert spec.loader; spec.loader.exec_module(M)
|
|
|
|
class SchedulerTests(unittest.TestCase):
|
|
def test_audit_excludes_mother_node(self):
|
|
value=M.audit(); self.assertEqual(value["outcome"],"PASS"); self.assertTrue(value["mother_node_excluded"])
|
|
def test_pending_workers_do_not_fake_a_lease(self):
|
|
value=M.select({"min_cpu_cores":1,"min_memory_mb":256}); self.assertEqual(value["outcome"],"NO_ELIGIBLE_WORKER")
|
|
def test_active_worker_is_selected_by_capacity(self):
|
|
pool=M.load_map(); pool["nodes"][2]["state"]="ACTIVE_WORKER"; value=M.select({"min_cpu_cores":2,"min_memory_mb":1000},pool); self.assertEqual(value["outcome"],"LEASE_REQUESTED"); self.assertEqual(value["node_id"],"XX-GZ-001")
|
|
|
|
if __name__=="__main__": unittest.main()
|