Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/framework/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# SPDX-License-Identifier: Apache-2.0
"""Wrapper over an http session with timed requests."""
# pylint: disable=unused-import
import requests_unixsocket
import requests
from requests_unixsocket import DEFAULT_SCHEME, UnixAdapter

from framework import decorators


class Session(requests_unixsocket.Session):
class Session(requests.Session):
"""Wrapper over requests_unixsocket.Session limiting the call duration.

Only the API calls relevant to Firecracker (GET, PUT, PATCH) are
Expand All @@ -18,6 +19,11 @@ def __init__(self):
"""Create a Session object and set the is_good_response callback."""
super().__init__()

# The `pool_connections` argument indicates the maximum number of
# open connections allowed at a time. This value is set to 10 for
# consistency with the micro-http's `MAX_CONNECTIONS`.
self.mount(DEFAULT_SCHEME, UnixAdapter(pool_connections=10))

def is_good_response(response: int):
"""Return `True` for all HTTP 2xx response codes."""
return 200 <= response < 300
Expand Down