Skip to content

Commit

Permalink
Add integration test to test for accept-encoding: gzip (#883)
Browse files Browse the repository at this point in the history
* add integration test to test for accept-encoding

* typo
  • Loading branch information
thomasht86 authored Aug 21, 2024
1 parent 668328e commit f79700e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/integration/test_integration_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,32 @@ async def async_is_http2_client(self, app):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.http_version, "HTTP/2")

def sync_client_accept_encoding_gzip(self, app):
data = {
"yql": "select * from sources * where true",
"hits": 10,
}
with app.syncio() as sync_app:
response = sync_app.http_session.post(app.search_end_point, json=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["content-encoding"], "gzip")
# Check that gzip is in request headers
self.assertIn("gzip", response.request.headers["Accept-Encoding"])

async def async_client_accept_encoding_gzip(self, app):
data = {
"yql": "select * from sources * where true",
"hits": 10,
}
async with app.asyncio() as async_app:
response = await async_app.httpx_client.post(
app.search_end_point, json=data
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["content-encoding"], "gzip")
# Check that gzip is in request headers
self.assertIn("gzip", response.request.headers["Accept-Encoding"])

def execute_data_operations(
self,
app,
Expand Down Expand Up @@ -946,6 +972,12 @@ def setUp(self) -> None:
def test_is_using_http2_client(self):
asyncio.run(self.async_is_http2_client(app=self.app))

def test_sync_client_accept_encoding(self):
self.sync_client_accept_encoding_gzip(app=self.app)

def test_async_client_accept_encoding(self):
asyncio.run(self.async_client_accept_encoding_gzip(app=self.app))

def test_handle_longlived_connection(self):
asyncio.run(self.handle_longlived_connection(app=self.app))

Expand Down Expand Up @@ -1102,6 +1134,12 @@ def sentence_to_doc(sentences):
)
self.app.delete_all_docs(content_cluster_name="qa_content", schema="sentence")

def test_sync_client_accept_encoding(self):
self.sync_client_accept_encoding_gzip(app=self.app)

def test_async_client_accept_encoding(self):
asyncio.run(self.async_client_accept_encoding_gzip(app=self.app))

def tearDown(self) -> None:
self.vespa_docker.container.stop(timeout=CONTAINER_STOP_TIMEOUT)
self.vespa_docker.container.remove()
Expand Down

0 comments on commit f79700e

Please sign in to comment.