Skip to content

Commit

Permalink
refactor(negative): create statefulset replica check func
Browse files Browse the repository at this point in the history
Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang committed Nov 3, 2023
1 parent b7cf081 commit f663eef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
31 changes: 19 additions & 12 deletions e2e/libs/workload/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,28 @@ def create_statefulset(volume_type, option):
statefulset_name = statefulset.metadata.name
replicas = statefulset.spec.replicas

retry_count, retry_interval = get_retry_count_and_interval()
for i in range(retry_count):
statefulset = api.read_namespaced_stateful_set(
name=statefulset_name,
namespace=namespace)
# statefulset is none if statefulset is not yet created
if statefulset is not None and \
statefulset.status.ready_replicas == replicas:
break
time.sleep(retry_interval)

assert statefulset.status.ready_replicas == replicas
wait_for_statefulset_replicas_ready(statefulset_name, replicas)

return statefulset_name

def wait_for_statefulset_replicas_ready(statefulset_name, expected_ready_count, namespace='default'):
apps_v1_api = client.AppsV1Api()

retry_count, retry_interval = get_retry_count_and_interval()
for i in range(retry_count):
logging(f"Waiting for statefulset {statefulset_name} replica ready ({i}) ...")

statefulset = apps_v1_api.read_namespaced_stateful_set(
name=statefulset_name,
namespace=namespace)
# statefulset is none if statefulset is not yet created
if statefulset is not None and \
statefulset.status.ready_replicas == expected_ready_count:
break
time.sleep(retry_interval)

assert statefulset.status.ready_replicas == expected_ready_count

def delete_statefulset(name, namespace='default'):
api = client.AppsV1Api()

Expand Down
1 change: 0 additions & 1 deletion e2e/tests/stress_cpu.robot
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Stress Volume Node CPU When Replica Is Rebuilding
And Check data is intact
END


Stress Volume Node CPU When Volume Is Detaching and Attaching
Given Create a volume with 5 GB and 3 replicas
And Write data to the volume
Expand Down

0 comments on commit f663eef

Please sign in to comment.