Skip to content

Commit

Permalink
cst: Skip hash loading for some anomaly tests
Browse files Browse the repository at this point in the history
A method is added which stores a dummy hash on disk. This makes the
anomaly detector believe that hashes were loaded from inv. service,
which then enables the rest of the test to proceed as written
originally.

Without this, we do not perform segment existence checks if the hashes
are not found on disk.

This allows tests which have complex assertions depending on quotas to
work unmodified. In real world usage, where hashes are available, quota
is largely irrelevant now, but has not been fully removed yet to limit
the scope of the change.
  • Loading branch information
abhijat committed Sep 7, 2024
1 parent 2177e04 commit aafbbbd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/v/cloud_storage/tests/anomalies_detector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ class bucket_view_fixture : public http_imposter_fixture {
return path_hashes(std::move(paths));
}

ss::future<> put_dummy_hash() {
// Write a dummy hash to disk, for when we want the hash to be loaded
// but the rest of API calls to progress as if none of the segments were
// in the hash set, for example to test segment depth.
return cloud_storage::inventory::flush_ntp_hashes(
config::node_config().cloud_storage_inventory_hash_path(),
get_stm_manifest().get_ntp(),
{0xDEADBEEF},
0);
}

private:
void remove_json_stm_manifest(
const cloud_storage::partition_manifest& manifest) {
Expand Down Expand Up @@ -640,6 +651,8 @@ FIXTURE_TEST(test_segment_depth_limit, bucket_view_fixture) {
BOOST_REQUIRE_EQUAL(get_spillover_manifests().at(0).size(), 2);
BOOST_REQUIRE_EQUAL(get_spillover_manifests().at(1).size(), 2);

put_dummy_hash().get();

// check that with depth 0 we still process at least 1 segment
auto fwd_progress_res = run_detector(
cloud_storage::anomalies_detector::segment_depth_t{0});
Expand Down Expand Up @@ -970,6 +983,8 @@ FIXTURE_TEST(test_filtering_of_segment_merge, bucket_view_fixture) {
remove_segment(get_stm_manifest(), first_seg);
remove_segment(get_stm_manifest(), last_seg);

put_dummy_hash().get();

const auto result = run_detector(archival::run_quota_t{100});
BOOST_REQUIRE_EQUAL(result.status, cloud_storage::scrub_status::full);
BOOST_REQUIRE(result.detected.has_value());
Expand Down Expand Up @@ -1039,6 +1054,8 @@ FIXTURE_TEST(test_filtering_of_archive_segments, bucket_view_fixture) {
get_spillover_manifests().at(0),
*get_spillover_manifests().at(0).begin());

put_dummy_hash().get();

const auto result = run_detector(archival::run_quota_t{100});
BOOST_REQUIRE_EQUAL(result.status, cloud_storage::scrub_status::full);
BOOST_REQUIRE(result.detected.has_value());
Expand Down

0 comments on commit aafbbbd

Please sign in to comment.