"""Cluster exclusion does not depend on unrelated sandbox guests.""" import importlib.util import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[2] spec = importlib.util.spec_from_file_location('runtime_guard', ROOT / 'scripts/cluster-runtime-guard.py') guard = importlib.util.module_from_spec(spec) spec.loader.exec_module(guard) class SandboxGuardTests(unittest.TestCase): def test_unrelated_vms_are_not_cluster_guests(self): self.assertFalse(guard.is_competing_cluster_vm(9100, 'jeannie-sandbox-openwrt', {9001, 9010, 9011})) self.assertFalse(guard.is_competing_cluster_vm(9101, 'another-lab', {9001, 9010, 9011})) def test_declared_and_named_cluster_vms_remain_conflicts(self): self.assertTrue(guard.is_competing_cluster_vm(9010, 'renamed', {9001, 9010, 9011})) self.assertTrue(guard.is_competing_cluster_vm(9100, 'renamed', {9100})) self.assertTrue(guard.is_competing_cluster_vm(9200, 'pimox-worker-03', {9001, 9010, 9011})) if __name__ == '__main__': unittest.main()