diff --git a/controlpanel/api/helm.py b/controlpanel/api/helm.py index a61a06f18..74de216e0 100644 --- a/controlpanel/api/helm.py +++ b/controlpanel/api/helm.py @@ -73,7 +73,7 @@ def upgrade_release(self, release, chart, *args): HelmRepository.update() return self.__class__.execute( - "upgrade", "--install", "--wait", release, chart, *args, + "upgrade", "--install", "--wait", "--force", release, chart, *args, ) def delete(self, purge=True, *args): diff --git a/tests/api/test_helm.py b/tests/api/test_helm.py index 133078575..516e756cc 100644 --- a/tests/api/test_helm.py +++ b/tests/api/test_helm.py @@ -1,9 +1,10 @@ from datetime import datetime, timedelta import pytest -from unittest.mock import patch +from unittest.mock import MagicMock, patch from controlpanel.api.helm import ( Chart, + helm, HelmRepository, ) @@ -16,10 +17,7 @@ def setup_function(fn): def test_chart_app_version(): app_version = "RStudio: 1.2.1335+conda, R: 3.5.1, Python: 3.7.1, patch: 10" chart = Chart( - "rstudio", - "RStudio with Auth0 authentication proxy", - "2.2.5", - app_version, + "rstudio", "RStudio with Auth0 authentication proxy", "2.2.5", app_version, ) assert chart.app_version == app_version @@ -53,7 +51,9 @@ def test_helm_repository_chart_info_when_chart_found(helm_repository_index): # See tests/api/fixtures/helm_mojanalytics_index.py rstudio_info = HelmRepository.get_chart_info("rstudio") - rstudio_2_2_5_app_version = "RStudio: 1.2.1335+conda, R: 3.5.1, Python: 3.7.1, patch: 10" + rstudio_2_2_5_app_version = ( + "RStudio: 1.2.1335+conda, R: 3.5.1, Python: 3.7.1, patch: 10" + ) assert len(rstudio_info) == 2 assert "2.2.5" in rstudio_info @@ -64,3 +64,19 @@ def test_helm_repository_chart_info_when_chart_found(helm_repository_index): # "recently" so for testing that for old chart # version this returns `None` assert rstudio_info["1.0.0"].app_version == None + + +def test_helm_upgrade_release(): + helm.__class__.execute = MagicMock() + + upgrade_args = ( + "release-name", + "helm-chart-name", + "--namespace=user-alice", + "--set=username=alice", + ) + helm.upgrade_release(*upgrade_args) + + helm.__class__.execute.assert_called_with( + "upgrade", "--install", "--wait", "--force", *upgrade_args, + )