Skip to content

Commit

Permalink
Merge pull request #1576 from c3y1huang/refactor-rename-func-check-da…
Browse files Browse the repository at this point in the history
…ta-checksum

refactor(negative): rename function to reflect purpose
  • Loading branch information
khushboo-rancher authored Nov 1, 2023
2 parents 7ea8d89 + 65092ee commit eb8d4a1
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion e2e/keywords/volume.resource
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Wait until replica ${replica_0} rebuilt, delete replica ${replica_2}
delete_replica ${volume_name} ${replica_2}

Check data is intact
check_data ${volume_name} ${volume_data_checksum}
check_data_checksum ${volume_name} ${volume_data_checksum}

Check volume ${idx} works
${volume_data_checksum} = write_volume_random_data ${volume_list}[${idx}] 1024
Expand Down
4 changes: 2 additions & 2 deletions e2e/keywords/workload.resource
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ Keep writing data to statefulset ${idx}
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 ${pod_name} ${pod_data_checksum}
check_pod_data_checksum ${pod_name} ${pod_data_checksum}

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 ${pod_name} ${pod_data_checksum}
check_pod_data_checksum ${pod_name} ${pod_data_checksum}

Wait for statefulset ${idx} stable
wait_for_workload_pod_stable ${statefulset_list}[${idx}]
4 changes: 2 additions & 2 deletions e2e/libs/keywords/volume_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def keep_writing_data(self, volume_name):
self.volume.keep_writing_data(volume_name)


def check_data(self, volume_name, checksum):
def check_data_checksum(self, volume_name, checksum):
logging(f"Checking volume {volume_name} data with checksum {checksum}")
self.volume.check_data(volume_name, checksum)
self.volume.check_data_checksum(volume_name, checksum)


def delete_replica(self, volume_name, replica_node):
Expand Down
4 changes: 2 additions & 2 deletions e2e/libs/keywords/workload_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def keep_writing_pod_data(self, pod_name):
def write_pod_random_data(self, pod, size_in_mb):
return write_pod_random_data(pod, size_in_mb)

def check_pod_data(self, pod_name, checksum):
check_pod_data(pod_name, checksum)
def check_pod_data_checksum(self, pod_name, checksum):
check_pod_data_checksum(pod_name, checksum)

def cleanup_deployments(self, deployment_names):
for name in deployment_names:
Expand Down
2 changes: 1 addition & 1 deletion e2e/libs/volume/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def wait_for_replica_rebuilding_complete(self, volume_name, node_name):
return NotImplemented

@abstractmethod
def check_data(self, volume_name, checksum):
def check_data_checksum(self, volume_name, checksum):
return NotImplemented

@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion e2e/libs/volume/crd.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def wait_for_replica_rebuilding_complete(self, volume_name, node_name):
node_name
)

def check_data(self, volume_name, checksum):
def check_data_checksum(self, volume_name, checksum):
node_name = self.get(volume_name)["spec"]["nodeID"]
endpoint = self.get_endpoint(volume_name)
_checksum = self.node_exec.issue_cmd(
Expand Down
2 changes: 1 addition & 1 deletion e2e/libs/volume/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def wait_for_replica_rebuilding_complete(self, volume_name, node_name):
time.sleep(RETRY_INTERVAL)
assert completed

def check_data(self, volume_name, checksum):
def check_data_checksum(self, volume_name, checksum):
return NotImplemented

def cleanup(self, volume_names):
Expand Down
6 changes: 3 additions & 3 deletions e2e/libs/volume/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def wait_for_replica_rebuilding_complete(self, volume_name, node_name):
node_name
)

def check_data(self, volume_name, checksum):
return self.volume.check_data(volume_name, checksum)
def check_data_checksum(self, volume_name, checksum):
return self.volume.check_data_checksum(volume_name, checksum)

def cleanup(self, volume_names):
return self.volume.cleanup(volume_names)
return self.volume.cleanup(volume_names)
9 changes: 5 additions & 4 deletions e2e/libs/workload/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def keep_writing_pod_data(pod_name, size_in_mb=256, path="/data/overwritten-data
logging(f"Created process to keep writing pod {pod_name}")
return res

def check_pod_data(pod_name, checksum, path="/data/random-data"):
def check_pod_data_checksum(pod_name, checksum, path="/data/random-data"):
logging(f"Checking pod {pod_name} data checksum")
api = client.CoreV1Api()
cmd = [
'/bin/sh',
Expand All @@ -284,9 +285,9 @@ def check_pod_data(pod_name, checksum, path="/data/random-data"):
api.connect_get_namespaced_pod_exec, pod_name, 'default',
command=cmd, stderr=True, stdin=False, stdout=True,
tty=False)
logging(f"Got {path} checksum = {_checksum},\
expected checksum = {checksum}")
assert _checksum == checksum
assert _checksum == checksum, \
f"Got {path} checksum = {_checksum}\n" \
f"Expected checksum = {checksum}"

def wait_for_workload_pod_stable(workload_name):
stable_pod = None
Expand Down

0 comments on commit eb8d4a1

Please sign in to comment.