|
| 1 | +import os |
| 2 | +import sys |
| 3 | + |
| 4 | +from sonic_py_common.general import load_module_from_source |
| 5 | +from unittest import TestCase, mock |
| 6 | + |
| 7 | +class TestCaclmgrdNamespaceDockerIP(TestCase): |
| 8 | + """ |
| 9 | + Test caclmgrd Namespace docker management IP |
| 10 | + """ |
| 11 | + def setUp(self): |
| 12 | + test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 13 | + modules_path = os.path.dirname(test_path) |
| 14 | + scripts_path = os.path.join(modules_path, "scripts") |
| 15 | + sys.path.insert(0, modules_path) |
| 16 | + caclmgrd_path = os.path.join(scripts_path, 'caclmgrd') |
| 17 | + self.caclmgrd = load_module_from_source('caclmgrd', caclmgrd_path) |
| 18 | + self.maxDiff = None |
| 19 | + |
| 20 | + def test_caclmgrd_namespace_docker_ip(self): |
| 21 | + self.caclmgrd.ControlPlaneAclManager.get_namespace_mgmt_ip = mock.MagicMock(return_value=[]) |
| 22 | + self.caclmgrd.ControlPlaneAclManager.get_namespace_mgmt_ipv6 = mock.MagicMock(return_value=[]) |
| 23 | + with mock.patch('sonic_py_common.multi_asic.get_all_namespaces', |
| 24 | + return_value={'front_ns': ['asic0'], 'back_ns': ['asic1'], 'fabric_ns': ['asic2']}): |
| 25 | + caclmgrd_daemon = self.caclmgrd.ControlPlaneAclManager("caclmgrd") |
| 26 | + self.assertTrue('asic0' in caclmgrd_daemon.namespace_docker_mgmt_ip) |
| 27 | + self.assertTrue('asic1' in caclmgrd_daemon.namespace_docker_mgmt_ip) |
| 28 | + self.assertTrue('asic2' in caclmgrd_daemon.namespace_docker_mgmt_ip) |
| 29 | + self.assertListEqual(caclmgrd_daemon.namespace_docker_mgmt_ip['asic0'], []) |
0 commit comments