From a45cc5f71e200e78e4e93ae41e2731244bb20ac9 Mon Sep 17 00:00:00 2001 From: onalante-msft <89409054+onalante-msft@users.noreply.github.com> Date: Tue, 12 Apr 2022 19:19:51 -0700 Subject: [PATCH] [main] Rust toolchain upgrade fixes (#6283) Continuation of #6278. Resolves clippy failures not caught due to pipelines not triggering on changes to `rust-toolchain.toml`. ## Azure IoT Edge PR checklist: --- builds/checkin/api-proxy.yaml | 2 +- builds/checkin/edgelet.yaml | 2 +- builds/checkin/mqtt.yaml | 2 +- builds/checkin/rust-test-modules.yaml | 2 +- builds/checkin/watchdog.yaml | 2 +- builds/ci/mqtt.yaml | 3 ++- edge-hub/watchdog/src/child.rs | 10 +++++----- mqtt/mqtt-broker/src/tls.rs | 6 +++--- mqtt/mqtt-broker/tests/persist_failpoints.rs | 4 ++-- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/builds/checkin/api-proxy.yaml b/builds/checkin/api-proxy.yaml index 47afbf92b24..cd83095dc32 100644 --- a/builds/checkin/api-proxy.yaml +++ b/builds/checkin/api-proxy.yaml @@ -15,7 +15,7 @@ jobs: vmImage: "ubuntu-18.04" steps: - bash: | - git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(builds|edge-modules/api-proxy-module|mqtt/edgelet-client)' + git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(rust-toolchain\.toml|builds|edge-modules/api-proxy-module|mqtt/edgelet-client)' if [[ $? == 0 ]]; then echo "Detected changes inside builds or edge-modules/api-proxy-module or mqtt/edgelet-client folders" echo "##vso[task.setvariable variable=RUN_PIPELINE;isOutput=true]TRUE" diff --git a/builds/checkin/edgelet.yaml b/builds/checkin/edgelet.yaml index dd8c7671b90..1a2ccfaa7fb 100644 --- a/builds/checkin/edgelet.yaml +++ b/builds/checkin/edgelet.yaml @@ -14,7 +14,7 @@ jobs: vmImage: "ubuntu-18.04" steps: - bash: | - git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(builds|edgelet)' + git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(rust-toolchain\.toml|builds|edgelet)' if [[ $? == 0 ]]; then echo "Detected changes inside builds or edgelet folders" echo "##vso[task.setvariable variable=RUN_PIPELINE;isOutput=true]TRUE" diff --git a/builds/checkin/mqtt.yaml b/builds/checkin/mqtt.yaml index 8c657449c37..de90269c593 100644 --- a/builds/checkin/mqtt.yaml +++ b/builds/checkin/mqtt.yaml @@ -17,7 +17,7 @@ jobs: submodules: false fetchDepth: 3 - bash: | - git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(builds|mqtt)' + git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(rust-toolchain\.toml|builds|mqtt)' if [[ $? == 0 ]]; then echo "Detected changes inside builds or mqtt folders" echo "##vso[task.setvariable variable=RUN_PIPELINE;isOutput=true]TRUE" diff --git a/builds/checkin/rust-test-modules.yaml b/builds/checkin/rust-test-modules.yaml index 562636a2f97..d216eb6dc60 100644 --- a/builds/checkin/rust-test-modules.yaml +++ b/builds/checkin/rust-test-modules.yaml @@ -17,7 +17,7 @@ jobs: submodules: false fetchDepth: 3 - bash: | - git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(builds|test/modules/generic-mqtt-tester|test/rust-test-util|mqtt/mqtt-broker-tests-util)' + git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(rust-toolchain\.toml|builds|test/modules/generic-mqtt-tester|test/rust-test-util|mqtt/mqtt-broker-tests-util)' if [[ $? == 0 ]]; then echo "Detected changes inside builds or rust test module folders" echo "##vso[task.setvariable variable=RUN_PIPELINE;isOutput=true]TRUE" diff --git a/builds/checkin/watchdog.yaml b/builds/checkin/watchdog.yaml index ff767a4ccd0..32759765c4f 100644 --- a/builds/checkin/watchdog.yaml +++ b/builds/checkin/watchdog.yaml @@ -14,7 +14,7 @@ jobs: vmImage: "ubuntu-18.04" steps: - bash: | - git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(builds|edge-hub/watchdog)' + git log -m -1 --name-only --first-parent --pretty="" | egrep -i '^(rust-toolchain\.toml|builds|edge-hub/watchdog)' if [[ $? == 0 ]]; then echo "Detected changes inside builds or edgehub folders" echo "##vso[task.setvariable variable=RUN_PIPELINE;isOutput=true]TRUE" diff --git a/builds/ci/mqtt.yaml b/builds/ci/mqtt.yaml index aa54d861ad5..01ad24f14fa 100644 --- a/builds/ci/mqtt.yaml +++ b/builds/ci/mqtt.yaml @@ -5,6 +5,7 @@ trigger: - release/* paths: include: + - "rust-toolchain.toml" - "mqtt/*" - "builds/*" pr: none @@ -92,4 +93,4 @@ jobs: testResultsFormat: "JUnit" testResultsFiles: "**/test-results.xml" failTaskOnFailedTests: true - condition: succeededOrFailed() \ No newline at end of file + condition: succeededOrFailed() diff --git a/edge-hub/watchdog/src/child.rs b/edge-hub/watchdog/src/child.rs index f5d5770c952..b6a5d0c6b0b 100644 --- a/edge-hub/watchdog/src/child.rs +++ b/edge-hub/watchdog/src/child.rs @@ -28,7 +28,7 @@ impl ChildProcess { Self { name, process } } - pub fn is_running(&mut self) -> bool { + pub fn poll_running(&mut self) -> bool { match self.process.try_wait() { Ok(status) => status.is_none(), Err(e) => { @@ -39,7 +39,7 @@ impl ChildProcess { } pub fn shutdown_if_running(&mut self) { - if self.is_running() { + if self.poll_running() { info!("Terminating {} process", self.name); self.send_signal(Signal::SIGTERM); } else { @@ -48,7 +48,7 @@ impl ChildProcess { self.wait_for_exit(); - if self.is_running() { + if self.poll_running() { info!("Killing {} process", self.name); self.send_signal(Signal::SIGKILL); } @@ -73,7 +73,7 @@ impl ChildProcess { fn wait_for_exit(&mut self) { let mut elapsed_secs = 0; - while elapsed_secs < PROCESS_SHUTDOWN_TOLERANCE_SECS.as_secs() && self.is_running() { + while elapsed_secs < PROCESS_SHUTDOWN_TOLERANCE_SECS.as_secs() && self.poll_running() { thread::sleep(PROCESS_POLL_INTERVAL_SECS); elapsed_secs += PROCESS_POLL_INTERVAL_SECS.as_secs(); } @@ -99,7 +99,7 @@ pub fn run( let mut child_process = ChildProcess::new(name, child); - while child_process.is_running() && !should_shutdown.load(Ordering::Relaxed) { + while child_process.poll_running() && !should_shutdown.load(Ordering::Relaxed) { thread::sleep(PROCESS_POLL_INTERVAL_SECS); } diff --git a/mqtt/mqtt-broker/src/tls.rs b/mqtt/mqtt-broker/src/tls.rs index b0a6cf58056..38e2db25290 100644 --- a/mqtt/mqtt-broker/src/tls.rs +++ b/mqtt/mqtt-broker/src/tls.rs @@ -154,7 +154,7 @@ mod tests { tokio::spawn(async move { let mut buffer = [0_u8; 1024]; while stream.read(&mut buffer).await.unwrap() > 0 { - stream.write(&buffer).await.unwrap(); + assert_eq!(buffer.len(), stream.write(&buffer).await.unwrap()); } }); } @@ -180,10 +180,10 @@ mod tests { let mut tls = SslStream::new(ssl, tcp).unwrap(); Pin::new(&mut tls).connect().await.unwrap(); - tls.write(message).await.unwrap(); + assert_eq!(message.len(), tls.write(message).await.unwrap()); let mut buffer = vec![0; message.len()]; - tls.read(&mut buffer[..]).await.unwrap(); + assert_eq!(buffer.len(), tls.read(&mut buffer[..]).await.unwrap()); buffer } diff --git a/mqtt/mqtt-broker/tests/persist_failpoints.rs b/mqtt/mqtt-broker/tests/persist_failpoints.rs index c5bcfe277a3..16da3b13d4d 100644 --- a/mqtt/mqtt-broker/tests/persist_failpoints.rs +++ b/mqtt/mqtt-broker/tests/persist_failpoints.rs @@ -34,8 +34,8 @@ fn arb_op() -> impl Strategy { prop_oneof![ Just(Op::Load), Just(Op::Store(BrokerSnapshot::default())), - proptest::sample::select(FAILPOINTS).prop_map(|f| Op::AddFailpoint(f)), - proptest::sample::select(FAILPOINTS).prop_map(|f| Op::RemoveFailpoint(f)), + proptest::sample::select(FAILPOINTS).prop_map(Op::AddFailpoint), + proptest::sample::select(FAILPOINTS).prop_map(Op::RemoveFailpoint), ] }