Skip to content

Commit

Permalink
test: update a read-only setting
Browse files Browse the repository at this point in the history
Ref: 5989

Signed-off-by: James Lu <[email protected]>
  • Loading branch information
mantissahz committed Oct 27, 2023
1 parent 3d5f5ef commit 3ac1f0a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
7 changes: 4 additions & 3 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
SETTING_BACKUP_TARGET_CREDENTIAL_SECRET = "backup-target-credential-secret"
SETTING_BACKUPSTORE_POLL_INTERVAL = "backupstore-poll-interval"
SETTING_CREATE_DEFAULT_DISK_LABELED_NODES = "create-default-disk-labeled-nodes"
SETTING_CURRENT_LONGHORN_VERSION = "current-longhorn-version"
SETTING_DEFAULT_DATA_LOCALITY = "default-data-locality"
SETTING_DEFAULT_DATA_PATH = "default-data-path"
SETTING_DEFAULT_LONGHORN_STATIC_SC = "default-longhorn-static-storage-class"
Expand Down Expand Up @@ -5530,11 +5531,11 @@ def cleanup_all_support_bundles(client):
Clean up all support bundles
:param client: The Longhorn client to use in the request.
"""
longhorn_version = client.by_id_setting('current-longhorn-version').value
lh_version = client.by_id_setting(SETTING_CURRENT_LONGHORN_VERSION).value
version_doesnt_have_support_bundle_manager = ['v1.1', 'v1.2', 'v1.3']
if any(_version in longhorn_version for
if any(_version in lh_version for
_version in version_doesnt_have_support_bundle_manager):
print(f'{longhorn_version} doesn\'t have support bundle manager')
print(f'{lh_version} doesn\'t have support bundle manager')
return

support_bundles = client.list_support_bundle()
Expand Down
26 changes: 26 additions & 0 deletions manager/integration/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SETTING_DEFAULT_REPLICA_COUNT,
SETTING_BACKUP_TARGET,
SETTING_CONCURRENT_VOLUME_BACKUP_RESTORE,
SETTING_CURRENT_LONGHORN_VERSION,
RETRY_COUNTS, RETRY_INTERVAL, RETRY_INTERVAL_LONG,
update_setting, BACKING_IMAGE_QCOW2_URL, BACKING_IMAGE_NAME,
create_backing_image_with_matching_url, BACKING_IMAGE_EXT4_SIZE,
Expand Down Expand Up @@ -1241,3 +1242,28 @@ def test_setting_update_with_invalid_value_via_configmap(core_api, request): #
""])

cleanup_volume_by_name(client, vol_name)

def test_setting_update_readonly(): # NOQA
"""
Test update read-only setting
1. Update read-only setting `current-longhorn-version`
2. An exception is returned with substring `read-only`
3. Update non-read-only setting `backup-target` and
it should be updated successfully
"""
client = get_longhorn_api_client() # NOQA

setting = client.by_id_setting(SETTING_CURRENT_LONGHORN_VERSION)
assert setting.value != ""

with pytest.raises(Exception) as e:
client.update(setting, value="v1.10.0-failed")
assert 'read-only' in str(e.value)

bt_setting_value_str = "nfs://invalid/faked"
bt_setting = client.by_id_setting(SETTING_BACKUP_TARGET)
bt_setting = client.update(bt_setting, value=bt_setting_value_str)
assert bt_setting.value == bt_setting_value_str
bt_setting = client.update(bt_setting, value="")
assert bt_setting.value == ""

0 comments on commit 3ac1f0a

Please sign in to comment.