mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
Bugfix/output timeout (#2471)
* Fix: Test with the buf reader never finishing * fix NoOutput deserialization --------- Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>
This commit is contained in:
@@ -396,7 +396,7 @@ impl DockerProcedure {
|
|||||||
|
|
||||||
cmd.arg("exec");
|
cmd.arg("exec");
|
||||||
|
|
||||||
cmd.args(self.docker_args_inject(pkg_id).await?);
|
cmd.args(self.docker_args_inject(pkg_id));
|
||||||
let input_buf = if let (Some(input), Some(format)) = (&input, &self.io_format) {
|
let input_buf = if let (Some(input), Some(format)) = (&input, &self.io_format) {
|
||||||
cmd.stdin(std::process::Stdio::piped());
|
cmd.stdin(std::process::Stdio::piped());
|
||||||
Some(format.to_vec(input)?)
|
Some(format.to_vec(input)?)
|
||||||
@@ -756,7 +756,7 @@ impl DockerProcedure {
|
|||||||
+ self.args.len(), // [ARG...]
|
+ self.args.len(), // [ARG...]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
async fn docker_args_inject(&self, pkg_id: &PackageId) -> Result<Vec<Cow<'_, OsStr>>, Error> {
|
fn docker_args_inject(&self, pkg_id: &PackageId) -> Vec<Cow<'_, OsStr>> {
|
||||||
let mut res = self.new_docker_args();
|
let mut res = self.new_docker_args();
|
||||||
if let Some(shm_size_mb) = self.shm_size_mb {
|
if let Some(shm_size_mb) = self.shm_size_mb {
|
||||||
res.push(OsStr::new("--shm-size").into());
|
res.push(OsStr::new("--shm-size").into());
|
||||||
@@ -769,7 +769,7 @@ impl DockerProcedure {
|
|||||||
|
|
||||||
res.extend(self.args.iter().map(|s| OsStr::new(s).into()));
|
res.extend(self.args.iter().map(|s| OsStr::new(s).into()));
|
||||||
|
|
||||||
Ok(res)
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,13 +893,11 @@ async fn buf_reader_to_lines(
|
|||||||
limit: impl Into<Option<usize>>,
|
limit: impl Into<Option<usize>>,
|
||||||
) -> Result<Vec<String>, Error> {
|
) -> Result<Vec<String>, Error> {
|
||||||
let mut lines = reader.lines();
|
let mut lines = reader.lines();
|
||||||
let mut output = RingVec::new(limit.into().unwrap_or(1000));
|
let mut answer = RingVec::new(limit.into().unwrap_or(1000));
|
||||||
while let Ok(line) = lines.next_line().await {
|
while let Some(line) = lines.next_line().await? {
|
||||||
if let Some(line) = line {
|
answer.push(line);
|
||||||
output.push(line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let output: Vec<String> = output.value.into_iter().collect();
|
let output: Vec<String> = answer.value.into_iter().collect();
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -964,4 +962,11 @@ mod tests {
|
|||||||
assert_eq!(CAPACITY_IN, ring.value.capacity());
|
assert_eq!(CAPACITY_IN, ring.value.capacity());
|
||||||
assert_eq!(CAPACITY_IN, ring.value.len());
|
assert_eq!(CAPACITY_IN, ring.value.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tests_buf_reader_to_lines() {
|
||||||
|
let mut reader = BufReader::new("hello\nworld\n".as_bytes());
|
||||||
|
let lines = futures::executor::block_on(buf_reader_to_lines(&mut reader, None)).unwrap();
|
||||||
|
assert_eq!(lines, vec!["hello", "world"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,13 @@ impl<'de> Deserialize<'de> for NoOutput {
|
|||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let _ = Value::deserialize(deserializer)?;
|
let _ = Value::deserialize(deserializer);
|
||||||
Ok(NoOutput)
|
Ok(NoOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_deser_no_output() {
|
||||||
|
serde_json::from_str::<NoOutput>("").unwrap();
|
||||||
|
serde_json::from_str::<Result<NoOutput, NoOutput>>("{\"Ok\": null}").unwrap();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user