mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-09 20:21:01 +00:00
Make soak tests work again now that we subscribe by genesis hash (#399)
* Make soak tests work again with genesis hash subscribing * cargo fmt * derive hex from hash * actually compile code * fmt Co-authored-by: David Palm <dvdplm@gmail.com>
This commit is contained in:
@@ -34,6 +34,7 @@ In general, if you run into issues, it may be better to run this on a linux
|
||||
box; MacOS seems to hit limits quicker in general.
|
||||
*/
|
||||
|
||||
use common::node_types::BlockHash;
|
||||
use common::ws_client::SentMessage;
|
||||
use futures::{future, StreamExt};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -115,6 +116,9 @@ async fn run_soak_test(opts: SoakTestOpts) {
|
||||
nodes.append(&mut conns);
|
||||
}
|
||||
|
||||
let genesis_hash = BlockHash::from_low_u64_be(1);
|
||||
let genesis_hash_string = format!("{:0x}", genesis_hash);
|
||||
|
||||
// Start nodes talking to the shards:
|
||||
let bytes_in = Arc::new(AtomicUsize::new(0));
|
||||
let ids_per_node = opts.ids_per_node;
|
||||
@@ -125,12 +129,13 @@ async fn run_soak_test(opts: SoakTestOpts) {
|
||||
let tx = tx.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
let telemetry = test_utils::fake_telemetry::FakeTelemetry::new(
|
||||
Duration::from_secs(3),
|
||||
format!("Node {}", (ids_per_node * idx) + id + 1),
|
||||
"Polkadot".to_owned(),
|
||||
id + 1,
|
||||
);
|
||||
let telemetry = test_utils::fake_telemetry::FakeTelemetry {
|
||||
block_time: Duration::from_secs(3),
|
||||
node_name: format!("Node {}", (ids_per_node * idx) + id + 1),
|
||||
chain: "Polkadot".to_owned(),
|
||||
genesis_hash: genesis_hash,
|
||||
message_id: id + 1,
|
||||
};
|
||||
|
||||
let res = telemetry
|
||||
.start(|msg| async {
|
||||
@@ -156,7 +161,9 @@ async fn run_soak_test(opts: SoakTestOpts) {
|
||||
|
||||
// Every feed subscribes to the chain above to recv messages about it:
|
||||
for (feed_tx, _) in &mut feeds {
|
||||
feed_tx.send_command("subscribe", "Polkadot").unwrap();
|
||||
feed_tx
|
||||
.send_command("subscribe", &genesis_hash_string)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Also start receiving messages, counting the bytes received so far.
|
||||
|
||||
@@ -8,22 +8,14 @@ use tokio::time::{self, MissedTickBehavior};
|
||||
/// This emits fake but realistic looking telemetry messages.
|
||||
/// Can be connected to a telemetry server to emit realistic messages.
|
||||
pub struct FakeTelemetry {
|
||||
block_time: Duration,
|
||||
node_name: String,
|
||||
chain: String,
|
||||
message_id: usize,
|
||||
pub block_time: Duration,
|
||||
pub node_name: String,
|
||||
pub chain: String,
|
||||
pub genesis_hash: BlockHash,
|
||||
pub message_id: usize,
|
||||
}
|
||||
|
||||
impl FakeTelemetry {
|
||||
pub fn new(block_time: Duration, node_name: String, chain: String, message_id: usize) -> Self {
|
||||
Self {
|
||||
block_time,
|
||||
node_name,
|
||||
chain,
|
||||
message_id,
|
||||
}
|
||||
}
|
||||
|
||||
/// Begin emitting messages from this node, calling the provided callback each
|
||||
/// time a new message is emitted.
|
||||
// Unused assignments allowed because macro seems to mess with knowledge of what's
|
||||
@@ -38,6 +30,7 @@ impl FakeTelemetry {
|
||||
let id = self.message_id;
|
||||
let name = self.node_name;
|
||||
let chain = self.chain;
|
||||
let genesis_hash = self.genesis_hash;
|
||||
let block_time = self.block_time;
|
||||
|
||||
// Our "state". These numbers can be hashed to give a block hash,
|
||||
@@ -62,7 +55,7 @@ impl FakeTelemetry {
|
||||
"authority":true,
|
||||
"chain":chain,
|
||||
"config":"",
|
||||
"genesis_hash":block_hash(best_block_n),
|
||||
"genesis_hash":genesis_hash,
|
||||
"implementation":"Substrate Node",
|
||||
"msg":"system.connected",
|
||||
"name":name,
|
||||
|
||||
Reference in New Issue
Block a user