Skip to content

Commit 1ec32f5

Browse files
authored
Improve the speed of pod status testings (#82)
Good performance optimization, LGTM!
1 parent 90e38f1 commit 1ec32f5

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

tests/interop/utils.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,16 @@ def send_get_request(site_url):
3838
def verify_pod_in_project(openshift_dyn_client, project, pod):
3939
pod_name = pod
4040
logger.debug(f'Verify pod "{pod}" in project "{project}"')
41-
try:
42-
pods = Pod.get(dyn_client=openshift_dyn_client, namespace=project)
43-
for pod in pods:
44-
logger.debug(f"Current pod: {pod.instance.metadata.name}")
45-
if pod.instance.metadata.name == pod_name:
46-
logger.debug("Pod name match!")
47-
for container in pod.instance.status.containerStatuses:
48-
if container.state.terminated:
49-
if (
50-
container.state.terminated.reason
51-
!= Resource.Status.COMPLETED
52-
):
53-
return False
54-
elif not container.state.running:
55-
return False
56-
return True
57-
return False
58-
except StopIteration:
59-
raise
41+
pod = Pod(client=openshift_dyn_client, namespace=project, name=pod_name)
42+
if pod.exists:
43+
for container in pod.instance.status.containerStatuses:
44+
if container.state.terminated:
45+
if container.state.terminated.reason != Resource.Status.COMPLETED:
46+
return False
47+
elif not container.state.running:
48+
return False
49+
return True
50+
return False
6051

6152

6253
def verify_pod_by_deployment(openshift_dyn_client, project, deployment):

0 commit comments

Comments
 (0)