5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-03 01:18:02 +03:00
proxmox-backup/tests/catar.rs
Christian Ebner 5a5d454083 client: chunk stream: switch payload stream chunker
Use the dedicated chunker with boundary suggestions for the payload
stream, by attaching the channel sender to the archiver and the
channel receiver to the payload stream chunker.

The archiver sends the file boundaries for the chunker to consume.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 16:39:42 +02:00

78 lines
1.7 KiB
Rust

use std::process::Command;
use anyhow::Error;
use pbs_client::pxar::*;
fn run_test(dir_name: &str) -> Result<(), Error> {
println!("run pxar test {}", dir_name);
Command::new("casync")
.arg("make")
.arg("test-casync.catar")
.arg(dir_name)
.status()
.expect("failed to execute casync");
let writer = std::fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open("test-proxmox.catar")?;
let writer = pxar::PxarVariant::Unified(pxar::encoder::sync::StandardWriter::new(writer));
let dir = nix::dir::Dir::open(
dir_name,
nix::fcntl::OFlag::O_NOFOLLOW,
nix::sys::stat::Mode::empty(),
)?;
let options = PxarCreateOptions {
entries_max: ENCODER_MAX_ENTRIES,
..PxarCreateOptions::default()
};
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(create_archive(
dir,
PxarWriters::new(writer, None),
Flags::DEFAULT,
|_| Ok(()),
options,
None,
None,
))?;
Command::new("cmp")
.arg("--verbose")
.arg("test-casync.catar")
.arg("test-proxmox.catar")
.status()
.expect("test failed - archives are different");
Ok(())
}
fn run_all_tests() -> Result<(), Error> {
run_test("tests/catar_data/test_file")?;
run_test("tests/catar_data/test_symlink")?;
run_test("tests/catar_data/test_subdir")?;
run_test("tests/catar_data/test_goodbye_sort_order")?;
run_test("tests/catar_data/test_files_and_subdirs")?;
Ok(())
}
#[test]
#[ignore]
fn catar_simple() {
if let Err(err) = run_all_tests() {
eprintln!("Error: {}", err);
std::process::exit(1);
}
}