0.00% (0/437) Uncovered changed code (with context): ================================================================================ programs/keeper-bench/Generator.cpp ================================================================================ --- uncovered block 155-160 --- 153 | continue; 154 | >> 155 | const auto current_path_key_string = key + "." + path_key; >> 156 | const auto children_of_key = current_path_key_string + ".children_of"; >> 157 | const auto tagged_key = current_path_key_string + ".tagged"; >> 158 | if (config.has(children_of_key)) >> 159 | { >> 160 | auto parent_node = config.getString(children_of_key); 161 | if (parent_node.empty() || parent_node[0] != '/') 162 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Invalid path for request generator: '{}'", parent_node); --- uncovered block 162-174 --- 160 | auto parent_node = config.getString(children_of_key); 161 | if (parent_node.empty() || parent_node[0] != '/') >> 162 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Invalid path for request generator: '{}'", parent_node); >> 163 | path_getter.parent_paths.push_back(std::move(parent_node)); >> 164 | } >> 165 | else if (config.has(tagged_key)) >> 166 | { >> 167 | auto tag_name = config.getString(tagged_key); >> 168 | if (tag_name.empty()) >> 169 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Empty tag name for request generator in key '{}'", current_path_key_string); >> 170 | path_getter.tag_names.push_back(std::move(tag_name)); >> 171 | } >> 172 | else >> 173 | { >> 174 | auto path = config.getString(key + "." + path_key); 175 | 176 | if (path.empty() || path[0] != '/') --- uncovered block 180-181 --- 178 | 179 | path_getter.paths.push_back(std::move(path)); >> 180 | } >> 181 | } 182 | 183 | if (path_getter.paths.empty() && path_getter.parent_paths.empty() && path_getter.tag_names.empty()) --- uncovered block 183-184 --- 181 | } 182 | >> 183 | if (path_getter.paths.empty() && path_getter.parent_paths.empty() && path_getter.tag_names.empty()) >> 184 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "PathGetter has no paths configured for key '{}'", key); 185 | 186 | if (!path_getter.paths.empty()) --- uncovered block 186-186 --- 184 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "PathGetter has no paths configured for key '{}'", key); 185 | >> 186 | if (!path_getter.paths.empty()) 187 | path_getter.path_picker = std::uniform_int_distribution(0, path_getter.paths.size() - 1); 188 | return path_getter; --- uncovered block 188-189 --- 186 | if (!path_getter.paths.empty()) 187 | path_getter.path_picker = std::uniform_int_distribution(0, path_getter.paths.size() - 1); >> 188 | return path_getter; >> 189 | } 190 | 191 | void PathGetter::initialize(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 192-194 --- 190 | 191 | void PathGetter::initialize(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 192 | { >> 193 | for (const auto & parent_path : parent_paths) >> 194 | { 195 | auto list_promise = std::make_shared>(); 196 | auto list_future = list_promise->get_future(); --- uncovered block 208-209 --- 206 | 207 | for (const auto & child : list_response.names) >> 208 | paths.push_back(std::filesystem::path(parent_path) / child); >> 209 | } 210 | 211 | for (const auto & tag_name : tag_names) --- uncovered block 211-214 --- 209 | } 210 | >> 211 | for (const auto & tag_name : tag_names) >> 212 | { >> 213 | if (!tagged_paths) >> 214 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Tag '{}' referenced but no tagged paths available (is setup missing?)", tag_name); 215 | 216 | auto it = tagged_paths->find(tag_name); --- uncovered block 216-222 --- 214 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Tag '{}' referenced but no tagged paths available (is setup missing?)", tag_name); 215 | >> 216 | auto it = tagged_paths->find(tag_name); >> 217 | if (it == tagged_paths->end()) >> 218 | throw DB::Exception( >> 219 | DB::ErrorCodes::BAD_ARGUMENTS, >> 220 | "Tag '{}' not found in setup. Available tags: {}", >> 221 | tag_name, >> 222 | tagged_paths->empty() ? "(none)" : fmt::to_string(fmt::join(*tagged_paths | std::views::keys, ", "))); 223 | 224 | for (const auto & path : it->second) --- uncovered block 224-226 --- 222 | tagged_paths->empty() ? "(none)" : fmt::to_string(fmt::join(*tagged_paths | std::views::keys, ", "))); 223 | >> 224 | for (const auto & path : it->second) >> 225 | paths.push_back(path); >> 226 | } 227 | 228 | if (paths.empty()) --- uncovered block 228-232 --- 226 | } 227 | >> 228 | if (paths.empty()) >> 229 | throw DB::Exception( >> 230 | DB::ErrorCodes::BAD_ARGUMENTS, >> 231 | "PathGetter has no paths after initialization. " >> 232 | "Check that children_of targets have children, tagged nodes exist, or add explicit path entries"); 233 | 234 | path_picker = std::uniform_int_distribution(0, paths.size() - 1); --- uncovered block 234-235 --- 232 | "Check that children_of targets have children, tagged nodes exist, or add explicit path entries"); 233 | >> 234 | path_picker = std::uniform_int_distribution(0, paths.size() - 1); >> 235 | initialized = true; 236 | } 237 | --- uncovered block 256-257 --- 254 | if (!description.empty()) 255 | description += ", "; >> 256 | description += fmt::format("children of {}", path); >> 257 | } 258 | 259 | for (const auto & tag_name : tag_names) --- uncovered block 259-264 --- 257 | } 258 | >> 259 | for (const auto & tag_name : tag_names) >> 260 | { >> 261 | if (!description.empty()) >> 262 | description += ", "; >> 263 | description += fmt::format("tagged \"{}\"", tag_name); >> 264 | } 265 | 266 | for (const auto & path : paths) --- uncovered block 266-268 --- 264 | } 265 | >> 266 | for (const auto & path : paths) >> 267 | { >> 268 | if (!description.empty()) 269 | description += ", "; 270 | description += path; --- uncovered block 364-365 --- 362 | for (const auto & request_generator : request_generators) 363 | description += fmt::format("\n{}\n", request_generator->description()); >> 364 | return description + guard; >> 365 | } 366 | 367 | void RequestGetter::startup(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 368-371 --- 366 | 367 | void RequestGetter::startup(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 368 | { >> 369 | for (const auto & request_generator : request_generators) >> 370 | request_generator->startup(zookeeper, tagged_paths); >> 371 | } 372 | 373 | void RequestGetter::setSeed(uint64_t seed) --- uncovered block 377-378 --- 375 | rng.seed(seed); 376 | for (size_t i = 0; i < request_generators.size(); ++i) >> 377 | request_generators[i]->setSeed(seed + i + 1); >> 378 | } 379 | 380 | void RequestGetter::setWatchCallback(Coordination::WatchCallbackPtr callback) --- uncovered block 381-384 --- 379 | 380 | void RequestGetter::setWatchCallback(Coordination::WatchCallbackPtr callback) >> 381 | { >> 382 | for (auto & gen : request_generators) >> 383 | gen->setWatchCallback(callback); >> 384 | } 385 | 386 | const std::vector & RequestGetter::requestGenerators() const --- uncovered block 387-388 --- 385 | 386 | const std::vector & RequestGetter::requestGenerators() const >> 387 | { >> 388 | return request_generators; 389 | } 390 | --- uncovered block 410-411 --- 408 | ZooKeeperRequestWithCallbacks RequestGenerator::generate(const Coordination::ACLs & acls) 409 | { >> 410 | return generateImpl(acls); >> 411 | } 412 | 413 | void RequestGenerator::startup(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 414-416 --- 412 | 413 | void RequestGenerator::startup(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 414 | { >> 415 | startupImpl(zookeeper, tagged_paths); >> 416 | } 417 | 418 | void RequestGenerator::setSeed(uint64_t seed) --- uncovered block 420-421 --- 418 | void RequestGenerator::setSeed(uint64_t seed) 419 | { >> 420 | setSeedImpl(seed); >> 421 | } 422 | 423 | void RequestGenerator::setWatchCallback(Coordination::WatchCallbackPtr callback) --- uncovered block 424-427 --- 422 | 423 | void RequestGenerator::setWatchCallback(Coordination::WatchCallbackPtr callback) >> 424 | { >> 425 | watch_callback_ptr = callback; >> 426 | setWatchCallbackImpl(std::move(callback)); >> 427 | } 428 | 429 | size_t RequestGenerator::getWeight() const --- uncovered block 430-431 --- 428 | 429 | size_t RequestGenerator::getWeight() const >> 430 | { >> 431 | return weight; 432 | } 433 | --- uncovered block 440-442 --- 438 | 439 | void CreateRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) >> 440 | { >> 441 | if (config.has(key + ".watch_probability")) >> 442 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability is not supported for create requests (key '{}')", key); 443 | 444 | parent_path = PathGetter::fromConfig(key, config); --- uncovered block 444-444 --- 442 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability is not supported for create requests (key '{}')", key); 443 | >> 444 | parent_path = PathGetter::fromConfig(key, config); 445 | 446 | name = StringGetter(NumberGetter::fromConfig(key + ".name_length", config, 5)); --- uncovered block 446-446 --- 444 | parent_path = PathGetter::fromConfig(key, config); 445 | >> 446 | name = StringGetter(NumberGetter::fromConfig(key + ".name_length", config, 5)); 447 | 448 | if (config.has(key + ".data")) --- uncovered block 474-475 --- 472 | name.description(), 473 | data_string, >> 474 | remove_factor_string); >> 475 | } 476 | 477 | void CreateRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 478-480 --- 476 | 477 | void CreateRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 478 | { >> 479 | parent_path.initialize(zookeeper, tagged_paths); >> 480 | } 481 | 482 | void CreateRequestGenerator::setSeedImpl(uint64_t seed) --- uncovered block 567-569 --- 565 | 566 | void SetRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) >> 567 | { >> 568 | if (config.has(key + ".watch_probability")) >> 569 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability is not supported for set requests (key '{}')", key); 570 | 571 | path = PathGetter::fromConfig(key, config); --- uncovered block 571-571 --- 569 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability is not supported for set requests (key '{}')", key); 570 | >> 571 | path = PathGetter::fromConfig(key, config); 572 | 573 | data = StringGetter::fromConfig(key + ".data", config); --- uncovered block 573-573 --- 571 | path = PathGetter::fromConfig(key, config); 572 | >> 573 | data = StringGetter::fromConfig(key + ".data", config); 574 | } 575 | --- uncovered block 591-592 --- 589 | request->path = path.getPath(); 590 | request->data = data.getString(); >> 591 | return {.request = request, .on_success_callbacks = {}, .on_failure_callbacks = {}}; >> 592 | } 593 | 594 | void SetRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 595-597 --- 593 | 594 | void SetRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 595 | { >> 596 | path.initialize(zookeeper, tagged_paths); >> 597 | } 598 | 599 | void SetRequestGenerator::setSeedImpl(uint64_t seed) --- uncovered block 606-607 --- 604 | 605 | void GetRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) >> 606 | { >> 607 | path = PathGetter::fromConfig(key, config); 608 | 609 | if (config.has(key + ".watch_probability")) --- uncovered block 609-615 --- 607 | path = PathGetter::fromConfig(key, config); 608 | >> 609 | if (config.has(key + ".watch_probability")) >> 610 | { >> 611 | watch_probability = config.getDouble(key + ".watch_probability"); >> 612 | if (*watch_probability < 0.0 || *watch_probability > 1.0) >> 613 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability must be in [0.0, 1.0], got {}", *watch_probability); >> 614 | } >> 615 | } 616 | 617 | std::string GetRequestGenerator::descriptionImpl() --- uncovered block 618-625 --- 616 | 617 | std::string GetRequestGenerator::descriptionImpl() >> 618 | { >> 619 | std::string watch_string = watch_probability.has_value() ? fmt::format("\n- watch probability: {}", *watch_probability) : ""; >> 620 | return fmt::format( >> 621 | "Get Request Generator\n" >> 622 | "- path(s) to get: {}{}", >> 623 | path.description(), >> 624 | watch_string); >> 625 | } 626 | 627 | ZooKeeperRequestWithCallbacks GetRequestGenerator::generateImpl(const Coordination::ACLs & /*acls*/) --- uncovered block 628-637 --- 626 | 627 | ZooKeeperRequestWithCallbacks GetRequestGenerator::generateImpl(const Coordination::ACLs & /*acls*/) >> 628 | { >> 629 | auto request = std::make_shared(); >> 630 | request->path = path.getPath(); >> 631 | if (watch_probability.has_value() && watch_picker(watch_rng) < *watch_probability) >> 632 | { >> 633 | request->has_watch = true; >> 634 | request->watch_callback = watch_callback_ptr; >> 635 | } >> 636 | return {.request = request, .on_success_callbacks = {}, .on_failure_callbacks = {}}; >> 637 | } 638 | 639 | void GetRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 640-642 --- 638 | 639 | void GetRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 640 | { >> 641 | path.initialize(zookeeper, tagged_paths); >> 642 | } 643 | 644 | void GetRequestGenerator::setSeedImpl(uint64_t seed) --- uncovered block 645-648 --- 643 | 644 | void GetRequestGenerator::setSeedImpl(uint64_t seed) >> 645 | { >> 646 | path.setSeed(seed + 100003); >> 647 | watch_rng.seed(seed + 400009); >> 648 | } 649 | 650 | void ListRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) --- uncovered block 651-652 --- 649 | 650 | void ListRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) >> 651 | { >> 652 | path = PathGetter::fromConfig(key, config); 653 | 654 | if (config.has(key + ".watch_probability")) --- uncovered block 654-660 --- 652 | path = PathGetter::fromConfig(key, config); 653 | >> 654 | if (config.has(key + ".watch_probability")) >> 655 | { >> 656 | watch_probability = config.getDouble(key + ".watch_probability"); >> 657 | if (*watch_probability < 0.0 || *watch_probability > 1.0) >> 658 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability must be in [0.0, 1.0], got {}", *watch_probability); >> 659 | } >> 660 | } 661 | 662 | std::string ListRequestGenerator::descriptionImpl() --- uncovered block 663-670 --- 661 | 662 | std::string ListRequestGenerator::descriptionImpl() >> 663 | { >> 664 | std::string watch_string = watch_probability.has_value() ? fmt::format("\n- watch probability: {}", *watch_probability) : ""; >> 665 | return fmt::format( >> 666 | "List Request Generator\n" >> 667 | "- path(s) to list: {}{}", >> 668 | path.description(), >> 669 | watch_string); >> 670 | } 671 | 672 | ZooKeeperRequestWithCallbacks ListRequestGenerator::generateImpl(const Coordination::ACLs & /*acls*/) --- uncovered block 673-682 --- 671 | 672 | ZooKeeperRequestWithCallbacks ListRequestGenerator::generateImpl(const Coordination::ACLs & /*acls*/) >> 673 | { >> 674 | auto request = std::make_shared(); >> 675 | request->path = path.getPath(); >> 676 | if (watch_probability.has_value() && watch_picker(watch_rng) < *watch_probability) >> 677 | { >> 678 | request->has_watch = true; >> 679 | request->watch_callback = watch_callback_ptr; >> 680 | } >> 681 | return {.request = request, .on_success_callbacks = {}, .on_failure_callbacks = {}}; >> 682 | } 683 | 684 | void ListRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 685-687 --- 683 | 684 | void ListRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 685 | { >> 686 | path.initialize(zookeeper, tagged_paths); >> 687 | } 688 | 689 | void ListRequestGenerator::setSeedImpl(uint64_t seed) --- uncovered block 690-693 --- 688 | 689 | void ListRequestGenerator::setSeedImpl(uint64_t seed) >> 690 | { >> 691 | path.setSeed(seed + 100003); >> 692 | watch_rng.seed(seed + 400009); >> 693 | } 694 | 695 | void MultiRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) --- uncovered block 696-698 --- 694 | 695 | void MultiRequestGenerator::getFromConfigImpl(const std::string & key, const Poco::Util::AbstractConfiguration & config) >> 696 | { >> 697 | if (config.has(key + ".watch_probability")) >> 698 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability is not supported on multi requests directly; set it on individual get/list sub-requests instead (key '{}')", key); 699 | 700 | if (config.has(key + ".size")) --- uncovered block 700-701 --- 698 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "watch_probability is not supported on multi requests directly; set it on individual get/list sub-requests instead (key '{}')", key); 699 | >> 700 | if (config.has(key + ".size")) >> 701 | size = NumberGetter::fromConfig(key + ".size", config); 702 | 703 | request_getter = RequestGetter::fromConfig(key, config, /*for_multi*/ true); --- uncovered block 765-766 --- 763 | .request = std::make_shared(ops, acls), 764 | .on_success_callbacks = std::move(on_success_callbacks), >> 765 | .on_failure_callbacks = std::move(on_failure_callbacks)}; >> 766 | } 767 | 768 | void MultiRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) --- uncovered block 769-771 --- 767 | 768 | void MultiRequestGenerator::startupImpl(Coordination::ZooKeeper & zookeeper, const TaggedPaths * tagged_paths) >> 769 | { >> 770 | request_getter.startup(zookeeper, tagged_paths); >> 771 | } 772 | 773 | void MultiRequestGenerator::setWatchCallbackImpl(Coordination::WatchCallbackPtr callback) --- uncovered block 774-776 --- 772 | 773 | void MultiRequestGenerator::setWatchCallbackImpl(Coordination::WatchCallbackPtr callback) >> 774 | { >> 775 | request_getter.setWatchCallback(std::move(callback)); >> 776 | } 777 | 778 | void MultiRequestGenerator::setSeedImpl(uint64_t seed) --- uncovered block 785-786 --- 783 | request_getter.setSeed(seed + 500009); 784 | if (size) >> 785 | size->setSeed(seed + 100003); >> 786 | } 787 | 788 | void Generator::startup(const Poco::Util::AbstractConfiguration & config, Coordination::ZooKeeper & zookeeper, size_t thread_idx, const TaggedPaths * tagged_paths) --- uncovered block 789-791 --- 787 | 788 | void Generator::startup(const Poco::Util::AbstractConfiguration & config, Coordination::ZooKeeper & zookeeper, size_t thread_idx, const TaggedPaths * tagged_paths) >> 789 | { >> 790 | if (config.has("generator.seed")) >> 791 | seed = config.getUInt64("generator.seed") + thread_idx; 792 | else 793 | seed = randomSeed(); --- uncovered block 804-805 --- 802 | { 803 | std::cerr << "Generator seed: " << seed << std::endl; >> 804 | std::cerr << request_getter.description() << std::endl; >> 805 | } 806 | 807 | request_getter.startup(zookeeper, tagged_paths); --- uncovered block 807-808 --- 805 | } 806 | >> 807 | request_getter.startup(zookeeper, tagged_paths); >> 808 | } 809 | 810 | void Generator::setWatchCallback(Coordination::WatchCallbackPtr callback) No lost baseline coverage found. WARNING: Failed to get start time for [Print Uncovered Code] - start time and duration won't be set --- Coverage counts --- Lines : baseline 742,074/883,209 → current 742,222/883,268 (Δ +148 / +59) Functions : baseline 798,716/878,988 → current 798,712/878,993 (Δ -4 / +5) Branches : baseline 240,745/314,576 → current 240,772/314,616 (Δ +27 / +40)