Skip to content

Conversation

sunshowers
Copy link
Contributor

This proptest would catch the issue detected in #9080.

Closes #9081.

Created using spr 1.3.6-beta.1
Comment on lines +1871 to +1885
#[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),
)
}
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

Created using spr 1.3.6-beta.1
Copy link
Contributor

@jgallagher jgallagher left a comment

Choose a reason for hiding this comment

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

Thanks! This looks like it was pretty tedious, but is way more robust than the path I started down.


// location of the baseboard (that we'd pass to MGS)
/// what type of baseboard this is
#[cfg_attr(test, strategy(proptest::prop_oneof![
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there something preventing us from deriving Arbitrary for SpType?

Copy link
Contributor Author

@sunshowers sunshowers Sep 25, 2025

Choose a reason for hiding this comment

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

Ended up replace-ing the SpType in gateway-client in favor of the one in gateway-types: #9093

With that change, we can derive Arbitrary on SpType.

Comment on lines +1871 to +1885
#[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),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ooof

@sunshowers sunshowers enabled auto-merge (squash) September 26, 2025 22:57
@sunshowers sunshowers merged commit 7c89519 into main Sep 27, 2025
18 checks passed
@sunshowers sunshowers deleted the sunshowers/spr/nexus-types-test-that-planningreports-can-be-roundtrip-serialized branch September 27, 2025 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test that PlanningReport can be serialized as JSON
2 participants