Skip to content

Commit

Permalink
Verify message of invalid backup target
Browse files Browse the repository at this point in the history
Longhorn 8210

Signed-off-by: Eric Weber <eric.weber@suse.com>
  • Loading branch information
ejweber authored and khushboo-rancher committed Apr 1, 2024
1 parent 3d3184c commit 7ba43f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@

HOST_PROC_DIR = "/host/proc"

BACKUP_TARGET_MESSAGE_EMPTY_URL = "backup target URL is empty"
BACKUP_TARGET_MESSAGES_INVALID = ["failed to init backup target clients",
"failed to list backup volumes in"]

# customize the timeout for HDD
disktype = os.environ.get('LONGHORN_DISK_TYPE')
if disktype == "hdd":
Expand Down
15 changes: 15 additions & 0 deletions manager/integration/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
from common import get_custom_object_api_client
from common import RETRY_COUNTS_SHORT
from common import scale_up_engine_image_daemonset
from common import BACKUP_TARGET_MESSAGE_EMPTY_URL
from common import BACKUP_TARGET_MESSAGES_INVALID

from backupstore import backupstore_delete_volume_cfg_file
from backupstore import backupstore_cleanup
Expand Down Expand Up @@ -5666,6 +5668,7 @@ def test_backuptarget_invalid(apps_api, # NOQA
Then
- Backup will be failed and the backup state is Error.
- Backup target will be unavailable with an explanatory condition.
"""
volume = create_and_check_volume(client, volume_name)
pvc_name = volume_name + "-pvc"
Expand Down Expand Up @@ -5698,6 +5701,18 @@ def test_backuptarget_invalid(apps_api, # NOQA
assert backups["items"][0]["spec"]["snapshotName"] == snap.name
assert backups["items"][0]["status"]["state"] == "Error"

# In https://github.com/longhorn/longhorn/issues/8210, the backup target
# could not properly reconcile when the URL or secret were "broken", and
# the condition/message was not updated. Verify the condition/message is
# correct under these conditions.
backup_targets = client.list_backup_target()
assert not backup_targets[0]["available"]
# If the condition/message was not updated, it is likely still this one.
assert backup_targets[0]["message"] != BACKUP_TARGET_MESSAGE_EMPTY_URL
# Depending on the exact nature of the failure, we expect one of these
# strings to be in the condition/message.
assert any(message in backup_targets[0]["message"] for message in
BACKUP_TARGET_MESSAGES_INVALID)

@pytest.mark.volume_backup_restore # NOQA
def test_volume_backup_and_restore_with_lz4_compression_method(client, set_random_backupstore, volume_name): # NOQA
Expand Down

0 comments on commit 7ba43f7

Please sign in to comment.