Bug 2007 fixed: removed the while true from K8sHelmBaseConnector._store_status
[osm/N2VC.git] / n2vc / tests / unit / test_k8s_helm_conn.py
index 9508b66..5e36938 100644 (file)
@@ -38,7 +38,7 @@ class TestK8sHelmConn(asynctest.TestCase):
         self.namespace = "testk8s"
         self.service_account = "osm"
         self.cluster_id = "helm_cluster_id"
-        self.cluster_uuid = self.cluster_id
+        self.cluster_uuid = "{}:{}".format(self.namespace, self.cluster_id)
         # pass fake kubectl and helm commands to make sure it does not call actual commands
         K8sHelmConnector._check_file_exists = asynctest.Mock(return_value=True)
         K8sHelmConnector._local_async_exec = asynctest.CoroutineMock(
@@ -69,7 +69,7 @@ class TestK8sHelmConn(asynctest.TestCase):
 
         self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
         self.helm_conn.fs.reverse_sync.assert_called_once_with(
-            from_path=self.cluster_id
+            from_path=self.cluster_uuid
         )
         self.assertEqual(
             self.helm_conn._local_async_exec.call_count,
@@ -170,8 +170,6 @@ class TestK8sHelmConn(asynctest.TestCase):
             namespace=self.namespace,
             db_dict=db_dict,
             operation="install",
-            run_once=True,
-            check_every=0,
         )
         command = (
             "env KUBECONFIG=./tmp/helm_cluster_id/.kube/config /usr/bin/helm install "
@@ -214,8 +212,6 @@ class TestK8sHelmConn(asynctest.TestCase):
             namespace=self.namespace,
             db_dict=db_dict,
             operation="upgrade",
-            run_once=True,
-            check_every=0,
         )
         command = (
             "env KUBECONFIG=./tmp/helm_cluster_id/.kube/config /usr/bin/helm upgrade "
@@ -255,8 +251,6 @@ class TestK8sHelmConn(asynctest.TestCase):
             namespace=self.namespace,
             db_dict=db_dict,
             operation="rollback",
-            run_once=True,
-            check_every=0,
         )
         command = (
             "env KUBECONFIG=./tmp/helm_cluster_id/.kube/config "
@@ -451,8 +445,6 @@ class TestK8sHelmConn(asynctest.TestCase):
             namespace=self.namespace,
             db_dict=db_dict,
             operation="install",
-            run_once=True,
-            check_every=0,
         )
         self.helm_conn._status_kdu.assert_called_once_with(
             cluster_id=self.cluster_id,
@@ -492,7 +484,6 @@ class TestK8sHelmConn(asynctest.TestCase):
                 "updated": "2020-10-30 11:11:20.376744191 +0000 UTC",
             }
         ]
-        self.helm_conn._get_namespace = Mock(return_value=self.namespace)
         self.helm_conn._uninstall_sw = asynctest.CoroutineMock()
         self.helm_conn.instances_list = asynctest.CoroutineMock(return_value=instances)
         self.helm_conn.uninstall = asynctest.CoroutineMock()
@@ -502,9 +493,6 @@ class TestK8sHelmConn(asynctest.TestCase):
         self.helm_conn.fs.file_delete.assert_called_once_with(
             self.cluster_id, ignore_non_exist=True
         )
-        self.helm_conn._get_namespace.assert_called_once_with(
-            cluster_uuid=self.cluster_uuid
-        )
         self.helm_conn.instances_list.assert_called_once_with(
             cluster_uuid=self.cluster_uuid
         )
@@ -512,7 +500,7 @@ class TestK8sHelmConn(asynctest.TestCase):
             cluster_uuid=self.cluster_uuid, kdu_instance=kdu_instance
         )
         self.helm_conn._uninstall_sw.assert_called_once_with(
-            cluster_id=self.cluster_id, namespace=self.namespace
+            self.cluster_id, self.namespace
         )
 
     @asynctest.fail_on(active_handles=True)
@@ -547,10 +535,8 @@ class TestK8sHelmConn(asynctest.TestCase):
         )
         call2_kargs = calls[2][1]
         command_2 = (
-            "/usr/bin/kubectl --kubeconfig={} --namespace {} delete "
-            "serviceaccount/{}".format(
-                self.kube_config, self.namespace, self.service_account
-            )
+            "/usr/bin/kubectl --kubeconfig={} --namespace kube-system delete "
+            "serviceaccount/{}".format(self.kube_config, self.service_account)
         )
         self.assertEqual(
             call2_kargs,