Skip to content

Commit fb1a800

Browse files
authored
[DAPS-1774] - Core, Python, Database, Foxx, Test add query end to end tests (#1779)
* [DAPS-1775] - fix: core, foxx, add missing {}, foxx query_router add params object schema to routes. (#1781) * [DAPS-1777] - fix: foxx, user_router fix regression in missing response. (#1778) * [DAPS-1786] - refactor: web tests, add test for hitting password reset. (#1787) * [DAPS-1277] - fix: mock, core, common, PROXY_BASIC_ZMQ and PROXY_CUSTOM correctly defined * [DAPS-1790] - fix: common, core, repo, zmq assertion failure during EXCEPT call due to callin zmq_msg with invalid state after closing it. * [DAPS-1791] - fix: build, python client, requirements.txt was being moved to a folder named requirements.txt during cmake configure script.
1 parent dfb241a commit fb1a800

File tree

9 files changed

+271
-19
lines changed

9 files changed

+271
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ endif()
200200

201201
if( BUILD_PYTHON_CLIENT )
202202
# make target = pydatafed
203-
file(COPY ${PROJECT_SOURCE_DIR}/external/DataFedDependencies/python/datafed_pkg/requirements.txt DESTINATION ${PROJECT_SOURCE_DIR}/python/datafed_pkg/requirements.txt)
203+
file(COPY ${PROJECT_SOURCE_DIR}/external/DataFedDependencies/python/datafed_pkg/requirements.txt DESTINATION ${PROJECT_SOURCE_DIR}/python/datafed_pkg/)
204204
add_subdirectory( python EXCLUDE_FROM_ALL )
205205
endif()
206206

common/source/ServerFactory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
// Local private includes
33
#include "servers/Proxy.hpp"
4+
#include "servers/ProxyBasicZMQ.hpp"
45

56
// Local public includes
67
#include "common/IServer.hpp"
@@ -39,7 +40,7 @@ std::unique_ptr<IServer> ServerFactory::create(
3940
"been provided that will never be used!");
4041
}
4142
return std::unique_ptr<IServer>(
42-
new Proxy(socket_options, socket_credentials, m_log_context));
43+
new ProxyBasicZMQ(socket_options, socket_credentials, m_log_context));
4344
}
4445

4546
EXCEPT_PARAM(1, "Error Server type unsupported");

common/source/communicators/ZeroMQCommunicator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,11 @@ void receiveBody(IMessage &msg, Buffer &buffer, ProtoBufFactory &factory,
378378
if (frame_size > 0) {
379379

380380
if (zmq_msg_size(&zmq_msg) != frame_size) {
381+
size_t msg_size = zmq_msg_size(&zmq_msg);
381382
zmq_msg_close(&zmq_msg);
382383
EXCEPT_PARAM(1, "RCV Invalid message body received. Expected: "
383384
<< frame_size
384-
<< ", got: " << zmq_msg_size(&zmq_msg));
385+
<< ", got: " << msg_size);
385386
}
386387

387388
copyToBuffer(buffer, zmq_msg_data(&zmq_msg), frame_size);

core/database/foxx/api/query_router.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ router
6666

6767
g_lib.procInputParam(req.body, "title", false, obj);
6868

69-
//console.log("qry/create filter:",obj.qry_filter);
70-
7169
var qry = g_db.q.save(obj, {
7270
returnNew: true,
7371
}).new;
@@ -124,7 +122,7 @@ router
124122
qry_begin: joi.string().required(),
125123
qry_end: joi.string().required(),
126124
qry_filter: joi.string().allow("").required(),
127-
params: joi.any().required(),
125+
params: joi.object().required(),
128126
limit: joi.number().integer().required(),
129127
query: joi.any().required(),
130128
})
@@ -169,6 +167,7 @@ router
169167
qry.qry_begin = req.body.qry_begin;
170168
qry.qry_end = req.body.qry_end;
171169
qry.qry_filter = req.body.qry_filter;
170+
172171
qry.params = req.body.params;
173172
qry.limit = req.body.limit;
174173
qry.query = req.body.query;
@@ -178,7 +177,6 @@ router
178177
qry.params.cols = null;
179178
}*/
180179

181-
//console.log("qry/upd filter:",obj.qry_filter);
182180
qry = g_db._update(qry._id, qry, {
183181
mergeObjects: false,
184182
returnNew: true,
@@ -231,7 +229,7 @@ router
231229
qry_begin: joi.string().required(),
232230
qry_end: joi.string().required(),
233231
qry_filter: joi.string().allow("").required(),
234-
params: joi.any().required(),
232+
params: joi.object().required(),
235233
limit: joi.number().integer().required(),
236234
query: joi.any().required(),
237235
})
@@ -597,10 +595,6 @@ function execQuery(client, mode, published, orig_query) {
597595

598596
qry += query.qry_end;
599597

600-
//console.log( "execqry" );
601-
//console.log( "qry", qry );
602-
//console.log( "params", query.params );
603-
604598
// Enforce query paging limits
605599
if (query.params.cnt > g_lib.MAX_PAGE_SIZE) {
606600
query.params.cnt = g_lib.MAX_PAGE_SIZE;
@@ -725,7 +719,7 @@ router
725719

726720
const query = {
727721
...req.body,
728-
params: JSON.parse(req.body.params),
722+
params: req.body.params,
729723
};
730724
results = execQuery(client, req.body.mode, req.body.published, query);
731725

@@ -762,7 +756,7 @@ router
762756
qry_begin: joi.string().required(),
763757
qry_end: joi.string().required(),
764758
qry_filter: joi.string().optional().allow(""),
765-
params: joi.string().required(),
759+
params: joi.object().required(),
766760
limit: joi.number().integer().required(),
767761
})
768762
.required(),

core/server/CoreServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void Server::msgRouter(LogContext log_context, int thread_count) {
241241
}
242242

243243
ServerFactory server_factory(log_context);
244-
auto proxy = server_factory.create(ServerType::PROXY_BASIC_ZMQ,
244+
auto proxy = server_factory.create(ServerType::PROXY_CUSTOM,
245245
socket_options, socket_credentials);
246246

247247
// Ceate worker threads
@@ -439,7 +439,7 @@ void Server::ioInsecure(LogContext log_context, int thread_count) {
439439
}
440440

441441
ServerFactory server_factory(log_context);
442-
auto proxy = server_factory.create(ServerType::PROXY_BASIC_ZMQ,
442+
auto proxy = server_factory.create(ServerType::PROXY_CUSTOM,
443443
socket_options, socket_credentials);
444444

445445
proxy->run();

core/server/DatabaseAPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ void DatabaseAPI::generalSearch(const Auth::SearchRequest &a_request,
13081308
payload["qry_begin"] = qry_begin;
13091309
payload["qry_end"] = qry_end;
13101310
payload["qry_filter"] = qry_filter;
1311-
payload["params"] = "{" + params + "}";
1311+
payload["params"] = params;
13121312
payload["limit"] = to_string(cnt);
13131313

13141314
string body = payload.dump(-1, ' ', true);
@@ -3942,7 +3942,7 @@ uint32_t DatabaseAPI::parseSearchRequest(const Auth::SearchRequest &a_request,
39423942
a_qry_begin = a_qry_begin;
39433943
a_qry_end = a_qry_end;
39443944
a_qry_filter = a_qry_filter;
3945-
3945+
a_params = "{" + a_params + "}";
39463946
return cnt;
39473947
}
39483948

tests/end-to-end/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if( ENABLE_END_TO_END_API_TESTS )
1010
add_test(NAME end_to_end_alloc COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_api_alloc.py")
1111
add_test(NAME end_to_end_collection COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_api_collection.py")
1212
add_test(NAME end_to_end_record COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_api_record.py")
13+
add_test(NAME end_to_end_query COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_api_query.py")
1314

1415
# Note because these tests are all using the same database we cannot run most of them concurrently
1516
# They must be run sequentially so that concurrent API calls do not create problems
@@ -26,5 +27,7 @@ if( ENABLE_END_TO_END_API_TESTS )
2627
set_tests_properties(end_to_end_alloc PROPERTIES FIXTURES_SETUP FIX_ALLOC)
2728
set_tests_properties(end_to_end_collection PROPERTIES FIXTURES_REQUIRED FIX_ALLOC)
2829
set_tests_properties(end_to_end_record PROPERTIES FIXTURES_REQUIRED FIX_ALLOC)
30+
set_tests_properties(end_to_end_record PROPERTIES FIXTURES_SETUP FIX_RECORD)
31+
set_tests_properties(end_to_end_query PROPERTIES FIXTURES_REQUIRED FIX_RECORD)
2932

3033
endif()

0 commit comments

Comments
 (0)