Skip to content

Commit 73db4b3

Browse files
hubatishcopybara-github
authored andcommitted
Require successful IsReady calls & allow for custom InvokeCommands
PiperOrigin-RevId: 828111142
1 parent 97f22f8 commit 73db4b3

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

perfkitbenchmarker/app_service.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,23 @@ def Invoke(
244244
An object containing success, response string, & latency. Latency is
245245
also negative in the case of a failure.
246246
"""
247-
return self.poller.Run(
248-
self.vm,
249-
self.endpoint,
250-
retries=retries,
251-
expected_response=self.builder.GetExpectedResponse(),
247+
cmd = self.builder.InvokeCommand(self.endpoint)
248+
if not cmd:
249+
return self.poller.Run(
250+
self.vm,
251+
self.endpoint,
252+
retries=retries,
253+
expected_response=self.builder.GetExpectedResponse(),
254+
)
255+
start_time = time.time()
256+
out, err = self.vm.RemoteCommand(cmd, ignore_failure=True)
257+
# Assert error is empty & out is not.
258+
success = (not bool(err)) and bool(out) and ('timeout' not in out)
259+
end_time = time.time()
260+
return http_poller.PollingResponse(
261+
success=success,
262+
response=out,
263+
latency=end_time - start_time,
252264
)
253265

254266
def _IsReady(self) -> bool:
@@ -267,7 +279,7 @@ def _IsReady(self) -> bool:
267279
response.success,
268280
response.latency,
269281
)
270-
return response.latency > 0
282+
return response.latency > 0 and response.success
271283

272284
def _CreateDependencies(self):
273285
"""Creates dependencies needed before _CreateResource() is called."""

0 commit comments

Comments
 (0)