mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-29 14:14:13 +00:00
fix: adapt release backport test dependencies
Copy the writer observation test utility from #9505 (18726c7602) for the #9919 staging regression, initialize the release-only catchup location hint, and remove main-only unused imports.
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
@@ -107,8 +107,7 @@ use common_telemetry::{debug, info, tracing, warn};
|
||||
use common_wal::options::WalOptions;
|
||||
use datafusion_common::ScalarValue;
|
||||
use datafusion_expr::Expr;
|
||||
use futures::FutureExt;
|
||||
use futures::future::{self, join_all, try_join_all};
|
||||
use futures::future::{join_all, try_join_all};
|
||||
use futures::stream::{self, Stream, StreamExt};
|
||||
use object_store::manager::ObjectStoreManagerRef;
|
||||
use region_hook::RegionHookRef;
|
||||
|
||||
@@ -1468,6 +1468,7 @@ async fn test_downgrade_during_alter_keeps_acknowledged_writes_with_local_wal()
|
||||
set_writable: true,
|
||||
entry_id: Some(reported),
|
||||
metadata_entry_id: None,
|
||||
location_id: None,
|
||||
checkpoint: None,
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use derive_builder::Builder;
|
||||
pub use oio::*;
|
||||
@@ -225,6 +225,50 @@ impl oio::Read for MockReader {
|
||||
}
|
||||
}
|
||||
|
||||
/// Writer calls observed before forwarding, including calls that fail.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct WriterObservations {
|
||||
pub write_sizes: Vec<usize>,
|
||||
pub close_calls: usize,
|
||||
pub abort_calls: usize,
|
||||
}
|
||||
|
||||
/// Records calls without changing the inner writer's completion or abort semantics.
|
||||
pub struct ObservedWriter {
|
||||
inner: oio::Writer,
|
||||
observations: Arc<Mutex<WriterObservations>>,
|
||||
}
|
||||
|
||||
impl ObservedWriter {
|
||||
pub fn new(inner: oio::Writer, observations: Arc<Mutex<WriterObservations>>) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
observations,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl oio::Write for ObservedWriter {
|
||||
async fn write(&mut self, bytes: Buffer) -> Result<()> {
|
||||
self.observations
|
||||
.lock()
|
||||
.unwrap()
|
||||
.write_sizes
|
||||
.push(bytes.len());
|
||||
self.inner.write(bytes).await
|
||||
}
|
||||
|
||||
async fn close(&mut self) -> Result<Metadata> {
|
||||
self.observations.lock().unwrap().close_calls += 1;
|
||||
self.inner.close().await
|
||||
}
|
||||
|
||||
async fn abort(&mut self) -> Result<()> {
|
||||
self.observations.lock().unwrap().abort_calls += 1;
|
||||
self.inner.abort().await
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MockWriter {
|
||||
inner: oio::Writer,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user