Skip to content

Commit

Permalink
Merge pull request #819 from ministryofjustice/ag--helm-upgrade-force
Browse files Browse the repository at this point in the history
Helm upgrade uses --force flag now
  • Loading branch information
xoen authored Jun 18, 2020
2 parents 37a8428 + e68e352 commit c190927
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controlpanel/api/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
28 changes: 22 additions & 6 deletions tests/api/test_helm.py
Original file line number Diff line number Diff line change
@@ -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,
)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
)

0 comments on commit c190927

Please sign in to comment.