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 1, 2024
1 parent 949f27c commit a22060d
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 279 deletions.
26 changes: 10 additions & 16 deletions e2e/keywords/common.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
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 ***
Expand All @@ -19,22 +19,16 @@ 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
24 changes: 9 additions & 15 deletions e2e/keywords/deployment.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@
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} using 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}

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}
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
15 changes: 0 additions & 15 deletions e2e/keywords/kubelet.resource

This file was deleted.

50 changes: 12 additions & 38 deletions e2e/keywords/node.resource
Original file line number Diff line number Diff line change
@@ -1,68 +1,42 @@
*** Settings ***
Documentation Physical Node Keywords
Library ../libs/keywords/volume_keywords.py
Library ../libs/keywords/common_keywords.py
Library ../libs/keywords/instancemanager_keywords.py
Library ../libs/keywords/network_keywords.py
Library ../libs/keywords/node_keywords.py
Library ../libs/keywords/volume_keywords.py
Library ../libs/keywords/workload_keywords.py
Library ../libs/keywords/network_keywords.py

*** Keywords ***
During replica rebuilding, reboot volume node
Reboot volume ${volume_id} volume node
${volume_name} = generate_name_with_suffix volume ${volume_id}
reboot_volume_node ${volume_name}

During replica rebuilding, reboot replica node
Reboot volume ${volume_id} replica node
${volume_name} = generate_name_with_suffix volume ${volume_id}
reboot_replica_node ${volume_name}

Reboot volume ${idx} volume node
reboot_volume_node ${volume_list}[${idx}]
FOR ${item} IN @{volume_list}
wait for volume_attached ${item}
END

Reboot volume ${idx} replica node
reboot_replica_node ${volume_list}[${idx}]
FOR ${item} IN @{volume_list}
wait for volume_attached ${item}
END

Reboot node ${idx}
reboot_node_by_index ${idx}

Restart all worker nodes
reboot_all_worker_nodes

Reboot volume node of statefulset ${idx}
${volume_name} = get_workload_volume_name ${statefulset_list}[${idx}]
${node_name} = get_replica_node_attached_to_volume ${volume_name}
reboot_node_by_name ${node_name}

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}

Power off volume node of statefulset ${idx} for ${power_off_time_in_min} mins
${volume_name} = get_workload_volume_name ${statefulset_list}[${idx}]
${node_name} = get_replica_node_attached_to_volume ${volume_name}
reboot_node_by_name ${node_name} ${power_off_time_in_min}

Wait for longhorn ready
wait_for_all_instance_manager_running
FOR ${deployment} IN @{deployment_list}
wait_for_workload_pod_stable ${deployment}
END
FOR ${statefulset} IN @{statefulset_list}
wait_for_workload_pod_stable ${statefulset}
END
wait_for_workload_pods_stable deployment
wait_for_workload_pods_stable statefulset

Restart cluster
reboot_all_nodes
setup_control_plane_network_latency
wait_for_all_instance_manager_running
FOR ${deployment} IN @{deployment_list}
wait_for_workload_pod_stable ${deployment}
END
FOR ${statefulset} IN @{statefulset_list}
wait_for_workload_pod_stable ${statefulset}
END
wait_for_workload_pods_stable deployment
wait_for_workload_pods_stable statefulset
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}
107 changes: 51 additions & 56 deletions e2e/keywords/statefulset.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,57 @@
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 ${claim_index} by ${size} MiB
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
expand_workload_claim_size_by_mib ${statefulset_name} ${claim_index} ${size}

Write ${size} MB data to file ${file_id} in statefulset ${statefulset_id}
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
${file_name} = generate_name_with_suffix file ${file_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_id} is intact
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
${file_name} = generate_name_with_suffix file ${file_id}
check_workload_pod_data_checksum ${statefulset_name} ${file_name}

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

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

Wait for statefulset ${statefulset_id} stable
${statefulset_name} = generate_name_with_suffix statefulset ${statefulset_id}
wait_for_workload_pod_stable ${statefulset_name}
17 changes: 13 additions & 4 deletions e2e/keywords/stress.resource
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
*** Settings ***
Documentation Stress Node Keywords
Library ../libs/keywords/node_keywords.py
Library ../libs/keywords/stress_keywords.py

*** Keywords ***
Stress the CPU of all ${role} nodes
stress_node_cpu_by_role ${role}

Stress the CPU of all volume nodes
stress_node_cpu_by_volumes ${volume_list}
Stress the CPU of all nodes with volume
stress_node_cpu_of_all_volumes

Stress the CPU of node with volume ${volume_id}
${volume_name} = generate_name_with_suffix volume ${volume_id}
stress_node_cpu_by_volume ${volume_name}

Stress the memory of all ${role} nodes
stress_node_memory_by_role ${role}

Stress the memory of all volume nodes
stress_node_memory_by_volumes ${volume_list}
Stress the memory of all nodes with volume
stress_node_memory_of_all_volumes

Stress the memory of node with volume ${volume_id}
${volume_name} = generate_name_with_suffix volume ${volume_id}
stress_node_memory_by_volume ${volume_name}
Loading

0 comments on commit a22060d

Please sign in to comment.