Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

7 changes: 6 additions & 1 deletion common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,12 @@ impl From<ByteCount> for i64 {
Diffable,
)]
#[daft(leaf)]
pub struct Generation(u64);
#[cfg_attr(any(test, feature = "testing"), derive(test_strategy::Arbitrary))]
pub struct Generation(
// Generations are restricted to 2**63 - 1 as documented above.
#[cfg_attr(any(test, feature = "testing"), strategy(0..=i64::MAX as u64))]
u64,
);

impl Generation {
// `as` is a little distasteful because it allows lossy conversion, but we
Expand Down
1 change: 1 addition & 0 deletions common/src/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ impl DiskManagementError {
Diffable,
strum::EnumIter,
)]
#[cfg_attr(any(test, feature = "testing"), derive(test_strategy::Arbitrary))]
pub enum M2Slot {
A,
B,
Expand Down
5 changes: 5 additions & 0 deletions gateway-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ hex.workspace = true
omicron-common.workspace = true
omicron-uuid-kinds.workspace = true
omicron-workspace-hack.workspace = true
proptest = { workspace = true, optional = true }
schemars.workspace = true
serde.workspace = true
test-strategy = { workspace = true, optional = true }
thiserror.workspace = true
tufaceous-artifact.workspace = true
uuid.workspace = true

[features]
testing = ["dep:proptest", "dep:test-strategy"]
1 change: 1 addition & 0 deletions gateway-types/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::rot::RotState;
Diffable,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(any(test, feature = "testing"), derive(test_strategy::Arbitrary))]
pub enum SpType {
Sled,
Power,
Expand Down
1 change: 1 addition & 0 deletions gateway-types/src/rot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ impl From<gateway_messages::RotBootInfo> for RotState {
JsonSchema,
)]
#[serde(tag = "slot", rename_all = "snake_case")]
#[cfg_attr(any(test, feature = "testing"), derive(test_strategy::Arbitrary))]
pub enum RotSlot {
A,
B,
Expand Down
9 changes: 9 additions & 0 deletions nexus-sled-agent-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ omicron-passwords.workspace = true
omicron-uuid-kinds.workspace = true
omicron-workspace-hack.workspace = true
# TODO: replace uses of propolis_client with local types
proptest = { workspace = true, optional = true }
schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
sled-hardware-types.workspace = true
strum.workspace = true
test-strategy = { workspace = true, optional = true }
thiserror.workspace = true
tufaceous-artifact.workspace = true
uuid.workspace = true

[dev-dependencies]
proptest.workspace = true
test-strategy.workspace = true

[features]
testing = ["dep:proptest", "dep:test-strategy"]
16 changes: 15 additions & 1 deletion nexus-sled-agent-shared/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,8 +1500,22 @@ fn default_nexus_lockstep_port() -> u16 {
/// please add it here rather than doing something ad-hoc in the calling code
/// so it's more legible.
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, EnumIter,
Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Diffable,
EnumIter,
Deserialize,
Serialize,
JsonSchema,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(any(test, feature = "testing"), derive(test_strategy::Arbitrary))]
pub enum ZoneKind {
BoundaryNtp,
Clickhouse,
Expand Down
6 changes: 6 additions & 0 deletions nexus/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ slog-error-chain.workspace = true
steno.workspace = true
strum.workspace = true
tabled.workspace = true
test-strategy.workspace = true
textwrap.workspace = true
thiserror.workspace = true
tokio.workspace = true
Expand All @@ -71,6 +72,11 @@ tough.workspace = true
# common to both, put them in `omicron-common` or `nexus-sled-agent-shared`.

[dev-dependencies]
gateway-types = { workspace = true, features = ["testing"] }
iddqd = { workspace = true, features = ["proptest"] }
newtype-uuid = { workspace = true, features = ["proptest1"] }
nexus-sled-agent-shared = { workspace = true, features = ["testing"] }
omicron-common = { workspace = true, features = ["testing"] }
omicron-test-utils.workspace = true
proptest.workspace = true
test-strategy.workspace = true
29 changes: 29 additions & 0 deletions nexus/types/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,7 @@ impl fmt::Display for BlueprintZoneDisposition {
Diffable,
)]
#[serde(tag = "type", rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum BlueprintZoneImageSource {
/// This zone's image source is whatever happens to be on the sled's
/// "install" dataset.
Expand Down Expand Up @@ -1343,6 +1344,7 @@ impl fmt::Display for BlueprintZoneImageSource {
Diffable,
)]
#[serde(tag = "artifact_version", rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum BlueprintArtifactVersion {
/// A specific version of the image is available.
Available { version: ArtifactVersion },
Expand Down Expand Up @@ -1466,6 +1468,7 @@ impl fmt::Display for BlueprintHostPhase2DesiredContents {
Copy,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum MgsUpdateComponent {
Sp,
Rot,
Expand All @@ -1488,12 +1491,17 @@ impl Display for MgsUpdateComponent {
#[derive(
Clone, Debug, Eq, PartialEq, Deserialize, Serialize, JsonSchema, Diffable,
)]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct PendingMgsUpdates {
// The IdOrdMap key is the baseboard_id. Only one outstanding MGS-managed
// update is allowed for a given baseboard.
//
// Note that keys aren't strings so this can't be serialized as a JSON map,
// but IdOrdMap serializes as an array.
//
// For proptest, make this map small to avoid bloating the size of generated
// test data.
#[cfg_attr(test, any(((0, 16).into(), Default::default())))]
by_baseboard: IdOrdMap<PendingMgsUpdate>,
}

Expand Down Expand Up @@ -1562,6 +1570,7 @@ impl<'a> IntoIterator for &'a PendingMgsUpdates {
#[derive(
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct PendingMgsUpdate {
// identity of the baseboard
/// id of the baseboard that we're going to update
Expand Down Expand Up @@ -1658,6 +1667,7 @@ impl PendingMgsUpdate {
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[serde(tag = "component", rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum PendingMgsUpdateDetails {
/// the SP itself is being updated
Sp(PendingMgsUpdateSpDetails),
Expand Down Expand Up @@ -1720,6 +1730,7 @@ impl slog::KV for PendingMgsUpdateDetails {
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct PendingMgsUpdateSpDetails {
// implicit: component = SP_ITSELF
// implicit: firmware slot id = 0 (always 0 for SP itself)
Expand Down Expand Up @@ -1752,6 +1763,7 @@ impl slog::KV for PendingMgsUpdateSpDetails {
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct PendingMgsUpdateRotDetails {
// implicit: component = ROT
// implicit: firmware slot id will be the inactive slot
Expand Down Expand Up @@ -1823,6 +1835,7 @@ impl slog::KV for PendingMgsUpdateRotDetails {
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct PendingMgsUpdateRotBootloaderDetails {
// implicit: component = STAGE0
// implicit: firmware slot id = 1 (always 1 (Stage0Next) for RoT bootloader)
Expand Down Expand Up @@ -1859,6 +1872,7 @@ impl slog::KV for PendingMgsUpdateRotBootloaderDetails {
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct PendingMgsUpdateHostPhase1Details {
/// Which slot is currently active according to the SP.
///
Expand Down Expand Up @@ -1899,9 +1913,22 @@ pub struct PendingMgsUpdateHostPhase1Details {
/// don't need to be able to represent an invalid inactive slot.
pub expected_inactive_phase_2_hash: ArtifactHash,
/// Address for contacting sled-agent to check phase 2 contents.
#[cfg_attr(test, strategy(socket_addr_v6_without_flowinfo()))]
pub sled_agent_address: SocketAddrV6,
}

// For proptest, we pass in flowinfo = 0, because flowinfo doesn't roundtrip
// through JSON.
#[cfg(test)]
fn socket_addr_v6_without_flowinfo()
-> impl proptest::strategy::Strategy<Value = SocketAddrV6> {
use proptest::strategy::Strategy;

proptest::arbitrary::any::<(Ipv6Addr, u16, u32)>().prop_map(
|(addr, port, scope_id)| SocketAddrV6::new(addr, port, 0, scope_id),
)
}
Comment on lines +1916 to +1930
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooof


impl slog::KV for PendingMgsUpdateHostPhase1Details {
fn serialize(
&self,
Expand Down Expand Up @@ -1954,6 +1981,7 @@ impl slog::KV for PendingMgsUpdateHostPhase1Details {
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[serde(tag = "kind", content = "version", rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum ExpectedVersion {
/// We expect to find _no_ valid caboose in this slot
NoValidVersion,
Expand Down Expand Up @@ -1986,6 +2014,7 @@ impl fmt::Display for ExpectedVersion {
#[derive(
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub struct ExpectedActiveRotSlot {
pub slot: RotSlot,
pub version: ArtifactVersion,
Expand Down
2 changes: 2 additions & 0 deletions nexus/types/src/deployment/planning_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ impl CockroachDbSettings {
JsonSchema,
Diffable,
)]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum CockroachDbClusterVersion {
#[display("22.1")]
V22_1,
Expand Down Expand Up @@ -522,6 +523,7 @@ impl CockroachDbClusterVersion {
Diffable,
)]
#[serde(tag = "action", content = "data", rename_all = "snake_case")]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
pub enum CockroachDbPreserveDowngrade {
/// Do not modify the setting.
DoNotModify,
Expand Down
Loading
Loading