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(
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,
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 "
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 "
namespace=self.namespace,
db_dict=db_dict,
operation="rollback",
- run_once=True,
- check_every=0,
)
command = (
"env KUBECONFIG=./tmp/helm_cluster_id/.kube/config "
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,
"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()
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
)
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)
)
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,