diff --git a/integration/backupstore.html b/integration/backupstore.html index a304d0eeeb..413ff15345 100644 --- a/integration/backupstore.html +++ b/integration/backupstore.html @@ -51,6 +51,7 @@
tests.backupstore
tests.backupstore
tests.backupstore
tests.backupstore
tests.backupstore
+def backup_cleanup()
+
def backup_cleanup():
+ # Use k8s api to delete all backup especially backup in error state
+ # Because backup in error state does not have backup volume
+ api = get_custom_object_api_client()
+ backups = api.list_namespaced_custom_object("longhorn.io",
+ "v1beta2",
+ "longhorn-system",
+ "backups")
+ for backup in backups['items']:
+ api.delete_namespaced_custom_object("longhorn.io",
+ "v1beta2",
+ "longhorn-system",
+ "backups",
+ backup['metadata']['name'])
+
def backup_volume_path(volume_name)
+def backupstore_invalid(client)
+
@pytest.fixture
+def backupstore_invalid(client):
+ set_backupstore_invalid(client)
+ yield
+ reset_backupstore_setting(client)
+ backup_cleanup()
+
def backupstore_nfs(client)
+def set_backupstore_invalid(client)
+
def set_backupstore_invalid(client):
+ poll_interval = get_backupstore_poll_interval()
+ set_backupstore_url(client, "nfs://notexist:/opt/backupstore")
+ set_backupstore_credential_secret(client, "")
+ set_backupstore_poll_interval(client, poll_interval)
+
def set_backupstore_nfs(client)
backup_cleanup
backup_volume_path
backupstore_cleanup
backupstore_corrupt_backup_cfg_file
backupstore_get_backup_volume_prefix
backupstore_get_secret
backupstore_get_volume_cfg_file_path
backupstore_invalid
backupstore_nfs
backupstore_s3
backupstore_wait_for_lock_expiration
nfs_write_backup_cfg_file
reset_backupstore_setting
set_backupstore_credential_secret
set_backupstore_invalid
set_backupstore_nfs
set_backupstore_poll_interval
set_backupstore_s3
tests.test_basic
tests.test_basic
tests.test_basic
tests.test_basic
-def test_backuptarget_invalid()
+def test_backuptarget_invalid(apps_api, client, core_api, backupstore_invalid, make_deployment_with_pvc, pvc_name, request, volume_name)
Related issue : @@ -8603,8 +8641,14 @@
@pytest.mark.skip(reason="TODO")
-def test_backuptarget_invalid(): # NOQA
+def test_backuptarget_invalid(apps_api, # NOQA
+ client, # NOQA
+ core_api, # NOQA
+ backupstore_invalid, # NOQA
+ make_deployment_with_pvc, # NOQA
+ pvc_name, # NOQA
+ request, # NOQA
+ volume_name): # NOQA
"""
Related issue :
https://github.com/longhorn/longhorn/issues/1249
@@ -8624,7 +8668,36 @@ Functions
Then
- Backup will be failed and the backup state is Error.
"""
- pass
+ volume = create_and_check_volume(client, volume_name)
+ pvc_name = volume_name + "-pvc"
+ create_pv_for_volume(client, core_api, volume, volume_name)
+ create_pvc_for_volume(client, core_api, volume, pvc_name)
+
+ deployment_name = volume_name + "-dep"
+ deployment = make_deployment_with_pvc(deployment_name, pvc_name)
+ create_and_wait_deployment(apps_api, deployment)
+
+ pod_names = common.get_deployment_pod_names(core_api, deployment)
+ write_pod_volume_random_data(core_api, pod_names[0], "/data/test",
+ DATA_SIZE_IN_MB_1)
+
+ volume = client.by_id_volume(volume_name)
+ snap = create_snapshot(client, volume_name)
+ volume.snapshotBackup(name=snap.name)
+
+ for i in range(RETRY_COMMAND_COUNT):
+ api = get_custom_object_api_client()
+ backups = api.list_namespaced_custom_object("longhorn.io",
+ "v1beta2",
+ "longhorn-system",
+ "backups")
+
+ if backups["items"][0]["status"]["state"] != "":
+ break
+ time.sleep(RETRY_INTERVAL)
+
+ assert backups["items"][0]["spec"]["snapshotName"] == snap.name
+ assert backups["items"][0]["status"]["state"] == "Error"