Skip to content

Commit

Permalink
Merge #100
Browse files Browse the repository at this point in the history
100: Add mqtt tester to flake r=TheNeikos a=TheNeikos



Co-authored-by: Marcel Müller <[email protected]>
Co-authored-by: Matthias Beyer <[email protected]>
  • Loading branch information
3 people authored Jan 4, 2023
2 parents bb1f78c + 705adf3 commit 8439983
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@

cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
cargoExtraArgs = "--all-features --all";
};

cloudmqtt = craneLib.buildPackage {
inherit cargoArtifacts src version;
cargoExtraArgs = "--all-features";
cargoExtraArgs = "--all-features --all";
};

cloudmqtt-client = craneLib.buildPackage {
Expand All @@ -64,6 +65,7 @@

cloudmqtt-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
cargoExtraArgs = "--all --all-features";
cargoClippyExtraArgs = "-- --deny warnings";
};

Expand Down Expand Up @@ -93,12 +95,10 @@

devShells.default = devShells.cloudmqtt;
devShells.cloudmqtt = pkgs.mkShell {
buildInputs = [
];
buildInputs = [ ];

nativeBuildInputs = [
rustTarget
#unstableRustTarget

pkgs.cargo-msrv
pkgs.cargo-deny
Expand Down
7 changes: 3 additions & 4 deletions mqtt-tester/src/client_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use std::time::Duration;

use futures::FutureExt;
use mqtt_format::v3::connect_return::MConnectReturnCode;
use mqtt_format::v3::header::MPacketKind;

use mqtt_format::v3::identifier::MPacketIdentifier;
use mqtt_format::v3::packet::{MConnack, MPacket, MPublish, MSubscribe};
use mqtt_format::v3::qos::MQualityOfService;
use mqtt_format::v3::strings::MString;
use mqtt_format::v3::packet::{MConnack, MPacket, MSubscribe};

use mqtt_format::v3::subscription_request::MSubscriptionRequests;
use tokio::process::Command;

Expand Down
8 changes: 6 additions & 2 deletions mqtt-tester/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ pub struct Command {
inner: tokio::process::Command,
}

pub type CheckBytesFn = Box<dyn FnOnce(&[u8]) -> bool>;

pub enum ClientCommand {
Send(Vec<u8>),
#[allow(unused)]
WaitFor(Vec<u8>),
WaitAndCheck(Box<dyn FnOnce(&[u8]) -> bool>),
#[allow(unused)]
WaitAndCheck(CheckBytesFn),
}

impl Command {
Expand All @@ -41,7 +45,7 @@ impl Command {
to_client.write_all(&bytes).await.into_diagnostic()?
}
ClientCommand::WaitFor(expected_bytes) => {
let mut buf = Vec::with_capacity(expected_bytes.len());
let mut buf = vec![0; expected_bytes.len()];
match tokio::time::timeout(
std::time::Duration::from_millis(100),
from_client.read_exact(&mut buf),
Expand Down
1 change: 1 addition & 0 deletions mqtt-tester/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::io::Write;
pub enum ReportResult {
Success,
Failure,
#[allow(unused)]
Inconclusive,
}

Expand Down
2 changes: 1 addition & 1 deletion mqtt-tester/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::pin::Pin;
use miette::IntoDiagnostic;
use mqtt_format::v3::packet::MPacket;

pub async fn packet_to_vec<'m>(mpacket: MPacket<'m>) -> miette::Result<Vec<u8>> {
pub async fn packet_to_vec(mpacket: MPacket<'_>) -> miette::Result<Vec<u8>> {
let mut buf = vec![];
{
let mut cursor = futures::io::Cursor::new(&mut buf);
Expand Down

0 comments on commit 8439983

Please sign in to comment.