Skip to content

Commit 2941e3f

Browse files
chriscchienyangchiu
authored andcommitted
test(robot): Automate test case Upgrade Conflict Handling test
longhorn/longhorn-11160 Signed-off-by: Chris Chien <chris.chien@suse.com>
1 parent 35681d0 commit 2941e3f

3 files changed

Lines changed: 93 additions & 0 deletions

File tree

e2e/keywords/longhorn.resource

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,6 @@ Upgrade Longhorn to custom version should fail
125125
Check Longhorn node ${type} state on power off node is ${expect_state}
126126
${status} = get_longhorn_node_condition_status ${last_volume_node} ${type}
127127
Should Be Equal ${status} ${expect_state}
128+
129+
Check longhorn manager pods not restarted after test start
130+
check_pod_not_restart_after_specific_time longhorn-system app=longhorn-manager ${test_start_time}

e2e/libs/keywords/workload_keywords.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
from utility.constant import LABEL_LONGHORN_COMPONENT
3636
from utility.utility import convert_size_to_bytes
3737
from utility.utility import logging
38+
from utility.utility import list_namespaced_pod
3839

3940
from volume import Volume
41+
from datetime import datetime, timezone
4042

4143

4244
class workload_keywords:
@@ -241,3 +243,14 @@ def check_workload_pod_did_not_restart(self, workload_name):
241243
def get_workload_pod_uids(self, workload_name):
242244
pod_list = get_workload_pods(workload_name)
243245
return {pod.metadata.name: pod.metadata.uid for pod in pod_list}
246+
247+
def check_pod_not_restart_after_specific_time(self, namespace, label, time):
248+
pods = list_namespaced_pod(namespace, label)
249+
250+
if time.tzinfo is None:
251+
time = time.replace(tzinfo=timezone.utc)
252+
253+
for pod in pods:
254+
creation_time = pod.metadata.creation_timestamp
255+
logging(f"Comparing pod creation: {creation_time} < {time}")
256+
assert creation_time < time, f"{pod.metadata.name} restarted after test started"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
*** Settings ***
2+
Documentation Manual Test Cases
3+
Test Tags negative
4+
5+
Resource ../keywords/variables.resource
6+
Resource ../keywords/common.resource
7+
Resource ../keywords/longhorn.resource
8+
Resource ../keywords/volume.resource
9+
Resource ../keywords/setting.resource
10+
Resource ../keywords/storageclass.resource
11+
Resource ../keywords/workload.resource
12+
Resource ../keywords/statefulset.resource
13+
Resource ../keywords/backup.resource
14+
Resource ../keywords/recurringjob.resource
15+
Library DateTime
16+
17+
Test Setup Set up test environment
18+
Test Teardown Cleanup test resources
19+
20+
*** Keywords ***
21+
Get test start time
22+
${test_start_time}= Get Current Date result_format=datetime
23+
Log ${test_start_time}
24+
Set Test Variable ${test_start_time}
25+
26+
Perform recurring job workflow under load
27+
${NUM_VOLUMES} = Set Variable 100
28+
${NUM_VOLUMES_DETACH} = Set Variable 20
29+
30+
When Get test start time
31+
And Create storageclass longhorn-test with dataEngine=${DATA_ENGINE}
32+
FOR ${i} IN RANGE ${NUM_VOLUMES}
33+
And Create statefulset ${i} using RWO volume with longhorn-test storageclass and size 10 Mi
34+
And Write 1 MB data to file data.txt in statefulset ${i}
35+
END
36+
37+
And Create snapshot recurringjob 0
38+
... groups=["default"]
39+
... cron=*/1 * * * *
40+
... concurrency=5
41+
... labels={"test":"recurringjob"}
42+
43+
FOR ${i} IN RANGE ${NUM_VOLUMES_DETACH}
44+
When Create backup ${i} for statefulset ${i} volume
45+
Then Scale down statefulset ${i} to detach volume
46+
And Scale up statefulset ${i} to attach volume
47+
END
48+
49+
And Check longhorn manager pods not restarted after test start
50+
51+
*** Test Cases ***
52+
Test Stability of Longhorn with Large Workload
53+
Perform recurring job workflow under load
54+
55+
Test Upgrade Stability with Large Workload
56+
${LONGHORN_STABLE_VERSION}= Get Environment Variable LONGHORN_STABLE_VERSION default=''
57+
IF '${LONGHORN_STABLE_VERSION}' == ''
58+
Fail Environment variable LONGHORN_STABLE_VERSION is not set
59+
END
60+
61+
Given Set setting deleting-confirmation-flag to true
62+
And Uninstall Longhorn
63+
And Check Longhorn CRD removed
64+
65+
When Install Longhorn stable version
66+
And set_backupstore
67+
68+
When Perform recurring job workflow under load
69+
And Upgrade Longhorn to custom version
70+
71+
When Get test start time
72+
FOR ${i} IN RANGE ${NUM_VOLUMES_DETACH}
73+
And Scale down statefulset ${i} to detach volume
74+
And Scale up statefulset ${i} to attach volume
75+
END
76+
77+
And Check longhorn manager pods not restarted after test start

0 commit comments

Comments
 (0)