Skip to content

Commit c1ef2db

Browse files
committed
Add test for llm
Signed-off-by: Ryan Levick <[email protected]>
1 parent 1ba24e3 commit c1ef2db

File tree

10 files changed

+688
-30
lines changed

10 files changed

+688
-30
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/e2e-testing/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ doctest = false
1010
[dependencies]
1111
anyhow = "1.0"
1212
async-trait = "0.1"
13-
tokio = { version = "1.23", features = [ "full" ] }
14-
hyper = { version = "0.14", features = [ "full" ] }
13+
tokio = { version = "1.23", features = ["full"] }
1514
regex = "1.5.5"
1615
reqwest = { version = "0.11", features = ["blocking"] }
1716
nix = "0.26.1"
1817
url = "2.2.2"
1918
derive_builder = "0.12.0"
2019
hyper-tls = "0.5.0"
21-
tempfile = "3.3.0"
20+
tempfile = "3.3.0"

crates/e2e-testing/src/http_asserts.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use crate::ensure_eq;
22
use anyhow::Result;
3-
use hyper::client::HttpConnector;
4-
use hyper::{body, Body, Client, Method, Request, Response};
5-
use hyper_tls::HttpsConnector;
3+
use reqwest::{Method, Request, Response};
64
use std::str;
75

86
pub async fn assert_status(url: &str, expected: u16) -> Result<()> {
97
let resp = make_request(Method::GET, url, "").await?;
108
let status = resp.status();
119

12-
let response = body::to_bytes(resp.into_body()).await.unwrap().to_vec();
13-
let actual_body = str::from_utf8(&response).unwrap().to_string();
10+
let body = resp.bytes().await?;
11+
let actual_body = str::from_utf8(&body).unwrap().to_string();
1412

1513
ensure_eq!(status, expected, "{}", actual_body);
1614

@@ -29,8 +27,8 @@ pub async fn assert_http_response(
2927

3028
let status = res.status();
3129
let headers = res.headers().clone();
32-
let response = body::to_bytes(res.into_body()).await.unwrap().to_vec();
33-
let actual_body = str::from_utf8(&response).unwrap().to_string();
30+
let body = res.bytes().await?;
31+
let actual_body = str::from_utf8(&body).unwrap().to_string();
3432

3533
ensure_eq!(
3634
expected,
@@ -55,26 +53,15 @@ pub async fn assert_http_response(
5553
Ok(())
5654
}
5755

58-
pub async fn create_request(method: Method, url: &str, body: &str) -> Result<Request<Body>> {
59-
let req = Request::builder()
60-
.method(method)
61-
.uri(url)
62-
.body(Body::from(body.to_string()))
63-
.expect("request builder");
56+
pub async fn create_request(method: Method, url: &str, body: &str) -> Result<Request> {
57+
let mut req = reqwest::Request::new(method, url.try_into()?);
58+
*req.body_mut() = Some(body.to_owned().into());
6459

6560
Ok(req)
6661
}
6762

68-
pub fn create_client() -> Client<HttpsConnector<HttpConnector>> {
69-
let connector = HttpsConnector::new();
70-
Client::builder()
71-
.pool_max_idle_per_host(0)
72-
.build::<_, hyper::Body>(connector)
73-
}
74-
75-
pub async fn make_request(method: Method, path: &str, body: &str) -> Result<Response<Body>> {
76-
let c = create_client();
77-
let req = create_request(method, path, body);
78-
let resp = c.request(req.await?).await.unwrap();
79-
Ok(resp)
63+
pub async fn make_request(method: Method, path: &str, body: &str) -> Result<Response> {
64+
let req = create_request(method, path, body).await?;
65+
let client = reqwest::Client::new();
66+
Ok(client.execute(req).await?)
8067
}

sdk/rust/src/http.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ impl Response {
262262
ResponseBuilder { response: self }
263263
}
264264

265-
fn builder() -> ResponseBuilder {
265+
/// Creates a [`ResponseBuilder`]
266+
pub fn builder() -> ResponseBuilder {
266267
ResponseBuilder::new(200)
267268
}
268269
}

tests/spinup_tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ mod spinup_tests {
103103
testcases::head_rust_sdk_redis(CONTROLLER).await
104104
}
105105

106+
#[tokio::test]
107+
async fn llm_works() {
108+
testcases::llm_works(CONTROLLER).await
109+
}
110+
106111
#[tokio::test]
107112
async fn header_env_routes_works() {
108113
testcases::header_env_routes_works(CONTROLLER).await

0 commit comments

Comments
 (0)