From 01fdf40a0201df46ddb9b299cbe9f7dfd090a650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Mon, 3 Aug 2020 06:52:29 +0200 Subject: [PATCH] aquatic_ws_load_test: send num_want and better offer fake type This means wt-tracker starts sending offers --- TODO.md | 5 +++-- aquatic_ws_load_test/src/common.rs | 3 --- aquatic_ws_load_test/src/network.rs | 4 ++-- aquatic_ws_load_test/src/utils.rs | 15 ++++++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/TODO.md b/TODO.md index 7bf24f0..981ca23 100644 --- a/TODO.md +++ b/TODO.md @@ -49,9 +49,10 @@ ## aquatic_ws_load_test * still maybe too few answers received with aquatic_ws -* no offers received with wt-tracker. does it check that they are valid? * why does wt-tracker freak out when numwant is set to offers.len()? lots - of broken pipe errors etc. maybe wheck source for when it sends offers + of broken pipe errors etc. likely because it sends offers when it is set. +* wt-tracker source: event needs to be undefined in answer for it to register + as an answer ## aquatic_udp * handle errors similarily to aquatic_ws, including errors in socket workers diff --git a/aquatic_ws_load_test/src/common.rs b/aquatic_ws_load_test/src/common.rs index b1075fe..db3be95 100644 --- a/aquatic_ws_load_test/src/common.rs +++ b/aquatic_ws_load_test/src/common.rs @@ -5,9 +5,6 @@ use rand_distr::Pareto; pub use aquatic_ws_protocol::*; -/// JSON string used as fake announce offer / offer response -pub const JSON_VALUE: &str = r#"{ "offer": "abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh" }"#; - #[derive(PartialEq, Eq, Clone)] pub struct TorrentPeer { diff --git a/aquatic_ws_load_test/src/network.rs b/aquatic_ws_load_test/src/network.rs index 438b5c7..f3ba6c0 100644 --- a/aquatic_ws_load_test/src/network.rs +++ b/aquatic_ws_load_test/src/network.rs @@ -196,7 +196,7 @@ impl Connection { if let Some((peer_id, offer_id)) = self.send_answer { r.to_peer_id = Some(peer_id); r.offer_id = Some(offer_id); - r.answer = Some(JsonValue(::serde_json::Value::from(JSON_VALUE))); + r.answer = Some(JsonValue(::serde_json::json!({"abc": "def"}))); r.offers = None; } @@ -219,7 +219,7 @@ impl Connection { false } Err(err) => { - eprintln!("send request error: {:?}", err); + // eprintln!("send request error: {:?}", err); true } diff --git a/aquatic_ws_load_test/src/utils.rs b/aquatic_ws_load_test/src/utils.rs index f2af42f..f325a33 100644 --- a/aquatic_ws_load_test/src/utils.rs +++ b/aquatic_ws_load_test/src/utils.rs @@ -43,6 +43,7 @@ pub fn create_random_request( } + #[inline] fn create_announce_request( config: &Config, @@ -59,13 +60,17 @@ fn create_announce_request( }; let info_hash_index = select_info_hash_index(config, &state, rng); - - let mut offers = Vec::with_capacity(10); - for _ in 0..10 { + const NUM_OFFERS: usize = 2; + + let mut offers = Vec::with_capacity(NUM_OFFERS); + + for _ in 0..NUM_OFFERS { offers.push(AnnounceRequestOffer { offer_id: OfferId(rng.gen()), - offer: JsonValue(::serde_json::Value::from(JSON_VALUE)), + offer: JsonValue(::serde_json::json!( + {"sdp": "abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-abcdefg-"} + )), }) } @@ -79,7 +84,7 @@ fn create_announce_request( peer_id, bytes_left: Some(bytes_left), event, - numwant: None, + numwant: Some(offers.len()), offers: Some(offers), answer: None, to_peer_id: None,