Skip to content

Commit

Permalink
[main] Rust toolchain upgrade fixes (#6283)
Browse files Browse the repository at this point in the history
Continuation of #6278.

Resolves clippy failures not caught due to pipelines not triggering on changes to `rust-toolchain.toml`.

## Azure IoT Edge PR checklist:
  • Loading branch information
onalante-msft authored Apr 13, 2022
1 parent 35be5fe commit a45cc5f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion builds/checkin/api-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion builds/checkin/edgelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion builds/checkin/mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion builds/checkin/rust-test-modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion builds/checkin/watchdog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion builds/ci/mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ trigger:
- release/*
paths:
include:
- "rust-toolchain.toml"
- "mqtt/*"
- "builds/*"
pr: none
Expand Down Expand Up @@ -92,4 +93,4 @@ jobs:
testResultsFormat: "JUnit"
testResultsFiles: "**/test-results.xml"
failTaskOnFailedTests: true
condition: succeededOrFailed()
condition: succeededOrFailed()
10 changes: 5 additions & 5 deletions edge-hub/watchdog/src/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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 {
Expand All @@ -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);
}
Expand All @@ -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();
}
Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions mqtt/mqtt-broker/src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
});
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions mqtt/mqtt-broker/tests/persist_failpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn arb_op() -> impl Strategy<Value = Op> {
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),
]
}

Expand Down

0 comments on commit a45cc5f

Please sign in to comment.