diff --git a/crates/extensions/c8y_mapper_ext/src/operations/handlers/firmware_update.rs b/crates/extensions/c8y_mapper_ext/src/operations/handlers/firmware_update.rs index 7049b3f87b..eb0cb2b112 100644 --- a/crates/extensions/c8y_mapper_ext/src/operations/handlers/firmware_update.rs +++ b/crates/extensions/c8y_mapper_ext/src/operations/handlers/firmware_update.rs @@ -77,7 +77,7 @@ impl OperationContext { .with_qos(QoS::AtLeastOnce); Ok(OperationOutcome::Finished { - messages: vec![c8y_notification, twin_metadata], + messages: vec![twin_metadata, c8y_notification], }) } CommandStatus::Failed { reason } => Err(anyhow::anyhow!(reason).into()), @@ -530,11 +530,11 @@ mod tests { assert_received_contains_str( &mut mqtt, [ - ("c8y/s/us", "503,c8y_Firmware"), // SmartREST successful ( "te/device/main///twin/firmware", r#"{"name":"myFirmware","version":"1.0","url":"http://www.my.url"}"#, ), // Twin firmware metadata + ("c8y/s/us", "503,c8y_Firmware"), // SmartREST successful ("te/device/main///cmd/firmware_update/c8y-mapper-1234", ""), // Clear cmd ], ) @@ -579,11 +579,11 @@ mod tests { assert_received_contains_str( &mut mqtt, [ - ("c8y/s/us/test-device:device:child1", "503,c8y_Firmware"), // SmartREST successful ( "te/device/child1///twin/firmware", r#"{"name":"myFirmware","version":"1.0","url":"http://www.my.url"}"#, ), // Twin firmware metadata + ("c8y/s/us/test-device:device:child1", "503,c8y_Firmware"), // SmartREST successful ("te/device/child1///cmd/firmware_update/c8y-mapper-1234", ""), // Clear cmd ], ) @@ -623,11 +623,11 @@ mod tests { assert_received_contains_str( &mut mqtt, [ - ("c8y/s/us", "506,1234"), // SmartREST successful ( "te/device/main///twin/firmware", r#"{"name":"myFirmware","version":"1.0","url":"http://www.my.url"}"#, ), // Twin firmware metadata + ("c8y/s/us", "506,1234"), // SmartREST successful ("te/device/main///cmd/firmware_update/c8y-mapper-1234", ""), // Clear cmd ], ) diff --git a/crates/extensions/c8y_mapper_ext/src/operations/handlers/software_update.rs b/crates/extensions/c8y_mapper_ext/src/operations/handlers/software_update.rs index 92cff85d85..07592575e8 100644 --- a/crates/extensions/c8y_mapper_ext/src/operations/handlers/software_update.rs +++ b/crates/extensions/c8y_mapper_ext/src/operations/handlers/software_update.rs @@ -49,8 +49,8 @@ impl OperationContext { Ok(OperationOutcome::Finished { messages: vec![ - MqttMessage::new(topic, smartrest_set_operation), self.request_software_list(&target.topic_id), + MqttMessage::new(topic, smartrest_set_operation), ], }) } @@ -64,8 +64,8 @@ impl OperationContext { Ok(OperationOutcome::Finished { messages: vec![ - MqttMessage::new(topic, smartrest_set_operation), self.request_software_list(&target.topic_id), + MqttMessage::new(topic, smartrest_set_operation), ], }) } @@ -197,9 +197,6 @@ mod tests { .await .expect("Send failed"); - // Expect `503` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. - assert_received_contains_str(&mut mqtt, [("c8y/s/us", "503,c8y_SoftwareUpdate")]).await; - // An updated list of software is requested assert_received_contains_str( &mut mqtt, @@ -210,6 +207,9 @@ mod tests { ) .await; + // Expect `503` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. + assert_received_contains_str(&mut mqtt, [("c8y/s/us", "503,c8y_SoftwareUpdate")]).await; + // The successful state is cleared assert_received_contains_str( &mut mqtt, @@ -254,9 +254,6 @@ mod tests { .await .expect("Send failed"); - // Expect `506` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. - assert_received_contains_str(&mut mqtt, [("c8y/s/us", "506,123")]).await; - // An updated list of software is requested assert_received_contains_str( &mut mqtt, @@ -267,6 +264,9 @@ mod tests { ) .await; + // Expect `506` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. + assert_received_contains_str(&mut mqtt, [("c8y/s/us", "506,123")]).await; + // The successful state is cleared assert_received_contains_str( &mut mqtt, @@ -294,22 +294,22 @@ mod tests { .await .expect("Send failed"); - // `502` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. + // An updated list of software is requested assert_received_contains_str( &mut mqtt, [( - "c8y/s/us", - "502,c8y_SoftwareUpdate,Partial failure: Couldn't install collectd and nginx", + "te/device/main///cmd/software_list/+", + r#"{"status":"init"}"#, )], ) .await; - // An updated list of software is requested + // `502` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. assert_received_contains_str( &mut mqtt, [( - "te/device/main///cmd/software_list/+", - r#"{"status":"init"}"#, + "c8y/s/us", + "502,c8y_SoftwareUpdate,Partial failure: Couldn't install collectd and nginx", )], ) .await; @@ -345,22 +345,22 @@ mod tests { .await .expect("Send failed"); - // `505` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. + // An updated list of software is requested assert_received_contains_str( &mut mqtt, [( - "c8y/s/us", - "505,123,Partial failure: Couldn't install collectd and nginx", + "te/device/main///cmd/software_list/+", + r#"{"status":"init"}"#, )], ) .await; - // An updated list of software is requested + // `505` messages with correct payload have been received on `c8y/s/us`, if no msg received for the timeout the test fails. assert_received_contains_str( &mut mqtt, [( - "te/device/main///cmd/software_list/+", - r#"{"status":"init"}"#, + "c8y/s/us", + "505,123,Partial failure: Couldn't install collectd and nginx", )], ) .await;