Skip to content

Commit

Permalink
refactor(negative): adapt keywords to test
Browse files Browse the repository at this point in the history
longhorn/longhorn-7034

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang committed Mar 5, 2024
1 parent ba0f560 commit dd2d6b0
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 315 deletions.
30 changes: 10 additions & 20 deletions e2e/keywords/common.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,29 @@
Documentation Common keywords
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/stress_keywords.py
Library ../libs/keywords/volume_keywords.py
Library ../libs/keywords/recurringjob_keywords.py
Library ../libs/keywords/deployment_keywords.py
Library ../libs/keywords/network_keywords.py
Library ../libs/keywords/recurringjob_keywords.py
Library ../libs/keywords/statefulset_keywords.py
Library ../libs/keywords/stress_keywords.py
Library ../libs/keywords/volume_keywords.py
Library ../libs/keywords/workload_keywords.py
Library ../libs/keywords/network_keywords.py


*** Variables ***


*** Keywords ***
Set test environment
init_k8s_api_client
init_node_exec ${SUITE NAME.rsplit('.')[1]}
init_storageclasses
@{volume_list} = Create List
Set Test Variable ${volume_list}
@{deployment_list} = Create List
Set Test Variable ${deployment_list}
@{statefulset_list} = Create List
Set Test Variable ${statefulset_list}
@{persistentvolumeclaim_list} = Create List
Set Test Variable ${persistentvolumeclaim_list}

setup_control_plane_network_latency

Cleanup test resources
cleanup_control_plane_network_latency
cleanup_node_exec
cleanup_stress_helper
cleanup_recurringjobs ${volume_list}
cleanup_volumes ${volume_list}
cleanup_deployments ${deployment_list}
cleanup_statefulsets ${statefulset_list}
cleanup_recurringjobs
cleanup_deployments
cleanup_statefulsets
cleanup_persistentvolumeclaims
cleanup_volumes
cleanup_storageclasses
26 changes: 12 additions & 14 deletions e2e/keywords/deployment.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@
Documentation Deployment Keywords
Library Collections
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/deployment_keywords.py

*** Keywords ***
Create deployment ${idx} with ${volume_type} volume
${deployment_name} = create_deployment ${volume_type}
Insert Into List ${deployment_list} ${idx} ${deployment_name}
Create deployment ${deployment_id} with persistentvolumeclaim ${claim_id}
${deployment_name} = generate_name_with_suffix deployment ${deployment_id}
${claim_name} = generate_name_with_suffix claim ${claim_id}
create_deployment ${deployment_name} ${claim_name}

Create deployment ${idx} with ${volume_type} and ${option} volume
${deployment_name} = create_deployment ${volume_type} ${option}
Insert Into List ${deployment_list} ${idx} ${deployment_name}
Check deployment ${deployment_id} works
${deployment_name} = generate_name_with_suffix deployment ${deployment_id}
write_workload_pod_random_data ${deployment_name} 1024 random-data
check_workload_pod_data_checksum ${deployment_name} random-data

Keep writing data to deployment ${idx}
${pod_name} = get_workload_pod_name ${deployment_list}[${idx}]
keep_writing_pod_data ${pod_name}

Check deployment ${idx} works
${pod_name} = get_workload_pod_name ${deployment_list}[${idx}]
${pod_data_checksum} = write_pod_random_data ${pod_name} 1024
check_pod_data_checksum ${pod_name} ${pod_data_checksum}
Wait for deployment ${deployment_id} pods stable
${deployment_name} = generate_name_with_suffix deployment ${deployment_id}
wait_for_workload_pods_stable ${deployment_name}
1 change: 0 additions & 1 deletion e2e/keywords/engine.resource
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Documentation Longhorn engine related keywords
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/engine_keywords.py


*** Keywords ***
Engine state should eventually be ${expected_engine_state}
Run keyword And Continue On Failure
Expand Down
15 changes: 0 additions & 15 deletions e2e/keywords/kubelet.resource

This file was deleted.

21 changes: 21 additions & 0 deletions e2e/keywords/longhorn.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*** Settings ***
Documentation Longhorn Keywords
Library ../libs/keywords/instancemanager_keywords.py
Library ../libs/keywords/workload_keywords.py

*** Variables ***
@{longhorn_workloads}
... csi-attacher
... csi-provisioner
... csi-resizer
... csi-snapshotter
... longhorn-driver-deployer
... longhorn-csi-plugin
... longhorn-manager
... longhorn-ui

*** Keywords ***
Wait for longhorn ready
wait_for_all_instance_manager_running
wait_for_workloads_pods_stable ${longhorn_workloads} longhorn-system
68 changes: 0 additions & 68 deletions e2e/keywords/node.resource

This file was deleted.

34 changes: 34 additions & 0 deletions e2e/keywords/node_instance.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
*** Settings ***
Documentation Physical Node Keywords
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/instancemanager_keywords.py
Library ../libs/keywords/network_keywords.py
Library ../libs/keywords/node_instance_keywords.py
Library ../libs/keywords/volume_keywords.py
Library ../libs/keywords/workload_keywords.py

*** Keywords ***
Reboot volume ${volume_id} volume node
${volume_name} = generate_name_with_suffix volume ${volume_id}
reboot_volume_node ${volume_name}

Reboot volume ${volume_id} replica node
${volume_name} = generate_name_with_suffix volume ${volume_id}
reboot_replica_node ${volume_name}

Reboot node ${idx}
reboot_node_by_index ${idx}

Restart all worker nodes
reboot_all_worker_nodes

Power off node ${idx} for ${power_off_time_in_min} mins
reboot_node_by_index ${idx} ${power_off_time_in_min}

Power off all worker nodes for ${power_off_time_in_min} mins
reboot_all_worker_nodes ${power_off_time_in_min}

Restart cluster
reboot_all_nodes
setup_control_plane_network_latency
15 changes: 15 additions & 0 deletions e2e/keywords/persistentvolumeclaim.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*** Settings ***
Documentation PersistentVolumeClaim Keywords
Library Collections
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/persistentvolumeclaim_keywords.py

*** Keywords ***
Create persistentvolumeclaim ${claim_id} using ${volume_type} volume
${claim_name} = generate_name_with_suffix claim ${claim_id}
create_persistentvolumeclaim ${claim_name} ${volume_type}

Create persistentvolumeclaim ${claim_id} using ${volume_type} volume with ${option} storageclass
${claim_name} = generate_name_with_suffix claim ${claim_id}
create_persistentvolumeclaim ${claim_name} ${volume_type} ${option}
13 changes: 8 additions & 5 deletions e2e/keywords/recurringjob.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
Documentation Recurring Job Keywords
Library Collections
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/recurringjob_keywords.py

*** Keywords ***
Create snapshot and backup recurringjob for volume ${idx}
create_snapshot_recurringjob_for_volume ${volume_list}[${idx}]
create_backup_recurringjob_for_volume ${volume_list}[${idx}]
Create snapshot and backup recurringjob for volume ${volume_id}
${volume_name} = generate_name_with_suffix volume ${volume_id}
create_snapshot_recurringjob_for_volume ${volume_name}
create_backup_recurringjob_for_volume ${volume_name}

Check recurringjobs for volume ${idx} work
check_recurringjobs_work ${volume_list}[${idx}]
Check recurringjobs for volume ${volume_id} work
${volume_name} = generate_name_with_suffix volume ${volume_id}
check_recurringjobs_work ${volume_name}
105 changes: 49 additions & 56 deletions e2e/keywords/statefulset.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,55 @@
Documentation StatefulSet Keywords
Library Collections
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/statefulset_keywords.py

*** Keywords ***
Create statefulset ${idx} with ${volume_type} volume
${statefulset_name} = create_statefulset ${volume_type}
Insert Into List ${statefulset_list} ${idx} ${statefulset_name}

${volume_name} = get_workload_volume_name ${statefulset_name}
Insert Into List ${volume_list} ${idx} ${volume_name}

${pvc_name} = get_workload_pvc_name ${statefulset_name}
Insert Into List ${persistentvolumeclaim_list} ${idx} ${pvc_name}

Create statefulset ${idx} with ${volume_type} and ${option} volume
${statefulset_name} = create_statefulset ${volume_type} ${option}
Insert Into List ${statefulset_list} ${idx} ${statefulset_name}

Scale down statefulset ${idx} to detach volume
${statefulset} = get_statefulset ${statefulset_list}[${idx}]
${scale_up_replica_count} = Set Variable ${statefulset.spec.replicas}
Set Test Variable ${scale_up_replica_count}

scale_statefulset ${statefulset_list}[${idx}] 0
wait_for_volume_detached ${volume_list}[${idx}]

Scale up statefulset ${idx} to attach volume
scale_statefulset ${statefulset_list}[${idx}] ${scale_up_replica_count}
wait_for_volume_healthy ${volume_list}[${idx}]
wait_for_statefulset_replicas_ready ${statefulset_list}[${idx}] ${scale_up_replica_count}

Expand statefulset ${idx} volume by ${size} MiB
${expected_size} = expand_pvc_size_by_mib ${persistentvolumeclaim_list}[${idx}] ${size}
Set Test Variable ${expected_size}

Write ${size} MB data to statefulset ${idx}
${pod_name} = get_workload_pod_name ${statefulset_list}[${idx}]
${pod_data_checksum} = write_pod_random_data ${pod_name} ${size}
Insert Into List ${data_checksum_list} ${idx} ${pod_data_checksum}

Keep writing data to statefulset ${idx}
${pod_name} = get_workload_pod_name ${statefulset_list}[${idx}]
keep_writing_pod_data ${pod_name}

Check statefulset ${idx} works
${pod_name} = get_workload_pod_name ${statefulset_list}[${idx}]
${pod_data_checksum} = write_pod_random_data ${pod_name} 1024
check_pod_data_checksum ${pod_name} ${pod_data_checksum}

Check statefulset ${idx} data is intact
${pod_name} = get_workload_pod_name ${statefulset_list}[${idx}]
${expected_data_checksum} = Get From List ${data_checksum_list} ${idx}
check_pod_data_checksum ${pod_name} ${expected_data_checksum}

Wait for statefulset ${idx} volume size expanded
wait_for_volume_expand_to_size ${volume_list}[${idx}] ${expected_size}

Wait for statefulset ${idx} stable
wait_for_workload_pod_stable ${statefulset_list}[${idx}]

Create statefulset ${statefulset_id} using ${volume_type} volume
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
create_statefulset ${statefulset_name} ${volume_type}

Create statefulset ${statefulset_id} using ${volume_type} volume with ${option} storageclass
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
create_statefulset ${statefulset_name} ${volume_type} ${option}

Scale statefulset ${statefulset_id} to ${replicaset_size}
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
scale_statefulset ${statefulset_name} ${replicaset_size}

Scale down statefulset ${statefulset_id} to detach volume
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
scale_statefulset_down ${statefulset_name}

Scale up statefulset ${statefulset_id} to attach volume
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
scale_statefulset_up ${statefulset_name}

Expand statefulset ${statefulset_id} volume by ${size} MiB
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
expand_workload_claim_size_by_mib ${statefulset_name} ${size}

Write ${size} MB data to file ${file_name} in statefulset ${statefulset_id}
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
write_workload_pod_random_data ${statefulset_name} ${size} ${file_name}

Check statefulset ${statefulset_id} works
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
write_workload_pod_random_data ${statefulset_name} 1024 random-data
check_workload_pod_data_checksum ${statefulset_name} random-data

Check statefulset ${statefulset_id} data in file ${file_name} is intact
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
check_workload_pod_data_checksum ${statefulset_name} ${file_name}

Wait for statefulset ${statefulset_id} volume size expanded
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
wait_for_workload_claim_size_expanded ${statefulset_name}

Wait for statefulset ${statefulset_id} volume detached
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
wait_for_workload_volume_detached ${statefulset_name}

Wait for statefulset ${statefulset_id} pods stable
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
wait_for_workload_pods_stable ${statefulset_name}
Loading

0 comments on commit dd2d6b0

Please sign in to comment.