-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage
: move storage_e2e_fixture
to its own header file
- Loading branch information
1 parent
7a29f24
commit c0d76d1
Showing
3 changed files
with
57 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
#include "redpanda/tests/fixture.h" | ||
#include "storage/disk_log_impl.h" | ||
#include "storage/segment.h" | ||
#include "test_utils/scoped_config.h" | ||
|
||
#include <seastar/core/future.hh> | ||
#include <seastar/core/shared_ptr.hh> | ||
|
||
struct storage_e2e_fixture : public redpanda_thread_fixture { | ||
scoped_config test_local_cfg; | ||
|
||
// Produces to the given fixture's partition for 10 seconds. | ||
ss::future<> produce_to_fixture(model::topic topic_name, int* incomplete) { | ||
tests::kafka_produce_transport producer(co_await make_kafka_client()); | ||
co_await producer.start(); | ||
const int cardinality = 10; | ||
auto now = ss::lowres_clock::now(); | ||
while (ss::lowres_clock::now() < now + 5s) { | ||
for (int i = 0; i < cardinality; i++) { | ||
co_await producer.produce_to_partition( | ||
topic_name, | ||
model::partition_id(0), | ||
tests::kv_t::sequence(i, 1)); | ||
} | ||
} | ||
*incomplete -= 1; | ||
} | ||
|
||
ss::future<> remove_segment_permanently( | ||
storage::disk_log_impl* log, ss::lw_shared_ptr<storage::segment> seg) { | ||
return log->remove_segment_permanently(seg, "storage_e2e_fixture") | ||
.then([&, log, seg]() { | ||
auto& segs = log->segments(); | ||
auto it = std::find(segs.begin(), segs.end(), seg); | ||
if (it == segs.end()) { | ||
return; | ||
} | ||
segs.erase(it, std::next(it)); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters