Fix null MPA values in get_lot_as_json with recursive=true #13
Triggered via pull request
February 22, 2024 22:55
jhiemstrawisc
opened
#14
Status
Failure
Total duration
23s
Artifacts
–
Annotations
3 errors and 10 warnings
Run linters
reviewdog: Too many results (annotations) in diff.
You may miss some annotations due to GitHub limitation for annotation created by logging command.
Please check GitHub Actions log console to see all results.
Limitation:
- 10 warning annotations and 10 error annotations per step
- 50 annotations per job (sum of annotations from all the steps)
- 50 annotations per run (separate from the job annotations, these annotations aren't created by users)
Source: https://github.community/t5/GitHub-Actions/Maximum-number-of-annotations-that-can-be-created-using-GitHub/m-p/39085
|
Run linters
Process completed with exit code 1.
|
Run linters
This action does not have permission to push to forks. You may want to run it only on `push` events.
|
Run linters:
src/lotman.cpp#L861
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman.cpp:861:-int lotman_get_policy_attributes(const char *policy_attributes_JSON_str,
src/lotman.cpp:862:- char **output,
src/lotman.cpp:863:- char **err_msg) {
src/lotman.cpp:864:- try {
src/lotman.cpp:865:- json get_attrs_obj = json::parse(policy_attributes_JSON_str);
src/lotman.cpp:866:-
src/lotman.cpp:867:- // Validate the incoming JSON
src/lotman.cpp:868:- json_validator validator;
src/lotman.cpp:869:- validator.set_root_schema(lotman_schemas::get_policy_attrs_schema);
src/lotman.cpp:870:- validator.validate(get_attrs_obj);
src/lotman.cpp:871:-
src/lotman.cpp:872:- // Assert lot exists
src/lotman.cpp:873:- auto rp = lotman::Lot::lot_exists(get_attrs_obj["lot_name"]);
src/lotman.cpp:874:- if (!rp.first) {
src/lotman.cpp:875:- if (err_msg) {
src/lotman.cpp:876:- if (rp.second.empty()) { // function worked, but lot does not exist
src/lotman.cpp:877:- *err_msg = strdup("That was easy! The lot does not exist, so it has no policy attributes.");
src/lotman.cpp:878:- }
src/lotman.cpp:879:- else {
src/lotman.cpp:880:- std::string int_err = rp.second;
src/lotman.cpp:881:- std::string ext_err = "Function call to lotman::Lot::lot_exists failed: ";
src/lotman.cpp:882:- *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:883:- }
src/lotman.cpp:884:- return -1;
src/lotman.cpp:885:- }
src/lotman.cpp:886:- }
src/lotman.cpp:887:-
src/lotman.cpp:888:- lotman::Lot lot(get_attrs_obj["lot_name"].get<std::string>());
src/lotman.cpp:889:-
src/lotman.cpp:890:- json output_obj;
src/lotman.cpp:891:- for (const auto &pair : get_attrs_obj.items()) {
src/lotman.cpp:892:- if (pair.key() != "lot_name") {
src/lotman.cpp:893:- auto rp_json_bool = lot.get_restricting_attribute(pair.key(), pair.value());
src/lotman.cpp:894:- if (!rp_json_bool.second.empty()) { // There was an error
src/lotman.cpp:895:- if (err_msg) {
src/lotman.cpp:896:- std::string int_err = rp.second;
src/lotman.cpp:897:- std::string ext_err = "Failed to initialize lot name: ";
src/lotman.cpp:898:- *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:899:- }
src/lotman.cpp:900:- return -1;
src/lotman.cpp:901:- }
src/lotman.cpp:902:- if (pair.value() == "true") {
src/lotman.cpp:903:- // In this case, we unpack the returned object
src/lotman.cpp:904:- output_obj[pair.key()] = rp_json_bool.first["value"];
src/lotman.cpp:905:- }
src/lotman.cpp:906:- output_obj[pair.key()] = rp_json_bool.first;
src/lotman.cpp:907:- }
src/lotman.cpp:908:- }
src/lotman.cpp:909:-
src/lotman.cpp:910:- std::string output_str = output_obj.dump();
src/lotman.cpp:911:- auto output_str_c = static_cast<char *>(malloc(sizeof(char) * (output_str.length() + 1)));
src/lotman.cpp:912:- output_str_c = strdup(output_str.c_str());
src/lotman.cpp:913:- *output = output_str_c;
src/lotman.cpp:914:- return 0;
src/lotman.cpp:915:- }
src/lotman.cpp:916:- catch (std::exception &exc) {
src/lotman.cpp:917:- if (err_msg) {
src/lotman.cpp:918:- *err_msg = strdup(exc.what());
src/lotman.cpp:886:+int lotman_get_policy_attributes(const char *policy_attributes_JSON_str,
src/lotman.cpp:887:+ char **output, char **err_msg) {
src/lotman.cpp:888:+ try {
src/lotman.cpp:889:+ json get_attrs_obj = json::parse(policy_attributes_JSON_str);
src/lotman.cpp:890:+
src/lotman.cpp:891:+ // Validate the incoming JSON
src/lotman.cpp:892:+ json_validator validator;
src/lotman.
|
Run linters:
src/lotman.cpp#L1565
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman.cpp:1565:- if (err_msg) {
src/lotman.cpp:1566:- std::string int_err = rp_json_str.second;
src/lotman.cpp:1567:- std::string ext_err = "Failure on call to get_lot_dirs: ";
src/lotman.cpp:1568:- *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:1569:- }
src/lotman.cpp:1570:- return -1;
src/lotman.cpp:1571:- }
src/lotman.cpp:1572:- output_obj["paths"] = rp_json_str.first;
src/lotman.cpp:1573:-
src/lotman.cpp:1574:- // Add management policy attributes according to recursive flag
src/lotman.cpp:1575:- std::array<std::string, 6> man_pol_keys = {"dedicated_GB", "opportunistic_GB", "max_num_objects", "creation_time", "deletion_time", "expiration_time"};
src/lotman.cpp:1576:- json internal_man_pol_obj;
src/lotman.cpp:1577:- json internal_man_pol_obj_restrictive;
src/lotman.cpp:1578:- for (const auto &key : man_pol_keys) {
src/lotman.cpp:1579:- rp_json_str = lot.get_restricting_attribute(key, false);
src/lotman.cpp:1580:- if (!rp_json_str.second.empty()) { // There was an error
src/lotman.cpp:1581:- if (err_msg) {
src/lotman.cpp:1582:- std::string int_err = rp_json_str.second;
src/lotman.cpp:1583:- std::string ext_err = "Failure on call to get_restricting_attribute: ";
src/lotman.cpp:1584:- *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:1585:- }
src/lotman.cpp:1586:- return -1;
src/lotman.cpp:1587:- }
src/lotman.cpp:1588:-
src/lotman.cpp:1589:- internal_man_pol_obj[key] = rp_json_str.first["value"];
src/lotman.cpp:1590:-
src/lotman.cpp:1591:- if (recursive) {
src/lotman.cpp:1592:- rp_json_str = lot.get_restricting_attribute(key, true);
src/lotman.cpp:1593:- if (!rp_json_str.second.empty()) { // There was an error
src/lotman.cpp:1594:- if (err_msg) {
src/lotman.cpp:1595:- std::string int_err = rp_json_str.second;
src/lotman.cpp:1596:- std::string ext_err = "Failure on call to get_restricting_attribute: ";
src/lotman.cpp:1597:- *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:1598:- }
src/lotman.cpp:1599:- return -1;
src/lotman.cpp:1600:- }
src/lotman.cpp:1601:-
src/lotman.cpp:1602:-
src/lotman.cpp:1603:- internal_man_pol_obj_restrictive[key] = rp_json_str.first;
src/lotman.cpp:1604:- }
src/lotman.cpp:1605:- }
src/lotman.cpp:1606:- output_obj["management_policy_attrs"] = internal_man_pol_obj;
src/lotman.cpp:1607:-
src/lotman.cpp:1608:- if (recursive) {
src/lotman.cpp:1609:- output_obj["restrictive_management_policy_attrs"] = internal_man_pol_obj_restrictive;
src/lotman.cpp:1651:+ if (err_msg) {
src/lotman.cpp:1652:+ std::string int_err = rp_json_str.second;
src/lotman.cpp:1653:+ std::string ext_err =
src/lotman.cpp:1654:+ "Failure on call to get_restricting_attribute: ";
src/lotman.cpp:1655:+ *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:1656:+ }
src/lotman.cpp:1657:+ return -1;
|
Run linters:
src/lotman.cpp#L1612
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman.cpp:1612:- // Add usage according to recursive flag
src/lotman.cpp:1613:- std::array<std::string, 6> usage_keys = {"dedicated_GB", "opportunistic_GB", "total_GB", "num_objects", "GB_being_written", "objects_being_written"};
src/lotman.cpp:1614:- json internal_usage_obj;
src/lotman.cpp:1615:- for (const auto &key : usage_keys) {
src/lotman.cpp:1616:- rp_json_str = lot.get_lot_usage(key, recursive);
src/lotman.cpp:1617:- if (!rp_json_str.second.empty()) { // There was an error
src/lotman.cpp:1618:- if (err_msg) {
src/lotman.cpp:1619:- std::string int_err = rp_json_str.second;
src/lotman.cpp:1620:- std::string ext_err = "Failure on call to get_lot_usage: ";
src/lotman.cpp:1621:- *err_msg = strdup((ext_err + int_err).c_str());
src/lotman.cpp:1622:- }
src/lotman.cpp:1623:- return -1;
src/lotman.cpp:1624:- }
src/lotman.cpp:1625:- internal_usage_obj[key] = rp_json_str.first;
src/lotman.cpp:1626:- }
src/lotman.cpp:1627:- output_obj["usage"] = internal_usage_obj;
src/lotman.cpp:1660:+ internal_man_pol_obj_restrictive[key] = rp_json_str.first;
src/lotman.cpp:1661:+ }
src/lotman.cpp:1662:+ }
src/lotman.cpp:1663:+ output_obj["management_policy_attrs"] = internal_man_pol_obj;
|
Run linters:
src/lotman_internal.cpp#L525
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman_internal.cpp:525:- std::string int_err = rp.second;
src/lotman_internal.cpp:526:- std::string ext_err = "Failure on call to SQL_get_matches: ";
src/lotman_internal.cpp:527:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:528:- }
src/lotman_internal.cpp:529:- value = rp.first;
src/lotman_internal.cpp:530:- std::string restricting_parent_name = lot_name;
src/lotman_internal.cpp:531:-
src/lotman_internal.cpp:532:- if (recursive) {
src/lotman_internal.cpp:533:- auto rp2 = this->get_parents(true);
src/lotman_internal.cpp:534:- if (!rp2.second.empty()) { // There was an error
src/lotman_internal.cpp:535:- std::string int_err = rp2.second;
src/lotman_internal.cpp:536:- std::string ext_err = "Failure to get lot parents: ";
src/lotman_internal.cpp:537:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:538:- }
src/lotman_internal.cpp:539:-
src/lotman_internal.cpp:540:- std::vector<lotman::Lot> parents = rp2.first;
src/lotman_internal.cpp:541:- for (const auto &parent : parents) {
src/lotman_internal.cpp:542:- std::map<std::string, std::vector<int>> policy_attr_query_parent_str_map{{parent.lot_name, {1}}};
src/lotman_internal.cpp:543:- rp = lotman::Checks::SQL_get_matches(policy_attr_query, policy_attr_query_parent_str_map);
src/lotman_internal.cpp:544:- if (!rp.second.empty()) { // There was an error
src/lotman_internal.cpp:545:- std::string int_err = rp.second;
src/lotman_internal.cpp:546:- std::string ext_err = "Failure on call to SQL_get_matches: ";
src/lotman_internal.cpp:547:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:548:- }
src/lotman_internal.cpp:549:-
src/lotman_internal.cpp:550:- std::vector<std::string> compare_value = rp.first;
src/lotman_internal.cpp:551:- if (std::stod(compare_value[0]) < std::stod(value[0])) {
src/lotman_internal.cpp:552:- value[0] = compare_value[0];
src/lotman_internal.cpp:553:- restricting_parent_name = parent.lot_name;
src/lotman_internal.cpp:554:- }
src/lotman_internal.cpp:555:- }
src/lotman_internal.cpp:556:- internal_obj["lot_name"] = restricting_parent_name;
src/lotman_internal.cpp:557:- internal_obj["value"] = std::stod(value[0]);
src/lotman_internal.cpp:558:- } else {
src/lotman_internal.cpp:559:- internal_obj["value"] = std::stod(value[0]);
src/lotman_internal.cpp:560:- }
src/lotman_internal.cpp:561:- return std::make_pair(internal_obj, "");
src/lotman_internal.cpp:562:- }
src/lotman_internal.cpp:563:- else {
src/lotman_internal.cpp:564:- return std::make_pair(json(), " The key \"" + key + "\" is not recognized.");
src/lotman_internal.cpp:565:- }
src/lotman_internal.cpp:616:+ std::string int_err = rp.second;
src/lotman_internal.cpp:617:+ std::string ext_err = "Failure on call to SQL_get_matches: ";
src/lotman_internal.cpp:618:+ return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:619:+ }
src/lotman_internal.cpp:620:+
src/lotman_internal.cpp:621:+ std::vector<std::string> compare_value = rp.first;
src/lotman_internal.cpp:622:+ if (std::stod(compare_value[0]) < std::stod(value[0])) {
src/lotman_internal.cpp:623:+ value[0] = compare_value[0];
src/lotman_internal.cpp:624:+ restricting_parent_name = parent.lot_name;
src/lotman_internal.cpp:625:+ }
src/lotman_internal.cpp:626:+ }
src/lotman_internal.cpp:627:+ internal_obj["lot_name"] = restricting_parent_name;
src/lotman_internal.cpp:628:+ internal_obj["value"] = std::stod(value[0]);
src/lotman_internal.cpp:629:
|
Run linters:
src/lotman_internal.cpp#L634
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman_internal.cpp:634:-std::pair<json, std::string> lotman::Lot::get_lot_usage(const std::string key, const bool recursive) {
src/lotman_internal.cpp:635:-
src/lotman_internal.cpp:636:-// TODO: Introduce some notion of verbocity to give options for output, like:
src/lotman_internal.cpp:637:- // {"dedicated_GB" : 10} vs {"dedicated_GB" : {"personal": 5, "children" : 5}} vs {"dedicated_GB" : {"personal" : 5, "child1" : 2.5, "child2" : 2.5}}
src/lotman_internal.cpp:638:- // Think a bit more about whether this makes sense.
src/lotman_internal.cpp:639:-
src/lotman_internal.cpp:640:- // TODO: Might be worthwhile to join some of these sections that share a common preamble
src/lotman_internal.cpp:641:-
src/lotman_internal.cpp:642:- json output_obj;
src/lotman_internal.cpp:643:- std::array<std::string, 6> allowed_keys = {"dedicated_GB", "opportunistic_GB", "total_GB", "num_objects", "GB_being_written", "objects_being_written"};
src/lotman_internal.cpp:644:- if (std::find(allowed_keys.begin(), allowed_keys.end(), key) == allowed_keys.end()) {
src/lotman_internal.cpp:645:- return std::make_pair(json(), "The key \"" + key + "\" is not recognized.");
src/lotman_internal.cpp:646:- }
src/lotman_internal.cpp:647:-
src/lotman_internal.cpp:648:- std::vector<std::string> query_output;
src/lotman_internal.cpp:649:- std::vector<std::vector<std::string>> query_multi_out;
src/lotman_internal.cpp:650:-
src/lotman_internal.cpp:651:- if (key == "dedicated_GB") {
src/lotman_internal.cpp:652:- if (recursive) {
src/lotman_internal.cpp:653:- std::string rec_ded_usage_query = "SELECT "
src/lotman_internal.cpp:654:- "CASE "
src/lotman_internal.cpp:655:- "WHEN lot_usage.self_GB + lot_usage.children_GB <= management_policy_attributes.dedicated_GB THEN lot_usage.self_GB + lot_usage.children_GB "
src/lotman_internal.cpp:656:- "ELSE management_policy_attributes.dedicated_GB "
src/lotman_internal.cpp:657:- "END AS total, " // For readability, not actually referencing these column names
src/lotman_internal.cpp:658:- "CASE "
src/lotman_internal.cpp:659:- "WHEN lot_usage.self_GB >= management_policy_attributes.dedicated_GB THEN management_policy_attributes.dedicated_GB "
src/lotman_internal.cpp:660:- "ELSE lot_usage.self_GB "
src/lotman_internal.cpp:661:- "END AS self_contrib, "
src/lotman_internal.cpp:662:- "CASE "
src/lotman_internal.cpp:663:- "WHEN lot_usage.self_GB >= management_policy_attributes.dedicated_GB THEN '0' "
src/lotman_internal.cpp:664:- "WHEN lot_usage.self_GB + lot_usage.children_GB >= management_policy_attributes.dedicated_GB THEN management_policy_attributes.dedicated_GB - lot_usage.self_GB "
src/lotman_internal.cpp:665:- "ELSE lot_usage.children_GB "
src/lotman_internal.cpp:666:- "END AS children_contrib "
src/lotman_internal.cpp:667:- "FROM lot_usage "
src/lotman_internal.cpp:668:- "INNER JOIN management_policy_attributes ON lot_usage.lot_name=management_policy_attributes.lot_name "
src/lotman_internal.cpp:669:- "WHERE lot_usage.lot_name = ?;";
src/lotman_internal.cpp:670:- std::map<std::string, std::vector<int>> ded_GB_query_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:671:- auto rp_mu
|
Run linters:
src/lotman_internal.cpp#L705
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman_internal.cpp:705:- else if (key == "opportunistic_GB") {
src/lotman_internal.cpp:706:- if (recursive) {
src/lotman_internal.cpp:707:- std::string rec_opp_usage_query = "SELECT "
src/lotman_internal.cpp:708:- "CASE "
src/lotman_internal.cpp:709:- "WHEN lot_usage.self_GB + lot_usage.children_GB >= management_policy_attributes.opportunistic_GB +management_policy_attributes.dedicated_GB THEN management_policy_attributes.opportunistic_GB "
src/lotman_internal.cpp:710:- "WHEN lot_usage.self_GB + lot_usage.children_GB >= management_policy_attributes.dedicated_GB THEN lot_usage.self_GB + lot_usage.children_GB - management_policy_attributes.dedicated_GB "
src/lotman_internal.cpp:711:- "ELSE '0' "
src/lotman_internal.cpp:712:- "END AS total, "
src/lotman_internal.cpp:713:- "CASE "
src/lotman_internal.cpp:714:- "WHEN lot_usage.self_GB >= management_policy_attributes.opportunistic_GB + management_policy_attributes.dedicated_GB THEN management_policy_attributes.opportunistic_GB "
src/lotman_internal.cpp:715:- "WHEN lot_usage.self_GB >= management_policy_attributes.dedicated_GB THEN lot_usage.self_GB - management_policy_attributes.dedicated_GB "
src/lotman_internal.cpp:716:- "ELSE '0' "
src/lotman_internal.cpp:717:- "END AS self_contrib, "
src/lotman_internal.cpp:718:- "CASE "
src/lotman_internal.cpp:719:- "WHEN lot_usage.self_GB >= management_policy_attributes.opportunistic_GB + management_policy_attributes.dedicated_GB THEN '0' "
src/lotman_internal.cpp:720:- "WHEN lot_usage.self_GB >= management_policy_attributes.dedicated_GB AND lot_usage.self_GB + lot_usage.children_GB >= management_policy_attributes.opportunistic_GB + management_policy_attributes.dedicated_GB THEN management_policy_attributes.opportunistic_GB + management_policy_attributes.dedicated_GB - lot_usage.self_GB "
src/lotman_internal.cpp:721:- "WHEN lot_usage.self_GB >= management_policy_attributes.dedicated_GB AND lot_usage.self_GB + lot_usage.children_GB < management_policy_attributes.opportunistic_GB + management_policy_attributes.dedicated_GB THEN lot_usage.children_GB "
src/lotman_internal.cpp:722:- "WHEN lot_usage.self_GB < management_policy_attributes.dedicated_GB AND lot_usage.self_GB + lot_usage.children_GB >= management_policy_attributes.opportunistic_GB + management_policy_attributes.dedicated_GB THEN management_policy_attributes.opportunistic_GB "
src/lotman_internal.cpp:723:- "WHEN lot_usage.self_GB < management_policy_attributes.dedicated_GB AND lot_usage.self_GB + lot_usage.children_GB > management_policy_attributes.dedicated_GB THEN lot_usage.self_GB + lot_usage.children_GB - management_policy_attributes.dedicated_GB "
src/lotman_internal.cpp:724:- "ELSE '0' "
src/lotman_internal.cpp:725:- "END AS children_contrib "
src/lotman_internal.cpp:726:- "FROM "
src/lotman_internal.cpp:727:- "lot_usage "
src/lotman_internal.cpp:728:- "INNER JOIN management_policy_attributes ON lot_usage.lo
|
Run linters:
src/lotman_internal.cpp#L766
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman_internal.cpp:766:- else if (key == "total_GB") {
src/lotman_internal.cpp:767:- // Get the total usage
src/lotman_internal.cpp:768:- if (recursive) {
src/lotman_internal.cpp:769:- // Need to consider usage from children
src/lotman_internal.cpp:770:- std::string child_usage_GB_query = "SELECT self_GB, children_GB FROM lot_usage WHERE lot_name = ?;";
src/lotman_internal.cpp:771:- std::map<std::string, std::vector<int>> child_usage_GB_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:772:- auto rp_multi = lotman::Checks::SQL_get_matches_multi_col(child_usage_GB_query, 2, child_usage_GB_str_map);
src/lotman_internal.cpp:773:- if (!rp_multi.second.empty()) { // There was an error
src/lotman_internal.cpp:774:- std::string int_err = rp_multi.second;
src/lotman_internal.cpp:775:- std::string ext_err = "Failure on call to SQL_get_matches_multi_col: ";
src/lotman_internal.cpp:776:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:777:- }
src/lotman_internal.cpp:778:- query_multi_out = rp_multi.first;
src/lotman_internal.cpp:779:- output_obj["self_contrib"] = std::stod(query_multi_out[0][0]);
src/lotman_internal.cpp:780:- output_obj["children_contrib"] = std::stod(query_multi_out[0][1]);
src/lotman_internal.cpp:781:- output_obj["total"] = std::stod(query_multi_out[0][0]) + std::stod(query_multi_out[0][1]);
src/lotman_internal.cpp:782:- }
src/lotman_internal.cpp:783:- else {
src/lotman_internal.cpp:784:- std::string usage_GB_query = "SELECT self_GB FROM lot_usage WHERE lot_name = ?;";
src/lotman_internal.cpp:785:- std::map<std::string, std::vector<int>> usage_GB_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:786:- auto rp_single = lotman::Checks::SQL_get_matches(usage_GB_query, usage_GB_str_map);
src/lotman_internal.cpp:787:- if (!rp_single.second.empty()) { // There was an error
src/lotman_internal.cpp:788:- std::string int_err = rp_single.second;
src/lotman_internal.cpp:789:- std::string ext_err = "Failure on call to SQL_get_matches: ";
src/lotman_internal.cpp:790:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:791:- }
src/lotman_internal.cpp:792:- query_output = rp_single.first;
src/lotman_internal.cpp:793:- output_obj["self_contrib"] = std::stod(query_output[0]);
src/lotman_internal.cpp:794:- }
src/lotman_internal.cpp:795:- }
src/lotman_internal.cpp:796:-
src/lotman_internal.cpp:797:- else if (key == "num_objects") {
src/lotman_internal.cpp:798:- if (recursive) {
src/lotman_internal.cpp:799:- std::string rec_num_obj_query = "SELECT self_objects, children_objects FROM lot_usage WHERE lot_name = ?;";
src/lotman_internal.cpp:800:- std::map<std::string, std::vector<int>> rec_num_obj_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:801:- auto rp_multi = lotman::Checks::SQL_get_matches_multi_col(rec_num_obj_query, 2, rec_num_obj_str_map);
src/lotman_internal.cpp:802:- if (!rp_multi.second.empty()) { // There was an error
src/lotman_internal.cpp:803:- std::string int_err = rp_multi.second;
src/lotman_internal.cpp:804:- std::string ext_err = "Failure on call to SQL_get_matches_multi_col: ";
src/lotman_internal.cpp:805:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:806:- }
src/lotman_internal.cpp:807:- query_multi_out = rp_multi.first;
src/lotman_internal.cpp:808:- output_obj["self_contrib"] = std::stod(query_multi_out[0][0]);
src/lotman_internal.cpp:809:- output_obj["children_contrib"] = std::stod(query_multi_out[0][1]);
src/lotman_internal.cpp:810:- output_obj["total"] = std::stod(query_multi_out[0][0]) + std::stod(query_multi_ou
|
Run linters:
src/lotman_internal.cpp#L827
[lint] reported by reviewdog 🐶
Raw Output:
src/lotman_internal.cpp:827:- else if (key == "GB_being_written") {
src/lotman_internal.cpp:828:- if (recursive) {
src/lotman_internal.cpp:829:- std::string rec_GB_being_written_query = "SELECT self_GB_being_written, children_GB_being_written FROM lot_usage WHERE lot_name = ?;";
src/lotman_internal.cpp:830:- std::map<std::string, std::vector<int>> rec_GB_being_written_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:831:- auto rp_multi = lotman::Checks::SQL_get_matches_multi_col(rec_GB_being_written_query, 2, rec_GB_being_written_str_map);
src/lotman_internal.cpp:832:- if (!rp_multi.second.empty()) { // There was an error
src/lotman_internal.cpp:833:- std::string int_err = rp_multi.second;
src/lotman_internal.cpp:834:- std::string ext_err = "Failure on call to SQL_get_matches_multi_col: ";
src/lotman_internal.cpp:835:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:836:- }
src/lotman_internal.cpp:837:- query_multi_out = rp_multi.first;
src/lotman_internal.cpp:838:- output_obj["self_contrib"] = std::stod(query_multi_out[0][0]);
src/lotman_internal.cpp:839:- output_obj["children_contrib"] = std::stod(query_multi_out[0][1]);
src/lotman_internal.cpp:840:- output_obj["total"] = std::stod(query_multi_out[0][0]) + std::stod(query_multi_out[0][1]);
src/lotman_internal.cpp:841:- }
src/lotman_internal.cpp:842:- else {
src/lotman_internal.cpp:843:-
src/lotman_internal.cpp:844:- std::string GB_being_written_query = "SELECT self_GB_being_written FROM lot_usage WHERE lot_name = ?;";
src/lotman_internal.cpp:845:- std::map<std::string, std::vector<int>> GB_being_written_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:846:- auto rp_single = lotman::Checks::SQL_get_matches(GB_being_written_query, GB_being_written_str_map);
src/lotman_internal.cpp:847:- if (!rp_single.second.empty()) { // There was an error
src/lotman_internal.cpp:848:- std::string int_err = rp_single.second;
src/lotman_internal.cpp:849:- std::string ext_err = "Failure on call to SQL_get_matches: ";
src/lotman_internal.cpp:850:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:851:- }
src/lotman_internal.cpp:852:- query_output = rp_single.first;
src/lotman_internal.cpp:853:- output_obj["self_contrib"] = std::stod(query_output[0]);
src/lotman_internal.cpp:854:- }
src/lotman_internal.cpp:855:- }
src/lotman_internal.cpp:856:-
src/lotman_internal.cpp:857:- else if (key == "objects_being_written") {
src/lotman_internal.cpp:858:- if (recursive) {
src/lotman_internal.cpp:859:- std::string rec_objects_being_written_query = "SELECT self_objects_being_written, children_objects_being_written FROM lot_usage WHERE lot_name = ?;";
src/lotman_internal.cpp:860:- std::map<std::string, std::vector<int>> rec_objects_being_written_str_map{{lot_name, {1}}};
src/lotman_internal.cpp:861:- auto rp_multi = lotman::Checks::SQL_get_matches_multi_col(rec_objects_being_written_query, 2, rec_objects_being_written_str_map);
src/lotman_internal.cpp:862:- if (!rp_multi.second.empty()) { // There was an error
src/lotman_internal.cpp:863:- std::string int_err = rp_multi.second;
src/lotman_internal.cpp:864:- std::string ext_err = "Failure on call to SQL_get_matches_multi_col: ";
src/lotman_internal.cpp:865:- return std::make_pair(json(), ext_err + int_err);
src/lotman_internal.cpp:866:- }
src/lotman_internal.cpp:867:- query_multi_out = rp_multi.first;
src/lotman_internal.cpp:868:- output_obj["self_contrib"] = std::stod(query_multi_out[0][0]);
src/lotman_internal.cpp:869:- output_obj["children_contrib"] = std::stod(query_multi_out[0][1]);
src/lotman_internal.cpp:870:-
|
Run linters:
test/main.cpp#L266
[lint] reported by reviewdog 🐶
Raw Output:
test/main.cpp:266:- TEST_F(LotManTest, SetGetUsageTest) {
test/main.cpp:267:- // Update/Get usage for a lot that doesn't exist
test/main.cpp:268:- char *err_msg;
test/main.cpp:269:- const char *non_existent_lot = "non_existent_lot";
test/main.cpp:270:- bool deltaMode = false;
test/main.cpp:271:- const char *bad_usage_update_JSON = "{\"lot_name\":\"non_existent_lot\", \"self_GB\":10.5, \"self_objects\":4, \"self_GB_being_written\":2.2, \"self_objects_being_written\":2}";
test/main.cpp:272:- int rv = lotman_update_lot_usage(bad_usage_update_JSON, deltaMode, &err_msg);
test/main.cpp:273:- ASSERT_FALSE(rv == 0);
test/main.cpp:274:- free(err_msg);
test/main.cpp:275:-
test/main.cpp:276:- char *err_msg2;
test/main.cpp:277:- const char *bad_usage_query_JSON = "{\"lot_name\":\"non_existent_lot\", \"dedicated_GB\": true, \"opportunistic_GB\": true, \"total_GB\": true}";
test/main.cpp:278:- char *output;
test/main.cpp:279:- rv = lotman_get_lot_usage(bad_usage_query_JSON, &output, &err_msg2);
test/main.cpp:280:- ASSERT_FALSE(rv == 0);
test/main.cpp:281:- free(err_msg2);
test/main.cpp:282:-
test/main.cpp:283:- // Update by lot
test/main.cpp:284:- char *err_msg3;
test/main.cpp:285:- const char *usage1_update_JSON = "{\"lot_name\":\"lot4\", \"self_GB\":10.5, \"self_objects\":4, \"self_GB_being_written\":2.2, \"self_objects_being_written\":2}";
test/main.cpp:286:- rv = lotman_update_lot_usage(usage1_update_JSON, deltaMode, &err_msg3);
test/main.cpp:287:- ASSERT_TRUE(rv == 0) << err_msg3;
test/main.cpp:288:-
test/main.cpp:289:- const char *usage2_update_JSON = "{\"lot_name\":\"lot5\",\"self_GB\":3.5, \"self_objects\":7, \"self_GB_being_written\":1.2, \"self_objects_being_written\":5}";
test/main.cpp:290:- rv = lotman_update_lot_usage(usage2_update_JSON, deltaMode, &err_msg3);
test/main.cpp:291:- ASSERT_TRUE(rv == 0) << err_msg3;
test/main.cpp:292:-
test/main.cpp:293:- const char *usage_query_JSON = "{\"lot_name\":\"lot5\", \"dedicated_GB\": true, \"opportunistic_GB\": true, \"total_GB\": true}";
test/main.cpp:294:- rv = lotman_get_lot_usage(usage_query_JSON, &output, &err_msg3);
test/main.cpp:295:- ASSERT_TRUE(rv == 0) << err_msg3;
test/main.cpp:296:-
test/main.cpp:297:- json json_out = json::parse(output);
test/main.cpp:298:- ASSERT_TRUE(json_out["dedicated_GB"]["children_contrib"] == 6.5 && json_out["dedicated_GB"]["self_contrib"] == 3.5 && json_out["dedicated_GB"]["total"] == 10 &&
test/main.cpp:299:- json_out["opportunistic_GB"]["children_contrib"] == 3.5 && json_out["opportunistic_GB"]["self_contrib"] == 0 && json_out["opportunistic_GB"]["total"] == 3.5 &&
test/main.cpp:300:- json_out["total_GB"]["children_contrib"] == 10.5 && json_out["total_GB"]["self_contrib"] == 3.5 && json_out["total_GB"]["total"] == 14);
test/main.cpp:301:-
test/main.cpp:302:- free(output);
test/main.cpp:303:-
test/main.cpp:304:- // Update by dir -- This ends up updating default, lot1 and lot4
test/main.cpp:305:- const char *update_JSON_str = "[{\"includes_subdirs\": true,\"num_obj\": 40,\"path\": \"/1/2/3\",\"size_GB\": 5.12,\"subdirs\": [{\"includes_subdirs\": true,\"num_obj\": 6,\"path\": \"4\",\"size_GB\": 3.14,\"subdirs\": [{\"includes_subdirs\": false,\"num_obj\": 0,\"path\": \"5\",\"size_GB\": 1.6,\"subdirs\": []}]},{\"includes_subdirs\": false,\"num_obj\": 0,\"path\": \"5/6\",\"size_GB\": 0.5,\"subdirs\": []},{\"includes_subdirs\": false,\"num_obj\": 0,\"path\": \"6\",\"size_GB\": 0.25,\"subdirs\": []}]},{\"includes_subdirs\": true,\"num_obj\": 6,\"path\": \"foo/bar\",\"size_GB\": 9.153,\"subdirs\": [{\"includes_subdirs\": true,\"num_obj\": 0,\"path\": \"baz\",\"size_GB\": 5.35,\"subdirs\": [{\"includes_subdirs\": false,\"num_obj\": 0,\"path\": \"more_more_files\",\"size_GB\": 2.2,\"subdirs\": []}]}]}]";
test/main.cpp:306:- rv = lotman_update_lot_usage_b
|
Run linters:
test/main.cpp#L607
[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},"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;
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 =
|