fix http handler flaky test
@@ -98,32 +98,31 @@ async fn test_bad_sql() -> Result<()> {
}
#[tokio::test]
-#[ignore]
async fn test_async() -> Result<()> {
let ep = create_endpoint();
- let sql = "select sleep(0.2)";
+ let sql = "select sleep(0.01)";
let json = serde_json::json!({"sql": sql.to_string(), "pagination": {"wait_time_secs": 0}});
let (status, result) = post_json_to_endpoint(&ep, &json).await?;
assert_eq!(status, StatusCode::OK);
- let query_id = result.id;
- let next_uri = make_page_uri(&query_id, 0);
+ let query_id = &result.id;
+ let next_uri = make_page_uri(query_id, 0);
+ assert!(result.error.is_none(), "{:?}", result);
assert_eq!(result.data.len(), 0);
- assert!(result.error.is_none(), "{:?}", result.error);
assert_eq!(result.next_uri, Some(next_uri));
assert!(result.stats.progress.is_some());
assert!(result.schema.is_some());
assert_eq!(result.state, ExecuteStateName::Running,);
- sleep(Duration::from_millis(300)).await;
+ sleep(Duration::from_millis(100)).await;
// get page, support retry
for _ in 1..3 {
- let uri = make_page_uri(&query_id, 0);
+ let uri = make_page_uri(query_id, 0);
let (status, result) = get_uri_checked(&ep, &uri).await?;
assert_eq!(status, StatusCode::OK);
- assert_eq!(result.data.len(), 1);
- assert!(result.error.is_none(), "{:?}", result.error);
+ assert!(result.error.is_none(), "{:?}", result);
+ assert_eq!(result.data.len(), 1, "{:?}", result);
assert!(result.next_uri.is_none());
assert!(result.schema.is_none());
assert!(result.stats.progress.is_some());
@@ -131,7 +130,7 @@ async fn test_async() -> Result<()> {
}
// get state
- let uri = make_state_uri(&query_id);
+ let uri = make_state_uri(query_id);
let (status, result) = get_uri_checked(&ep, &uri).await?;
assert_eq!(status, StatusCode::OK);
assert!(result.error.is_none(), "{:?}", result.error);
@@ -142,14 +141,14 @@ async fn test_async() -> Result<()> {
assert_eq!(result.state, ExecuteStateName::Succeeded);
// get page not expected
- let uri = make_page_uri(&query_id, 1);
+ let uri = make_page_uri(query_id, 1);
let response = get_uri(&ep, &uri).await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
let body = response.into_body().into_string().await.unwrap();
assert_eq!(body, "wrong page number 1");
// delete
- let status = delete_query(&ep, query_id.clone()).await;
+ let status = delete_query(&ep, query_id).await;
assert_eq!(status, StatusCode::OK);
let response = get_uri(&ep, &uri).await;
@@ -243,8 +242,8 @@ async fn test_insert() -> Result<()> {
Ok(())
}
-async fn delete_query(ep: &EndpointType, query_id: String) -> StatusCode {
- let uri = make_final_uri(&query_id);
+async fn delete_query(ep: &EndpointType, query_id: &str) -> StatusCode {
+ let uri = make_final_uri(query_id);
let resp = get_uri(ep, &uri).await;
resp.status()
}
