-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add test suite and minor refinements to the utility subsystem #1403
Conversation
Unfortunately, the test fails right now for reasons which seem very odd. Just have to keep poking at it.
let _ = async move { unordered.collect::<Vec<_>>() }.await; | ||
.collect::<FuturesUnordered<_>>() | ||
.map(Ok) | ||
.forward(drain()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The root problem here was two-fold: - there was a circular dependency from subsystem -> test-helpers/subsystem -> subsystem - cfg(test) doesn't propagate between crates The solution: move the subsystem test helpers into a sub-module within subsystem. Publicly export them from the previous location so no other code breaks. Doing this has an additional benefit: it ensures that no production code can ever accidentally use the subsystem helpers, as they are compile- gated on cfg(test).
Log tests weren't the best idea in the first place, so I replaced that whole system in f0c23de |
It's not obvious whether we'll ever really want to chase down these errors outside a testing context, but having the capability won't hurt.
also fix polkadot-node-core-backing tests
rx_to: mpsc::Receiver<Self::ToJob>, | ||
tx_from: mpsc::Sender<Self::FromJob>, | ||
receiver: mpsc::Receiver<Self::ToJob>, | ||
sender: mpsc::Sender<Self::FromJob>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
node/subsystem/src/util.rs
Outdated
if let Some(mut err_tx) = err_tx { | ||
// if we can't send the notification of error on the error channel, then | ||
// there's no point trying to propagate this error onto the channel too | ||
let _ = err_tx.send((Some(parent_hash), JobsError::Job(e))).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we print a warning here at least? This seems to be a more general question how we want to handle these cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly one question how we want to handle cases where channels are saturated / unabled to send to the overseer? I am in favor of warn!
Combine tests of starting and stopping job: leaving a test executor with a job running was pretty clearly the cause of the sometimes-hang. Also, add a timeout so tests _can't_ hang anymore; they just fail after a while.
/// | ||
/// This variant is only valid while testing, but makes the process of testing the | ||
/// subsystem job manager much simpler. | ||
#[cfg(test)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want #[cfg(any(test, feature = "test-helpers"))]
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No: this is only used within the internal unit tests of the job manager. If we come up with a use for it later, we can add it then. Until then, I think YAGNI is the better part of valor.
No description provided.