]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: unit test updates for new subnet function
authorPaul Cuzner <pcuzner@redhat.com>
Thu, 14 Jan 2021 20:56:15 +0000 (09:56 +1300)
committerPaul Cuzner <pcuzner@redhat.com>
Tue, 2 Feb 2021 01:22:42 +0000 (14:22 +1300)
Adds tests to validate the check_subnet function will work as
expected with various inputs

Signed-off-by: Paul Cuzner <pcuzner@redhat.com>
src/cephadm/tests/test_cephadm.py

index dae49a090374791f9d2f4af4b127f4d3e4c34832..f0c496092d185e42f4f48fa1b5f22a4c1cf9382a 100644 (file)
@@ -652,6 +652,22 @@ iMN28C2bKGao5UHvdER1rGy7
         with pytest.raises(HTTPError, match=r"HTTP Error 501: .*") as e:
             urlopen(req)
 
+    def test_ipv4_subnet(self):
+        rc, v, msg = cd.check_subnet('192.168.1.0/24')
+        assert rc == 0 and v == 4
+    
+    def test_ipv6_subnet(self):
+        rc, v, msg = cd.check_subnet('fe80::/64')
+        assert rc == 0 and v == 6
+    
+    def test_subnet_mask_missing(self):
+        rc, v, msg = cd.check_subnet('192.168.1.58')
+        assert rc == 1 and msg
+    
+    def test_subnet_mask_junk(self):
+        rc, v, msg = cd.check_subnet('wah')
+        assert rc == 1 and msg
+
 
 class TestMaintenance:
     systemd_target = "ceph.00000000-0000-0000-0000-000000c0ffee.target"