Report uncertain FTP mutation outcomes
This commit is contained in:
+24
-1
@@ -16,6 +16,7 @@ pub enum Scenario {
|
||||
CancelledPreflight,
|
||||
ExpiredListing,
|
||||
LostMutationReply,
|
||||
LostUploadCompletion,
|
||||
}
|
||||
|
||||
struct State {
|
||||
@@ -23,6 +24,8 @@ struct State {
|
||||
control_connections: usize,
|
||||
listings: usize,
|
||||
mkdir_commands: usize,
|
||||
upload_commands: usize,
|
||||
uploaded_bytes: usize,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
@@ -35,6 +38,8 @@ pub struct Summary {
|
||||
pub control_connections: usize,
|
||||
pub listings: usize,
|
||||
pub mkdir_commands: usize,
|
||||
pub upload_commands: usize,
|
||||
pub uploaded_bytes: usize,
|
||||
}
|
||||
|
||||
pub fn install(scenario: Scenario) -> Fixture {
|
||||
@@ -43,6 +48,8 @@ pub fn install(scenario: Scenario) -> Fixture {
|
||||
control_connections: 0,
|
||||
listings: 0,
|
||||
mkdir_commands: 0,
|
||||
upload_commands: 0,
|
||||
uploaded_bytes: 0,
|
||||
}));
|
||||
ACTIVE.set(Some(state.clone()));
|
||||
Fixture(state)
|
||||
@@ -55,6 +62,8 @@ impl Fixture {
|
||||
control_connections: state.control_connections,
|
||||
listings: state.listings,
|
||||
mkdir_commands: state.mkdir_commands,
|
||||
upload_commands: state.upload_commands,
|
||||
uploaded_bytes: state.uploaded_bytes,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,8 +133,16 @@ impl Tcp {
|
||||
}
|
||||
|
||||
pub fn write(&self, bytes: &[u8]) -> Result<u32, HostError> {
|
||||
let Kind::Control(index) = self.kind else {
|
||||
if matches!(self.kind, Kind::Data) {
|
||||
let mut state = self.state.borrow_mut();
|
||||
if matches!(state.scenario, Scenario::LostUploadCompletion) {
|
||||
state.uploaded_bytes += bytes.len();
|
||||
return Ok(bytes.len() as u32);
|
||||
}
|
||||
return Err(HostError::InvalidInput);
|
||||
}
|
||||
let Kind::Control(index) = self.kind else {
|
||||
unreachable!();
|
||||
};
|
||||
let command = std::str::from_utf8(bytes)
|
||||
.map_err(|_| HostError::InvalidInput)?
|
||||
@@ -154,6 +171,12 @@ impl Tcp {
|
||||
return Err(HostError::Unavailable);
|
||||
}
|
||||
"NOOP" => "200 Still connected\r\n",
|
||||
"STOR /upload"
|
||||
if matches!(state.scenario, Scenario::LostUploadCompletion) =>
|
||||
{
|
||||
state.upload_commands += 1;
|
||||
"150 Upload started\r\n"
|
||||
}
|
||||
"MKD /new"
|
||||
if index == 1
|
||||
&& matches!(state.scenario, Scenario::LostMutationReply) =>
|
||||
|
||||
Reference in New Issue
Block a user