Skip to content

Commit

Permalink
Unify mocks and test-util feature in crates
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Jun 14, 2024
1 parent 17fd0df commit a173914
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 51 deletions.
2 changes: 1 addition & 1 deletion crates/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tracing = { workspace = true }

[dev-dependencies]
restate-schema = { workspace = true, features = ["test-util"] }
restate-schema-api = { workspace = true, features = ["mocks"] }
restate-schema-api = { workspace = true, features = ["test-util"] }
restate-test-util = { workspace = true }

tempfile = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/ingress-dispatcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false

[features]
default = []
mocks = ["dep:restate-test-util"]
test-util = ["dep:restate-test-util"]

[dependencies]
restate-bifrost = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/ingress-dispatcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ impl IngressDispatcherRequest {
}
}

#[cfg(feature = "mocks")]
pub mod mocks {
#[cfg(feature = "test-util")]
pub mod test_util {
use super::*;

use crate::error::IngressDispatchError;
Expand Down
4 changes: 2 additions & 2 deletions crates/ingress-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ humantime = { workspace = true }

[dev-dependencies]
restate-core = { workspace = true, features = ["test-util"] }
restate-ingress-dispatcher = { workspace = true, features = ["mocks"] }
restate-ingress-dispatcher = { workspace = true, features = ["test-util"] }
restate-test-util = { workspace = true }
restate-types = { workspace = true, features = ["test-util"] }
restate-schema-api = { workspace = true, features = ["mocks"]}
restate-schema-api = { workspace = true, features = ["test-util"]}

hyper = { version = "1.0", features = ["full"] }
hyper-util = { version = "0.1", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/ingress-http/src/handler/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use http::StatusCode;
use http::{Method, Request, Response};
use http_body_util::{BodyExt, Empty, Full};
use restate_core::TestCoreEnv;
use restate_ingress_dispatcher::mocks::MockDispatcher;
use restate_ingress_dispatcher::test_util::MockDispatcher;
use restate_ingress_dispatcher::IngressDispatcherRequest;
use restate_schema_api::invocation_target::{
InputContentType, InputRules, InputValidationRule, InvocationTargetMetadata,
Expand Down
4 changes: 2 additions & 2 deletions crates/ingress-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ mod mocks {
use super::*;

use anyhow::Error;
use restate_schema_api::invocation_target::mocks::MockInvocationTargetResolver;
use restate_schema_api::invocation_target::test_util::MockInvocationTargetResolver;
use restate_schema_api::invocation_target::{
InvocationTargetMetadata, InvocationTargetResolver, DEFAULT_IDEMPOTENCY_RETENTION,
};
use restate_schema_api::service::mocks::MockServiceMetadataResolver;
use restate_schema_api::service::test_util::MockServiceMetadataResolver;
use restate_schema_api::service::{HandlerMetadata, ServiceMetadata, ServiceMetadataResolver};
use restate_types::identifiers::DeploymentId;
use restate_types::ingress::InvocationResponse;
Expand Down
2 changes: 1 addition & 1 deletion crates/ingress-http/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ mod tests {
use hyper_util::client::legacy::Client;
use hyper_util::rt::TokioExecutor;
use restate_core::{TaskCenter, TaskKind, TestCoreEnv};
use restate_ingress_dispatcher::mocks::MockDispatcher;
use restate_ingress_dispatcher::test_util::MockDispatcher;
use restate_ingress_dispatcher::{IngressDispatcherRequest, IngressInvocationResponse};
use restate_test_util::assert_eq;
use restate_types::identifiers::InvocationId;
Expand Down
4 changes: 2 additions & 2 deletions crates/ingress-kafka/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ tracing = { workspace = true }
tracing-opentelemetry = { workspace = true }

[dev-dependencies]
restate-ingress-dispatcher = { workspace = true, features = ["mocks"] }
restate-ingress-dispatcher = { workspace = true, features = ["test-util"] }
restate-schema = { workspace = true }
restate-schema-api = { workspace = true, features = ["mocks"] }
restate-schema-api = { workspace = true, features = ["test-util"] }
restate-test-util = { workspace = true }
restate-types = { workspace = true, features = ["test-util"] }

Expand Down
3 changes: 1 addition & 2 deletions crates/invoker-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ publish = false

[features]
default = []
mocks = []
test-util = ["restate-types/test-util"]
serde = ["dep:serde"]

[dependencies]
restate-errors = { workspace = true }
restate-types = { workspace = true }


anyhow = { workspace = true }
bytes = { workspace = true }
bytestring = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/invoker-api/src/entry_enricher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub trait EntryEnricher {
) -> Result<EnrichedRawEntry, InvocationError>;
}

#[cfg(any(test, feature = "mocks"))]
pub mod mocks {
#[cfg(any(test, feature = "test-util"))]
pub mod test_util {
use super::*;

use restate_types::identifiers::{InvocationId, InvocationUuid};
Expand Down
4 changes: 2 additions & 2 deletions crates/invoker-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub use journal_reader::{JournalMetadata, JournalReader};
pub use state_reader::{EagerState, StateReader};
pub use status_handle::{InvocationErrorReport, InvocationStatusReport, StatusHandle};

#[cfg(any(test, feature = "mocks"))]
pub mod mocks {
#[cfg(any(test, feature = "test-util"))]
pub mod test_util {
use super::*;
use bytes::Bytes;
use restate_types::identifiers::{InvocationId, ServiceId};
Expand Down
4 changes: 2 additions & 2 deletions crates/invoker-api/src/status_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ pub trait StatusHandle {
) -> impl Future<Output = Self::Iterator> + Send;
}

#[cfg(any(test, feature = "mocks"))]
pub mod mocks {
#[cfg(any(test, feature = "test-util"))]
pub mod test_util {
use super::*;

#[derive(Debug, Clone, Default)]
Expand Down
4 changes: 2 additions & 2 deletions crates/invoker-impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ tracing-opentelemetry = { workspace = true }

[dev-dependencies]
restate-core = { workspace = true, features = ["test-util"] }
restate-invoker-api = { workspace = true, features = ["mocks"] }
restate-schema-api = { workspace = true, features = ["mocks"] }
restate-invoker-api = { workspace = true, features = ["test-util"] }
restate-schema-api = { workspace = true, features = ["test-util"] }
restate-service-protocol = { workspace = true, features = ["codec"] }
restate-test-util = { workspace = true }
restate-types = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ use restate_types::journal::EntryType;
use restate_types::service_protocol::ServiceProtocolVersion;
use std::collections::HashSet;
use std::future::poll_fn;
use tracing::log::warn;
use tracing::{debug, info, trace, Span};
use tracing::{debug, info, trace, warn, Span};
use tracing_opentelemetry::OpenTelemetrySpanExt;

/// Runs the interaction between the server and the service endpoint.
Expand Down
6 changes: 3 additions & 3 deletions crates/invoker-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ mod tests {
use bytes::Bytes;
use restate_core::TaskKind;
use restate_core::TestCoreEnv;
use restate_invoker_api::mocks::EmptyStorageReader;
use restate_invoker_api::test_util::EmptyStorageReader;
use restate_types::arc_util::Constant;
use restate_types::config::InvokerOptionsBuilder;
use tempfile::tempdir;
Expand All @@ -1030,7 +1030,7 @@ mod tests {
use tokio_util::sync::CancellationToken;

use restate_invoker_api::{entry_enricher, ServiceHandle};
use restate_schema_api::deployment::mocks::MockDeploymentMetadataRegistry;
use restate_schema_api::deployment::test_util::MockDeploymentMetadataRegistry;
use restate_test_util::{check, let_assert};
use restate_types::identifiers::{LeaderEpoch, PartitionId};
use restate_types::journal::enriched::EnrichedEntryHeader;
Expand Down Expand Up @@ -1161,7 +1161,7 @@ mod tests {
restate_service_client::AssumeRoleCacheMode::None,
)
.unwrap(),
entry_enricher::mocks::MockEntryEnricher,
entry_enricher::test_util::MockEntryEnricher,
);

let mut handle = service.handle();
Expand Down
2 changes: 1 addition & 1 deletion crates/schema-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish = false
default = []

deployment = ["dep:restate-types", "dep:http", "dep:base64", "dep:restate-base64-util", "dep:bytestring", "service"]
mocks = []
test-util = []
serde = ["dep:serde", "dep:serde_with", "dep:restate-serde-util"]
serde_schema = ["serde", "dep:schemars", "restate-types?/schemars", "restate-serde-util?/schema"]
service = ["dep:bytes", "dep:restate-types", "dep:humantime"]
Expand Down
4 changes: 2 additions & 2 deletions crates/schema-api/src/invocation_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ impl fmt::Display for OutputContentTypeRule {
}
}

#[cfg(feature = "mocks")]
#[cfg(feature = "test-util")]
#[allow(dead_code)]
pub mod mocks {
pub mod test_util {
use super::*;

use std::collections::HashMap;
Expand Down
8 changes: 4 additions & 4 deletions crates/schema-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ pub mod deployment {
fn get_deployments(&self) -> Vec<(Deployment, Vec<(String, ServiceRevision)>)>;
}

#[cfg(feature = "mocks")]
pub mod mocks {
#[cfg(feature = "test-util")]
pub mod test_util {
use super::*;

use restate_types::service_protocol::MAX_SERVICE_PROTOCOL_VERSION_VALUE;
Expand Down Expand Up @@ -413,9 +413,9 @@ pub mod service {
fn list_services(&self) -> Vec<ServiceMetadata>;
}

#[cfg(feature = "mocks")]
#[cfg(feature = "test-util")]
#[allow(dead_code)]
pub mod mocks {
pub mod test_util {
use super::*;

use std::collections::HashMap;
Expand Down
2 changes: 1 addition & 1 deletion crates/service-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ awakeable-id = ["dep:base64", "dep:restate-base64-util", "dep:restate-types"]
codec = ["dep:restate-types", "dep:paste"]
discovery = ["dep:serde", "dep:serde_json", "dep:regress", "dep:tracing", "dep:codederror", "dep:restate-errors", "dep:restate-schema-api", "dep:hyper", "dep:restate-service-client", "dep:restate-types", "dep:tokio"]
message = ["dep:restate-types", "dep:bytes-utils", "dep:codederror", "dep:restate-errors", "dep:size", "dep:tracing"]
mocks = ["awakeable-id"]
test-util = ["awakeable-id"]

[dependencies]
restate-base64-util = { workspace = true, optional = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/service-protocol/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ impl RawEntryCodec for ProtobufRawEntryCodec {
}
}

#[cfg(feature = "mocks")]
mod mocks {
#[cfg(feature = "test-util")]
mod test_util {
use std::str::FromStr;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/storage-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license.workspace = true
publish = false

[features]
mocks = []
test-util = []
serde = ["dep:serde"]

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/storage-api/src/invocation_status_table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ pub trait InvocationStatusTable: ReadOnlyInvocationStatusTable {
) -> impl Future<Output = ()> + Send;
}

#[cfg(any(test, feature = "mocks"))]
mod mocks {
#[cfg(any(test, feature = "test-util"))]
mod test_util {
use super::*;

use restate_types::invocation::VirtualObjectHandlerType;
Expand Down
8 changes: 4 additions & 4 deletions crates/storage-query-datafusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ tracing = { workspace = true }

[dev-dependencies]
restate-core = { workspace = true, features = ["test-util"] }
restate-invoker-api = { workspace = true, features = ["mocks"] }
restate-invoker-api = { workspace = true, features = ["test-util"] }
restate-rocksdb = { workspace = true, features = ["test-util"] }
restate-schema-api = { workspace = true, features = ["mocks"] }
restate-storage-api = { workspace = true, features = ["mocks"] }
restate-service-protocol = { workspace = true, features = ["mocks"] }
restate-schema-api = { workspace = true, features = ["test-util"] }
restate-storage-api = { workspace = true, features = ["test-util"] }
restate-service-protocol = { workspace = true, features = ["test-util"] }
restate-types = { workspace = true, features = ["test-util"] }

googletest = { workspace = true }
6 changes: 3 additions & 3 deletions crates/storage-query-datafusion/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ use datafusion::arrow::record_batch::RecordBatch;
use datafusion::execution::SendableRecordBatchStream;
use googletest::matcher::{Matcher, MatcherResult};
use restate_core::task_center;
use restate_invoker_api::status_handle::mocks::MockStatusHandle;
use restate_invoker_api::status_handle::test_util::MockStatusHandle;
use restate_invoker_api::StatusHandle;
use restate_partition_store::{OpenMode, PartitionStore, PartitionStoreManager};
use restate_rocksdb::RocksDbManager;
use restate_schema_api::deployment::mocks::MockDeploymentMetadataRegistry;
use restate_schema_api::deployment::test_util::MockDeploymentMetadataRegistry;
use restate_schema_api::deployment::{Deployment, DeploymentResolver};
use restate_schema_api::service::mocks::MockServiceMetadataResolver;
use restate_schema_api::service::test_util::MockServiceMetadataResolver;
use restate_schema_api::service::{ServiceMetadata, ServiceMetadataResolver};
use restate_types::arc_util::Constant;
use restate_types::config::{CommonOptions, QueryEngineOptions, WorkerOptions};
Expand Down
2 changes: 1 addition & 1 deletion crates/storage-query-datafusion/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use futures::StreamExt;
use googletest::all;
use googletest::prelude::{assert_that, eq};
use restate_core::TaskCenterBuilder;
use restate_invoker_api::status_handle::mocks::MockStatusHandle;
use restate_invoker_api::status_handle::test_util::MockStatusHandle;
use restate_invoker_api::status_handle::InvocationStatusReportInner;
use restate_invoker_api::{InvocationErrorReport, InvocationStatusReport};
use restate_storage_api::invocation_status_table::{
Expand Down
6 changes: 3 additions & 3 deletions crates/worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ tracing-opentelemetry = { workspace = true }
[dev-dependencies]
restate-core = { workspace = true, features = ["test-util"] }
restate-rocksdb = { workspace = true, features = ["test-util"] }
restate-schema-api = { workspace = true, features = ["mocks"] }
restate-service-protocol = { workspace = true, features = ["mocks"] }
restate-storage-api = { workspace = true, features = ["mocks"] }
restate-schema-api = { workspace = true, features = ["test-util"] }
restate-service-protocol = { workspace = true, features = ["test-util"] }
restate-storage-api = { workspace = true, features = ["test-util"] }
restate-test-util = { workspace = true, features = ["prost"] }
restate-types = { workspace = true, features = ["test-util"] }
prost = { workspace = true }
Expand Down

0 comments on commit a173914

Please sign in to comment.