Skip to content

Commit

Permalink
Test ArtifactGatherer on its own.
Browse files Browse the repository at this point in the history
  • Loading branch information
nfachan committed Jan 22, 2025
1 parent 68ceb29 commit 1a8c12f
Show file tree
Hide file tree
Showing 7 changed files with 765 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ gethostname = "0.4.2"
globset = "0.4"
gloo-net = "0.6"
gloo-utils = "0.2"
hashbag = "0.1.12"
heck = "0.5.0"
hex = "0.4.3"
hyper = { version = "0.14", features = ["http1", "server", "tcp", "stream"] }
Expand Down
34 changes: 33 additions & 1 deletion crates/maelstrom-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,28 @@ macro_rules! manifest_digest {
}

/// An absolute job ID that includes a [`ClientId`] for disambiguation.
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[derive(
Copy, Clone, Debug, Deserialize, Display, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize,
)]
#[display("{cid}.{cjid}")]
pub struct JobId {
pub cid: ClientId,
pub cjid: ClientJobId,
}

impl<ClientIdT, ClientJobIdT> From<(ClientIdT, ClientJobIdT)> for JobId
where
ClientId: From<ClientIdT>,
ClientJobId: From<ClientJobIdT>,
{
fn from((cid, cjid): (ClientIdT, ClientJobIdT)) -> Self {
Self {
cid: ClientId::from(cid),
cjid: ClientJobId::from(cjid),
}
}
}

#[pocket_definition(export)]
#[derive(Debug, Deserialize, EnumIter, EnumSetType, Serialize)]
pub enum JobDevice {
Expand Down Expand Up @@ -833,6 +849,22 @@ mod tests {
assert_eq!(format!("{:3}", WorkerId::from(43)), " 43");
}

#[test]
fn job_id_from() {
assert_eq!(
JobId {
cid: ClientId::from(1),
cjid: ClientJobId::from(2)
},
JobId::from((1, 2))
);
}

#[test]
fn job_id_display() {
assert_eq!(format!("{}", JobId::from((0, 0))), "0.0");
}

#[test]
fn sha256_digest_from_u64() {
assert_eq!(
Expand Down
1 change: 1 addition & 0 deletions crates/maelstrom-broker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clap.workspace = true
derive_more.workspace = true
enum-map.workspace = true
futures.workspace = true
hashbag.workspace = true
hyper-tungstenite.workspace = true
hyper.workspace = true
maelstrom-base.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/maelstrom-broker/src/scheduler_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use scheduler::{Message, Scheduler, SchedulerDeps};
use std::{path::PathBuf, sync::mpsc as std_mpsc};
use tokio::{io::AsyncRead, sync::mpsc as tokio_mpsc, task::JoinSet};

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct ManifestReadRequest<ArtifactStreamT> {
manifest_stream: ArtifactStreamT,
digest: Sha256Digest,
Expand Down
Loading

0 comments on commit 1a8c12f

Please sign in to comment.