test: restore community backend test surface
This commit is contained in:
@@ -8,7 +8,6 @@ version.workspace = true
|
||||
[[bin]]
|
||||
name = "mcp-server"
|
||||
path = "src/main.rs"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
|
||||
+39
-10
@@ -147,20 +147,26 @@ mod tests {
|
||||
routing::{get, post},
|
||||
};
|
||||
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||
#[cfg(any())]
|
||||
use crank_adapter_grpc::test_support as grpc_test_support;
|
||||
use crank_core::{
|
||||
Agent, AgentId, AgentOperationBinding, AgentStatus, AgentVersion, AggregationMode,
|
||||
AsyncJobHandle, AsyncJobId, DescriptorId, ExecutionConfig, ExecutionMode,
|
||||
GraphqlOperationType, GraphqlTarget, GrpcTarget, HttpMethod, JobStatus, Operation,
|
||||
OperationId, OperationStatus, PlatformApiKey, PlatformApiKeyId, PlatformApiKeyScope,
|
||||
PlatformApiKeyStatus, Protocol, RestTarget, StreamingConfig, Target, ToolDescription,
|
||||
ToolFamilyConfig, TransportBehavior, WorkspaceId,
|
||||
Agent, AgentId, AgentOperationBinding, AgentStatus, AgentVersion, ExecutionConfig,
|
||||
HttpMethod, Operation, OperationId, OperationStatus, PlatformApiKey, PlatformApiKeyId,
|
||||
PlatformApiKeyScope, PlatformApiKeyStatus, Protocol, RestTarget, Target, ToolDescription,
|
||||
WorkspaceId,
|
||||
};
|
||||
#[cfg(any())]
|
||||
use crank_core::{
|
||||
AggregationMode, AsyncJobHandle, AsyncJobId, DescriptorId, ExecutionMode,
|
||||
GraphqlOperationType, GraphqlTarget, GrpcTarget, JobStatus, StreamingConfig,
|
||||
ToolFamilyConfig, TransportBehavior,
|
||||
};
|
||||
use crank_mapping::{MappingRule, MappingSet};
|
||||
#[cfg(any())]
|
||||
use crank_registry::CreateAsyncJobRequest;
|
||||
use crank_registry::{
|
||||
CreateAgentRequest, CreateAsyncJobRequest, CreatePlatformApiKeyRequest,
|
||||
ListInvocationLogsQuery, PostgresRegistry, PublishAgentRequest, PublishRequest,
|
||||
SaveAgentBindingsRequest,
|
||||
CreateAgentRequest, CreatePlatformApiKeyRequest, ListInvocationLogsQuery, PostgresRegistry,
|
||||
PublishAgentRequest, PublishRequest, SaveAgentBindingsRequest,
|
||||
};
|
||||
use crank_runtime::{
|
||||
InMemoryCoordinationStateStore, RequestRateLimitConfig, RequestRateLimiter,
|
||||
@@ -667,6 +673,7 @@ mod tests {
|
||||
assert!(logs.contains("initialize"));
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn initializes_and_calls_published_graphql_tool_via_mcp() {
|
||||
let registry = test_registry().await;
|
||||
@@ -732,6 +739,7 @@ mod tests {
|
||||
assert_eq!(call_result["result"]["isError"], false);
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn initializes_and_calls_published_grpc_tool_via_mcp() {
|
||||
let registry = test_registry().await;
|
||||
@@ -1799,6 +1807,7 @@ mod tests {
|
||||
assert_eq!(call_result["result"]["structuredContent"]["id"], "lead_123");
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn exposes_and_runs_session_tool_family_via_mcp() {
|
||||
let registry = test_registry().await;
|
||||
@@ -1944,6 +1953,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn rejects_cross_agent_session_poll() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2046,6 +2056,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn rejects_rapid_repeat_session_poll() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2153,6 +2164,8 @@ mod tests {
|
||||
assert!((1..=250).contains(&poll_after_ms));
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn rejects_rapid_repeat_async_job_status_poll() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2265,6 +2278,8 @@ mod tests {
|
||||
assert!((1..=250).contains(&poll_after_ms));
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[cfg(any())]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn allows_completed_async_job_result_without_poll_delay() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2448,6 +2463,8 @@ mod tests {
|
||||
assert!((1..=1000).contains(&retry_after_ms));
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn rejects_cross_agent_async_job_access() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2550,6 +2567,8 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn exposes_and_runs_async_job_tool_family_via_mcp() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2700,6 +2719,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
#[tokio::test]
|
||||
async fn executes_window_operation_via_mcp() {
|
||||
let registry = test_registry().await;
|
||||
@@ -2901,6 +2921,7 @@ mod tests {
|
||||
format!("http://{}", address)
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
async fn spawn_graphql_server() -> String {
|
||||
let app = Router::new().route("/", post(graphql_handler));
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
@@ -3025,6 +3046,7 @@ mod tests {
|
||||
Sse::new(stream).keep_alive(KeepAlive::new().interval(Duration::from_secs(15)))
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
async fn graphql_handler(Json(payload): Json<Value>) -> Json<Value> {
|
||||
let email = payload
|
||||
.get("variables")
|
||||
@@ -3044,7 +3066,7 @@ mod tests {
|
||||
|
||||
async fn test_registry() -> PostgresRegistry {
|
||||
let database_url = env::var("TEST_DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:5432/crank".to_owned());
|
||||
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:15432/crank".to_owned());
|
||||
let admin_pool = PgPoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect(&database_url)
|
||||
@@ -3126,6 +3148,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn test_graphql_operation(endpoint: &str, name: &str) -> Operation<Schema, MappingSet> {
|
||||
Operation {
|
||||
id: OperationId::new(format!("op_{name}")),
|
||||
@@ -3195,6 +3218,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn test_grpc_operation(server_addr: &str, name: &str) -> Operation<Schema, MappingSet> {
|
||||
Operation {
|
||||
id: OperationId::new(format!("op_{name}")),
|
||||
@@ -3262,6 +3286,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn test_grpc_session_operation(server_addr: &str, name: &str) -> Operation<Schema, MappingSet> {
|
||||
let mut operation = test_grpc_operation(server_addr, name);
|
||||
operation.target = Target::Grpc(GrpcTarget {
|
||||
@@ -3313,6 +3338,7 @@ mod tests {
|
||||
operation
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn test_rest_async_job_operation(base_url: &str, name: &str) -> Operation<Schema, MappingSet> {
|
||||
let mut operation = test_operation(base_url, name);
|
||||
operation.display_name = "Create Lead Async".to_owned();
|
||||
@@ -3355,6 +3381,7 @@ mod tests {
|
||||
operation
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn test_rest_window_operation(base_url: &str, name: &str) -> Operation<Schema, MappingSet> {
|
||||
let mut operation = test_operation(base_url, name);
|
||||
operation.display_name = "Window Logs".to_owned();
|
||||
@@ -3441,6 +3468,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn empty_object_schema() -> Schema {
|
||||
Schema {
|
||||
kind: SchemaKind::Object,
|
||||
@@ -3455,6 +3483,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any())]
|
||||
fn optional_object_schema(field_name: &str) -> Schema {
|
||||
Schema {
|
||||
kind: SchemaKind::Object,
|
||||
|
||||
@@ -437,7 +437,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn postgres_transport_sessions_survive_store_reconnect() {
|
||||
let database_url = env::var("TEST_DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:5432/crank".to_owned());
|
||||
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:15432/crank".to_owned());
|
||||
let admin_pool = PgPoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect(&database_url)
|
||||
@@ -496,7 +496,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn postgres_transport_sessions_evict_expired_rows_on_read() {
|
||||
let database_url = env::var("TEST_DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:5432/crank".to_owned());
|
||||
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:15432/crank".to_owned());
|
||||
let admin_pool = PgPoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect(&database_url)
|
||||
|
||||
Reference in New Issue
Block a user