Add full integration tests and more debug outout
This commit is contained in:
parent
d6640abcbd
commit
2ecb214510
|
|
@ -69,7 +69,8 @@ KompanionQtServer::KompanionQtServer(const QString &backend, KomMcpServer *logic
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
addRequestHandler([this](const QUuid &, const QMcpCallToolRequest &request, QMcpJSONRPCErrorError *error) {
|
addRequestHandler([this](const QUuid &correlationId, const QMcpCallToolRequest &request, QMcpJSONRPCErrorError *error) {
|
||||||
|
qDebug() << "KompanionQtServer: Received tool call request:" << correlationId;
|
||||||
QMcpCallToolResult result;
|
QMcpCallToolResult result;
|
||||||
|
|
||||||
if (!m_logic) {
|
if (!m_logic) {
|
||||||
|
|
@ -138,7 +139,9 @@ KompanionQtServer::KompanionQtServer(const QString &backend, KomMcpServer *logic
|
||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray payload = QJsonDocument(args).toJson(QJsonDocument::Compact);
|
const QByteArray payload = QJsonDocument(args).toJson(QJsonDocument::Compact);
|
||||||
|
qDebug() << "KompanionQtServer: Dispatching payload:" << payload;
|
||||||
const std::string responseStr = m_logic->dispatch(toolKey, payload.toStdString());
|
const std::string responseStr = m_logic->dispatch(toolKey, payload.toStdString());
|
||||||
|
qDebug() << "KompanionQtServer: Received response:" << responseStr.c_str();
|
||||||
const QByteArray jsonBytes = QByteArray::fromStdString(responseStr);
|
const QByteArray jsonBytes = QByteArray::fromStdString(responseStr);
|
||||||
|
|
||||||
QJsonParseError parseError{};
|
QJsonParseError parseError{};
|
||||||
|
|
@ -158,6 +161,7 @@ KompanionQtServer::KompanionQtServer(const QString &backend, KomMcpServer *logic
|
||||||
|
|
||||||
QList<QMcpTool> KompanionQtServer::loadToolsFromSchema() const
|
QList<QMcpTool> KompanionQtServer::loadToolsFromSchema() const
|
||||||
{
|
{
|
||||||
|
qDebug() << "KompanionQtServer: Loading tools from schema...";
|
||||||
QList<QMcpTool> tools;
|
QList<QMcpTool> tools;
|
||||||
QFile kSchemaResource(":/kompanion/ToolSchemas.json");
|
QFile kSchemaResource(":/kompanion/ToolSchemas.json");
|
||||||
if (!kSchemaResource.open(QIODevice::ReadOnly)) {
|
if (!kSchemaResource.open(QIODevice::ReadOnly)) {
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,9 @@ target_link_libraries(test_memory_exchange PRIVATE kom_dal)
|
||||||
target_compile_options(test_memory_exchange PRIVATE -fexceptions)
|
target_compile_options(test_memory_exchange PRIVATE -fexceptions)
|
||||||
|
|
||||||
add_test(NAME mcp_memory_exchange COMMAND test_memory_exchange)
|
add_test(NAME mcp_memory_exchange COMMAND test_memory_exchange)
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME e2e_mcp_test
|
||||||
|
COMMAND /bin/bash ${CMAKE_CURRENT_SOURCE_DIR}/e2e_mcp_test.sh
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ MCP_SERVER_URL="http://${MCP_SERVER_HOST}:${MCP_SERVER_PORT}"
|
||||||
# --- Cleanup Function ---
|
# --- Cleanup Function ---
|
||||||
cleanup() {
|
cleanup() {
|
||||||
echo "--- Cleaning up ---"
|
echo "--- Cleaning up ---"
|
||||||
|
if [ -n "$mcp_server_pid" ]; then
|
||||||
|
kill "$mcp_server_pid" || true
|
||||||
|
fi
|
||||||
pkill -f kom_mcp || true
|
pkill -f kom_mcp || true
|
||||||
sleep 1 # Give the OS time to release the port
|
sleep 1 # Give the OS time to release the port
|
||||||
netstat -tuln | grep ":${MCP_SERVER_PORT}" || true # Check if port is still in use
|
netstat -tuln | grep ":${MCP_SERVER_PORT}" || true # Check if port is still in use
|
||||||
|
|
@ -31,10 +34,13 @@ export DB_URL="dbname=${TEST_DB_NAME} user=kompanion host=/var/run/postgresql" E
|
||||||
python3 "${PROJECT_ROOT_DIR}/tools/ingest_dir.py" "${PROJECT_ROOT_DIR}/tests/test_data" "dev_knowledge"
|
python3 "${PROJECT_ROOT_DIR}/tools/ingest_dir.py" "${PROJECT_ROOT_DIR}/tests/test_data" "dev_knowledge"
|
||||||
|
|
||||||
echo ">> Starting MCP server..."
|
echo ">> Starting MCP server..."
|
||||||
$MCP_SERVER_EXECUTABLE --backend sse --address "${MCP_SERVER_HOST}:${MCP_SERVER_PORT}" &
|
sleep 2
|
||||||
|
timeout 10 $MCP_SERVER_EXECUTABLE --backend sse --address "${MCP_SERVER_HOST}:${MCP_SERVER_PORT}" < /dev/null > /dev/null 2>&1 &
|
||||||
|
mcp_server_pid=$!
|
||||||
mcp_server_pid=$!
|
mcp_server_pid=$!
|
||||||
|
|
||||||
sleep 3
|
sleep 5
|
||||||
|
ps -ef | grep kom_mcp
|
||||||
|
|
||||||
# --- API Test Functions ---
|
# --- API Test Functions ---
|
||||||
|
|
||||||
|
|
@ -47,9 +53,9 @@ send_request() {
|
||||||
# --- Running API tests ---
|
# --- Running API tests ---
|
||||||
|
|
||||||
echo "--> Establishing SSE connection..."
|
echo "--> Establishing SSE connection..."
|
||||||
SSE_RESPONSE=$(curl -s -N -H "Accept:text/event-stream" "${MCP_SERVER_URL}/")
|
SSE_RESPONSE=$(curl -s -N -H "Accept:text/event-stream" "${MCP_SERVER_URL}/sse")
|
||||||
sleep 1 # Give the server time to send the response
|
sleep 1 # Give the server time to send the response
|
||||||
SESSION_ID=$(echo "$SSE_RESPONSE" | grep -oE 'data: /messages/\?session_id=([a-f0-9-]+)' | cut -d '=' -f 2)
|
SESSION_ID=$(echo "$SSE_RESPONSE" | grep -m 1 -oE 'data: /messages/\?session_id=([a-f0-9-]+)' | cut -d '=' -f 2)
|
||||||
|
|
||||||
if [ -z "$SESSION_ID" ]; then
|
if [ -z "$SESSION_ID" ]; then
|
||||||
echo "Failed to get session ID"
|
echo "Failed to get session ID"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue