Skip to content

Commit 36d12ed

Browse files
committed
Added method to poll tasks if needed
Signed-off-by: Mike Raineri <[email protected]>
1 parent 938a1e0 commit 36d12ed

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

redfish_protocol_validator/service_details.py

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def test_ssdp_can_be_disabled(sut: SystemUnderTest):
217217
headers = {'If-Match': etag} if etag else {}
218218
r = sut.session.patch(sut.rhost + sut.mgr_net_proto_uri,
219219
json=payload, headers=headers)
220+
r = poll_task(sut, r)
220221
if r.ok:
221222
services = utils.discover_ssdp(search_target=SSDP_REDFISH)
222223
uuids = services.keys()

redfish_protocol_validator/utils.py

+18
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ def is_text_in_extended_error(text: str, body: dict):
103103
return False
104104

105105

106+
def poll_task(sut, response):
107+
# If the response doesn't show 202 Accepted, there's nothing to poll
108+
if response.status_code != requests.codes.ACCEPTED:
109+
return response
110+
111+
# Get the task monitor URI and poll it
112+
task_monitor = response.headers.get('Location')
113+
if task_monitor:
114+
# Try for up to 1 minute at 5 second intervals
115+
for _ in range(12):
116+
time.sleep(5)
117+
response = sut.session.get(sut.rhost + task_monitor)
118+
# Once the task is done, break out
119+
if response.status_code != requests.codes.ACCEPTED:
120+
break
121+
return response
122+
123+
106124
def get_sse_stream(sut):
107125
response = None
108126
event_dest_uri = None

0 commit comments

Comments
 (0)