Reformat N2VC to standardized format
[osm/N2VC.git] / n2vc / tests / unit / test_k8s_helm3_conn.py
1 ##
2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
3 # not use this file except in compliance with the License. You may obtain
4 # a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations
12 # under the License.
13 #
14 # For those usages not covered by the Apache License, Version 2.0 please
15 # contact: alfonso.tiernosepulveda@telefonica.com
16 ##
17
18 import asynctest
19 import logging
20
21 from asynctest.mock import Mock
22 from osm_common.dbmemory import DbMemory
23 from osm_common.fslocal import FsLocal
24 from n2vc.k8s_helm3_conn import K8sHelm3Connector
25
26 __author__ = "Isabel Lloret <illoret@indra.es>"
27
28
29 class TestK8sHelm3Conn(asynctest.TestCase):
30 logging.basicConfig(level=logging.DEBUG)
31 logger = logging.getLogger(__name__)
32 logger.setLevel(logging.DEBUG)
33
34 async def setUp(self):
35 self.db = Mock(DbMemory())
36 self.fs = asynctest.Mock(FsLocal())
37 self.fs.path = "./tmp/"
38 self.namespace = "testk8s"
39 self.cluster_id = "helm3_cluster_id"
40 self.cluster_uuid = "{}:{}".format(self.namespace, self.cluster_id)
41 # pass fake kubectl and helm commands to make sure it does not call actual commands
42 K8sHelm3Connector._check_file_exists = asynctest.Mock(return_value=True)
43 cluster_dir = self.fs.path + self.cluster_id
44 self.env = {
45 "HELM_CACHE_HOME": "{}/.cache/helm".format(cluster_dir),
46 "HELM_CONFIG_HOME": "{}/.config/helm".format(cluster_dir),
47 "HELM_DATA_HOME": "{}/.local/share/helm".format(cluster_dir),
48 "KUBECONFIG": "{}/.kube/config".format(cluster_dir),
49 }
50 self.helm_conn = K8sHelm3Connector(self.fs, self.db, log=self.logger)
51 self.logger.debug("Set up executed")
52
53 @asynctest.fail_on(active_handles=True)
54 async def test_init_env(self):
55 k8s_creds = "false_credentials_string"
56 self.helm_conn._get_namespaces = asynctest.CoroutineMock(return_value=[])
57 self.helm_conn._create_namespace = asynctest.CoroutineMock()
58 self.helm_conn.repo_list = asynctest.CoroutineMock(return_value=[])
59 self.helm_conn.repo_add = asynctest.CoroutineMock()
60
61 k8scluster_uuid, installed = await self.helm_conn.init_env(
62 k8s_creds, namespace=self.namespace, reuse_cluster_uuid=self.cluster_id
63 )
64
65 self.assertEqual(
66 k8scluster_uuid,
67 "{}:{}".format(self.namespace, self.cluster_id),
68 "Check cluster_uuid format: <namespace>.<cluster_id>",
69 )
70 self.helm_conn._get_namespaces.assert_called_once_with(self.cluster_id)
71 self.helm_conn._create_namespace.assert_called_once_with(
72 self.cluster_id, self.namespace
73 )
74 self.helm_conn.repo_list.assert_called_once_with(k8scluster_uuid)
75 self.helm_conn.repo_add.assert_called_once_with(
76 k8scluster_uuid, "stable", "https://charts.helm.sh/stable"
77 )
78 self.helm_conn.fs.reverse_sync.assert_called_once_with(
79 from_path=self.cluster_id
80 )
81 self.logger.debug(f"cluster_uuid: {k8scluster_uuid}")
82
83 @asynctest.fail_on(active_handles=True)
84 async def test_repo_add(self):
85 repo_name = "bitnami"
86 repo_url = "https://charts.bitnami.com/bitnami"
87 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
88
89 await self.helm_conn.repo_add(self.cluster_uuid, repo_name, repo_url)
90
91 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
92 self.helm_conn.fs.reverse_sync.assert_called_once_with(
93 from_path=self.cluster_id
94 )
95 self.assertEqual(
96 self.helm_conn._local_async_exec.call_count,
97 2,
98 "local_async_exec expected 2 calls, called {}".format(
99 self.helm_conn._local_async_exec.call_count
100 ),
101 )
102
103 repo_update_command = "/usr/bin/helm3 repo update"
104 repo_add_command = "/usr/bin/helm3 repo add {} {}".format(repo_name, repo_url)
105 calls = self.helm_conn._local_async_exec.call_args_list
106 call0_kargs = calls[0][1]
107 self.assertEqual(
108 call0_kargs.get("command"),
109 repo_update_command,
110 "Invalid repo update command: {}".format(call0_kargs.get("command")),
111 )
112 self.assertEqual(
113 call0_kargs.get("env"),
114 self.env,
115 "Invalid env for update command: {}".format(call0_kargs.get("env")),
116 )
117 call1_kargs = calls[1][1]
118 self.assertEqual(
119 call1_kargs.get("command"),
120 repo_add_command,
121 "Invalid repo add command: {}".format(call1_kargs.get("command")),
122 )
123 self.assertEqual(
124 call1_kargs.get("env"),
125 self.env,
126 "Invalid env for add command: {}".format(call1_kargs.get("env")),
127 )
128
129 @asynctest.fail_on(active_handles=True)
130 async def test_repo_list(self):
131
132 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
133
134 await self.helm_conn.repo_list(self.cluster_uuid)
135
136 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
137 self.helm_conn.fs.reverse_sync.assert_called_once_with(
138 from_path=self.cluster_id
139 )
140 command = "/usr/bin/helm3 repo list --output yaml"
141 self.helm_conn._local_async_exec.assert_called_with(
142 command=command, env=self.env, raise_exception_on_error=False
143 )
144
145 @asynctest.fail_on(active_handles=True)
146 async def test_repo_remove(self):
147
148 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
149 repo_name = "bitnami"
150 await self.helm_conn.repo_remove(self.cluster_uuid, repo_name)
151
152 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
153 self.helm_conn.fs.reverse_sync.assert_called_once_with(
154 from_path=self.cluster_id
155 )
156 command = "/usr/bin/helm3 repo remove {}".format(repo_name)
157 self.helm_conn._local_async_exec.assert_called_with(
158 command=command, env=self.env, raise_exception_on_error=True
159 )
160
161 @asynctest.fail_on(active_handles=True)
162 async def test_install(self):
163 kdu_model = "stable/openldap:1.2.2"
164 kdu_instance = "stable-openldap-0005399828"
165 db_dict = {}
166 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
167 self.helm_conn._status_kdu = asynctest.CoroutineMock(return_value=None)
168 self.helm_conn._store_status = asynctest.CoroutineMock()
169 self.kdu_instance = "stable-openldap-0005399828"
170 self.helm_conn.generate_kdu_instance_name = Mock(return_value=self.kdu_instance)
171 self.helm_conn._get_namespaces = asynctest.CoroutineMock(return_value=[])
172 self.helm_conn._create_namespace = asynctest.CoroutineMock()
173
174 await self.helm_conn.install(
175 self.cluster_uuid,
176 kdu_model,
177 self.kdu_instance,
178 atomic=True,
179 namespace=self.namespace,
180 db_dict=db_dict,
181 )
182
183 self.helm_conn._get_namespaces.assert_called_once()
184 self.helm_conn._create_namespace.assert_called_once_with(
185 self.cluster_id, self.namespace
186 )
187 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
188 self.helm_conn.fs.reverse_sync.assert_called_once_with(
189 from_path=self.cluster_id
190 )
191 self.helm_conn._store_status.assert_called_with(
192 cluster_id=self.cluster_id,
193 kdu_instance=kdu_instance,
194 namespace=self.namespace,
195 db_dict=db_dict,
196 operation="install",
197 run_once=True,
198 check_every=0,
199 )
200 command = (
201 "/usr/bin/helm3 install stable-openldap-0005399828 --atomic --output yaml "
202 "--timeout 300s --namespace testk8s stable/openldap --version 1.2.2"
203 )
204 self.helm_conn._local_async_exec.assert_called_once_with(
205 command=command, env=self.env, raise_exception_on_error=False
206 )
207
208 @asynctest.fail_on(active_handles=True)
209 async def test_upgrade(self):
210 kdu_model = "stable/openldap:1.2.3"
211 kdu_instance = "stable-openldap-0005399828"
212 db_dict = {}
213 instance_info = {
214 "chart": "openldap-1.2.2",
215 "name": kdu_instance,
216 "namespace": self.namespace,
217 "revision": 1,
218 "status": "DEPLOYED",
219 }
220 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
221 self.helm_conn._store_status = asynctest.CoroutineMock()
222 self.helm_conn.get_instance_info = asynctest.CoroutineMock(
223 return_value=instance_info
224 )
225
226 await self.helm_conn.upgrade(
227 self.cluster_uuid, kdu_instance, kdu_model, atomic=True, db_dict=db_dict
228 )
229 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
230 self.helm_conn.fs.reverse_sync.assert_called_once_with(
231 from_path=self.cluster_id
232 )
233 self.helm_conn._store_status.assert_called_with(
234 cluster_id=self.cluster_id,
235 kdu_instance=kdu_instance,
236 namespace=self.namespace,
237 db_dict=db_dict,
238 operation="upgrade",
239 run_once=True,
240 check_every=0,
241 )
242 command = (
243 "/usr/bin/helm3 upgrade stable-openldap-0005399828 stable/openldap "
244 "--namespace testk8s --atomic --output yaml --timeout 300s "
245 "--version 1.2.3"
246 )
247 self.helm_conn._local_async_exec.assert_called_once_with(
248 command=command, env=self.env, raise_exception_on_error=False
249 )
250
251 @asynctest.fail_on(active_handles=True)
252 async def test_rollback(self):
253 kdu_instance = "stable-openldap-0005399828"
254 db_dict = {}
255 instance_info = {
256 "chart": "openldap-1.2.3",
257 "name": kdu_instance,
258 "namespace": self.namespace,
259 "revision": 2,
260 "status": "DEPLOYED",
261 }
262 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
263 self.helm_conn._store_status = asynctest.CoroutineMock()
264 self.helm_conn.get_instance_info = asynctest.CoroutineMock(
265 return_value=instance_info
266 )
267
268 await self.helm_conn.rollback(
269 self.cluster_uuid, kdu_instance=kdu_instance, revision=1, db_dict=db_dict
270 )
271 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
272 self.helm_conn.fs.reverse_sync.assert_called_once_with(
273 from_path=self.cluster_id
274 )
275 self.helm_conn._store_status.assert_called_with(
276 cluster_id=self.cluster_id,
277 kdu_instance=kdu_instance,
278 namespace=self.namespace,
279 db_dict=db_dict,
280 operation="rollback",
281 run_once=True,
282 check_every=0,
283 )
284 command = "/usr/bin/helm3 rollback stable-openldap-0005399828 1 --namespace=testk8s --wait"
285 self.helm_conn._local_async_exec.assert_called_once_with(
286 command=command, env=self.env, raise_exception_on_error=False
287 )
288
289 @asynctest.fail_on(active_handles=True)
290 async def test_uninstall(self):
291 kdu_instance = "stable-openldap-0005399828"
292 instance_info = {
293 "chart": "openldap-1.2.2",
294 "name": kdu_instance,
295 "namespace": self.namespace,
296 "revision": 3,
297 "status": "DEPLOYED",
298 }
299 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
300 self.helm_conn._store_status = asynctest.CoroutineMock()
301 self.helm_conn.get_instance_info = asynctest.CoroutineMock(
302 return_value=instance_info
303 )
304
305 await self.helm_conn.uninstall(self.cluster_uuid, kdu_instance)
306 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
307 self.helm_conn.fs.reverse_sync.assert_called_once_with(
308 from_path=self.cluster_id
309 )
310 command = "/usr/bin/helm3 uninstall {} --namespace={}".format(
311 kdu_instance, self.namespace
312 )
313 self.helm_conn._local_async_exec.assert_called_once_with(
314 command=command, env=self.env, raise_exception_on_error=True
315 )
316
317 @asynctest.fail_on(active_handles=True)
318 async def test_get_services(self):
319 kdu_instance = "test_services_1"
320 service = {"name": "testservice", "type": "LoadBalancer"}
321 self.helm_conn._local_async_exec_pipe = asynctest.CoroutineMock(
322 return_value=("", 0)
323 )
324 self.helm_conn._parse_services = Mock(return_value=["testservice"])
325 self.helm_conn._get_service = asynctest.CoroutineMock(return_value=service)
326
327 services = await self.helm_conn.get_services(
328 self.cluster_uuid, kdu_instance, self.namespace
329 )
330 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
331 self.helm_conn.fs.reverse_sync.assert_called_once_with(
332 from_path=self.cluster_id
333 )
334 self.helm_conn._parse_services.assert_called_once()
335 command1 = "/usr/bin/helm3 get manifest {} --namespace=testk8s".format(
336 kdu_instance
337 )
338 command2 = "/usr/bin/kubectl get --namespace={} -f -".format(self.namespace)
339 self.helm_conn._local_async_exec_pipe.assert_called_once_with(
340 command1, command2, env=self.env, raise_exception_on_error=True
341 )
342 self.assertEqual(
343 services, [service], "Invalid service returned from get_service"
344 )
345
346 @asynctest.fail_on(active_handles=True)
347 async def test_get_service(self):
348 service_name = "service1"
349
350 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
351 await self.helm_conn.get_service(
352 self.cluster_uuid, service_name, self.namespace
353 )
354
355 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
356 self.helm_conn.fs.reverse_sync.assert_called_once_with(
357 from_path=self.cluster_id
358 )
359 command = (
360 "/usr/bin/kubectl --kubeconfig=./tmp/helm3_cluster_id/.kube/config "
361 "--namespace=testk8s get service service1 -o=yaml"
362 )
363 self.helm_conn._local_async_exec.assert_called_once_with(
364 command=command, env=self.env, raise_exception_on_error=True
365 )
366
367 @asynctest.fail_on(active_handles=True)
368 async def test_inspect_kdu(self):
369 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
370
371 kdu_model = "stable/openldap:1.2.4"
372 repo_url = "https://kubernetes-charts.storage.googleapis.com/"
373 await self.helm_conn.inspect_kdu(kdu_model, repo_url)
374
375 command = (
376 "/usr/bin/helm3 show all openldap --repo "
377 "https://kubernetes-charts.storage.googleapis.com/ "
378 "--version 1.2.4"
379 )
380 self.helm_conn._local_async_exec.assert_called_with(
381 command=command, encode_utf8=True
382 )
383
384 @asynctest.fail_on(active_handles=True)
385 async def test_help_kdu(self):
386 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
387
388 kdu_model = "stable/openldap:1.2.4"
389 repo_url = "https://kubernetes-charts.storage.googleapis.com/"
390 await self.helm_conn.help_kdu(kdu_model, repo_url)
391
392 command = (
393 "/usr/bin/helm3 show readme openldap --repo "
394 "https://kubernetes-charts.storage.googleapis.com/ "
395 "--version 1.2.4"
396 )
397 self.helm_conn._local_async_exec.assert_called_with(
398 command=command, encode_utf8=True
399 )
400
401 @asynctest.fail_on(active_handles=True)
402 async def test_values_kdu(self):
403 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
404
405 kdu_model = "stable/openldap:1.2.4"
406 repo_url = "https://kubernetes-charts.storage.googleapis.com/"
407 await self.helm_conn.values_kdu(kdu_model, repo_url)
408
409 command = (
410 "/usr/bin/helm3 show values openldap --repo "
411 "https://kubernetes-charts.storage.googleapis.com/ "
412 "--version 1.2.4"
413 )
414 self.helm_conn._local_async_exec.assert_called_with(
415 command=command, encode_utf8=True
416 )
417
418 @asynctest.fail_on(active_handles=True)
419 async def test_instances_list(self):
420 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
421
422 await self.helm_conn.instances_list(self.cluster_uuid)
423 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
424 self.helm_conn.fs.reverse_sync.assert_called_once_with(
425 from_path=self.cluster_id
426 )
427 command = "/usr/bin/helm3 list --all-namespaces --output yaml"
428 self.helm_conn._local_async_exec.assert_called_once_with(
429 command=command, env=self.env, raise_exception_on_error=True
430 )
431
432 @asynctest.fail_on(active_handles=True)
433 async def test_status_kdu(self):
434 kdu_instance = "stable-openldap-0005399828"
435 self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
436
437 await self.helm_conn._status_kdu(
438 self.cluster_id, kdu_instance, self.namespace, return_text=True
439 )
440 command = "/usr/bin/helm3 status {} --namespace={} --output yaml".format(
441 kdu_instance, self.namespace
442 )
443 self.helm_conn._local_async_exec.assert_called_once_with(
444 command=command,
445 env=self.env,
446 raise_exception_on_error=True,
447 show_error_log=False,
448 )
449
450 @asynctest.fail_on(active_handles=True)
451 async def test_store_status(self):
452 kdu_instance = "stable-openldap-0005399828"
453 db_dict = {}
454 status = {
455 "info": {
456 "description": "Install complete",
457 "status": {
458 "code": "1",
459 "notes": "The openldap helm chart has been installed",
460 },
461 }
462 }
463 self.helm_conn._status_kdu = asynctest.CoroutineMock(return_value=status)
464 self.helm_conn.write_app_status_to_db = asynctest.CoroutineMock(
465 return_value=status
466 )
467
468 await self.helm_conn._store_status(
469 cluster_id=self.cluster_id,
470 kdu_instance=kdu_instance,
471 namespace=self.namespace,
472 db_dict=db_dict,
473 operation="install",
474 run_once=True,
475 check_every=0,
476 )
477 self.helm_conn._status_kdu.assert_called_once_with(
478 cluster_id=self.cluster_id,
479 kdu_instance=kdu_instance,
480 namespace=self.namespace,
481 return_text=False,
482 )
483 self.helm_conn.write_app_status_to_db.assert_called_once_with(
484 db_dict=db_dict,
485 status="Install complete",
486 detailed_status=str(status),
487 operation="install",
488 )
489
490 @asynctest.fail_on(active_handles=True)
491 async def test_reset_uninstall_false(self):
492 self.helm_conn._uninstall_sw = asynctest.CoroutineMock()
493
494 await self.helm_conn.reset(self.cluster_uuid, force=False, uninstall_sw=False)
495 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
496 self.helm_conn.fs.file_delete.assert_called_once_with(
497 self.cluster_id, ignore_non_exist=True
498 )
499 self.helm_conn._uninstall_sw.assert_not_called()
500
501 @asynctest.fail_on(active_handles=True)
502 async def test_reset_uninstall(self):
503 kdu_instance = "stable-openldap-0021099429"
504 instances = [
505 {
506 "app_version": "2.4.48",
507 "chart": "openldap-1.2.3",
508 "name": kdu_instance,
509 "namespace": self.namespace,
510 "revision": "1",
511 "status": "deployed",
512 "updated": "2020-10-30 11:11:20.376744191 +0000 UTC",
513 }
514 ]
515 self.helm_conn._uninstall_sw = asynctest.CoroutineMock()
516 self.helm_conn.instances_list = asynctest.CoroutineMock(return_value=instances)
517 self.helm_conn.uninstall = asynctest.CoroutineMock()
518
519 await self.helm_conn.reset(self.cluster_uuid, force=True, uninstall_sw=True)
520 self.helm_conn.fs.sync.assert_called_once_with(from_path=self.cluster_id)
521 self.helm_conn.fs.file_delete.assert_called_once_with(
522 self.cluster_id, ignore_non_exist=True
523 )
524 self.helm_conn.instances_list.assert_called_once_with(
525 cluster_uuid=self.cluster_uuid
526 )
527 self.helm_conn.uninstall.assert_called_once_with(
528 cluster_uuid=self.cluster_uuid, kdu_instance=kdu_instance
529 )
530 self.helm_conn._uninstall_sw.assert_called_once_with(
531 self.cluster_id, self.namespace
532 )
533
534 @asynctest.fail_on(active_handles=True)
535 async def test_sync_repos_add(self):
536 repo_list = [
537 {
538 "name": "stable",
539 "url": "https://kubernetes-charts.storage.googleapis.com/",
540 }
541 ]
542 self.helm_conn.repo_list = asynctest.CoroutineMock(return_value=repo_list)
543
544 def get_one_result(*args, **kwargs):
545 if args[0] == "k8sclusters":
546 return {
547 "_admin": {
548 "helm_chart_repos": ["4b5550a9-990d-4d95-8a48-1f4614d6ac9c"]
549 }
550 }
551 elif args[0] == "k8srepos":
552 return {
553 "_id": "4b5550a9-990d-4d95-8a48-1f4614d6ac9c",
554 "type": "helm-chart",
555 "name": "bitnami",
556 "url": "https://charts.bitnami.com/bitnami",
557 }
558
559 self.helm_conn.db.get_one = asynctest.Mock()
560 self.helm_conn.db.get_one.side_effect = get_one_result
561
562 self.helm_conn.repo_add = asynctest.CoroutineMock()
563 self.helm_conn.repo_remove = asynctest.CoroutineMock()
564
565 deleted_repo_list, added_repo_dict = await self.helm_conn.synchronize_repos(
566 self.cluster_uuid
567 )
568 self.helm_conn.repo_remove.assert_not_called()
569 self.helm_conn.repo_add.assert_called_once_with(
570 self.cluster_uuid, "bitnami", "https://charts.bitnami.com/bitnami"
571 )
572 self.assertEqual(deleted_repo_list, [], "Deleted repo list should be empty")
573 self.assertEqual(
574 added_repo_dict,
575 {"4b5550a9-990d-4d95-8a48-1f4614d6ac9c": "bitnami"},
576 "Repos added should include only one bitnami",
577 )
578
579 @asynctest.fail_on(active_handles=True)
580 async def test_sync_repos_delete(self):
581 repo_list = [
582 {
583 "name": "stable",
584 "url": "https://kubernetes-charts.storage.googleapis.com/",
585 },
586 {"name": "bitnami", "url": "https://charts.bitnami.com/bitnami"},
587 ]
588 self.helm_conn.repo_list = asynctest.CoroutineMock(return_value=repo_list)
589
590 def get_one_result(*args, **kwargs):
591 if args[0] == "k8sclusters":
592 return {"_admin": {"helm_chart_repos": []}}
593
594 self.helm_conn.db.get_one = asynctest.Mock()
595 self.helm_conn.db.get_one.side_effect = get_one_result
596
597 self.helm_conn.repo_add = asynctest.CoroutineMock()
598 self.helm_conn.repo_remove = asynctest.CoroutineMock()
599
600 deleted_repo_list, added_repo_dict = await self.helm_conn.synchronize_repos(
601 self.cluster_uuid
602 )
603 self.helm_conn.repo_add.assert_not_called()
604 self.helm_conn.repo_remove.assert_called_once_with(self.cluster_uuid, "bitnami")
605 self.assertEqual(
606 deleted_repo_list, ["bitnami"], "Deleted repo list should be bitnami"
607 )
608 self.assertEqual(added_repo_dict, {}, "No repos should be added")