Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 12 #15

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lotman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@
// Add name
output_obj["lot_name"] = lot_name;

// Add owner(s) according to recursive flag

Check warning on line 1510 in src/lotman.cpp

View workflow job for this annotation

GitHub Actions / Run linters

[lint] reported by reviewdog 🐶 Raw Output: src/lotman.cpp:1510:- // Add owner(s) according to recursive flag src/lotman.cpp:1511:- std::pair<std::vector<std::string>, std::string> rp_vec_str; src/lotman.cpp:1512:- rp_vec_str = lot.get_owners(recursive); src/lotman.cpp:1513:- if (!rp_vec_str.second.empty()) { // There was an error src/lotman.cpp:1514:- if (err_msg) { src/lotman.cpp:1515:- std::string int_err = rp_vec_str.second; src/lotman.cpp:1516:- std::string ext_err = "Failure on call to get_owners: "; src/lotman.cpp:1517:- *err_msg = strdup((ext_err + int_err).c_str()); src/lotman.cpp:1518:- } src/lotman.cpp:1519:- return -1; src/lotman.cpp:1520:- } src/lotman.cpp:1521:- if (recursive) { src/lotman.cpp:1522:- output_obj["owners"] = rp_vec_str.first; src/lotman.cpp:1523:- } src/lotman.cpp:1524:- else { src/lotman.cpp:1525:- output_obj["owner"] = rp_vec_str.first[0]; // Only one owner, this is where it will be. src/lotman.cpp:1526:- } src/lotman.cpp:1527:- src/lotman.cpp:1528:- // Add parents according to recursive flag src/lotman.cpp:1529:- std::pair<std::vector<lotman::Lot>, std::string> rp_lotvec_str; src/lotman.cpp:1530:- rp_lotvec_str = lot.get_parents(recursive, true); src/lotman.cpp:1531:- if (!rp_lotvec_str.second.empty()) { // There was an error src/lotman.cpp:1532:- if (err_msg) { src/lotman.cpp:1533:- std::string int_err = rp_lotvec_str.second; src/lotman.cpp:1534:- std::string ext_err = "Failure on call to get_parents: "; src/lotman.cpp:1535:- *err_msg = strdup((ext_err + int_err).c_str()); src/lotman.cpp:1536:- } src/lotman.cpp:1537:- return -1; src/lotman.cpp:1538:- } src/lotman.cpp:1539:- std::vector<std::string> tmp; src/lotman.cpp:1540:- for (const auto &parent : rp_lotvec_str.first) { src/lotman.cpp:1541:- tmp.push_back(parent.lot_name); src/lotman.cpp:1542:- } src/lotman.cpp:1543:- output_obj["parents"] = tmp; src/lotman.cpp:1544:- src/lotman.cpp:1545:- // Add children according to recursive flag src/lotman.cpp:1546:- rp_lotvec_str = lot.get_children(recursive, false); src/lotman.cpp:1547:- if (!rp_lotvec_str.second.empty()) { // There was an error src/lotman.cpp:1548:- if (err_msg) { src/lotman.cpp:1549:- std::string int_err = rp_lotvec_str.second; src/lotman.cpp:1550:- std::string ext_err = "Failure on call to get_children: "; src/lotman.cpp:1551:- *err_msg = strdup((ext_err + int_err).c_str()); src/lotman.cpp:1552:- } src/lotman.cpp:1553:- return -1; src/lotman.cpp:1554:- } src/lotman.cpp:1555:- tmp = {}; src/lotman.cpp:1556:- for (const auto &child : rp_lotvec_str.first) { src/lotman.cpp:1557:- tmp.push_back(child.lot_name); src/lotman.cpp:1558:- } src/lotman.cpp:1559:- output_obj["children"] = tmp; src/lotman.cpp:1560:- src/lotman.cpp:1561:- // Add paths according to recursive flag src/lotman.cpp:1562:- std::pair<json, std::string> rp_json_str; src/lotman.cpp:1563:- rp_json_str = lot.get_lot_dirs(recursive); src/lotman.cpp:1648:+ if (recursive) { src/lotman.cpp:1649:+ rp_json_str = lot.get_restricting_attribute(key, true);
std::pair<std::vector<std::string>, std::string> rp_vec_str;
rp_vec_str = lot.get_owners(recursive);
if (!rp_vec_str.second.empty()) { // There was an error
Expand All @@ -1522,7 +1522,7 @@
output_obj["owners"] = rp_vec_str.first;
}
else {
output_obj["owners"] = rp_vec_str.first[0]; // Only one owner, this is where it will be.
output_obj["owner"] = rp_vec_str.first[0]; // Only one owner, this is where it will be.
}

// Add parents according to recursive flag
Expand Down
2 changes: 1 addition & 1 deletion test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@
ASSERT_TRUE(size == 7);
lotman_free_string_list(output);
}

Check warning on line 607 in test/main.cpp

View workflow job for this annotation

GitHub Actions / Run linters

[lint] reported by reviewdog 🐶 Raw Output: test/main.cpp:607:- test/main.cpp:608:- TEST_F(LotManTest, GetLotJSONTest) { test/main.cpp:609:- // Try to get a lot that doesn't exist test/main.cpp:610:- char *err_msg; test/main.cpp:611:- char *output; test/main.cpp:612:- auto rv = lotman_get_lot_as_json("non_existent_lot", true, &output, &err_msg); test/main.cpp:613:- ASSERT_FALSE(rv == 0); test/main.cpp:614:- free(err_msg); test/main.cpp:615:- test/main.cpp:616:- // Non-recursive test test/main.cpp:617:- char *err_msg2; test/main.cpp:618:- rv = lotman_get_lot_as_json("lot3", false, &output, &err_msg); test/main.cpp:619:- ASSERT_TRUE(rv == 0) << err_msg; test/main.cpp:620:- json output_JSON = json::parse(output); test/main.cpp:621:- free(output); test/main.cpp:622:- json expected_output = R"({"children":["lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":123.0,"dedicated_GB":10.111,"deletion_time":333.0,"expiration_time":222.0,"max_num_objects":50.0,"opportunistic_GB":6.6},"owner":"not owner1","parents":["lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true}],"usage":{"GB_being_written":{"self_contrib":0.0},"dedicated_GB":{"self_contrib":0.0},"num_objects":{"self_contrib":0.0},"objects_being_written":{"self_contrib":0.0},"opportunistic_GB":{"self_contrib":0.0},"total_GB":{"self_contrib":0.0}}})"_json; test/main.cpp:623:- ASSERT_TRUE(output_JSON == expected_output) << output_JSON; test/main.cpp:624:- test/main.cpp:625:- char *output2; test/main.cpp:626:- rv = lotman_get_lot_as_json("lot3", true, &output2, &err_msg); test/main.cpp:627:- ASSERT_TRUE(rv == 0); test/main.cpp:628:- json output_JSON2 = json::parse(output2); test/main.cpp:629:- free(output2); test/main.cpp:630:- json expected_output2 = R"({"children":["lot4","lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":123.0,"dedicated_GB":10.111,"deletion_time":333.0,"expiration_time":222.0,"max_num_objects":50.0,"opportunistic_GB":6.6},"owners":["not owner1","owner1"],"parents":["lot1","lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true},{"lot_name":"lot4","path":"/1/2/3/4","recursive":true},{"lot_name":"lot4","path":"/345","recursive":true},{"lot_name":"lot5","path":"/456","recursive":false},{"lot_name":"lot5","path":"/567","recursive":true}],"restrictive_management_policy_attrs":{"creation_time":{"lot_name":"lot3","value":123.0},"dedicated_GB":{"lot_name":"sep_node","value":3.0},"deletion_time":{"lot_name":"lot3","value":333.0},"expiration_time":{"lot_name":"lot3","value":222.0},"max_num_objects":{"lot_name":"sep_node","value":10.0},"opportunistic_GB":{"lot_name":"lot2","value":1.5}},"usage":{"GB_being_written":{"children_contrib":3.4,"self_contrib":0.0,"total":3.4},"dedicated_GB":{"children_contrib":8.64,"self_contrib":0.0,"total":8.64},"num_objects":{"children_contrib":10.0,"self_contrib":0.0,"total":10.0},"objects_being_written":{"children_contrib":7.0,"self_contrib":0.0,"total":7.0},"opportunistic_GB":{"children_contrib":0.0,"self_contrib":0.0,"total":0.0},"total_GB":{"children_contrib":8.64,"self_contrib":0.0,"total":8.64}}})"_json; test/main.cpp:631:- ASSERT_TRUE(output_JSON2 == expected_output2) << output_JSON2; test/main.cpp:721:+ } test/main.cpp:722:+ ASSERT_FALSE(check); test/main.cpp:723:+ lotman_free_string_list(output2); test/main.cpp:724:+ test/main.cpp:725:+ // Check for lots past opportunistic storage limit test/main.cpp:726:+ char **output3; test/main.cpp:727:+ rv = lotman_get_lots_past_opp(true, true, &output3, &err_msg); test/main.cpp:728:+ ASSERT_TRUE(rv == 0) << err_msg; test/main.cpp:729:+ test/main.cpp:730:+ check = false; test/main.cpp:731:+ for (int iter = 0
TEST_F(LotManTest, GetLotJSONTest) {
// Try to get a lot that doesn't exist
char *err_msg;
Expand All @@ -619,7 +619,7 @@
ASSERT_TRUE(rv == 0) << err_msg;
json output_JSON = json::parse(output);
free(output);
json expected_output = R"({"children":["lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":123.0,"dedicated_GB":10.111,"deletion_time":333.0,"expiration_time":222.0,"max_num_objects":50.0,"opportunistic_GB":6.6},"owners":"not owner1","parents":["lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true}],"usage":{"GB_being_written":{"self_contrib":0.0},"dedicated_GB":{"self_contrib":0.0},"num_objects":{"self_contrib":0.0},"objects_being_written":{"self_contrib":0.0},"opportunistic_GB":{"self_contrib":0.0},"total_GB":{"self_contrib":0.0}}})"_json;
json expected_output = R"({"children":["lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":123.0,"dedicated_GB":10.111,"deletion_time":333.0,"expiration_time":222.0,"max_num_objects":50.0,"opportunistic_GB":6.6},"owner":"not owner1","parents":["lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true}],"usage":{"GB_being_written":{"self_contrib":0.0},"dedicated_GB":{"self_contrib":0.0},"num_objects":{"self_contrib":0.0},"objects_being_written":{"self_contrib":0.0},"opportunistic_GB":{"self_contrib":0.0},"total_GB":{"self_contrib":0.0}}})"_json;
ASSERT_TRUE(output_JSON == expected_output) << output_JSON;

char *output2;
Expand Down
Loading