From da2ade3ce8209cf072f0c728a2e41ac0037ea4ae Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Thu, 14 Nov 2024 14:14:54 +0800 Subject: [PATCH] refactor(robot): abstract state validation from volume detachement longhorn/longhorn-9781 Signed-off-by: Chin-Ya Huang --- e2e/libs/volume/crd.py | 2 -- e2e/tests/negative/network_disconnect.robot | 1 + e2e/tests/negative/stress_cpu.robot | 1 + e2e/tests/negative/stress_filesystem.robot | 1 + e2e/tests/negative/stress_memory.robot | 1 + e2e/tests/regression/test_backing_image.robot | 1 + e2e/tests/regression/test_backup.robot | 1 + e2e/tests/regression/test_basic.robot | 3 +++ e2e/tests/regression/test_settings.robot | 1 + e2e/tests/regression/test_v2.robot | 1 + 10 files changed, 11 insertions(+), 2 deletions(-) diff --git a/e2e/libs/volume/crd.py b/e2e/libs/volume/crd.py index 9598a99b8d..349e9a8a82 100644 --- a/e2e/libs/volume/crd.py +++ b/e2e/libs/volume/crd.py @@ -162,8 +162,6 @@ def detach(self, volume_name, node_name): # https://github.com/longhorn/longhorn/issues/3715 if e.reason != "Not Found": Exception(f'exception for patching volumeattachments:', e) - if len(body['spec']['attachmentTickets']) == 0: - self.wait_for_volume_state(volume_name, "detached") def get(self, volume_name): return self.obj_api.get_namespaced_custom_object( diff --git a/e2e/tests/negative/network_disconnect.robot b/e2e/tests/negative/network_disconnect.robot index 7cab8c6226..3e0b786c54 100644 --- a/e2e/tests/negative/network_disconnect.robot +++ b/e2e/tests/negative/network_disconnect.robot @@ -164,4 +164,5 @@ Node Disconnect With Statefulset And Wait for volume 0 healthy And Detach volume 0 from attached node + And Wait for volume 0 detached Then Wait for volume 0 detached diff --git a/e2e/tests/negative/stress_cpu.robot b/e2e/tests/negative/stress_cpu.robot index 1edcb15e60..b9d0a65836 100644 --- a/e2e/tests/negative/stress_cpu.robot +++ b/e2e/tests/negative/stress_cpu.robot @@ -41,6 +41,7 @@ Stress Volume Node CPU When Volume Is Detaching and Attaching FOR ${i} IN RANGE ${LOOP_COUNT} When Stress CPU of node with volume 0 And Detach volume 0 + And Wait for volume 0 detached And Attach volume 0 And Wait for volume 0 healthy Then Check volume 0 data is intact diff --git a/e2e/tests/negative/stress_filesystem.robot b/e2e/tests/negative/stress_filesystem.robot index e67b7b8a32..85ec54de9f 100644 --- a/e2e/tests/negative/stress_filesystem.robot +++ b/e2e/tests/negative/stress_filesystem.robot @@ -42,6 +42,7 @@ Stress Volume Node Filesystem When Volume Is Detaching and Attaching FOR ${i} IN RANGE ${LOOP_COUNT} And Detach volume 0 + And Wait for volume 0 detached And Attach volume 0 And Wait for volume 0 healthy And Check volume 0 data is intact diff --git a/e2e/tests/negative/stress_memory.robot b/e2e/tests/negative/stress_memory.robot index 91b9197777..6f3a5c6b90 100644 --- a/e2e/tests/negative/stress_memory.robot +++ b/e2e/tests/negative/stress_memory.robot @@ -43,6 +43,7 @@ Stress Volume Node Memory When Volume Is Detaching and Attaching When Stress memory of node with volume 0 And Detach volume 0 + And Wait for volume 0 detached And Attach volume 0 And Wait for volume 0 healthy Then Check volume 0 data is intact diff --git a/e2e/tests/regression/test_backing_image.robot b/e2e/tests/regression/test_backing_image.robot index b3ab113495..7eb1564a86 100644 --- a/e2e/tests/regression/test_backing_image.robot +++ b/e2e/tests/regression/test_backing_image.robot @@ -30,6 +30,7 @@ Test Backing Image Basic Operation And Verify clean up backing image bi from a disk will fail And Verify delete backing image bi will fail And Detach volume 0 + And Wait for volume 0 detached And Delete volume 0 And Clean up backing image bi from a disk And Delete backing image bi diff --git a/e2e/tests/regression/test_backup.robot b/e2e/tests/regression/test_backup.robot index 14cbc35cea..7a793d0131 100644 --- a/e2e/tests/regression/test_backup.robot +++ b/e2e/tests/regression/test_backup.robot @@ -102,6 +102,7 @@ Test Incremental Restore And Wait for volume 3 healthy And Check volume 3 data is backup 2 And Detach volume 3 + And Wait for volume 3 detached When Create persistentvolume for volume 3 And Create persistentvolumeclaim for volume 3 diff --git a/e2e/tests/regression/test_basic.robot b/e2e/tests/regression/test_basic.robot index 9274923182..b0791e30c9 100644 --- a/e2e/tests/regression/test_basic.robot +++ b/e2e/tests/regression/test_basic.robot @@ -53,6 +53,7 @@ Test Volume Basic Then Check volume 0 data is intact And Detach volume 0 + And Wait for volume 0 detached And Delete volume 0 Test Snapshot @@ -80,11 +81,13 @@ Test Snapshot And Check volume 0 data is data 2 When Detach volume 0 + And Wait for volume 0 detached And Attach volume 0 in maintenance mode And Wait for volume 0 healthy And Revert volume 0 to snapshot 1 And Detach volume 0 + And Wait for volume 0 detached And Attach volume 0 And Wait for volume 0 healthy Then Check volume 0 data is data 1 diff --git a/e2e/tests/regression/test_settings.robot b/e2e/tests/regression/test_settings.robot index 1bcffdc303..bb28480533 100644 --- a/e2e/tests/regression/test_settings.robot +++ b/e2e/tests/regression/test_settings.robot @@ -64,6 +64,7 @@ Test Setting Concurrent Rebuild Limit # Test the setting won't intervene normal attachment. Given Set setting concurrent-replica-rebuild-per-node-limit to 1 When Detach volume 1 + And Wait for volume 1 detached And Delete volume 0 replica on replica node And Wait until volume 0 replica rebuilding started on replica node And Attach volume 1 diff --git a/e2e/tests/regression/test_v2.robot b/e2e/tests/regression/test_v2.robot index 137d7eb7c3..fddba633a7 100644 --- a/e2e/tests/regression/test_v2.robot +++ b/e2e/tests/regression/test_v2.robot @@ -32,6 +32,7 @@ Test V2 Volume Basic And Write data to volume 0 Then Check volume 0 data is intact And Detach volume 0 + And Wait for volume 0 detached And Delete volume 0 Degraded Volume Replica Rebuilding