Organize RAG test files properly and update .gitignore

- Move RAG test files to dedicated test/rag/ directory
- Create proper Makefile in test/rag/ directory
- Remove build_rag_test.sh script (replaced by Makefile)
- Update .gitignore to exclude test/rag/test_rag_schema executable
- Update documentation to reflect new test structure
pull/5318/head
Rene Cannao 4 weeks ago
parent acd05b60a9
commit 7a7872f078

1
.gitignore vendored

@ -125,6 +125,7 @@ test/.vagrant
.DS_Store
proxysql-tests.ini
test/sqlite_history_convert
test/rag/test_rag_schema
#heaptrack
heaptrack.*

@ -1,31 +1,9 @@
#!/bin/make -f
PROXYSQL_PATH := $(shell while [ ! -f ./src/proxysql_global.cpp ]; do cd ../..; done; pwd)
include $(PROXYSQL_PATH)/include/makefiles_vars.mk
include $(PROXYSQL_PATH)/include/makefiles_paths.mk
IDIRS := -I$(PROXYSQL_IDIR) \
-I$(JEMALLOC_IDIR) \
-I$(MARIADB_IDIR) \
-I$(LIBCONFIG_IDIR) \
-I$(RE2_IDIR) \
-I$(SQLITE3_IDIR) \
-I$(PCRE_IDIR) \
-I$(SYS_LOC_IDIR) \
-I$(CLICKHOUSE_CPP_IDIR) \
-I$(MICROHTTPD_IDIR) \
-I$(LIBHTTPSERVER_IDIR) \
-I$(LIBINJECTION_IDIR) \
-I$(CURL_IDIR) \
-I$(EV_IDIR) \
-I$(JSON_IDIR) \
-I$(SSL_IDIR)
test_rag_schema: test_rag_schema.cpp
$(CXX) -ggdb $(PROXYSQL_OBJS) test_rag_schema.cpp -o test_rag_schema $(IDIRS) $(LDIRS) $(PROXYSQL_LIBS)
g++ -ggdb test_rag_schema.cpp ../../deps/sqlite3/libsqlite_rembed.a ../../deps/sqlite3/sqlite3/libsqlite3.so -o test_rag_schema -I../../deps/sqlite3/sqlite3 -lssl -lcrypto
clean:
rm -f test_rag_schema
.PHONY: clean
.PHONY: clean

@ -5,7 +5,7 @@
* Simple test to verify that RAG tables are created correctly in the vector database.
*/
#include "sqlite3db.h"
#include "sqlite3.h"
#include <iostream>
#include <vector>
#include <string>
@ -25,18 +25,26 @@ const std::vector<std::string> RAG_VIEWS = {
"rag_chunk_view"
};
static int callback(void *data, int argc, char **argv, char **azColName) {
int *count = (int*)data;
(*count)++;
return 0;
}
int main() {
// Initialize SQLite database
SQLite3DB* db = new SQLite3DB();
sqlite3 *db;
char *zErrMsg = 0;
int rc;
// Open the default vector database path
const char* db_path = "/var/lib/proxysql/ai_features.db";
std::cout << "Testing RAG schema in database: " << db_path << std::endl;
// Try to open the database
if (db->open((char*)db_path) != 0) {
std::cerr << "ERROR: Failed to open database at " << db_path << std::endl;
delete db;
rc = sqlite3_open(db_path, &db);
if (rc) {
std::cerr << "ERROR: Can't open database: " << sqlite3_errmsg(db) << std::endl;
sqlite3_close(db);
return 1;
}
@ -46,66 +54,49 @@ int main() {
bool all_tables_exist = true;
for (const std::string& table_name : RAG_TABLES) {
std::string query = "SELECT name FROM sqlite_master WHERE type='table' AND name='" + table_name + "'";
char* error = nullptr;
int cols = 0;
int affected_rows = 0;
SQLite3_result* result = db->execute_statement(query.c_str(), &error, &cols, &affected_rows);
int count = 0;
rc = sqlite3_exec(db, query.c_str(), callback, &count, &zErrMsg);
if (error) {
std::cerr << "ERROR: SQL error for table " << table_name << ": " << error << std::endl;
sqlite3_free(error);
if (rc != SQLITE_OK) {
std::cerr << "ERROR: SQL error: " << zErrMsg << std::endl;
sqlite3_free(zErrMsg);
all_tables_exist = false;
if (result) delete result;
continue;
}
if (result && result->rows_count() > 0) {
std::cout << "SUCCESS: Table '" << table_name << "' exists" << std::endl;
} else {
} else if (count == 0) {
std::cerr << "ERROR: Table '" << table_name << "' does not exist" << std::endl;
all_tables_exist = false;
} else {
std::cout << "SUCCESS: Table '" << table_name << "' exists" << std::endl;
}
if (result) delete result;
}
// Check if RAG views exist
bool all_views_exist = true;
for (const std::string& view_name : RAG_VIEWS) {
std::string query = "SELECT name FROM sqlite_master WHERE type='view' AND name='" + view_name + "'";
char* error = nullptr;
int cols = 0;
int affected_rows = 0;
SQLite3_result* result = db->execute_statement(query.c_str(), &error, &cols, &affected_rows);
int count = 0;
rc = sqlite3_exec(db, query.c_str(), callback, &count, &zErrMsg);
if (error) {
std::cerr << "ERROR: SQL error for view " << view_name << ": " << error << std::endl;
sqlite3_free(error);
if (rc != SQLITE_OK) {
std::cerr << "ERROR: SQL error: " << zErrMsg << std::endl;
sqlite3_free(zErrMsg);
all_views_exist = false;
if (result) delete result;
continue;
}
if (result && result->rows_count() > 0) {
std::cout << "SUCCESS: View '" << view_name << "' exists" << std::endl;
} else {
} else if (count == 0) {
std::cerr << "ERROR: View '" << view_name << "' does not exist" << std::endl;
all_views_exist = false;
} else {
std::cout << "SUCCESS: View '" << view_name << "' exists" << std::endl;
}
if (result) delete result;
}
// Clean up
db->close();
delete db;
sqlite3_close(db);
// Final result
if (all_tables_exist && all_views_exist) {
std::cout << std::endl << "SUCCESS: All RAG schema objects exist!" << std::endl;
std::cout << "SUCCESS: All RAG schema objects exist" << std::endl;
return 0;
} else {
std::cerr << std::endl << "ERROR: Some RAG schema objects are missing!" << std::endl;
std::cerr << "FAILURE: Some RAG schema objects are missing" << std::endl;
return 1;
}
}
}

Loading…
Cancel
Save