Skip to content

Commit 24abfde

Browse files
committed
Self-review updates
1 parent aee1a12 commit 24abfde

File tree

1 file changed

+19
-49
lines changed

1 file changed

+19
-49
lines changed

crates/worker/src/partition/snapshots/repository.rs

Lines changed: 19 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -548,42 +548,6 @@ mod tests {
548548
use restate_types::identifiers::{PartitionId, PartitionKey, SnapshotId};
549549
use restate_types::logs::{Lsn, SequenceNumber};
550550

551-
#[tokio::test]
552-
async fn test_repository_local() -> anyhow::Result<()> {
553-
tracing_subscriber::registry()
554-
.with(fmt::layer())
555-
.with(EnvFilter::from_default_env())
556-
.init();
557-
558-
let snapshot_source = TempDir::new()?;
559-
let source_dir = snapshot_source.path().to_path_buf();
560-
561-
let mut data = tokio::fs::File::create(source_dir.join("data.sst")).await?;
562-
data.write_all(b"snapshot-data").await?;
563-
564-
let snapshot = mock_snapshot_metadata(
565-
"/data.sst".to_owned(),
566-
source_dir.to_string_lossy().to_string(),
567-
);
568-
569-
let snapshots_destination = TempDir::new()?;
570-
let opts = SnapshotsOptions {
571-
destination: Some(
572-
Url::from_file_path(snapshots_destination.path())
573-
.unwrap()
574-
.to_string(),
575-
),
576-
..SnapshotsOptions::default()
577-
};
578-
let repository = SnapshotRepository::create_if_configured(&opts)
579-
.await?
580-
.unwrap();
581-
582-
repository.put(&snapshot, source_dir).await?;
583-
584-
Ok(())
585-
}
586-
587551
#[tokio::test]
588552
async fn test_overwrite_unparsable_latest() -> anyhow::Result<()> {
589553
tracing_subscriber::registry()
@@ -629,9 +593,9 @@ mod tests {
629593
}
630594

631595
#[tokio::test]
632-
async fn test_update_existing_snapshot_local_filesystem() -> anyhow::Result<()> {
596+
async fn test_put_snapshot_local_filesystem() -> anyhow::Result<()> {
633597
let snapshots_destination = TempDir::new()?;
634-
test_update_existing_snapshot_with_newer(
598+
test_put_snapshot(
635599
Url::from_file_path(snapshots_destination.path())
636600
.unwrap()
637601
.to_string(),
@@ -641,15 +605,14 @@ mod tests {
641605

642606
/// For this test to run, set RESTATE_S3_INTEGRATION_TEST_BUCKET_NAME to a writable S3 bucket name
643607
#[tokio::test]
644-
async fn test_update_existing_snapshot_s3() -> anyhow::Result<()> {
608+
async fn test_put_snapshot_s3() -> anyhow::Result<()> {
645609
let Ok(bucket_name) = std::env::var("RESTATE_S3_INTEGRATION_TEST_BUCKET_NAME") else {
646610
return Ok(());
647611
};
648-
test_update_existing_snapshot_with_newer(format!("s3://{bucket_name}/integration-test"))
649-
.await
612+
test_put_snapshot(format!("s3://{bucket_name}/integration-test")).await
650613
}
651614

652-
async fn test_update_existing_snapshot_with_newer(destination: String) -> anyhow::Result<()> {
615+
async fn test_put_snapshot(destination: String) -> anyhow::Result<()> {
653616
tracing_subscriber::registry()
654617
.with(fmt::layer())
655618
.with(EnvFilter::from_default_env())
@@ -658,6 +621,19 @@ mod tests {
658621
let snapshot_source = TempDir::new()?;
659622
let source_dir = snapshot_source.path().to_path_buf();
660623

624+
let destination_url = Url::parse(destination.as_str())?;
625+
let path = destination_url.path().to_string();
626+
let object_store = super::create_object_store_client(destination_url).await?;
627+
628+
let latest = object_store
629+
.get(&Path::from(format!(
630+
"{}/{}/latest.json",
631+
path,
632+
PartitionId::MIN,
633+
)))
634+
.await;
635+
assert!(matches!(latest, Err(object_store::Error::NotFound { .. })));
636+
661637
let mut data = tokio::fs::File::create(source_dir.join("data.sst")).await?;
662638
data.write_all(b"snapshot-data").await?;
663639

@@ -672,16 +648,10 @@ mod tests {
672648
);
673649

674650
let opts = SnapshotsOptions {
675-
destination: Some(destination.clone()),
651+
destination: Some(destination),
676652
..SnapshotsOptions::default()
677653
};
678654

679-
eprintln!("Destination: {}", destination);
680-
681-
let destination = Url::parse(destination.as_str())?;
682-
let path = destination.path().to_string();
683-
let object_store = super::create_object_store_client(destination).await?;
684-
685655
let repository = SnapshotRepository::create_if_configured(&opts)
686656
.await?
687657
.unwrap();

0 commit comments

Comments
 (0)