Skip to content

Commit 49937f4

Browse files
authored
182 erroneous read only on server start (#308)
* Update ImageTransactionRollback test and include new test FindImageEmptyDB This test runs a query with 2 FindImage commands on a new/empty PMGD db instance and validates the response contains the excepted message `"No entities found"`. Signed-off-by: Steven Rojas <[email protected]> * Update QueryNode and QueryEdge protobuf construct handler read mode to avoid internal PMGD validation check exception A read-write validation check is performed internally by PMGD. When running a query node/edge transaction with a readOnly flag a validation check will trigger an exception. The exception message will be propagated to the query response. This change allows the validation to pass while technically the transaction is still a readOnly operation. The validation occurs in the PMGD codebase, updating it is not reasonable at this time. Signed-off-by: Steven Rojas <[email protected]> * Restore previous test changes Signed-off-by: Steven Rojas <[email protected]> --------- Signed-off-by: Steven Rojas <[email protected]>
1 parent 605732c commit 49937f4

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/PMGDQuery.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ void PMGDQuery::QueryNode(int ref, const std::string &tag,
676676
const Json::Value &constraints,
677677
const Json::Value &results, bool unique,
678678
bool intermediate_query) {
679+
_readonly = false;
680+
679681
PMGDCmd *cmdquery = new PMGDCmd();
680682
cmdquery->set_cmd_id(PMGDCmd::QueryNode);
681683
cmdquery->set_cmd_grp_id(_current_group_id);
@@ -713,6 +715,8 @@ void PMGDQuery::QueryEdge(int ref, int src_ref, int dest_ref,
713715
const std::string &tag,
714716
const Json::Value &constraints,
715717
const Json::Value &results, bool unique) {
718+
_readonly = false;
719+
716720
PMGDCmd *cmdquery = new PMGDCmd();
717721
cmdquery->set_cmd_id(PMGDCmd::QueryEdge);
718722
cmdquery->set_cmd_grp_id(_current_group_id);

tests/unit_tests/RemoteConnection_test.cc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,58 @@ TEST_F(RemoteConnectionTest, ImageTransactionRollback) {
650650
printErrorMessage("ImageTransactionRollback");
651651
}
652652
}
653+
654+
TEST_F(RemoteConnectionTest, FindImageEmptyDB) {
655+
try {
656+
VDMS::Server VDMS_server("unit_tests/config-aws-tests.json", "", "", "");
657+
658+
QueryHandlerPMGD query_handler;
659+
query_handler.reset_autodelete_init_flag(); // set flag to show autodelete queue has
660+
// been initialized
661+
662+
VDMS::protobufs::queryMessage proto_query;
663+
VDMS::protobufs::queryMessage response;
664+
665+
Json::Reader json_reader;
666+
Json::Value json_response;
667+
668+
std::string string_query_image_lookup("[");
669+
string_query_image_lookup += " \
670+
{ \
671+
\"FindImage\": { \
672+
\"results\": { \
673+
\"list\": [\"name\"] \
674+
}, \
675+
\"constraints\": { \
676+
\"name\": [ \"==\", \"NonExistentImage1\" ] \
677+
} \
678+
} \
679+
}, \
680+
{ \
681+
\"FindImage\": { \
682+
\"results\": { \
683+
\"list\": [\"name\"] \
684+
}, \
685+
\"constraints\": { \
686+
\"name\": [ \"==\", \"NonExistentImage2\" ] \
687+
} \
688+
} \
689+
} \
690+
";
691+
string_query_image_lookup += "]";
692+
693+
proto_query.clear_blobs();
694+
proto_query.set_json(string_query_image_lookup);
695+
696+
query_handler.process_query(proto_query, response);
697+
json_reader.parse(response.json(), json_response);
698+
699+
EXPECT_EQ(json_response[0]["FindImage"]["status"].asString(), "0");
700+
EXPECT_EQ(json_response[0]["FindImage"]["info"], "No entities found");
701+
EXPECT_EQ(json_response[1]["FindImage"]["status"].asString(), "0");
702+
EXPECT_EQ(json_response[1]["FindImage"]["info"], "No entities found");
703+
704+
} catch (...) {
705+
printErrorMessage("FindImageEmptyDB");
706+
}
707+
}

0 commit comments

Comments
 (0)