Merge pull request #202 from ikatson/update-e2e-test-delete
Update e2e test to test deletion
This commit is contained in:
commit
d99ebccf4d
1 changed files with 34 additions and 6 deletions
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
tests::test_util::{
|
tests::test_util::{
|
||||||
create_default_random_dir_with_torrents, spawn_debug_server, TestPeerMetadata,
|
create_default_random_dir_with_torrents, spawn_debug_server, TestPeerMetadata,
|
||||||
},
|
},
|
||||||
AddTorrentOptions, AddTorrentResponse, Session, SessionOptions,
|
AddTorrentOptions, AddTorrentResponse, Session, SessionOptions, SessionPersistenceConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 64)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 64)]
|
||||||
|
|
@ -86,7 +86,6 @@ async fn _test_e2e_download() {
|
||||||
disable_dht: true,
|
disable_dht: true,
|
||||||
disable_dht_persistence: true,
|
disable_dht_persistence: true,
|
||||||
dht_config: None,
|
dht_config: None,
|
||||||
persistence: None,
|
|
||||||
peer_id: Some(peer_id),
|
peer_id: Some(peer_id),
|
||||||
peer_opts: None,
|
peer_opts: None,
|
||||||
listen_port_range: Some(listen_range),
|
listen_port_range: Some(listen_range),
|
||||||
|
|
@ -176,14 +175,18 @@ async fn _test_e2e_download() {
|
||||||
|
|
||||||
// 3. Start a client with the initial peers, and download the file.
|
// 3. Start a client with the initial peers, and download the file.
|
||||||
for _ in 0..client_iters {
|
for _ in 0..client_iters {
|
||||||
let outdir = tempfile::TempDir::with_prefix("rqbit_e2e_client").unwrap();
|
let root = tempfile::TempDir::with_prefix("rqbit_e2e_client").unwrap();
|
||||||
|
let outdir = root.path().join("out");
|
||||||
|
let session_persistence = root.path().join("session");
|
||||||
let session = Session::new_with_opts(
|
let session = Session::new_with_opts(
|
||||||
outdir.path().to_owned(),
|
outdir.to_owned(),
|
||||||
SessionOptions {
|
SessionOptions {
|
||||||
disable_dht: true,
|
disable_dht: true,
|
||||||
disable_dht_persistence: true,
|
disable_dht_persistence: true,
|
||||||
dht_config: None,
|
dht_config: None,
|
||||||
persistence: None,
|
persistence: Some(SessionPersistenceConfig::Json {
|
||||||
|
folder: Some(session_persistence),
|
||||||
|
}),
|
||||||
listen_port_range: None,
|
listen_port_range: None,
|
||||||
enable_upnp_port_forwarding: false,
|
enable_upnp_port_forwarding: false,
|
||||||
root_span: Some(error_span!("client")),
|
root_span: Some(error_span!("client")),
|
||||||
|
|
@ -263,7 +266,12 @@ async fn _test_e2e_download() {
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("handle is completed");
|
info!("handle is completed");
|
||||||
session.delete(id.into(), false).await.unwrap();
|
tokio::time::timeout(Duration::from_secs(5), session.delete(id.into(), false))
|
||||||
|
.await
|
||||||
|
.context("timeout deleting torrent")
|
||||||
|
.unwrap()
|
||||||
|
.context("error deleting")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
info!("deleted handle");
|
info!("deleted handle");
|
||||||
|
|
||||||
|
|
@ -306,6 +314,26 @@ async fn _test_e2e_download() {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
tokio::time::timeout(
|
||||||
|
Duration::from_secs(5),
|
||||||
|
session.delete(handle.id().into(), true),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.context("timeout")
|
||||||
|
.unwrap()
|
||||||
|
.context("error deleting")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// Ensure the files were deleted from the filesystem.
|
||||||
|
let d = std::fs::read_dir(&outdir)
|
||||||
|
.context("read_dir outdir")
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
d.into_iter().count(),
|
||||||
|
0,
|
||||||
|
"{outdir:?} was not empty after deletion"
|
||||||
|
);
|
||||||
|
|
||||||
info!("all good");
|
info!("all good");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue