Skip to content

Commit

Permalink
Merge pull request #36 from prazumovsky/fix-services-scenario
Browse files Browse the repository at this point in the history
Add timeout for request_node_port_service action
  • Loading branch information
prazumovsky authored Sep 12, 2018
2 parents 021b4fa + 2d7a9f8 commit 7e09f4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions xrally_kubernetes/tasks/scenarios/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ def run(self, image, port, protocol, command=None, custom_endpoint=False,
)
class PodWithNodePortService(common_scenario.BaseKubernetesScenario):

def run(self, image, port, protocol, command=None, status_wait=True):
def run(self, image, port, protocol, request_timeout=None,
command=None, status_wait=True):
"""Create pod and nodePort svc, request pod by port and delete then.
:param image: pod's image
:param port: pod's container port and svc port integer
:param protocol: pod's container port and svc port protocol
:param request_timeout: check request timeout
:param command: pod's array of strings representing command
:param status_wait: wait for pod status if True
"""
Expand Down Expand Up @@ -171,8 +173,11 @@ def run(self, image, port, protocol, command=None, status_wait=True):
str(node_port) + "/")
while i < retries_total:
try:
requests.get(url)
except requests.ConnectionError as ex:
kwargs = {}
if request_timeout:
kwargs["timeout"] = request_timeout
requests.get(url, **kwargs)
except (requests.ConnectionError, requests.ReadTimeout) as ex:
if i < retries_total:
i += 1
commonutils.interruptable_sleep(sleep_time)
Expand Down
1 change: 1 addition & 0 deletions xrally_tasks/all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ subtasks:
image: gcr.io/google-samples/hello-go-gke:1.0
port: 80
protocol: TCP
request_timeout: 10
runner:
constant:
concurrency: 2
Expand Down

0 comments on commit 7e09f4f

Please sign in to comment.