-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(robot): add test strict local volume disabled revision conuter by default #2080
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*** Settings *** | ||
Documentation Longhorn replica related keywords | ||
Library ../libs/keywords/common_keywords.py | ||
Library ../libs/keywords/replica_keywords.py | ||
|
||
*** Keywords *** | ||
Volume ${volume_id} replica ${setting_name} should be ${setting_value} | ||
${volume_name} = generate_name_with_suffix volume ${volume_id} | ||
validate_replica_setting ${volume_name} ${setting_name} ${setting_value} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from replica import Replica | ||
|
||
class replica_keywords: | ||
|
||
def __init__(self): | ||
self.replica = Replica() | ||
|
||
def validate_replica_setting(self, volume_name, setting_name, value): | ||
return self.replica.validate_replica_setting(volume_name, setting_name, value) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,9 @@ def cleanup_volumes(self): | |
for volume in volumes['items']: | ||
self.delete_volume(volume['metadata']['name']) | ||
|
||
def create_volume(self, volume_name, size="2Gi", numberOfReplicas=3, frontend="blockdev", migratable=False, accessMode="RWO", dataEngine="v1", backingImage="", Standby=False, fromBackup=""): | ||
def create_volume(self, volume_name, size="2Gi", numberOfReplicas=3, frontend="blockdev", migratable=False, dataLocality="disabled", accessMode="RWO", dataEngine="v1", backingImage="", Standby=False, fromBackup=""): | ||
logging(f'Creating volume {volume_name}') | ||
self.volume.create(volume_name, size, numberOfReplicas, frontend, migratable, accessMode, dataEngine, backingImage, Standby, fromBackup) | ||
self.volume.create(volume_name, size, numberOfReplicas, frontend, migratable, dataLocality, accessMode, dataEngine, backingImage, Standby, fromBackup) | ||
|
||
def delete_volume(self, volume_name): | ||
logging(f'Deleting volume {volume_name}') | ||
|
@@ -283,9 +283,7 @@ def create_persistentvolumeclaim_for_volume(self, volume_name, retry=True): | |
|
||
def record_volume_replica_names(self, volume_name): | ||
replica_list = self.replica.get(volume_name, node_name="") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to replace node_name="" to node_name=None? |
||
assert replica_list != "", f"failed to get replicas" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason of removing it? |
||
|
||
replica_names = [replica['metadata']['name'] for replica in replica_list['items']] | ||
replica_names = [replica['metadata']['name'] for replica in replica_list] | ||
logging(f"Found volume {volume_name} replicas: {replica_names}") | ||
|
||
replica_names_str = ",".join(replica_names) | ||
|
@@ -296,9 +294,7 @@ def check_volume_replica_names_recorded(self, volume_name): | |
expected_replica_names = sorted(replica_names_str.split(",")) | ||
|
||
replica_list = self.replica.get(volume_name, node_name="") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above node_name |
||
assert replica_list != "", f"failed to get replicas" | ||
|
||
actual_replica_names = [replica['metadata']['name'] for replica in replica_list['items']] | ||
actual_replica_names = [replica['metadata']['name'] for replica in replica_list] | ||
actual_replica_names = sorted(actual_replica_names) | ||
|
||
assert actual_replica_names == expected_replica_names, \ | ||
|
@@ -314,3 +310,6 @@ def wait_for_engine_image_upgrade_completed(self, volume_name, engine_image_name | |
|
||
def get_volume_checksum(self, volume_name): | ||
return self.volume.get_checksum(volume_name) | ||
|
||
def validate_volume_setting(self, volume_name, setting_name, value): | ||
return self.volume.validate_volume_setting(volume_name, setting_name, value) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,11 @@ class CRD(Base): | |
def __init__(self): | ||
self.obj_api = client.CustomObjectsApi() | ||
|
||
def get(self, volume_name, node_name): | ||
def get(self, volume_name, node_name=None): | ||
label_selector = [] | ||
if volume_name != "": | ||
label_selector.append(f"longhornvolume={volume_name}") | ||
if node_name != "": | ||
if node_name: | ||
label_selector.append(f"longhornnode={node_name}") | ||
|
||
replicas = self.obj_api.list_namespaced_custom_object( | ||
|
@@ -24,7 +24,7 @@ def get(self, volume_name, node_name): | |
plural="replicas", | ||
label_selector=",".join(label_selector) | ||
) | ||
return replicas | ||
return replicas["items"] | ||
|
||
def delete(self, volume_name, node_name): | ||
if volume_name == "" or node_name == "": | ||
|
@@ -33,10 +33,7 @@ def delete(self, volume_name, node_name): | |
logging( | ||
f"Deleting volume {volume_name} on node {node_name} replicas") | ||
|
||
resp = self.get(volume_name, node_name) | ||
assert resp != "", f"failed to get replicas" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the removal of |
||
|
||
replicas = resp['items'] | ||
replicas = self.get(volume_name, node_name) | ||
if len(replicas) == 0: | ||
return | ||
|
||
|
@@ -56,3 +53,9 @@ def wait_for_rebuilding_start(self, volume_name, node_name): | |
|
||
def wait_for_rebuilding_complete(self, volume_name, node_name): | ||
Rest().wait_for_rebuilding_complete(volume_name, node_name) | ||
|
||
def validate_replica_setting(self, volume_name, setting_name, value): | ||
replicas = self.get(volume_name) | ||
for replica in replicas: | ||
assert str(replica["spec"][setting_name]) == value, \ | ||
f"Expected volume {volume_name} replica setting {setting_name} is {value}, but it's {str(replica['spec'][setting_name])}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ def __init__(self): | |
self.retry_count, self.retry_interval = get_retry_count_and_interval() | ||
self.engine = Engine() | ||
|
||
def create(self, volume_name, size, numberOfReplicas, frontend, migratable, accessMode, dataEngine, backingImage, Standby, fromBackup): | ||
def create(self, volume_name, size, numberOfReplicas, frontend, migratable, dataLocality, accessMode, dataEngine, backingImage, Standby, fromBackup): | ||
size_suffix = size[-2:] | ||
size_number = size[:-2] | ||
size_unit = MEBIBYTE if size_suffix == "Mi" else GIBIBYTE | ||
|
@@ -48,6 +48,7 @@ def create(self, volume_name, size, numberOfReplicas, frontend, migratable, acce | |
"size": size, | ||
"numberOfReplicas": int(numberOfReplicas), | ||
"migratable": migratable, | ||
"dataLocality": dataLocality, | ||
"accessMode": accessMode, | ||
"dataEngine": dataEngine, | ||
"backingImage": backingImage, | ||
|
@@ -76,6 +77,7 @@ def create(self, volume_name, size, numberOfReplicas, frontend, migratable, acce | |
assert volume['spec']['numberOfReplicas'] == int(numberOfReplicas), f"expect volume numberOfReplicas is {numberOfReplicas}, but it's {volume['spec']['numberOfReplicas']}" | ||
assert volume['spec']['frontend'] == frontend, f"expect volume frontend is {frontend}, but it's {volume['spec']['frontend']}" | ||
assert volume['spec']['migratable'] == migratable, f"expect volume migratable is {migratable}, but it's {volume['spec']['migratable']}" | ||
assert volume['spec']['dataLocality'] == dataLocality, f"expect volume dataLocality is {dataLocality}, but it's {volume['spec']['dataLocality']}" | ||
assert volume['spec']['accessMode'] == accessMode, f"expect volume accessMode is {accessMode}, but it's {volume['spec']['accessMode']}" | ||
assert volume['spec']['backingImage'] == backingImage, f"expect volume backingImage is {backingImage}, but it's {volume['spec']['backingImage']}" | ||
assert volume['spec']['Standby'] == Standby, f"expect volume Standby is {Standby}, but it's {volume['spec']['Standby']}" | ||
|
@@ -504,3 +506,8 @@ def upgrade_engine_image(self, volume_name, engine_image_name): | |
|
||
def wait_for_engine_image_upgrade_completed(self, volume_name, engine_image_name): | ||
return Rest().wait_for_engine_image_upgrade_completed(volume_name, engine_image_name) | ||
|
||
def validate_volume_setting(self, volume_name, setting_name, value): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an extra line of separation in the function. |
||
volume = self.get(volume_name) | ||
assert str(volume["spec"][setting_name]) == value, \ | ||
f"Expected volume {volume_name} setting {setting_name} is {value}, but it's {str(volume['spec'][setting_name])}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If condition should be based on node_name
None