]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks/cephfs/test_nfs: fix info test
authorSage Weil <sage@newdream.net>
Fri, 7 May 2021 19:01:10 +0000 (15:01 -0400)
committerSage Weil <sage@newdream.net>
Tue, 25 May 2021 14:15:45 +0000 (10:15 -0400)
Signed-off-by: Sage Weil <sage@newdream.net>
qa/tasks/cephfs/test_nfs.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index fc0c3f467a163c7e521474558ef38d4fdb171cc7..83c4797b2818f99e0bd966629c86e99b0bd164ac 100644 (file)
@@ -243,9 +243,9 @@ class TestNFS(MgrTestCase):
         '''
         Return port and ip for a cluster
         '''
-        #{'test': [{'hostname': 'smithi068', 'ip': ['172.21.15.68'], 'port': 2049}]}
-        info_output = json.loads(self._nfs_cmd('cluster', 'info', self.cluster_id))['test'][0]
-        return info_output["port"], info_output["ip"][0]
+        #{'test': {'backend': [{'hostname': 'smithi068', 'ip': '172.21.15.68', 'port': 2049}]}}
+        info_output = json.loads(self._nfs_cmd('cluster', 'info', self.cluster_id))['test']['backend'][0]
+        return info_output["port"], info_output["ip"]
 
     def _test_mnt(self, pseudo_path, port, ip, check=True):
         '''
@@ -443,14 +443,23 @@ class TestNFS(MgrTestCase):
         '''
         self._test_create_cluster()
         info_output = json.loads(self._nfs_cmd('cluster', 'info', self.cluster_id))
-        info_ip = info_output[self.cluster_id][0].pop("ip")
-        host_details = {self.cluster_id: [{
-            "hostname": self._sys_cmd(['hostname']).decode("utf-8").strip(),
-            "port": 2049
-            }]}
+        print(f'info {info_output}')
+        info_ip = info_output[self.cluster_id].get('backend', [])[0].pop("ip")
+        host_details = {
+            self.cluster_id: {
+                'backend': [
+                    {
+                        "hostname": self._sys_cmd(['hostname']).decode("utf-8").strip(),
+                        "port": 2049
+                    }
+                ],
+                "virtual_ip": None,
+            }
+        }
         host_ip = self._sys_cmd(['hostname', '-I']).decode("utf-8").split()
+        print(f'host_ip is {host_ip}, info_ip is {info_ip}')
         self.assertDictEqual(info_output, host_details)
-        self.assertTrue(any([ip in info_ip for ip in host_ip]))
+        self.assertTrue(info_ip in host_ip)
         self._test_delete_cluster()
 
     def test_cluster_set_reset_user_config(self):
index 2517e288493d737fa991286e7c409c5c24d194c1..53d1f7283ada75998f16b797524f6eb5aef673ba 100644 (file)
@@ -755,6 +755,7 @@ class TestCephadm(object):
 
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}'))
     @mock.patch("cephadm.services.nfs.NFSService.run_grace_tool", mock.MagicMock())
+    @mock.patch("cephadm.services.nfs.NFSService.purge", mock.MagicMock())
     @mock.patch("cephadm.services.nfs.NFSService.create_rados_config_obj", mock.MagicMock())
     def test_nfs(self, cephadm_module):
         with with_host(cephadm_module, 'test'):